0

Here is a visual representation of what I am talking about: "Proof"

How do I make it so that at each proof, the counter resets to (1)?

Thank you for your answer.

5
  • 2
    The equation number should probably be relative to the theorem, rather that just a cold restart every time. Otherwise you'll be left with duplicate equation numbers. Would you agree?
    – Werner
    Feb 21, 2019 at 23:27
  • 1
    Do you have equation numbers outside proofs? If so, how should they be?
    – egreg
    Feb 21, 2019 at 23:38
  • I guess the problem is that even though I wrote \begin{theorem} statement, I couldn't get LaTex to recognize it. Is it possible that I am missing a package that allows it to recognize and show theorems? I have \documentclass[a4paper]{article} \usepackage[utf8]{inputenc} \usepackage{amsmath} \usepackage{amsthm} \usepackage{amssymb} I am a newbie, so I am sorry if I'm making a rookie mistake.
    – natsushima
    Feb 22, 2019 at 0:06
  • @natsushima, define \newtheorem{theorem}{Theorem} in preamble.
    – Sigur
    Feb 22, 2019 at 0:21
  • Thank you so much; that worked perfectly! However, it only shows the theorems, but it doesn't reset the counter for equations within theorems...
    – natsushima
    Feb 22, 2019 at 0:22

1 Answer 1

1

The simplest thing to do would be to create your own proof environment that resets the equation number:

\newenvironment{myproof}{\setcounter{equation}{0}\begin{proof}}{\end{proof}}

Or, if preferred, save the current equation number going into the proof so it can be restored afterwards:

\newcounter{savenumber}
\newenvironment{myproof}{%
\setcounter{savenumber}{\value{equation}}\setcounter{equation}{0}%
\begin{proof}}%
{\end{proof}%
\setcounter{equation}{\value{savenumber}}%
}

Example use and output

%\usepackage{amsmath} % preamble
%\usepackage{amsthm} % preamble
\begin{document}
\begin{equation}
    x=1
\end{equation}
\begin{equation}
    x=2
\end{equation}
\begin{myproof}
    \begin{equation}
        x=3
    \end{equation}
\end{myproof}
\begin{equation}
    x=4
\end{equation}
\end{document}

output1

Both are likely confusing to a reader and the hyperref package will complain (and not be able to correct link each equation), if you are using that. A better approach would be to add a visual identifier (and one for hyperref, if applicable) for equations in your new proof environment, such as:

\newcounter{savenumber}
\newenvironment{myproof}{%
\renewcommand{\theequation}{p.\arabic{equation}}% Visual identifier
% \renewcommand{\theHequation}{p.\arabic{equation}}% Uncomment if using hyperref
\setcounter{savenumber}{\value{equation}}\setcounter{equation}{0}%
\begin{proof}}%
{\end{proof}%
\setcounter{equation}{\value{savenumber}}
}

Then

output2

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .