In the standard document classes report
and book
, figure and table counters are reset after every chapter. On the other hand, article
does not reset these counters when a new section is started. The chngcntr
package provides the \counterwithin
and \counterwithout
commands to redefine a counter, by adding or removing a dependency. Through these commands, the behavior of the figure
and table
counters can be changed.
Continuous figure and table numbering in report/book
The \counterwithout
command removes a dependency from a counter and redefines \the’counter’ such that it is printed without the dependency.
Through \counterwithout
, the figure and table counters can be changed to continuously number these figures and tables throughout a report or book. The command also redefines the way the counter is printed, such that the chapter number is not shown (e.g. ‘Figure 3’ instead of ‘Figure 1.3′). Redefining \the’counter’ can be omitted through the starred version \counterwithout*
.
\usepackage{chngcntr} \counterwithout{figure}{chapter} \counterwithout{table}{chapter}
This is what it looks like in the list-of-figures. Chapter headings were added to make it clear where a new chapter is started.
Below is a complete minimal working example.
\documentclass[11pt]{report} \usepackage{chngcntr} \counterwithout{figure}{chapter} \newcommand*\dummyFigure[2]{% \begin{figure}[ht]\centering\rule{0.4\linewidth}{0.4\linewidth}\caption{#1}\label{#2}\end{figure} } \begin{document} \listoffigures \chapter{A dummy chapter} \dummyFigure{A figure}{fig1} \chapter{Another dummy chapter} \dummyFigure{Another figure}{fig2} \end{document}
Per-section figure and table numbering in article
Similarly, a reset-dependency can be added to any counter through \counterwithin
. The command also redefines \the’counter’ (e.g. ‘Figure 1.3’ instead of ‘Figure 1’). Again, the package provides a starred version \conterwithin*
that does not redefine \the’counter’.
As an example, the \counterwithin
command can be used to automatically reset the figure and table counters whenever a new section is started in an article
. Also, the command redefines \thefigure
to \thesection.\arabic{figure}. Therefore, figure 3 in section 1 will be printed as ‘Figure 1.3’. The same applies to \thetable
.
\usepackage{chngcntr} \counterwithin{figure}{section} \counterwithin{table}{section}
See the documentation for more information on the chngcntr package.
FrAnKenStEiN MC
this
helped me to convert numbering from 1.1 , 1.2 to 1 , 2 that was useful thanks
tom
Thanks for your comment. That’s a neat trick. Best, Tom.
Ayomikun
Hi Tom, i have a challenge with my figure numbering, it is so discontinuous.
tom
Please provide a minimal working example for illustration. You may use these lines to simulate figures:
Manuel
This was very useful, but how did you add “Chapter 1”, “Chapter 2” and so on?
tom
Hi Manuel,
How to add the chapter to the list of figures and tables is explained in this post.
Cheers, Tom.
Antti
Is there away to use normal article type countering for main text, and then, in the appendices, to use section-wise equation counter (iike (A.1), (A.2), (A.3))
Antti
This was easy. The amsmath command
in the middel of the text does it, ie this command does not need to be in the preample.
adam
Hi my problem is very strange. My document is using the article class, but the section numbers are shown for the figures, figure 2.3, instead of figure 4.
chngcntr does not work for me, because
\counterwithout{figure}{chapter}
only works for book class, not for article class. Any suggestion? Thanks.tom
Hi Adam,
You would have to provide a minimal working example for me to reproduce the problem.
Thanks,
Tom
adam
I may have to upload or email you my tex file. Anyway to do it? Thanks.
tom
Please just reduce your code to the minimum such that I can reproduce the problem and paste it here. Make sure that if I run it I can see the problem you describe.
Best, tom
Хатанболд Эрдэнэбаяр
Figure 1.1 change 1.1 Figure?
help me
tom
Hi there,
Sorry for the late response. You could set
\figurename
to be empty and print “Figure” with the counter. An example is give below.Best, Tom
Timo Müller
Hey, my Problem is that the Figure counter starts with Figure 0.1 ; 0.2 ; 0.3 and so on in the first Section. How can i change it to 1.1 ; 1.2 … in the first Section
tom
Hi Timo,
Is your first section unnumbered? You can manually increase the section counter (see example below).
Best, Tom