How to reduce space between $n\equiv 1\pmod{4}$

Judging from the italic font, the display is inside a theorem statement.

I would avoid the parentheses and the repetition of common parts:

\documentclass{article}
\usepackage{amsmath}

\newtheorem{theorem}{Theorem}
\DeclareMathOperator{\MSC}{MSC}

\begin{document}

\begin{theorem}
Blah, blah
\begin{equation*}
\MSC(C_n^2)=
\begin{cases}
  1, & \text{if $n$ is odd and $d$ is even, i.e., $n\equiv 1$},\\
  2, & \text{if $n$ is even and $d$ is even, i.e., $n\equiv 0$},\\
  3, & \text{if $n$ is odd and $d$ is odd, i.e., $n\equiv 3$},\\
  3, & \text{if $n$ is even and $d$ is odd, i.e., $n\equiv 2$},
\end{cases}
\end{equation*}
where congruences are modulo~$4$.
\end{theorem}

\end{document}

Some notes:

  1. “MSC” should be upright and treated as an operator;
  2. even in the context of italic font, math variables should be input in math mode;
  3. eqnarray is not to be used when amsmath is available (and it should be loaded whenever a document has serious math in it;
  4. use the proper environment, in this case equation* because you don't have an alignment.

enter image description here


Following Writing mod in congruence problems without leading space, use \Mod as defined below:

enter image description here

\documentclass{article}

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

\begin{document}

\begin{align*}
  MSC(C_n^2) &= 
    \begin{cases}
      1, & \text{if $n$ is odd and $d$ is even ($n \equiv 1 \Mod{4}$)},  \\
      2, & \text{if $n$ is even and $d$ is even ($n \equiv 0 \Mod{4}$)}, \\
      3, & \text{if $n$ is odd and $d$ is odd ($n \equiv 3 \Mod{4}$)},   \\
      3, & \text{if $n$ is even and $d$ is odd ($n \equiv 2 \Mod{4}$)}.
    \end{cases}
\end{align*}

\end{document}

The LaTeX kernel borrows its definition of \pmod

\def\pmod#1{%
  \allowbreak\mkern18mu({\operator@font mod}\,\,#1)}

(see ltmath.dtx, code lines 39–40) from plain TeX, in which it reads

\def\pmod#1{\allowbreak\mkern18mu({\rm mod}\,\,#1)}

(see The TeXbook, p. 361); in both cases, the space that precedes the word “mod” is 1em wide. The examples of use given on p. 164 of The TeXbook, as well as the answer to Exercise 18.4, show that Knuth intended that that amount of space ought to be used also in in-line math formulas. Nonetheless, the amsmath package modifies the above definition in such a way that a narrower space is employed when the formula is “not displayed”:

\newcommand{\pod}[1]{\allowbreak
  \if@display\mkern18mu\else\mkern8mu\fi(#1)}
\renewcommand{\pmod}[1]{\pod{{\operator@font mod}\mkern6mu#1}}

(see also this answer to Writing mod in congruence problems without leading space, a question already linked from the accepted answer to this question). As you can see, the condition of “not being in display” is detected through the \if@display switch.

Musing over this question, I began to wonder whether this could be a bug—or rather, a design flaw—in the package. Perhaps a better idea would be to have the amount of space change with the current math style, in a fashion similar to the way in which “big operator” symbols like \sum or \int change their size (and, to some extent, their shape) between display and non-display math. This behavior is easily achieved with the patch to the \pod command (defined by the amsmath package) that the following code shows:

% My standard header for TeX.SX answers:
\documentclass[a4paper]{article} % To avoid confusion, let us explicitly 
                                 % declare the paper format.

\usepackage[T1]{fontenc}         % Not always necessary, but recommended.
% End of standard header.  What follows pertains to the problem at hand.

% \usepackage{amsmath} % Required for what follows; but...
\usepackage{mathtools} % ... "mathtools" automatically loads "amsmath".

\makeatletter

\renewcommand*\pod[1]{%
  \allowbreak
  \mathchoice
    {\mkern 18mu}%
    {\mkern  8mu}%
    {\mkern  8mu}%
    {\mkern  8mu}%
  (#1)%
}

\makeatother

\newtheorem{thm}{Theorem}



\begin{document}

In-line: \( 5\equiv 1 \pmod 4 \).  In display:
\[ 5\equiv 1 \pmod 4 \]
Non-display inside display:
\[
    f(x) =
        \begin{cases}
            4 & \mbox{if $x\equiv 0 \pmod 4$,} \\
            x\bmod 4 & \mbox{otherwise.}
        \end{cases}
\]
The same thing, but with \texttt{cases*} (requires \textsf{mathtools}):
\[
    f(x) =
        \begin{cases*}
            4 & if $x\equiv 0 \pmod 4$, \\
            x\bmod 4 & otherwise.
        \end{cases*}
\]

\begin{thm}
    All over again.
    In-line: \( 5\equiv 1 \pmod 4 \).  In display:
    \[ 5\equiv 1 \pmod 4 \]
    Non-display inside display:
    \[
        f(x) =
            \begin{cases}
                4 & \mbox{if $x\equiv 0 \pmod 4$,} \\
                x\bmod 4 & \mbox{otherwise.}
            \end{cases}
    \]
    With \texttt{cases*}:
    \[
        f(x) =
            \begin{cases*}
                4 & if $x\equiv 0 \pmod 4$, \\
                x\bmod 4 & otherwise.
            \end{cases*}
    \]
\end{thm}

Nonetheless, inside an alignment, say
\begin{align*}
    2 &\equiv 9 \pmod 7 \\
    4 &\equiv 1 \pmod 3 \mbox{,}
\end{align*}
the output agrees with that of a displayed equation:
\[
    5\equiv 1 \pmod 4 \mbox{.}
\]

\end{document}

This is the output the above code yields:

Output of the code

This modification could be an elegant and consistent way of achieving what the question asks for. If the \mod command is used as well, it should be similarly modified too. Of course, one can’t introduce these changes in the code of masmath package without disrupting all existing documents that use these features…


Addition: Continuing to chew over this issue, I thought that it could even make sense to use the \pmod command in super/subscripts (see example below); and in this case, it seems that the space before the left parenthesis should be made even thinner.

% My standard header for TeX.SX answers:
\documentclass[a4paper]{article} % To avoid confusion, let us explicitly 
                                 % declare the paper format.

\usepackage[T1]{fontenc}         % Not always necessary, but recommended.
% End of standard header.  What follows pertains to the problem at hand.

% \usepackage{amsmath} % Required for what follows; but...
\usepackage{mathtools} % ... "mathtools" automatically loads "amsmath".

\makeatletter

\renewcommand*\pod[1]{%
  \allowbreak
  \mathchoice
    {\mkern 18mu}%
    {\mkern  8mu}%
    {\mkern  6mu}% "6mu" matches the space *after* the word "mod"
    {\mkern  6mu}%
  (#1)%
}

\makeatother

\newtheorem{thm}{Theorem}



\begin{document}

In-line: \( 5\equiv 1 \pmod{4} \).  In display:
\[ 5\equiv 1 \pmod{4} \]
Non-display inside display:
\[
    f(x) =
        \begin{cases}
            4 & \mbox{if $x\equiv 0 \pmod{4}$,} \\
            x\bmod 4 & \mbox{otherwise.}
        \end{cases}
\]
The same thing, but with \texttt{cases*} (requires \textsf{mathtools}):
\[
    f(x) =
        \begin{cases*}
            4 & if $x\equiv 0 \pmod{4}$, \\
            x\bmod 4 & otherwise.
        \end{cases*}
\]

\begin{thm}
    All over again.
    In-line: \( 5\equiv 1 \pmod{4} \).  In display:
    \[ 5\equiv 1 \pmod{4} \]
    Non-display inside display:
    \[
        f(x) =
            \begin{cases}
                4 & \mbox{if $x\equiv 0 \pmod{4}$,} \\
                x\bmod 4 & \mbox{otherwise.}
            \end{cases}
    \]
    With \texttt{cases*}:
    \[
        f(x) =
            \begin{cases*}
                4 & if $x\equiv 0 \pmod{4}$, \\
                x\bmod 4 & otherwise.
            \end{cases*}
    \]
\end{thm}

Nonetheless, inside an alignment, say
\begin{align*}
    2 &\equiv 9 \pmod{7} \\
    4 &\equiv 1 \pmod{3} \mbox{,}
\end{align*}
the output agrees with that of a displayed equation:
\[
    5\equiv 1 \pmod{4} \mbox{.}
\]

In super\slash subscripts:
\[
    \int_{0}^{3\pi} \sin x\,dx
        = -\cos x \biggr|_{0}^{3\pi}
        = -\cos x \biggr|_{x\equiv 0 \pmod{2\pi}}^{x\equiv 3\pi \pmod{2\pi}}
        = -\cos x \biggr|_{0}^{\pi}
        = 1-(-1) = 2
\]

\end{document}

The output in this second case is

Output of the second code sample