Skip to content

Show rule on a section reference #4427

Closed Answered by Mc-Zen
CDucloux asked this question in Q&A
Discussion options

You must be logged in to vote

Hi, you can do

#show ref: it => {
  let el = it.element
  if el != none and el.func() == heading and el.level == 1 {
    underline(stroke: 1.5pt   blue, offset: 3pt, it)
  } else { it }
}

We create a show rule for ref that filters for the element field of the reference. This element may be none (for citations for example). Then we check that the element is indeed a heading and that the level is 1. Alternatively, the last condition could be el.supplement == [Section], however, this does not work across different languages.

Now you can just reference your sections via @section and they will automatically have the desired style.

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Answer selected by CDucloux
Comment options

You must be logged in to vote
1 reply
@Mc-Zen
Comment options

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