I have been writing

$a \equiv r (\mod n)$

but this puts a space between the ( and mod. For example, r ( mod n ) instead of r (mod n). So, how do you write r (\mod n) without that space? What would be the correct way to write $a \equiv r (\mod n)$?


The spacing issue is an obvious indication that it's not meant to be used that way. However, you could wing your own, depending on the sophistication you're after:

enter image description here


\newcommand{\Mod}[1]{\ (\mathrm{mod}\ #1)}


  a &\equiv r \mod n \\
  a &\equiv r \pmod{n} \\
  a &\equiv r \Mod{n}

  • This is great! I like how \Mod{n} looks. The only problem I'm encountering with \Mod{n} is that the "mod" becomes italicized in theorem/lemma/example/proof/etc. environments. – Mathemanic Aug 31 '14 at 19:12
  • 1
    @Mathemanic: You can try using \textup (or perhaps \mbox) instead of \text. – Werner Aug 31 '14 at 19:38
  • 4
    This should be \mathrm{mod}. – egreg Mar 9 '17 at 13:23
  • @egreg why is it \mathrm over \operatorname? – It'sNotALie. Nov 3 '19 at 22:59
  • @It'sNotALie. Because this is not an operator. – egreg Nov 3 '19 at 23:27

I think $a \equiv r \;(\bmod\; n)$ does what you want (as mentioned by jfbu in the comment).


Both the latex kernel and amsmath provide the command \pmod. In the latex kernel \pmod provides a fixed amount of space before (mod ...). The amsmath version is slightly more sophisticated, using a smaller amount of space when not in a display. So one way is to define a new command that temporarily switches off the display mode:



Sample output





Text (no change): \( a\tpmod{b} \) vs.\ \( c\pmod{d} \).

  a\tpmod{b} \\


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.