我想要在以下 MWE 的附录中对每个小节的图进行编号:应该读作“图 A.1”而不是“图 2”。
\documentclass{article}
\usepackage{amsmath}
\numberwithin{equation}{section}
\usepackage[demo]{graphicx}
\usepackage{caption}
\captionsetup[figure]{figurewithin=section}
\newcommand*{\appheading}[1][Appendix]{%
\setcounter{secnumdepth}{0}\section{#1}\setcounter{secnumdepth}{3}%
\renewcommand*{\thesubsection}{\Alph{subsection}}
\numberwithin{equation}{subsection}
}
\begin{document}
\section{Foo}
\begin{equation}
x = 4
\end{equation}
\begin{figure}[htbp!]
\centering
\includegraphics{foo}
\caption{Fooo}
\end{figure}
\appheading
\appendix
\subsection{Baz}
\begin{equation}
y = 3
\end{equation}
\begin{figure}[htbp!]
\centering
\includegraphics{baz}
\caption{Baz}
\end{figure}
\end{document}
我尝试更换thefigure
计数器并使用该chngcntr
包,但无法使其工作。
答案1
使用\numberwithin
该figurewithin
选项:
\documentclass{article}
\usepackage{amsmath}
\numberwithin{equation}{section}
\usepackage[demo]{graphicx}
\usepackage{caption}
\numberwithin{figure}{section}
\newcommand*{\appheading}[1][Appendix]{%
\setcounter{secnumdepth}{0}\section{#1}\setcounter{secnumdepth}{3}%
\renewcommand*{\thesubsection}{\Alph{subsection}}
\numberwithin{equation}{subsection}
\numberwithin{figure}{subsection}
}
\begin{document}
\section{Foo}
\begin{equation}
x = 4
\end{equation}
\begin{figure}[htbp!]
\centering
\includegraphics{foo}
\caption{Fooo}
\end{figure}
\appheading
\appendix
\subsection{Baz}
\begin{equation}
y = 3
\end{equation}
\begin{figure}[htbp!]
\centering
\includegraphics{baz}
\caption{Baz}
\end{figure}
\end{document}
你为什么不使用\part*
这些技巧呢?
\documentclass{article}
\usepackage{amsmath}
\numberwithin{equation}{section}
\usepackage[demo]{graphicx}
\usepackage{caption}
\numberwithin{figure}{section}
\newcommand*{\appheading}[1][Appendix]{%
\part*{#1}
\renewcommand*{\thesection}{\Alph{section}}
}
\begin{document}
\section{Foo}
\begin{equation}
x = 4
\end{equation}
\begin{figure}[htbp!]
\centering
\includegraphics{foo}
\caption{Fooo}
\end{figure}
\appheading
\appendix
\section{Baz}
\begin{equation}
y = 3
\end{equation}
\begin{figure}[htbp!]
\centering
\includegraphics{baz}
\caption{Baz}
\end{figure}
\end{document}
答案2
在该行之后立即插入以下两行\subsction{Baz}
:
\setcounter{figure}{0}
\setcounter{section}{1}