I’m writing my thesis, using the CSL file to get the correct citation style (IEEE with URLs). When citing with the “prose” option, I get the author’s initial and last name - e.g. “J. Smith [1]”.
Is there a straigthforward way to output only the last name, without the initial?
Hi there!
It should be possible to create a custom citation style or maybe there is one already, but I’m not aware of it. Creating a custom citation style is pretty complicated and might be overkill for your purpose.
Something that seems to work though is the following:
#let my-cite(label) = {
show regex("[A-Z]. "): none
cite(label, form: "prose")
}
A citation in the style you asked for: #my-cite(<some-citation>)
#bibliography("bibliography.bib")
My answer is inspired by this post about getting rid of other parts of the citation (in another citation style)
This is not how regex works. Here is an explanation. For any language to work, "\p{Lu}\. " should be used, for only Latin letters: "[A-Z]\. ".
Indeed, the correct way would be to use a different CSL style, or copy the used one and patch it.
Since the text is supposed to be very short, I think this is a pretty good solution, though I think it will also remove the middle name, if it does exist and shows. If it was a longer text, then it can easily remove some other parts of the citation, since the regex is very generic.
Thank you for correcting me . I tend to forget the backslash…
And yes, you are correct, my expression is a little bit too specific.
I looked up the expression at regex - Rust, but the website you referenced looks better , so thank you very much for the advice .
Regarding editing the CSL style, I couldn’t find it in the github repo (I searched the website for “ieee”) and to be honest it might be a little too complex for me anyways.
I’ve tried going down the CSL editing path, but I believe the behavior of the “prose” setting for the #cite function is not necessarily dictated by the CSL style. I’m using IEEE and its inline citation is just numeric (e. g. [1]), but “prose” produces “J. Doe [1]”. So Typst adds the author from the bibliography entry.
Is there a way to manipulate this output to get rid of initials (just for this type of citation)? I haven’t found a way to access a string containing the author name while writing a show rule.
If you just want to apply the same workaround just for this form:
#show cite.where(form: "prose"): it => {
show regex("[A-Z]\. "): none
it
}
#let bib = ```yaml
a:
type: book
title: title
author: Doe, John
```.text
#cite(form: "prose", <a>)
@a
#bibliography(bytes(bib))