1

I am writing a document with several figures with subsections numbers in the 2.1, 2.2, etc. format. I would like to number the figures in each subsection with a 3 digit format, for example: Figure 2.1.1, Figure 2.1.2, Figure 2.2.1, etc. How do I go about doing this? I am very new to latex.

Andrew
  • 13
  • 1
    welcome to tex.sx. we really need to know what document class you are using, since different classes make different assumptions about (sub)numbering. it would be best if you can provide a small example with several fully nested subsections and a couple of "figures" in each section. just \begin{figure}\caption{dummy caption}\end{figure} should be enough; no actual graphics need to be included. – barbara beeton Aug 04 '15 at 20:45
  • Change section to subsection in the answer to the duplicate question. – Gonzalo Medina Aug 04 '15 at 21:03

1 Answers1

0

The below code should do the trick; chngcntr is a small package that resets a counter (1st argument) each time another counter (2nd argument) is increased, and ensures the first counter is displayed as 2nd counter.1st counter. If you want only to reset the first counter, and display this counter alone, use \counterwithin*.

\usepackage{chngcntr}
\counterwithin{figure}{subsection}
\counterwithin{table}{subsection}
Bernard
  • 271,350
  • I thought the name of the command is self-explanatory, but I can add some explanations… – Bernard Aug 04 '15 at 21:19
  • Thank you, this worked. It doesn't work the same way for equations it seems, and I need to number those the same way. I'm using the article document class. – Andrew Aug 04 '15 at 22:11
  • I've just tested, and I have no problem. What is your preamble? – Bernard Aug 04 '15 at 22:59
  • Solved the equation problem with \numberwithin, didn't work in my main tex file but it did in the section tex file. Thanks again for your help. – Andrew Aug 04 '15 at 23:12
  • You're welcome! Always glad to help. – Bernard Aug 04 '15 at 23:19