I’ve tried to use box
to add a background to any link
in my document. Problem is: there’s no breakable
argument in box
(allowing the box to break between lines). This argument only exists for block
element.
Is it possible to make a breakable inline? I’ve searched through docs, forum and repository and didn’t find any mention to that…
Thank you in advance!
Blaz
September 24, 2024, 5:39am
2
I’m not sure if you can achieve that with a box, but if you want to add a background color to your links you can combine a show rule with highlight :
#show link: it => highlight(fill: blue, it)
Breakable link with background:
#link("https://typst.app")[#lorem(50)]
2 Likes
Andrew
September 24, 2024, 8:42am
3
No, box
can’t be broken, that’s the point. You only want to break blocks, hence block
has a parameter for that.
FYI, a slightly simpler way to do this is:
#show link: highlight.with(fill: blue)
3 Likes
eduard
July 15, 2025, 10:05am
4
What if, instead, you want to have a line surrounding a link? The only way I can think of doing it is with a box, for example
#show ref: it => { box(stroke: 0.5pt + green, outset: 0.2em, it) }
This is a bit problematic with very long citations, with a lot of authors
2 Likes
bluss
July 15, 2025, 12:55pm
5
Highlight also supports stroke and fill settings, so it should still be the way to solve this, disable the fill and enable stroke and use highlight.
1 Like