How do I customize the numbering of the bibliography?

My bibliography looks like:
image
I want to change the numbering from “1” to “R1”. Is it possible?

Currently, bibliography entries are not easily customizable. A simple solution involves changing the citation style (if it is possible in your use case), since you won’t be following the IEEE reference guide. Assuming you don’t want to change the citation style, the following code could achieve what you want

#show regex("\[\d+\]"): num => {
  let text = num.text
  text.at(0) + "R" + text.slice(1)
}

Be aware that this solution could potentially change any unrelated text if there is a match with the regex. One way to handle this problem is by scoping the show rule specifically to the bibliography and the citations.

Solution
#let in-reference = state("in-reference", false)

#show bibliography: it => {
  in-reference.update(true)
  it
  in-reference.update(false)
}

#show cite: it => {
  in-reference.update(true)
  it
  in-reference.update(false)
}

#show regex("\[\d+\]"): num => context {
  if in-reference.get() {
    let text = num.text
    text.at(0) + "R" + text.slice(1)
  } else { num }
}

Now cite the reference @veritasium_big_2021, and notice that a number enclosed in brackets [3] is nos modified.

#bibliography("bib.yaml")
Result

change-bib-numbering

I have a feeling there might be better solutions at the moment, but at least this works for now.

The following doesn’t require state and is equivalent:

#show selector(bibliography).or(cite): it => {
  show regex("\[\d+\]"): num => {
    let text = num.text
    text.at(0) + "R" + text.slice(1)
  }
  it
}

// cites and bibliography may come afterwards
1 Like

Thank you very much!