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:
\usepackage{amsmath}
\makeatletter
\newcommand{\tpmod}[1]{{\@displayfalse\pmod{#1}}}
\makeatother

\documentclass{article}
\usepackage{amsmath}
\makeatletter
\newcommand{\tpmod}[1]{{\@displayfalse\pmod{#1}}}
\makeatother
\begin{document}
Text (no change): \( a\tpmod{b} \) vs.\ \( c\pmod{d} \).
Display:
\begin{gather*}
a\tpmod{b} \\
\intertext{vs.}
c\pmod{d}.
\end{gather*}
\end{document}
\pmod
(fromamsmath
), perhaps utilizing the redefinition as in Removing extra space with\pmod
command.\bmod
also fromamsmath
is an option.