The \mod operator is padded with too much space: $a \mod b$. Am I missing something in the TeX, or is something configured wrong?

I've tried with Firefox and Safari on OS X.

  • 9
    $\begingroup$ It's the correct behavior. If you want a "mod" with less space use \bmod (as in "binary mod"): $a \bmod b$. \mod is more keeping with the spirit of \pmod: $a \pmod{b}$. $\endgroup$ Commented Jul 11, 2015 at 8:36
  • 1
    $\begingroup$ TeX.SE: typesetting modulus operator, as in remainder BTW there is also \pmod if you want to get something like $x^2\equiv-1 \pmod n$. $\endgroup$ Commented Jul 11, 2015 at 8:38
  • $\begingroup$ Thanks. I chose \pmod. It looks like \mod is really useless and broken, but this is the wrong forum to complain about that :P . $\endgroup$ Commented Jul 11, 2015 at 8:40
  • 4
    $\begingroup$ Just to make sure that you know: \bmod is designed to look good if you want the remainder. Like $(7\bmod 5)=2$. OTOH \pmodis designed to look good, if you want a congruence. Like $5\equiv 7\pmod2$ or $14\equiv11\pmod3$. With \bmod the 'value' of the calculation is an integer. The 'value' of a congruence OTOH is boolean, because it is semantically a comparison operation. $\endgroup$ Commented Jul 11, 2015 at 9:02
  • $\begingroup$ @JyrkiLahtonen Oh, thanks, I guess my usage was wrong, then. $\endgroup$ Commented Jul 11, 2015 at 9:24

2 Answers 2


What \mod is for:

$$ 5 \equiv 8 \mod 3$$

What \bmod is for:

$$ 5 \bmod 3 = 2 $$

And for completeness, \pmod:

$$ -1 \equiv 8 \pmod 3$$


As a workaround with \mod (being a little forgetful and more than a little obstinate), I sometimes use the thin negative space modifier \! to remove the excess whitespace. Here are the results without the modifier, followed by using it once and then twice:

$$ 5 \equiv 8 \mod 3 $$

$$ 5 \equiv 8 \! \mod 3 $$

$$ 5 \equiv 8 \!\! \mod 3 $$

I generally find the latter to be about what I want for inline "modulo" equations.

  • 1
    $\begingroup$ you can also use \hspace{-2mm} $\endgroup$
    – Surb
    Commented Jul 13, 2015 at 20:06

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .