证明内的水平空间

证明内的水平空间

我在 LaTeX 中排版一些包含多个案例的证明,有时我希望缩进每个案例以使我的证明更清晰(水平空间与 大致相同\qquad)。

我浏览了 TeX Stack Exchange 上的许多帖子,并尝试了“有哪些用于水平间距的命令?”以及\indent,但都无济于事。

这是一个简单的例子:

\documentclass{article}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{amsthm}

\theoremstyle{definition}
\newtheorem{theorem}{Theorem}
\newtheorem{case}{Case}

\begin{document}

\begin{theorem}
$\forall (n \in \mathbb{Z})\; 2 \vert (n^2 + n)$
\end{theorem}

\begin{proof}
    \begin{case}
    $2 \vert n$ \\
      $2 \vert n \iff \exists (k \in \mathbb{Z}) \text{ s.t. } n = 2k$
      \[
      \begin{array}{r@{\;}l@{\;}l@{\qquad}l}
        \implies & n^2 &= (2k)^2 \\
        &&= 4k^2 \\
        \implies & n^2 + n &= 4k^2 + 2k \\
        &&=2(2k^2+k) \\
        \multicolumn{3}{@{}c}{\text{Let $s = 2k^2 + k$. $k \in \mathbb{Z} \implies s \in \mathbb{Z}$}} \\
        \implies & \multicolumn{2}{@{}l}{\exists (s \in \mathbb{Z}) \text{ s.t. } n^2 + n = 2s} \\
        \iff & 2 \vert (n^2 + n)
      \end{array}
      \]
    \end{case}

    \begin{case}
    $2 \hspace{-2.5pt}\not\vert\, n$ \\
      $2 \vert n \iff \exists (k \in \mathbb{Z}) \text{ s.t. } n = 2k + 1$
      \[
      \begin{array}{r@{\;}l@{\;}l@{\qquad}l}
        \implies & n^2 &= (2k + 1)^2 \\
        &&= 4k^2 + 4k + 1 \\
        \implies & n^2 + n &= 4k^2 + 4k + 1 + 2k + 1 \\
        &&= 4k^2 + 6k + 2 \\
        &&= 2(2k^2 + 3k + 1) \\
        \multicolumn{3}{@{}c}{\text{Let $s = 2k^2 + 3k + 1$. $k \in \mathbb{Z} \implies s \in \mathbb{Z}$}} \\
        \implies & \multicolumn{2}{@{}l}{\exists (s \in \mathbb{Z}) \text{ s.t. } n^2 + n = 2s} \\
        \iff & 2 \vert (n^2 + n)
      \end{array}
      \]
      \vspace*{-2.25\baselineskip} \\
      \qedhere
    \end{case}
\end{proof}

\end{document}

答案1

我会使用enumerate类似 的环境来做到这一点,该环境很容易使用 进行定制enumitem。因此,我定义了一个mycases列表,并带有方便的左边距:

\documentclass{article}
\usepackage{amsmath}
\usepackage{amssymb, bm}
\usepackage{amsthm}
\usepackage{calc}
\newlength{\casewd}
\setlength{\casewd}{\widthof{\bfseries Case 0.}}%
\theoremstyle{definition}
\newtheorem{theorem}{Theorem}
\usepackage{enumitem}
\newlist{mycases}{enumerate}{1}
\setlist[mycases,1]{label = Case \arabic*: , wide=0pt, leftmargin=\dimexpr\casewd + \labelsep, font=\bfseries, topsep=2pt, itemsep=0pt}%

\begin{document}

\begin{theorem}
$\forall (n \in \mathbb{Z})\; 2 \mid(n^2 + n)$
\end{theorem}

\begin{proof}\mbox{}

    \begin{mycases}
    \item $\bm{2 \mid n.} $ \\
      ${}\mkern2mu 2 \mid n \iff \exists (k \in \mathbb{Z}) \text{ s.t. } n = 2k$
      \[
      \begin{array}{r@{\;}l@{\;}l@{\qquad}l}
        \implies & n^2 &= (2k)^2 \\
        &&= 4k^2 \\
        \implies & n^2 + n &= 4k^2 + 2k \\
        &&=2(2k^2+k) \\
        \multicolumn{3}{@{}c}{\text{Let $s = 2k^2 + k$. $k \in \mathbb{Z} \implies s \in \mathbb{Z}$}} \\
        \implies & \multicolumn{2}{@{}l}{\exists (s \in \mathbb{Z}) \text{ s.t. } n^2 + n = 2s} \\
        \iff & 2 \mid (n^2 + n)
      \end{array}
      \]
    \item $\bm{2\nmid n.} $ \\
      ${}\mkern2mu 2 \nmid n \iff \exists (k \in \mathbb{Z}) \text{ s.t. } n = 2k + 1$
      \[
      \begin{array}{r@{\;}l@{\;}l@{\qquad}l}
        \implies & n^2 &= (2k + 1)^2 \\
        &&= 4k^2 + 4k + 1 \\
        \implies & n^2 + n &= 4k^2 + 4k + 1 + 2k + 1 \\
        &&= 4k^2 + 6k + 2 \\
        &&= 2(2k^2 + 3k + 1) \\
        \multicolumn{3}{@{}c}{\text{Let $s = 2k^2 + 3k + 1$. $k \in \mathbb{Z} \implies s \in \mathbb{Z}$}} \\
        \implies & \multicolumn{2}{@{}l}{\exists (s \in \mathbb{Z}) \text{ s.t. } n^2 + n = 2s} \\
        \iff & 2 \mid (n^2 + n)
      \end{array}
      \]
      \vspace*{-2.25\baselineskip} \\
      \qedhere
    \end{mycases}
\end{proof}

\end{document}

在此处输入图片描述

相关内容