How to prevent linebreak in citation ranges?

Using the bibliography with a numbered style such as ‘Nature’ will generate citation ranges in the form of two numbers and an en-dash that will look e.g. like

some example text1–3

Unfortunately, this can lead to line breaks after the en-dash and before the second number which I would like to avoid.

I already tried sth like this

#show regex("\\d+\u2013\\d+"): it => box(it)

to prevent the line break at the en-dash.

However this doesn’t work either because there are additional non-visible characters/symbols or the text gets generated at a different stage?

The numbers and the en dash come from different parts (text/delimiter/…) in the CSL (the citation style), and it looks like that typst does not allow a show rule to match across those parts…

Perhaps typst should provide a cite.group element to make show cite.group: box possible.
(The underlying rust code already implemented the struct CiteGroup.)

I think a word joiner should work, can you check if something like the following works:

#show regex("\u2013"): it => sym.wj + it + sym.wj
1 Like

Is there another workaround that can be used to prevent splitting?

This seems to work but will affect all en-dashes which may not be favorable

#show "–": [--#sym.zwj]
1 Like