# Manually set figure and table labels while compiling

I would like to manually set certain figure and table labels in LaTeX2e.

I imagine the process to go something like:

latex -> edit .aux file (?) to revise some labels -> pdf

The problem: the apa6e package mislabels figures in certain cases when using an appendix (see example below). I would like to change Figure A1, etc., throughout the body to Figure 1, preferably as a batch search-and-replace, while still retaining the automatic labelling for the rest of the document.

Example: The following code --

\documentclass{apa6e}
\title{}
\author{}
\shorttitle{}
\authornote{}
\begin{document}

This figure, in the body, should reference as Figure~1, not
Figure~\ref{bodyfigure}.

\begin{table*}
\caption{Body table.}
\end{table*}

\begin{figure}
\caption{Body figure.}
\label{bodyfigure}
\end{figure}

\appendix
\section{}

\begin{table*}
\caption{Appendix Table.}
\end{table*}

\end{document}


-- produces Figure A1 rather than Figure 1.

I would like to either (1) find a way to manually set labels before compiling the PDF, or (2) find a work-around for apa6e.

-

As I just have found out this is IMHO clearly a bug within the apa6e document class. The figure and table counter will be reset & redefined inside both files with extension .fff and .ttt (which are handled by the endfloat package). This is obviously wrong since the .fff file is responsible for figures only and .ttt for tables only. (As a result the figure label will be redefined and reset too soon when using your example document.)

So by redefining the internal macro \apaSIXe@appendixfloats@setup (which is responsible for the misbehavior) this could be fixed:


\documentclass{apa6e}

% Workaround for bug in apa6e document class
\makeatletter
\renewcommand{\apaSIXe@appendixfloats@setup}[1]{%
\efloat@iwrite{fff}{%
\string\makeatletter\string\apaSIXe@appendixfloats@figure{#1}\string\makeatother}%
\efloat@iwrite{ttt}{%
\string\makeatletter\string\apaSIXe@appendixfloats@table{#1}\string\makeatother}%
}
% The following stuff was done by \apaSIXe@appendixfloats@go before.
% I have split this macro into \...@figure and \...@table here:
\newcommand{\apaSIXe@appendixfloats@figure}[1]{%
\setcounter{figure}{0}%
\renewcommand{\thefigure}{#1\arabic{figure}}%
}
\newcommand{\apaSIXe@appendixfloats@table}[1]{%
\setcounter{table}{0}%
\renewcommand{\thetable}{#1\arabic{table}}%
}
\makeatother

\title{}
\author{}
\shorttitle{}
\authornote{}
\begin{document}

This figure, in the body, should reference as Figure~1, not
Figure~\ref{bodyfigure}.

\begin{table}
\caption{Body table.}
\end{table}

\begin{figure}
\caption{Body figure.}
\label{bodyfigure}
\end{figure}

\appendix
\section{}

\begin{table}
\caption{Appendix Table.}
\end{table}

\end{document}


Please do a bug report to the author of the apa6e document class so this bug will be fixed for future versions of apa6e.

-
Thank you! I have emailed the apa6e author. –  newresearcher Jul 2 '11 at 16:17

You should prefer to adjust this in the LaTeX code instead constantly have to hack the .aux file after every compilation.

This class changes the \thefigure macro which is responsible for the labeling of the figure. For some reason it does this not globally but in \begin{figure}. You need to change the definition to use simple Arabic numbers again before the caption and the label:

\begin{figure}
\renewcommand{\thefigure}{\arabic{figure}}%
\caption{Body figure.}
\label{bodyfigure}
\end{figure}


This changes both the \ref and caption number to Figure 1.

-
Since the bug in the apa6e document class will not only label the figure wrong, but will give them a wrong counter, too, this workaround seems to be ok for this particular MWE, but is not sufficient in general. –  Axel Sommerfeldt Jul 2 '11 at 9:58
@Axel: I see. Thanks for pointing it out. –  Martin Scharrer Jul 2 '11 at 9:59