Last active
October 6, 2024 12:47
-
-
Save avonmoll/e62facc7040f781d9e9ca5d6def9dc82 to your computer and use it in GitHub Desktop.
Categorized Bibliography in Typst
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library.yaml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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") | |
] | |
] |
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.
even better
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Consider changing
#show "Von Moll, A.": name => text(olive, strong(emph(name)))
to(period removed after A)
To correct highlighting when the last author