![セクションごとの図番号 - セクションごとにカウンターをリセット](https://rvso.com/image/298803/%E3%82%BB%E3%82%AF%E3%82%B7%E3%83%A7%E3%83%B3%E3%81%94%E3%81%A8%E3%81%AE%E5%9B%B3%E7%95%AA%E5%8F%B7%20-%20%E3%82%BB%E3%82%AF%E3%82%B7%E3%83%A7%E3%83%B3%E3%81%94%E3%81%A8%E3%81%AB%E3%82%AB%E3%82%A6%E3%83%B3%E3%82%BF%E3%83%BC%E3%82%92%E3%83%AA%E3%82%BB%E3%83%83%E3%83%88.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}