#Add prefix to citation

70 messages · Page 1 of 1 (latest)

noble axle
#

In German academia it is common to prefix a citation with Vgl. (cf./compare in English) to show an indirect quote (paraphrased)

In LaTeX it is possible to do: \footcite[cf.][pp. 5-10]{hevner} => ¹ cf. Hevner et al. (2024), “Design Science in Information Systems Research,” pp. 5-10.

In Typst I was able to reproduce the supplement: #cite(<hevner>, supplement: "pp. 5-10"), but there's no option to pass a prefix.

There's an open GitHub issue, but I'm unable to follow the workaround: https://github.com/typst/typst/issues/3020#issuecomment-2538545758

lean jacinth
#

which style are you using?

noble axle
#

I’m using a slightly modified Chicago notes

lean jacinth
#

can you send it?

#

or is the difference not relevant?

#

also are you looking to have the cf in the footnote entry displayed at the bottom, or at the citation point?

noble axle
noble axle
lean jacinth
#

yeah , so what you're looking for is that when you write "some text @thing", the cf. appears at the bottom of the page in the footnote, i.e. in the paragraph you get "some text ^1" and at the bottom it reads "^1 cf. Author (2024)", correct?

#

for some cases at least (not all)

noble axle
#

Yes but only if it’s an indirect citation, so I need some sort of conditional. If it quote something literally there must be no cf.

lean jacinth
#

okay

#

give me a moment

lean jacinth
# noble axle Yes but only if it’s an indirect citation, so I need some sort of conditional. I...

try this:

#let cf-foots = state("cf-foots", ())

#show footnote.entry: it => context {
  let foot-num = counter(footnote).at(it.note.location()).first()
  if foot-num in cf-foots.final() {
    show super: it => [#it;cf. #sym.wj]
    it
  } else {
    it
  }
}

#let cite-cf(..args) = {
  context {
    let foot-num = counter(footnote).get().first() + 1
    cf-foots.update(s => s + (foot-num,))
  }
  [#cite(..args)]
}

@first vs #cite-cf(<first>) dddd
#

note that the footnote.entry show rule must be at the top of your document

noble axle
#

That’s neat. I didn’t know you can access all the individual fields of a footnote. I thought it’s just one glob. That’s why I was only able to add it in front of the entire footnote line

lean jacinth
#

yeah, show rules give you access to fields

#

though in this case the footnote number is more of an implicit field

#

you need to read the counter at the original note's location

#

but otherwise it works

noble axle
#

Hypothetically, what would be the field for an in text citation? I assume something similar would work

lean jacinth
#

you mean a non-footnote style?

noble axle
#

Yep, like IEEE

#

Although IEEE doesn’t make sense

lean jacinth
#

without the footnote you'd have to hook into some specific output of the citation to know where it should be placed

#

it is often enough to just add a cf. before the citation itself in that case

#

but depends on what you need

noble axle
#

Uhm usually the citation is in braces. I ment turn (Hevner, 2020) into (cf. Hevner, 2020)

#

Is this inline citation not a field by itself?

lean jacinth
#

in that case you can #show "(": "(cf. "

#

when everything goes wrong, just use a text show rule and live on with your life

#

¯_(ツ)_/¯

noble axle
lean jacinth
#

you would do it inside the cite-cf function

#

show and set rules are scoped to the nearest containing { }

noble axle
#

Oh yeah that’s smart

#

Thanksssss hyper_fast_parrot

lean jacinth
#

no problem

noble axle
#

Uhm but do you agree that this should be part of typst? It’s common in Latex and I assume the functionally is similar to supplement, just a prefix and not and not a suffix

lean jacinth
#

it should be possible, but styles would also have to support it

#

so im not sure if it's achievable as is

lean jacinth
noble axle
lean jacinth
#

the supplement is passed as the locator CSL variable

noble axle
#

I though it’s just appended

lean jacinth
#

so the style chooses where to place it

#

in general it has to choose so it goes inside parentheses for example

noble axle
#

Anyway, I’m not super familiar sky CSL but what about form? I had the idea to change the style and maybe have a form for cf citations.

#

form: “cf”

#

But I guess this would screw with the real form.

lean jacinth
#

there's still some intervention from the style, overall we'd be forced to guess :p

#

e.g. if it starts with ( we place it there or something like that

#

so basically the alternatives are, text manipulation or make a proposal to the CSL spec

noble axle
#

You tested the code snippet, right? Maybe it would be a good idea to post it to the GitHub issue as a workaround

#

There was also the forum post

lean jacinth
#

yeah i tested it

#

but it only works for footnote styles

#

but yes, i can share it there

noble axle
#

Yep, the forum post was about footnotes

#

You’re cool otterhappy

lean jacinth
#

ty 😄

noble axle
#

While I'm at it, I have this long footnote, is there a way to indent the second line to start at the same level as the character S in the first line?

lean jacinth
#

one quick way if you can eyeball it is to use #show footnote.entry: set par(hanging-indent: 2em /* adjust this number */)

#

this wont work in typst 0.13 but you can just not switch to it yet

#

actually i think you dont have to eyeball it, it should be the same as footnote.entry.indent

#

which defaults to 1em i believe

#

so the proper way would be to do something like ```js
#show footnote.entry: it => grid(columns: 2, h(it.indent) + super(numbering(it.note.numbering, ..counter(footnote).at(it.note.location()))), it.body)

noble axle
# lean jacinth in that case you can `#show "(": "(cf. "`

This is how you intended it, right?

#let ccf(..args) = {
  show "(": "(cf. "
  cite(..args)
}
```I'm a bit confused about the `context` field you used in
```rust
#let cite-cf(..args) = {
  context {
    let foot-num = counter(footnote).get().first() + 1
    cf-foots.update(s => s + (foot-num,))
  }
  [#cite(..args)]
}
```And why it's wrapped in `[]` at `[#cite(..args)]`.