How to get the math class of a symbol?

I know that I can search and view the math class corresponding to each commonly used symbol in the document, but I want to be able to view the math class of a symbol directly in the Typst script. Is this possible?

The syntax I imagine should be similar to measure, that is:

#context measure-symbol(math.not).class

I don’t think this is possible in general.

For symbols where the class has been changed, you can access the new class:

#math.class("fence", "=").fields()

gives

(class: "fence", body: [=])

but if it has not changed it seems to me that a symbol behaves the same as normal text as far as typst scripting is concerned, just with a different .func().

(the only field a symbol has is text, containing the Unicode symbol, but that doesn’t help you)

1 Like

Inspired by what you said, you can look up the unicode-defined math class for a symbol - using package unichar – Typst Universe - but Typst can change its class of certain symbols anyway, so that will not be completely accurate.

2 Likes

unichar is indeed useful, thanks for the tip!