0

I used the following codes to achieve numbering the figure in section level like (1.1, 1.2...):

\usepackage{amsmath}
\numberwithin{figure}{section}

Then I can got the first figure in the first section is 1.1, the second figure in the second section is 1.2... but if there is a figure in subsection(1.2) in section 1, how to change the first figure label from 1.1 to 1.1.1?

marked as duplicate by Henri Menke, user31729, Mico, TeXnician, Stefan Pinnow Apr 2 '18 at 6:47

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • 3
    \numberwithin{figure}{subsection}? – Zarko Apr 2 '18 at 3:41
  • This is definitely a duplicate. This question has been asked a hundred times before. – Henri Menke Apr 2 '18 at 5:15
0

I think the numbering of images should be according to the chapters, but well, everything is possible in latex, to achieve what you want you just have to redefine the format of the figures counter \thefigure, the problem is that you must redefine it for each environment, here the code:

Standard format:

\renewcommand{\thefigure}{\arabic{chapter}.\arabic{figure}}

Format for sections:

\renewcommand{\thefigure}{\arabic{chapter}.\arabic{section}.\arabic{figure}}

For the following chapters you must redefine the standard if you do not want the following error to occur enter image description here

Finally the complete code and the result:

enter image description here

code:

% arara: pdflatex: {synctex: yes, action: nonstopmode}

\documentclass{scrreprt}
\usepackage{booktabs,caption}
\usepackage{graphicx}
\usepackage{subfigure}
\newcommand{\fakeimage}{{\fboxsep=-\fboxrule\fbox{\rule{0pt}{2.5cm}\hspace{3cm}}}}
\begin{document}
    \chapter{chapter one}

    \begin{figure}[h!]
        \centering
        \subfigure[fig 1]{\fakeimage} \qquad
        \subfigure[fig 2]{\fakeimage} 
        \caption{fig for chapter}
    \end{figure}
\renewcommand{\thefigure}{\arabic{chapter}.\arabic{section}.\arabic{figure}}
    \section{the section}
        \begin{figure}[h!]
        \centering
        \subfigure[fig 1]{\fakeimage} \qquad
        \subfigure[fig 2]{\fakeimage} 
        \caption{For section}
    \end{figure}
%for chapter Two you have to redefine \thefigure to the original
\renewcommand{\thefigure}{\arabic{chapter}.\arabic{figure}}
\chapter{Chapter two}
    \begin{figure}[h!]
    \centering
    \subfigure[fig 1]{\fakeimage} \qquad
    \subfigure[fig 2]{\fakeimage} 
    \caption{fig for chapter}
    \end{figure}
\renewcommand{\thefigure}{\arabic{chapter}.\arabic{section}.\arabic{figure}}
\section{the section}
\begin{figure}[h!]
    \centering
    \subfigure[fig 1]{\fakeimage} \qquad
    \subfigure[fig 2]{\fakeimage} 
    \caption{For section}
\end{figure}
\section{the section}
\begin{figure}[h!]
    \centering
    \subfigure[fig 1]{\fakeimage} \qquad
    \subfigure[fig 2]{\fakeimage} 
    \caption{For section}
\end{figure}
\end{document}
  • 1
    The subfigure package has been deprecated for a long time by now. Please consider rewriting your answer using the machinery of either the subfig or the subcaption caption. – Mico Apr 2 '18 at 4:29
  • 1
    Your approach requires the author to issue potentially lots of \renewcommand{\thefigure}{...} directives. Is there a way to automate your numbering system? – Mico Apr 2 '18 at 4:31
  • Well, that is what I can suggest in the short time I have, and yes, it is necessary to automate and maybe there is an effective method, which thanks to your observation can be solved here. – J Leon V. Apr 2 '18 at 4:42
  • Why \subfigure at all? – user31729 Apr 2 '18 at 5:03

Not the answer you're looking for? Browse other questions tagged or ask your own question.