How can I make sure all in-text cross-references are styled identically when using citations?

Hi there, newbie here: I’m using Typst to define a template for university term papers, for use with Quarto. It works great so far but there is something I don’t quite seem to understand correctly: namely, how styles can be applied to the references.

I would like for all in-text references to publications to be highlighted in blue. For some reason, this works just fine for parenthetical references: the full ones using the [@author_2022] syntax in Markdown, which display as text text (Author 2022) text text (with “Author 2022” in blue). But it does not work as expected when I just use an in-text reference using the @author_2022 syntax, which displays as text text Author (2022) text text (everything remains black).

In the first case, the whole reference is blue, in the second case, it is not. The underlying link is generated in both cases, but the reader has no way of knowing there is an underlying link in the second case as well. It just seems inconsistent.

This is the relevant snippet from my template:

  // Configure display of cross-references 
  show ref: set text(
    fill: rgb(17,86,142)
    )

And this is how an example section from the rendered PDF looks like:

Any hints are highly appreciated!

I am not aware that [@citation] and @sitation are different kinds of syntax in Typst, so it has to be a Quarto thing. Maybe someone here knows a solution, but you may need to look in different locations as well.

If you can get Quarto to output the Typst code it generated, that would be super helpful.

1 Like

Thanks for the quick feedback, that’s a great idea! This worked and shows that in the intermediate typ file, the two kinds of references look quite different:

The study of literary metaphors plays an integral part in literature-focused disciplines within the humanities. Computational metaphor detection (MD) has produced a wealth of approaches in the field of Natural Language Processing (NLP), where the focus lies on detecting everyday metaphors @pticek_2023_methods. In the Digital Humanities (DH) literary MD has not been extensively studied yet. In their Graph Project, #cite(<kesarwani_2017_metaphor>, form: "prose") and #cite(<tanasescu_2018_metaphor>, form: "prose") have applied rule-based and statistical machine learning approaches on an English poetry corpus.

Once it retains the @author syntax at this stage, once it transforms to #cite. So I went ahead and added the following to my template:

  show cite: set text(
    fill: rgb(17,86,142)
    )

And that solves the problem! Not very intuitive, but definitely a solution.

1 Like

Yeah, cite and ref share a syntax: Cite Function – Typst Documentation That means that @xy probably is a reference representing a citation (or something like that), while the other was a citation without a containing reference. So show cite was the correct one anyways, but for the reason above show ref worked “accidentally”.

1 Like

Thanks for the explanation. Indeed, removing the show statement for ref doesn’t change anything for the references now that the one for cite is there, it is needed for the other cross-references to tables and figures etc., though.

1 Like