What is the "right" way of determining the math class (e.g. ordinary/0, relation/3, closing/5, etc.) of a non-keyboard symbol?
Something like \oplus
is easy enough to guess, but I wasn't immediately sure about \upuparrows
(); on the one hand, my impression is that arrow symbols are generally treated as relations, while I know that Knuth's up-arrow notation uses it to denote a binary operation.
I tried writing
\documentclass{article}
\usepackage{amssymb}
\begin{document}
\the\mathcode\upuparrows
\end{document}
but this produced an error:
Bad character code (13332) \the\mathcode\upuparrows
Note that 13332
is the right number: writing
\def\test{\mathchar 13332 }
$\test$
does not produce an error, and gives the double-up-arrow symbol. And 13332
is equal to the hex number 3414
, which starts with 3, correctly indicating that it is a relation.
How did I end up figuring out that is correct? Because I ran the following extremely silly code:
\documentclass{article}
\usepackage{amssymb}
\begin{document}
\newlength{\test}
\setbox0=\hbox{$a\mathord{\upuparrows}b$}
\setbox1=\hbox{$a\mathop{\upuparrows}b$}
\setbox2=\hbox{$a\mathbin{\upuparrows}b$}
\setbox3=\hbox{$a\mathrel{\upuparrows}b$}
\setbox4=\hbox{$a\mathopen{\upuparrows}b$}
\setbox5=\hbox{$a\mathclose{\upuparrows}b$}
\setbox6=\hbox{$a\mathpunct{\upuparrows}b$}
\setbox7=\hbox{$a\upuparrows b$}
\begin{tabular}{ll}
mathord & \setlength{\test}{\wd0} \the\test\\
mathop & \setlength{\test}{\wd1} \the\test\\
mathbin & \setlength{\test}{\wd2} \the\test\\
mathrel & \setlength{\test}{\wd3} \the\test\\
mathopen & \setlength{\test}{\wd4} \the\test\\
mathclose & \setlength{\test}{\wd5} \the\test\\
mathpunct & \setlength{\test}{\wd6} \the\test\\[0.1in]
ACTUAL & \setlength{\test}{\wd7} \the\test\\
\end{tabular}
\end{document}
producing:
Obviously this is not the right way of going about it either; besides the silliness, there is the issue that several math classes can have the same length.
Now in contrast, writing \the\mathcode`<
worked fine; it produced 12604
(which is 313C
in hexadecimal, which has leading digit 3 = mathrel, as it should).
I did try adding the backtick in front of \upuparrows
, but this just produced the errors
Improper alphabetic constant \the\mathcode`\upuparrows
Missing $ inserted \the\mathcode`\upuparrows
Missing $ inserted
(Incidentally, what is the backtick doing exactly? I am reading the TeXbook and the examples given there use it, e.g. but I couldn't find an explanation.)
I also tried the approach that seemed to be suggested by this TeX.SE thread:
\documentclass{article}
\usepackage{amssymb}
\begin{document}
\the\mathcode\string\upuparrows
\end{document}
but that produced
Missing number, treated as zero \the\mathcode\string\upuparrows
`b
when TeX is looking for a number denotes the position ofb
in the ASCII code. It can be used only in front of a character or a (not necessarily defined) control sequence whose name consists of one character. Thus\the\mathcode`\\
is legal although not very useful because it gives the mathcode of the backslash. Only characters have a mathcode.