Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Figure numbers according to sections and subsections

Tags:

latex

I want to generate the figure numbers depending on the sections, for example, if section number is 1.1 then I want to generate the figure numbers as 1.1.1, 1.1.2 and so on.

Thanks in advance

like image 209
Smits Avatar asked Jun 20 '17 16:06

Smits


2 Answers

Add

\usepackage{chngcntr}
\counterwithin{figure}{section}

to your preamble.

Reference:

  • Continuous v. per-chapter/section numbering of figures, tables, and other document elements
like image 153
Werner Avatar answered Nov 09 '22 21:11

Werner


Add

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

to your document. This will redefine the figure number to contain the section and subsection number.

MWE:

\documentclass{article}

\usepackage{graphicx}
\renewcommand{\thefigure}{\arabic{section}.\arabic{subsection}.\arabic{figure}}

\begin{document}

\section{title}
\subsection{subtitle}

\begin{figure}[htbp]
\includegraphics[width=\textwidth]{example-image-duck}
\caption{content...}
\end{figure}

\end{document}
like image 3
Ahmed Shalaby Avatar answered Nov 09 '22 19:11

Ahmed Shalaby