LaTeX/Counters

Counters are an essential part of LaTeX: they allow you to control the numbering mechanism of everything (sections, lists, captions, etc.). To that end each counter stores an integer value in the range of long integer, i.e., from $$-2^{31}$$ to $$2^{31}-1$$. 

Counter manipulation
In LaTeX it is fairly easy to create new counters and even counters that reset automatically when another counter is increased (think subsection in a section for example). With the command

you create a new counter that is automatically set to zero. If you want the counter to be reset to zero every time another counter is increased, use:

For example, if you want to enumerate the equations in each chapter independently, you can create something like an "equationschapter" counter that will be automatically reset at the begin of each section.

To add to an existing counter another counter causing a reset when increased, use:

If this doesn't work it might be because of an old LaTeX version, the following should work in that case:

To undo this effect one can use:

or:

To increase the counter, either use

or

or

here the number can also be negative. For automatic resetting you need to use.

To set the counter value explicitly, use

Counter access
There are several ways to get access to a counter.
 * will print the formatted string related to the counter (note the "the" before the actual name of the counter).
 * will return the counter value which can be used by other counters or for calculations. It is not a formatted string, so it cannot be used in text.
 * will print the formatted counter using arabic numbers.

Note that may be used as a value too, but not the others.

Strangely enough, LaTeX counters are not introduced by a backslash in any case, even with the command. plainTeX equivalents and  do abide by the backslash rule.

Counter style
The following internal LaTeX commands will convert numeric value of specified counter into printable string and insert string into document:


 * Numbers from $$ -2^{31} $$ to $$ 2^{31}-1 $$ inclusive converted to strings «-2147483648», «-2147483647», …, «-1», «0», «1», …, «2147483646», «2147483647».
 * Example: 1, 2, 3, …
 * Example: 1, 2, 3, …


 * Numbers from 1 to 26 inclusive converted to strings «a», «b», …, «z». Other numbers (negative numbers, zero, 27, 28, …, $$ 2^{31}-1 $$) converted to empty string.
 * Example: a, b, c, …
 * Example: a, b, c, …


 * Same as, but upper case letters used.
 * Example: A, B, C, …
 * Example: A, B, C, …


 * Numbers from 1 to 4999 inclusive converted to strings «i» (1), «ii» (2), …, «mmmmcmxcix» (4999), where «i» — 1, «v» — 5, «x» — 10, «l» — 50, «c» — 100, «d» — 500, «m» — 1000. Numbers from 5000 to $$ 2^{31}-1 $$ inclusive converted to strings «mmmmm» (5000), «mmmmmi» (5001), …. Other numbers (negative numbers, zero) converted to empty string.
 * Example: i, ii, iii, …
 * Example: i, ii, iii, …


 * Same as, but upper case letters used.
 * Example: I, II, III, …
 * Example: I, II, III, …


 * Aimed at footnotes; prints a sequence of symbols.
 * {| class="wikitable"
 * {| class="wikitable"

! Number !! Symbol(s)
 * 1 || ∗
 * 2 || †
 * 3 || ‡
 * 4 || §
 * 5 || ¶
 * 6 || ∥
 * 7 || ∗∗
 * 8 || ††
 * 9 || ‡‡
 * Other numbers || Empty string
 * }
 * Example: ∗, †, ‡, …
 * 7 || ∗∗
 * 8 || ††
 * 9 || ‡‡
 * Other numbers || Empty string
 * }
 * Example: ∗, †, ‡, …
 * Other numbers || Empty string
 * }
 * Example: ∗, †, ‡, …
 * }
 * Example: ∗, †, ‡, …

LaTeX default counters

 * part
 * chapter
 * section
 * subsection
 * subsubsection
 * paragraph
 * subparagraph
 * page
 * figure
 * table
 * footnote
 * mpfootnote

For the environment:
 * enumi
 * enumii
 * enumiii
 * enumiv

For the environment:
 * equation

Book with parts, sections, but no chapters
Here follows an example where we want to use parts and sections, but no chapters in the book class :

Custom enumerate
See the List Structures chapter.

Custom sectioning
Here is an example for recreating something similar to a section and subsection counter that already exist in LaTeX: