Frequently Asked Question List for TeX
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}
\@addtoreset{figure}{chapter}
\renewcommand{\thefigure}{\thechapter.\@arabic\c@figure}
\makeatother
(the command \@addtoreset
is a part of LaTeX itself).
“fragment” for use within other packages: load by
\input{removefr}
)
FAQ ID: Q-running-nos