Hello everyone,
I’m trying to implement a specific formatting rule in my Typst document where uppercase letters in math mode should be upright by default (instead of the default italic style), but I still want to be able to selectively make some of them italic when needed.
Here’s what I’ve tried:
#show math.equation: eq => {
show regex("[A-Z]"): it => math.upright(it.text)
eq
}
$A = B + C + italic(A)$
The problem is that while this successfully makes all uppercase letters upright by default (A, B, C), the italic(A)
still appears upright, ignoring the italic()
function.
I understand this happens because the regex rule is applied after other styling, effectively “overriding” any italic()
commands.
Is there a way to achieve what I’m trying to do? Ideally, I’d like:
- All uppercase letters to be upright by default in math mode
- The ability to use something like
italic(A)
or a custom function to selectively make specific uppercase letters italic when needed
I don’t want to use “A” (quoted text) in math mode to get upright letters, as this would require changing too much of my existing document. I’m looking for a solution that works with regular uppercase letters and math syntax.
Any suggestions would be greatly appreciated!
Thank you!