TeXnik - Tips TeX and LaTeX

Welcome to the TeXnik website (under construction)

Counter - FAQ
TUG logo

Main page

Search CTAN:


Google c.t.t.

Google d.c.t.t.



Continuing Counting |  Counter-Reset | 
Increment of counters | 
New Counter |  Numbering |  Number of Figures/Pages/Tables/... in a Document | 
Predefined Counter | 
Removing a reset |  Resetting | 
Standard Counter |  Style of counters | 
Total Number of Figures/Tables/... in a Document | 
Available Packages on CTAN

Number of Figures/Pages/Tables/... in a Document
The number of pages in a document is available with the command \ref{TotPages} from package totpages from CTAN. If you want also write the total numbers of figures/tables/... at the beginning of your document, than try the following as an example for tables and documentclass book:
In your document you can write at the beginning or anywhere:
This doc has \AbsTables tables and \ref{TotPages} pages.
The above code for the preamble is different, if you
  • have document-classes without chapters
  • another counter reset

  • Continuing Counting
    1. If you want your figure to have the same number ("Figure 3") than the forgoing one, just write \addtocounter{figure}{-1} before the caption of the figures except the first.
    2. If you want Figure 3a, Figure 3b etc. then put the following lines in the preamble:
      Put \begin{subfigures} and \end{subfigures} before/after the figures.

    Increment of Counters
  • \stepcounter{myCounter} increments myCounter with 1.
  • \addtocounter{myCounter}{anyValue} adds anyValue to myCounter

    New Counter
    in latex preamble
  • without any automatic reset: \newcounter{myCounter}
  • with a reset by chapter: \newcounter{myCounter}[chapter]

    in LaTeX the counter is named c@myCounter

    Resetting a counter
    Removing a given reset
      is possible with package remreset
      Now myCounter is no longer reset when a new section starts.

    Automatic reset
      A given counter without any automatic reset can be modified with (in LaTeX preamble)
    Manual reset
    myCounter maybe any predefined or new defined (with \newcounter) counter.

    Predefined Counter
    The following counter are predefined by LaTeX:

    part enumi page
    chapter enumii equation
    section enumiii figure
    subsection enumiv table
    subsubsection footnote
    paragraph mpfootnote

    mpfootnote is the counter for footnotes in minipages. Remember that these counters are only predefined if the environment is also defined! For example: there is no chapter-counter in document-class article, because there is no chapter environment.

    Numbering of Counters
    Any counter can be printed with the prefix-command \the. A user defined counter myCounter can be printed with \themyCounter. The style can be changed with the \renewcommand. For example:

    in LaTeX preamble:

    Now the figures and equations are numbered like 2-5, means "chapter-number". This works only for book classes, because artice classes do not have chapters. The tables are numbered like 2.IV.
  • local time: Thu Feb 22 18:41:22 CET 2024 ; file is: 1706.28461805556 days old
    contact webmaster _at_ TeXnik.de