Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I want to the figure counting in my document when the appendix starts, and follow a different pattern than 1, 2, 3... Specifically, I want figures in the appendix to start with A.1 onward, instead of continuing on from the main document. How can I do this?

\documentclass[twoside]{article}

\usepackage{graphicx,dblfloatfix}


\usepackage{titlesec}% Allows customization of titles
\titleformat{\section}[block]{\large\scshape\centering{\Roman{section}.}}{}{1em}{} % Change the look of the section titles 

\begin{document}

\section{Introduction}
\subsection{Problem description}
Blah blah
\begin{figure}[!htb]
    \centering 
    \includegraphics{decon}
    \caption{Call this figure 1.}
\label{fig1} 
\end{figure}
\appendix
\section{Figures}

\begin{figure}[!htb]
    \centering 
    \includegraphics{decon}
    \caption{Call this figure A.1.}
\label{figa1} 
\end{figure}

\begin{figure}[!htb]
    \centering 
    \includegraphics{decon}
    \caption{Call this figure A.2.}
\label{figa2} 
\end{figure}

\end{document}
share|improve this question
add comment

2 Answers

up vote 11 down vote accepted

Redefine \thefigure when your appendices start, and set the figure counter to zero at the beginning of each appendix.

\documentclass{article}
\begin{document}
\begin{figure}
\centering\rule{1cm}{1cm}
\caption{This is a figure}
\end{figure}
\appendix
\renewcommand\thefigure{\thesection.\arabic{figure}}    
\section{A nice appendix}
\setcounter{figure}{0}    
\begin{figure}
\centering\rule{1cm}{1cm}
\caption{This is a figure in appendix A}
\end{figure}
\end{document}
share|improve this answer
add comment

You can use the chngcntr package which includes the command \counterwithin.

Using this as \counterwithin{figure}{section} changes the figure numbering from that point on so that the section number is included and resets the numbering of figures at the beginning each subsequent section. An example is:

\documentclass{article}

\usepackage{chngcntr}

\begin{document}

\section{Introduction}

\subsection{Problem description}

\begin{figure}[htp]
  \centering Figure
  \caption{Call this figure 1.}
  \label{fig1}
\end{figure}

\appendix
\counterwithin{figure}{section}

\section{Figures}

\begin{figure}[htp]
  \centering Figure
  \caption{Call this figure A.1.}
  \label{figa1}
\end{figure}

\begin{figure}[htp]
  \centering Figure
  \caption{Call this figure A.2.}
  \label{figa2}
\end{figure}

\end{document}

Sample output

share|improve this answer
    
To make this work for tables, you need to also put \counterwithin{table}{section}. –  ACD Nov 22 '13 at 3:06
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.