Skip to content

Color citation content but not brackets #4143

Answered by EpicEricEE
TheZoq2 asked this question in Q&A
Discussion options

You must be logged in to vote

Something like this should work. As cite elements are also references, you need to exclude them when coloring other references, so you don't end up with differently colored brackets:

#show cite: it => {
  // Only color the number, not the brackets.
  show regex("\d+"): set text(fill: green)
  // or regex("[\p{L}\d+]+") when using the alpha-numerical style
  it
}

#show ref: it => {
  if it.element == none {
    // This is a citation, which is handled above.
    return it
  }

  // Only color the number, not the supplement.
  show regex("[\d.]+"): set text(fill: blue)
  it
}

...or alpha-numerical with regex("[\p{L}\d+]+")

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@TheZoq2
Comment options

Answer selected by TheZoq2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants