I simplified your solution slightly, so it’s easier to read:
#set heading(numbering: "1.a")
#show heading.where(level: 1): set heading(
numbering: num => "Example " + numbering("1:", num),
supplement: "Example",
)
#show ref: it => {
let el = it.element
if el == none or el.func() != heading or el.level != 1 { return it }
let heading-levels = counter(heading).at(el.location())
let body = numbering(n => [#el.supplement #n], ..heading-levels)
link(el.location(), body)
}
#show ref: emph
Also note that you can use -
in label/function/variable names, which is also a conventional way to name things. So the <sub_four>
would be <sub-four>
and the reference would be @sub-four
.