[Tex/LaTex] Parts numbering in Proofs

amsthmnumberingtheorems

I am using proof environment from amsthm to type proofs. Some proofs are long, so it would be nice to split them into numbered parts. I have defined new theorem environment called proofpart for that purpose.

The problem is that the proofpart counter does not reset inside a new proof and continues to grow. So I wonder how the counter can be reset for such case.

Sample document:

\documentclass{article}
\usepackage{amsthm}


\theoremstyle{definition}
\newtheorem{proofpart}{Part}
\newtheorem{theorem}{Theorem}

\begin{document}
  \begin{theorem}
    Some theorem
  \end{theorem}

  \begin{proof}
    Proof of some theorem
    \begin{proofpart} % 1
      First part 
    \end{proofpart}
    \begin{proofpart} % 2
      Second part
    \end{proofpart}
  \end{proof}


  \begin{theorem}
    Another theorem
  \end{theorem}

  \begin{proof}
    Proof of another theorem
    \begin{proofpart} % 3, but should be 1
      First part
    \end{proofpart}
    \begin{proofpart} % 4, but should be 2
      Second part
    \end{proofpart}
  \end{proof}

\end{document}

Best Answer

One option would be to use \@addtoreset:

\documentclass{article}
\usepackage{amsthm}

\theoremstyle{definition}
\newtheorem{proofpart}{Part}
\newtheorem{theorem}{Theorem}
\makeatletter
\@addtoreset{proofpart}{theorem}
\makeatother

\begin{document}
  \begin{theorem}
    Some theorem
  \end{theorem}

  \begin{proof}
    Proof of some theorem
    \begin{proofpart} % 1
      First part 
    \end{proofpart}
    \begin{proofpart} % 2
      Second part\qedhere
    \end{proofpart}
  \end{proof}


  \begin{theorem}
    Another theorem
  \end{theorem}

  \begin{proof}
    Proof of another theorem
    \begin{proofpart} % it is 1
      First part
    \end{proofpart}
    \begin{proofpart} % it is 2
      Second part\qedhere
    \end{proofpart}
  \end{proof}

\end{document}

enter image description here

A little description taken from source2e:

\@addtoreset{foo}{bar} : Adds counterfooto the list of counters \cl@barto be reset when counterbar` is stepped.

Another option (suggested by Werner) would be to use the second optional argument for \newtheorem in the definition of proofpart (this requires defining this structure after the theorem environment) and a redefinition of the representation of the associated counter:

\documentclass{article}
\usepackage{amsthm}

\theoremstyle{definition}
\newtheorem{theorem}{Theorem}
\newtheorem{proofpart}{Part}[theorem]
\renewcommand\theproofpart{\arabic{proofpart}}

\begin{document}
  \begin{theorem}
    Some theorem
  \end{theorem}

  \begin{proof}
    Proof of some theorem
    \begin{proofpart} % 1
      First part 
    \end{proofpart}
    \begin{proofpart} % 2
      Second part\qedhere
    \end{proofpart}
  \end{proof}


  \begin{theorem}
    Another theorem
  \end{theorem}

  \begin{proof}
    Proof of another theorem
    \begin{proofpart} % it is 1
      First part
    \end{proofpart}
    \begin{proofpart} % it is 2
      Second part\qedhere
    \end{proofpart}
  \end{proof}

\end{document}

\newtheorem{env-name}{doc-name}[counter], where counter is an existing or previouly defined counter, causes the env-name counter to be reset whenever the parent counter counter is incremented; however, the label will have the counter number pre-pended, so a redefinition of the representation is needed to suppress the pre-pendend string.

I also used \qedhere to correct the end-mark position.