Here's a MWE:

\[a \x b\]
\[c \y d\]

The command \times apparently changes meaning at the \begin{document} line, because the alias made to it before that line does not work properly:

This does not happen without the unicode-math package. What am I seeing here? I have always thought of the \begin{document} as a rather innocent marker, which only delimits the end of preamble (disallowing further use of certain commands), but it apparently has side effects at least in interaction with this package.

I'm using xelatex if this makes any difference.

  • 1
    Lots of packages hook into \begin{document} (via \AtBeginDocument or \AtEndPreamble). Some because they need to execute code when all packages have been loaded (to avoid effects of package loading order) or when other packages have done their thing. I think it is not unusual for some font setup to happen at or around \begin{document}.
    – moewe
    May 15 '20 at 6:44
  • 2
    For alias command like this I would usually use \newcommand instead of \let. It always uses the current definition and does not blindly overwrite existing macros. \newcommand*{\x}{\times} and \newcommand*{\y}{\times} should give the same results in both places. (As a general note it is very dangerous to overwrite one letter commands with \let or \def. Many one-letter commands are already taken: \d, \c, ... If you redefine them, you may wreak havoc on the rest of your document.)
    – moewe
    May 15 '20 at 6:45
  • 4
    \begin{document} is not an innocent marker. If you want to see what is happening there put \tracingmacros=1 before is and \tracingmacros=0 behind it. Compile and then look in the log. (in a current tex system expect around 2.700.000 lines of log, stuff with __um in the name is from unicode math). May 15 '20 at 6:48

When you do \let\x\times the meaning of \times is still the LaTeX default; indeed, if you add


after the \let operation, you get

> \x=\mathchar"2202.
l.4 \show\x

If you further add \showthe\textfont2 before the first \], that is, in the display where \x is used, you get

> \TU/latinmodern-math.otf(2)/m/n/10 .
<to be read again>
l.7 \[a \x b\showthe\textfont2\]

You see that \x instructs TeX to make an operation symbol (first byte is 2) taking from the font in the math family 2 the character at slot "02. And indeed the log file shows

Missing character: There is no ^^B in font 

No character, but the spacing around the math binary operation symbol is honored.

Why doesn't unicode-math change the meaning of \times when it is loaded? Because it needs to know the entire math and text font setup, which can only be detected at begin document.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.