How to make a rule that increases tracking for uppercase text?

I want Typst to automatically increase tracking for both uppercase and small caps text.
For small caps I used this code:

show smallcaps: set text(tracking: 0.5pt)

but when I do the same with the upper function I get the following error message: “only element functions can be used as selectors.”
Could someone help me bypass this (without creating a custom function to use for uppercase text)?

Hi, welcome to the Typst forum!

For your question maybe you can use a regular expression?

#show regex("[[:upper:]]+"): set text(tracking: ...)

Replace "[[:upper:]]+" with "\b[[:upper:]]+\b" to affect only whole words made of upper charactres.

Thanks for the reply!
It works.

1 Like