Latex counters: modifying \numberwithin?

  • Context: LaTeX 
  • Thread starter Thread starter honestrosewater
  • Start date Start date
  • Tags Tags
    Latex
Click For Summary
SUMMARY

The discussion focuses on modifying LaTeX counters within the proof environment to reset the equation counter for each proof. Users suggest using the \setcounter command manually to reset the counter, while also exploring the possibility of automating this process within the proof environment defined in amsthm.sty. The conversation highlights the need for a solution that allows for clear referencing of formulas across multiple proofs without manual intervention. Ultimately, the consensus leans towards customizing the proof environment to include a reset mechanism for the equation counter.

PREREQUISITES
  • Familiarity with LaTeX document preparation system
  • Understanding of the amsthm package for theorem environments
  • Knowledge of LaTeX counters and the \setcounter command
  • Basic experience with the align environment for formatting equations
NEXT STEPS
  • Research how to customize the proof environment in LaTeX
  • Learn about the \numberwithin command and its applications
  • Explore advanced counter manipulation techniques in LaTeX
  • Investigate creating custom environments for specific formatting needs in LaTeX
USEFUL FOR

LaTeX users, mathematicians, and researchers who need to format proofs with numbered lines and references, particularly those working with the amsthm package.

honestrosewater
Gold Member
Messages
2,133
Reaction score
6
I am writing up some formal proofs using the proof and align environments. Each line in the proof needs to be numbered and will contain a formula and a statement referring to earlier lines in the proof that were used to derive it. I want to reset this counter for each proof. It should look something like this:
Proof [text]
(1) [formula] assumption
(2) [formula] assumption
(3) [formula] MP(1, 2)
...

Proof [text]
(1) [formula] assumption
(2) [formula] MT(repl, 1)
...

What's the easiest way to do this? Should I define a new proof counter and modify \numberwithin to reset the equation counter when proof is incremented? (I don't know how to do this.) Or should I skip using equation and just define my own counter that will increment with each new line in align? (I don't know how to do this either.)

Edit: Oh, duh, I'll just add \setcounter manually where I want it reset. Is there a way to get the proof environment to do this automatically?
 
Last edited:
Physics news on Phys.org
Here's the definition of the proof environment from amsthm.sty:
Code:
\newenvironment{proof}[1][\proofname]{\par
  \pushQED{\qed}%
  \normalfont \topsep6\p@\@plus6\p@\relax
  \trivlist
  \item[\hskip\labelsep
        \itshape
    #1\@addpunct{.}]\ignorespaces
}{%
  \popQED\endtrivlist\@endpefalse
}
You could always just repeat this in your document preamble (or put it in a style file of your own) and add in a \setcounter statement in the appropriate place.
 

Similar threads

  • · Replies 8 ·
Replies
8
Views
3K
  • · Replies 3 ·
Replies
3
Views
4K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 9 ·
Replies
9
Views
6K
  • · Replies 8 ·
Replies
8
Views
13K
  • · Replies 1 ·
Replies
1
Views
4K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 2 ·
Replies
2
Views
4K