1

In my chapter, I have several sections. How can I reset the counter of figures for each section?

i.e. In chapter 1, section 1, My figures should be numbered 1,2,3 (instead of 1.1, 1.2, 1.3). In section 2, my figures numbering should restart and they should be numbered 1,2,3 as well (instead of 1.4, 1.5, 1.6).

2
  • Though certainly possible, this seems like a bad idea. How should one tell apart which figure 1 you do mean when you reference it?
    – Skillmon
    Commented Sep 30, 2018 at 14:15
  • In my chapter, the section constitutes of independent articles. Therefore, one can easily tell the difference between figures. I want this trick to only be applicable for only one chapter and not all.
    – Rouge
    Commented Sep 30, 2018 at 14:18

1 Answer 1

3

You can do the following. But as already mentioned in my comment, this seems like a bad idea to me. Are you really sure you want to do this?

\counterwithin{figure}{section}
\renewcommand\thefigure{\arabic{figure}}

To undo this effect you can use:

\counterwithout{figure}{section}
\renewcommand\thefigure{\thechapter.\arabic{figure}}

A complete example (which also shows the problematic behaviour of it):

\documentclass[]{report}

\usepackage[]{graphicx}

\counterwithin{figure}{section}
\renewcommand\thefigure{\arabic{figure}}

\begin{document}
\chapter{Foo}
\section{Bar}
\begin{figure}% >>>
  \centering
  \includegraphics{example-image-duck}%
  \caption
    {%
      duck1%
      \label{fig:duck1}%
    }%
\end{figure}% <<<

\section{Baz}
\begin{figure}% >>>
  \centering
  \includegraphics{example-image-duck}%
  \caption
    {%
      duck2%
      \label{fig:duck2}%
    }%
\end{figure}% <<<
\end{document}
6
  • @Rouge because you only stated that you want that behaviour only in one chapter after I wrote my answer, see my edit for how to undo this effect.
    – Skillmon
    Commented Sep 30, 2018 at 14:24
  • Thanks @Skillmon, but it is not updating the figure number in the text. How shall that be fixed?
    – Rouge
    Commented Sep 30, 2018 at 14:38
  • 1
    @Rouge updating to what? Which figure number where? What should be updated in the text? I'm confused and don't understand what you mean at all.
    – Skillmon
    Commented Sep 30, 2018 at 14:43
  • oops sorry! It's working perfectly fine, I made a mistake. Thank you.
    – Rouge
    Commented Sep 30, 2018 at 14:49
  • Hi @Skillmon, is it possible to do the same trick for tables and equations? Which commands shall I use?
    – Rouge
    Commented Dec 3, 2018 at 8:58

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .