[Tex/LaTex] Why is this weird space appearing after the minus sign

math-operatorsspacing

I'm using MathJax-Node to turn TeX maths equations into both MathML and SVG on my server. Mostly this works fine. But when I render Tupper's self-referential formula, a weird space appears after the second minus sign in the exponent: Rendered formula.

The space also appears on mathURL (which is where the above image comes from). When I examine the MathML generated, I can see that MathJax has explicitly inserted a mspace element.

The TeX I'm using is as follows:

\frac12<\left\lfloor\mod\left(\left\lfloor\frac y{17}\right\rfloor2^{{-17}\left\lfloor x\right\rfloor-\mod\left(\left\lfloor y\right\rfloor,17\right)},2\right)\right\rfloor

Any idea what's going on here?

Best Answer

You're using “mod” as a math operator like “exp” or “sin”. The command \mod is for notation such as

5 \equiv 2 \mod{3}

and the inserted space is obviously wanted here.

Use \operatorname{mod} instead.

\documentclass{article}
\usepackage{amsmath}

\begin{document}

\[
\frac{1}{2}<
  \left\lfloor
    \operatorname{mod}\left(
      \left\lfloor\frac{y}{17}\right\rfloor
      2^{-17\lfloor x\rfloor-\operatorname{mod}(\lfloor y\rfloor,17)},2
    \right)
  \right\rfloor
\]

\end{document}

I've removed useless (and wrong) \left and \right pairs.

enter image description here

It works equally well in MathJax (tested on Math.SE):

enter image description here

Related Question