I’ve asked the other day on Discord how is one supposed to prepare content to typeset typographical stuff like em-dash, en-dash, ellipsis etc. I’ve found one post and wonder whether this is the recommended way or is there something else.
The answer was that this is the way, but wonder if there is some pre-prepared packaged to handle such things which are pretty common in LateX world?
Hello. It depends on how you are going to write the dash in the source code. I didn’t find any package for dashes, and it is not package-worthy if all you want is one small text show rule. You can use predefined symbol names though:
#show " " + sym.dash.em + " ": it => {
let space = sym.space.nobreak.narrow
space + sym.dash.em + space
}
test --- test
Or the shortest way, sacrificing easily seeing which exact characters are used:
#show " — ": " — "
If you need more customizability, then you can use h():
I was thinking about the package since it is not a question just about writing a dash, iow. there are several special characters (elipsis, protected space etc.) which are taken for granted when using LaTeX, but I get your point that creating show rules is the way to go in Typst-
Just in case this isn’t known, I’ll share that there is a full list of available shorthands here: Symbols – Typst Documentation
-- for en dash
--- for em dash
... for ellipsis
Yeah, if you want to customize every occurrence of a certain special character, using a show rule just on that character is the way to go.
I believe they weren’t necessarily referring to text show rules. But yes, be careful to not use a text show rule when you could use a variable or function instead (e.g. to apply some specific styling or display a constant multiple times).
In this case a text show rule is appropriate as it is about changing the styling of the document. In other words, if a package inserts text with an em dash, you want that em dash to be affected, so a global text show rule makes sense. But you wouldn’t want the word “number” from another package to be affected when creating a constant named “number”, for example, so you should create a variable named number instead of a show rule on that word.