# How to keep lists indented in proof environment?

I have the following proof environment:


\begin{proof}
\leavevmode

\begin{enumerate}
\item[Case 1:] $3\mid n$. Then $n=3k$ for some integer $k$. Thus $n^2 = 9k^2 = 3(3k^2)$, and so $3\mid n^2$.
\item[Case 2:] $3\nmid n$. By the division algorithm, either $n=3k+1$ or $n = 3k+2$ for some integer k.
\begin{enumerate}
\item[Case 2a)] Suppose $n=3k+1$. Then $n^2 = (3k+1)^2 = 9k^2 + 6k + 1$ and so $n^2 = 3(3k^2 + 2k) + 1$. Therefore, $n^2 = 3m+1$ for some integer m, and so $n^2 - 1 = 3m$, thus $3\mid n^2 - 1$.
\item[Case 2b)] Suppose $n = 3k + 2$. Then $n^2 = (3k+2)^2 = 9k^2 + 12k + 4 = 3(3k^2+4k + 1) + 1$. $n^2 - 1 = 3(3k^2 +4k + 1)$, thus $3\mid n^2 -1$.
\end{enumerate}

\end{enumerate}

\end{proof}


And it renders the following:

I would like it for Case 1 and Case 2 to be in line with "Proof" part of the proof environment, but nothing I do (including adding manual indentation with \indent) seems to work. What could I do?

• You are using amsthm. That by itself doesn't indent the heading, so it's necessary to know what document class you're using. (amsbook and amsproc do specify that "Proof" should be indented., but amsart does not.) Commented May 27, 2023 at 19:46
• I'm using \documentclass{article}! How does this differ depending on document class, though? Because in the future, I might transfer this to a document class of book. Commented May 27, 2023 at 21:15
• With amsthm, the proof heading is not indented in classes other than amsbook and amsproc (see tex.stackexchange.com/q/339440 and the answer by @egreg.) Something else is going on, as demonstrated in the answer. Commented May 27, 2023 at 21:48

If you add showframe you see what's going wrong.

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

\usepackage{showframe}

\begin{document}

\begin{proof}
\leavevmode

\begin{enumerate}
\item[Case 1:] $3\mid n$. Then $n=3k$ for some integer $k$. Thus $n^2 = 9k^2 = 3(3k^2)$, and so $3\mid n^2$.
\item[Case 2:] $3\nmid n$. By the division algorithm, either $n=3k+1$ or $n = 3k+2$ for some integer k.
\begin{enumerate}
\item[Case 2a)] Suppose $n=3k+1$. Then $n^2 = (3k+1)^2 = 9k^2 + 6k + 1$ and so $n^2 = 3(3k^2 + 2k) + 1$. Therefore, $n^2 = 3m+1$ for some integer m, and so $n^2 - 1 = 3m$, thus $3\mid n^2 - 1$.
\item[Case 2b)] Suppose $n = 3k + 2$. Then $n^2 = (3k+2)^2 = 9k^2 + 12k + 4 = 3(3k^2+4k + 1) + 1$. $n^2 - 1 = 3(3k^2 +4k + 1)$, thus $3\mid n^2 -1$.
\end{enumerate}

\end{enumerate}

\end{proof}

\end{document}


Use enumitem and remember about \qedhere (although adding some finishing words would be better).

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

\usepackage{showframe}

\begin{document}

\begin{proof}
We divide our proof into cases.
\begin{enumerate}[label=Case \arabic*:,ref=\arabic*,leftmargin=*]
\item $3\mid n$. Then $n=3k$ for some integer $k$. Thus $n^2 = 9k^2 = 3(3k^2)$,
and so $3\mid n^2$.

\item \label{case2} $3\nmid n$. By the division algorithm, either $n=3k+1$ or
$n = 3k+2$ for some integer k.
\begin{enumerate}[label=Case \ref{case2}\alph*),leftmargin=2em]
\item Suppose $n=3k+1$. Then $n^2 = (3k+1)^2 = 9k^2 + 6k + 1$ and so
$n^2 = 3(3k^2 + 2k) + 1$. Therefore, $n^2 = 3m+1$ for some integer m,
and so $n^2 - 1 = 3m$, thus $3\mid n^2 - 1$.
\item Suppose $n = 3k + 2$. Then $n^2 = (3k+2)^2 = 9k^2 + 12k + 4 = 3(3k^2+4k + 1) + 1$.
$n^2 - 1 = 3(3k^2 +4k + 1)$, thus $3\mid n^2 -1$.\qedhere
\end{enumerate}
\end{enumerate}
\end{proof}

\end{document}


• Thanks! You've saved me from trying to manufacture a patch. Commented May 27, 2023 at 22:06
• Thank you for the fix! However, I'm confused about what exactly you did that fixed it. I tried adding leftmargin=* on its own, but it didn't do anything; but when I added the rest of the code, which should just be for changing the labels, the indentation fixes itself. Also, do you happen to know why the enumerate environment isn't inside the box you displayed by default, but the proof is? Commented May 28, 2023 at 2:59
• @Mailbox The main fix is using label=… Commented May 28, 2023 at 7:03