附录后恢复图片编号

附录后恢复图片编号

我正在准备我的论文,该论文由 11 个章节组成,后面是附录,最后是另一个章节(即荷兰语摘要)。在最后一章(荷兰语摘要)中,我有几个图,我想恢复图编号(例如,荷兰语摘要章节的第一个图应编号为 12.1)。以下代码说明了该问题:

\documentclass[11pt,twoside,openright]{memoir}

\begin{document}

\begin{KeepFromToc}
\tableofcontents \cleardoublepage
\end{KeepFromToc}

\chapter{Introduction}
This is chapter 1.

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

\appendix
\addcontentsline{toc}{part}{Appendices} 
\part*{Appendices}

\chapter{Appendix A1}
This is A1.

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


\backmatter

\chapter{Dutch Summary}
This is chapter 2.

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


\end{document}

编译此文件时,您会看到第 1 章中的第一个图正确编号为“图 1.1”,但是,荷兰语摘要章节中的图编号为“图 1”,但应为“图 2.1”。任何有关如何解决此问题的想法都非常感谢!

答案1

这是一个具有xassoccnt\BackupCountersGroup\RestoreBackupCounterGroup功能的版本,可以存储指定数量的计数器的计数器值并在稍后重新注入它们。

\documentclass[11pt,twoside,openright]{memoir}

\usepackage{xassoccnt}

\DeclareBackupCountersGroupName{dutchchapter}

\AssignBackupCounters[name=dutchchapter,cascading=true]{chapter}

\makeatletter
\newcommand{\StoreCounterFormats}{%
  \let\latex@@thechapter\thechapter
  \let\latex@@thefigure\thefigure
  \let\latex@@thetable\thetable  
}

\newcommand{\ContinueOldCounting}[2]{%
  \RestoreBackupCounterGroup[backup-id=#1]{#2}%
  \refstepcounter{chapter}%
  \let\thechapter\latex@@thechapter
  \let\thefigure\latex@@thefigure
  \let\thetable\latex@@thetable
}
\makeatother

\AtBeginDocument{%
  \StoreCounterFormats%
}

\begin{document}

\begin{KeepFromToc}
\tableofcontents \cleardoublepage
\end{KeepFromToc}

\chapter{Introduction}
This is chapter 1.

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

%Code to produce some dummy chapters
\makeatletter
\newcount\foocnt
\foocnt\c@chapter
\loop\unless\ifnum\foocnt=11
\advance\foocnt by 1
\chapter{Dummy chapter \the\foocnt}
\repeat
\makeatother
%End of dummy chapters production

% Make a backup of the state!
\BackupCounterGroup[backup-id=beforeappendices]{dutchchapter}

\appendix
\addcontentsline{toc}{part}{Appendices} 
\part*{Appendices}

\chapter{Appendix A1}
This is A1.

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


\backmatter

% Restore the old state
\ContinueOldCounting{beforeappendices}{dutchchapter}
\chapter{Dutch Summary}
This is chapter \thechapter

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


\end{document}

在此处输入图片描述

我正在考虑在即将发布的版本中添加存储\the....宏的可能性。xassoccnt

答案2

这是一个快速解决方法。

\chapter{Dutch Summary}
\setcounter{chapter}{11}
\refstepcounter{chapter}
\renewcommand\thechapter{\arabic{chapter}}
\renewcommand\thefigure{\thechapter.\arabic{figure}} % for figures
\renewcommand\thetable{\thechapter.\arabic{table}} % for tables

相关内容