Skip to content

Instantly share code, notes, and snippets.

@avonmoll
Last active February 5, 2024 16:33
Show Gist options
  • Save avonmoll/e62facc7040f781d9e9ca5d6def9dc82 to your computer and use it in GitHub Desktop.
Save avonmoll/e62facc7040f781d9e9ca5d6def9dc82 to your computer and use it in GitHub Desktop.
Categorized Bibliography in Typst
library.yaml
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
// MIT No Attribution
//
// Copyright (c) 2023 Alexander Von Moll
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
// software and associated documentation files (the "Software"), to deal in the Software
// without restriction, including without limitation the rights to use, copy, modify,
// merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
// PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.#show bibliography: none
#show bibliography: none
#bibliography("library.yaml", style: "apa")
#show regex("Von Moll, A\\.?"): name => text(olive, underline(strong(name)))
// Filters
#let meFilter(p) = {
let (key, document) = p
"Von Moll, Alexander" in document.author
}
#let articleOrConference(p) = {
let (key, document) = p
if "parent" in document {
let par = none
if type(document.parent) == array {
par = document.parent.at(0)
} else {
par = document.parent
}
if par.type == "periodical" {
return "article"
} else if par.type == "proceedings" or parent.type == "conference" {
return "conference"
} else {
return p.type
}
} else {
return p.type
}
}
#let filterByType(p, type) = {
let (key, document) = p
if document.type == "article" {
type == articleOrConference(p)
} else {
document.type == type
}
}
// Define which sections to include
#let sections = (
("Journal Articles", "article"),
("Conference Papers", "conference"),
("Presentations", "misc"),
("Academic", "thesis"),
)
= Publications
#for (title, type) in sections [
#heading(level: 2, title)
#let entries = yaml("library.yaml").pairs().filter(meFilter).filter(p => filterByType(p, type)).sorted(key: p => p.at(1).date).rev().map(p => label(p.at(0)))
#for key in entries [
#cite(key, form: "full")
]
]
@avonmoll
Copy link
Author

avonmoll commented Feb 5, 2024

Thanks for pointing that out! This was also an issue for all entries where there was only one author. Rather than just matching on "Von Moll, A" (no period) I decided to make it a regex: #show regex("Von Moll, A\\.?"). So, generally, it will include the period after. I preferred the look better.

@agerlach
Copy link

agerlach commented Feb 5, 2024

even better

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment