Welcome to the UK List of TeX Frequently Asked Questions on the Web

Running equation, figure and table numbering

Many LaTeX classes (including the standard book class) number things per chapter; so figures in chapter 1 are numbered 1.1, 1.2, and so on. Sometimes this is not appropriate for the user’s needs.

Short of rewriting the whole class, one may use the chngcntr package, which provides commands `\``counterwithin` (which establishes this nested numbering relationship) and `\``counterwithout` (which undoes it).

So if you have figures numbered by chapter as 1.1, 1.2, 2.1, …, the command

```\counterwithout{figure}{chapter}
```

will convert them to figures 1, 2, 3, …. (Note that the command has also removed the chapter number from the counter’s definition.)

More elaborate use could change things numbered per section to things numbered per chapter:

```\counterwithout{equation}{section}
\counterwithin{equation}{chapter}
```

(assuming there was a class that did such a thing in the first place...)

The chngcntr approach doesn’t involve much programming, and the enthusiastic LaTeX programmer might choose to try the technique that we had to use before the advent of chngcntr. Each of the packages removefr and remreset defines a `\``@removefromreset` command, and having included the package one writes something like:

```\makeatletter
\@removefromreset{figure}{chapter}
\makeatother
```

and the automatic renumbering stops. You may then need to redefine the way in which the figure number (in this case) is printed:

```\makeatletter
\renewcommand{\thefigure}{\@arabic\c@figure}
\makeatother
```

(remember to do the whole job, for every counter you want to manipulate, within `\``makeatletter``\``makeatother`).

This technique, too, may be used to change where in a multilevel structure a counter is reset. Suppose your class numbers figures as <chapter>.<section>.<figure>, and you want figures numbered per chapter, try:

```\makeatletter
\@removefromreset{figure}{section}
\renewcommand{\thefigure}{\thechapter.\@arabic\c@figure}
\makeatother
```

(the command `\``@addtoreset` is a part of LaTeX itself).

chngcntr.sty
macros/latex/contrib/chngcntr (or browse the directory); catalogue entry
memoir.cls
macros/latex/contrib/memoir (or browse the directory); catalogue entry
removefr.tex
macros/latex/contrib/fragments/removefr.tex; catalogue entry (note, this is constructed as a “fragment” for use within other packages: load by `\``input{removefr}`)
remreset.sty
Distributed as part of macros/latex/contrib/carlisle (or browse the directory); catalogue entry

Go to previous question, or next question

Go to FAQ home.

URL for this question: http://www.tex.ac.uk/cgi-bin/texfaq2html?label=running-nos

Comments, suggestions, or error reports? - see “how to improve the FAQ”.

This is FAQ version 3.28, released on 2014-06-10.