编译时手动设置图形和表格标签

编译时手动设置图形和表格标签

我想在 LaTeX2e 中手动设置某些图形和表格标签。

我想象这个过程是这样的:

latex -> 编辑 .aux 文件(?)来修改一些标签 -> pdf

问题:apa6e在某些情况下,使用附录时,软件包会错误标记图形(见下面的示例)。我想将正文中的图 A1 等更改为图 1,最好是批量搜索和替换,同时仍保留文档其余部分的自动标记。

例如:以下代码——

\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}

-- 生产Figure A1而不是Figure 1

我希望 (1) 找到一种在编译 PDF 之前手动设置标签的方法,或者 (2) 找到 apa6e 的解决方法。

答案1

我刚刚发现,在我看来,这显然是 apa6e 文档类中的一个错误。图形和表格计数器将在扩展名为和的两个文件中重置和重新定义.fff.ttt由 endfloat 包处理)。这显然是错误的,因为该.fff文件仅负责图形和.ttt表格。(因此,在使用您的示例文档时,图形标签将被重新定义并过早重置。)

因此,通过重新定义内部宏\apaSIXe@appendixfloats@setup(导致不当行为的宏),可以修复此问题:


\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}

请向 apa6e 文档类的作者提交错误报告,以便在 apa6e 的未来版本中修复此错误。

答案2

您应该选择在 LaTeX 代码中调整这一点,而不是.aux在每次编译后不断地破解文件。

这个类更改了\thefigure负责标记的宏figure。出于某种原因,它不是全局执行此操作,而是在中执行此操作\begin{figure}。您需要更改定义以在标题和标签之前再次使用简单的阿拉伯数字:

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

这会将\ref和标题编号都更改为Figure 1

相关内容