Latex counters: modifying \numberwithin?

  • LaTeX
  • Thread starter honestrosewater
  • Start date
  • Tags
    Latex
In summary, the conversation discusses the need to reset the counter for each proof in the proof and align environments. There are two possible solutions proposed - defining a new proof counter and modifying \numberwithin to reset the equation counter, or manually adding \setcounter where the reset is needed. The definition of the proof environment from amsthm.sty is also provided, which can be used to add a \setcounter statement in the appropriate place for automatic reset.
  • #1
honestrosewater
Gold Member
2,142
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
  • #2
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.
 

What is the purpose of modifying \numberwithin in LaTeX counters?

The \numberwithin command is used to reset the numbering of a counter within a specific environment or section. Modifying it allows for more control over the numbering of objects in a document.

How do I modify the \numberwithin command?

To modify the \numberwithin command, you can use the \renewcommand or \newcommand commands, along with the desired modifications to the counter's format.

Can I modify the numbering of multiple counters with \numberwithin?

Yes, you can modify the numbering of multiple counters by using the \numberwithin command multiple times, each with a different counter name and format.

What are some examples of counters that can be modified with \numberwithin?

Counters such as figures, tables, equations, and sections can be modified using \numberwithin. Additionally, custom counters created with the \newcounter command can also be modified.

Are there any limitations to modifying \numberwithin?

There are some limitations to modifying \numberwithin, such as not being able to use it with counters that are automatically generated, such as page numbers. It also cannot be used to modify the numbering of counters that are referenced in other parts of the document.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
8
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
3
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
3
Views
340
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
9
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
3
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
8
Views
11K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
945
  • Calculus and Beyond Homework Help
Replies
1
Views
274
  • Linear and Abstract Algebra
Replies
11
Views
1K
Back
Top