[Tex/LaTex] Manually set figure and table labels while compiling

apa-styleappendicescross-referencingnumbering

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.

Best Answer

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.

Related Question