Recently I asked a different question: How to create a link to a section in such a way that link text will be the same as the heading itself, and if the heading will be changed, link text will be updated automatically, i.e. instead of writing #link<lorem>)[Lorem]
, we could write just #link<lorem>)[]
(https://forum.typst.app/t/1221). It was answered by @xkevio.
It seems that though #metadata
and #[ ... ]
solutions can work with xkevio’s solution in theory, it would be quite fragile. So currently I decided to use the target: selector(<...>).or(<...>)
solution, mentioned by @sijo above.
#show link: underline
// https://forum.typst.app/t/1221
#show link.where(body: []): l => {
let heading-elem = query(l.dest).first()
link(l.dest, heading-elem.body.text)
}
// --
// https://forum.typst.app/t/1307
#outline(title: [First outline], target: selector(<group1>).or(<lorem>).or(<ipsum>))
#outline(title: [Second outline], target: selector(<group2>).or(<dolor>))
#outline(title: [Third outline], target: selector(<group3>))
#pagebreak()
#link(<lorem>)[] \
#link(<ipsum>)[] \
#link(<dolor>)[]
#lorem(50)
= Lorem
<lorem>
#lorem(325)
= Ipsum
<ipsum>
#lorem(325)
= Dolor
<dolor>
#lorem(325)
= Sit
<group2>
#lorem(325)
= Amet
<group3>
#lorem(325)