[Tex/LaTex] Writing mod in congruence problems without leading space

math-modespacing

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)$?

Best Answer

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

\documentclass{article}

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

\begin{document}

\begin{align*}
  a &\equiv r \mod n \\
  a &\equiv r \pmod{n} \\
  a &\equiv r \Mod{n}
\end{align*}

\end{document}