![Нумерация рисунков по разделам - сброс счетчика в каждом разделе](https://rvso.com/image/298803/%D0%9D%D1%83%D0%BC%D0%B5%D1%80%D0%B0%D1%86%D0%B8%D1%8F%20%D1%80%D0%B8%D1%81%D1%83%D0%BD%D0%BA%D0%BE%D0%B2%20%D0%BF%D0%BE%20%D1%80%D0%B0%D0%B7%D0%B4%D0%B5%D0%BB%D0%B0%D0%BC%20-%20%D1%81%D0%B1%D1%80%D0%BE%D1%81%20%D1%81%D1%87%D0%B5%D1%82%D1%87%D0%B8%D0%BA%D0%B0%20%D0%B2%20%D0%BA%D0%B0%D0%B6%D0%B4%D0%BE%D0%BC%20%D1%80%D0%B0%D0%B7%D0%B4%D0%B5%D0%BB%D0%B5.png)
Я хотел бы добиться нумерации рисунков в виде книги для моего документа класса статей. MWE:
\documentclass[11pt,a4paper]{article}
\usepackage{graphicx}
% optionally - this creates: Figure 1.1 ... Figure 2.2
%\renewcommand{\thefigure}{\arabic{section}.\arabic{figure}}
\begin{document}
\section{first section}
\begin{figure}[h]
\centering
\includegraphics[width=\textwidth]{1.png}
\caption{figure 1.1} % should be 1.1
\end{figure}
\section{second section}
\begin{figure}[h]
\centering
\includegraphics[width=\textwidth]{1.png}
\caption{figure 2.1} % should be 2.1 - actually is 2 or 2.2 with optional code
\end{figure}
\end{document}
Я не хочу вручную сбрасывать счетчик в каждом разделе.
решение1
Это легко достигается с \numberwithin
помощьюпакет amsmath.
\documentclass[11pt,a4paper]{article}
\usepackage{graphicx}
\usepackage{amsmath}
\numberwithin{figure}{section}
\begin{document}
\section{first section}
\begin{figure}[h]
\centering
\rule{4cm}{4cm} % replace with image
\caption{figure 1.1}
\end{figure}
\section{second section}
\begin{figure}[h]
\centering
\rule{4cm}{4cm} % replace with image
\caption{figure 2.1}
\end{figure}
\end{document}