$n\equiv 1\pmod{4}$ 사이의 공간을 줄이는 방법

$n\equiv 1\pmod{4}$ 사이의 공간을 줄이는 방법

다음 코드를 실행했는데 \pmod함수를 사용할 때 다음과 같은 거대한 공간이 생겼습니다. 신문에 이상하게 나오네요. 공간을 줄이는 방법을 제안해 줄 수 있는 사람이 있나요?

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

여기에 이미지 설명을 입력하세요

답변1

수행원선행 공백 없이 합동 문제에서 모드 작성, \Mod아래 정의된 대로 사용합니다.

여기에 이미지 설명을 입력하세요

\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}

답변2

기울임꼴 글꼴로 판단하면 디스플레이가 정리문 내부에 있는 것입니다.

나는 괄호와 공통 부분의 반복을 피할 것입니다:

\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}

몇 가지 참고사항:

  1. “MSC”는 정직하고 운영자로서 대우받아야 합니다.
  2. 기울임꼴 글꼴의 경우에도 수학 변수는 수학 모드에서 입력해야 합니다.
  3. eqnarray사용 가능한 경우에는 사용되지 않습니다 amsmath. (그리고 문서에 심각한 수학이 있을 때마다 로드해야 합니다.
  4. 적절한 환경을 사용하십시오. 이 경우에는 equation*정렬이 없기 때문입니다.

여기에 이미지 설명을 입력하세요

답변3

LaTeX 커널은 다음의 정의를 차용합니다.\pmod

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

( ltmath.dtx코드 라인 39-40 참조) 일반 TeX에서 다음과 같이 읽습니다.

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

(보다TeXbook, p. 361); 두 경우 모두 "mod"라는 단어 앞에 오는 공백의 너비는 1em입니다. p.에 제시된 사용 예. 164개TeXbook, 그리고 연습 18.4에 대한 답은 Knuth가 그 정도의 공간을 인라인 수학 공식에도 사용해야 한다는 것을 보여줍니다. 그럼에도 불구하고 amsmath패키지는 수식이 "표시되지 않음"일 때 더 좁은 공간이 사용되는 방식으로 위의 정의를 수정합니다.

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

(또한보십시오이 답변에게선행 공백 없이 합동 문제에서 모드 작성, 이미 링크된 질문입니다.받아들인 대답이 질문에). 보시다시피 \if@display스위치를 통해 "표시되지 않음" 상태가 감지됩니다.

이 질문을 곰곰히 생각하면서 이것이 패키지의 버그(또는 오히려 설계 결함)일 수 있는지 궁금해지기 시작했습니다. 아마도 더 나은 아이디어는 "큰 연산자" 기호가 디스플레이 사이에서 크기(및 어느 정도 모양)를 좋아 \sum하거나 변경하는 방식과 유사한 방식으로 현재 수학 스타일로 공간 변경량을 갖는 것입니다. \int그리고 비 디스플레이 수학. 이 동작은 다음 코드에 표시된 \pod명령(패키지에 의해 정의됨 ) 에 대한 패치를 통해 쉽게 달성됩니다 .amsmath

% 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}

위 코드의 결과는 다음과 같습니다.

코드 출력

이러한 수정은 질문이 요구하는 것을 달성하는 우아하고 일관된 방법이 될 수 있습니다. 해당 \mod명령을 함께 사용하는 경우에도 비슷하게 수정해야 합니다. 물론 masmath이러한 기능을 사용하는 기존 문서를 모두 중단하지 않고는 패키지 코드에 이러한 변경 사항을 도입할 수 없습니다 .


덧셈: 이 문제를 계속 검토하면서 저는 이 \pmod명령을 위/아래 첨자에 사용하는 것이 합리적일 수 있다고 생각했습니다(아래 예 참조). 그리고 이 경우에는 왼쪽 괄호 앞의 공간을 더 얇게 만들어야 할 것 같습니다.

% 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}

이 두 번째 경우의 출력은 다음과 같습니다.

두 번째 코드 샘플의 출력

답변4

\pmod특히 외부(텍스트) 괄호가 이탤릭체인 경우 괄호 안에 사용하는 것이 그다지 좋아 보이지 않는다고 생각하므로 \bmod대신 사용하는 것이 좋습니다. 나는 두 가지 방법을 제안합니다: 모듈러스 조건을 정렬하기 위해 사례 eqparbox` cases*의 환경을 사용합니다.mathtools (simpler syntax), and with a standard,and

\documentclass{article}

\usepackage{mathtools}
\usepackage{eqparbox}

\begin{document}

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

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

\end{document} 

여기에 이미지 설명을 입력하세요

관련 정보