Hello everyone. Newbie here, coming from LaTeX.
I am currently working on a template, but I am looking to implement color boxes around hyperlinks (cross-references, citations, urls and so on). What I’ve seen is just a discussion on GitHub, but is limited to cross-references and links, however, there are some issues.
When using the numbering for headings and equations shown below, those are rendered with the dot and the parentheses, respectively. Such aspect does not happen with figures and tables, but as mentioned before, with citations are not possible.
Headings
set heading(numbering: "1.")
set math.equation(numbering: "(1)")
I am looking for a (LaTeX) hyperref-like behaviour that may be able to work with all hyperlinks and render correctly. The code that I am using is the same that was shared in the discussion, just that I remove the colored text. I’ve tried to convert supp
and num
to string, so I could strip dots and parentheses, but the second case is from a context type and couldn’t find how to do it. I would appreciate help with all that.
Code for hyperlinks
#let separate-supplement-style(supp, num) = {
box(supp + " " + num, stroke: 1pt + green, outset: (bottom:1.5pt, x:.5pt, y:.5pt))
}
#show ref: it => {
let (element, target, supplement: supp) = it.fields()
if element == none {
return it
}
let non_cite_ref = element.fields()
let supp = if supp == auto { non_cite_ref.supplement } else { supp }
let num = context {
let head-count = counter(heading).at(target)
numbering(non_cite_ref.numbering, ..head-count)
}
link(target, separate-supplement-style(supp, num))
}