I want to have per-subsection figure numbering in the appendix of the following MWE: it should read "Figure A.1" instead of "Figure 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}
I tried changing the thefigure
counter and also using the chngcntr
package but couldn't make it work.
\setcounter{figure}{0} \renewcommand{\thefigure}{Figure \Alph{chapter}.\arabic{figure}}
– Nicholas Hamilton May 31 '13 at 21:25figurewithin=section
should be directly passed to thecaption
package, i.e.\usepackage[figurewithin=section]{caption}
or\captionsetup{figurewithin=section}
(without the[figure]
stuff). – user2574 Jun 1 '13 at 12:23