像这个问题,我想将图片推迟到文档末尾(endfloat 的目的),但要对图片进行基于章节的编号。答案中给出的解决方案适用于简单文档,但如果我使用classicthesis.sty
,我会在图片编号/标题中丢失章节编号。
这里有一个最小代码。
\documentclass{book}
\usepackage{lipsum}
\usepackage[floatperchapter]{classicthesis} % ,manychapters
\usepackage{etoolbox}
\usepackage[nomarkers,nofiglist]{endfloat}
\makeatletter
\@ifpackageloaded{endfloat}
{
\efloat@condopen{fff}
\pretocmd\@chapter{\immediate\write\efloat@postfff{\noexpand\stepcounter{chapter}}}{}{\fail}
\AtBeginFigures{\setcounter{chapter}{0}}
}{}
\makeatother
\begin{document}
\chapter{First Chapter}
\lipsum[1-1]
\begin{figure}
\centering
\fbox{CHAPTER: 1 -- FIGURE: 1 -- ref=\ref{c1:f1}}
\caption{chapter 1 -- figure 1}
\label{c1:f1}
\end{figure}
\lipsum[2-2]
\begin{figure}
\centering
\fbox{CHAPTER: 1 -- FIGURE: 2 -- ref=\ref{c1:f2}}
\caption{chapter 1 -- figure 2}
\label{c1:f2}
\end{figure}
\lipsum[3-3]
\chapter{Second Chapter}
\lipsum[4-4]
\begin{figure}
\centering
\fbox{CHAPTER: 2 -- FIGURE: 1 -- ref=\ref{c2:f1}}
\caption{chapter 2 -- figure 1}
\label{c2:f1}
\end{figure}
\lipsum[5]
\begin{figure}
\centering
\fbox{CHAPTER: 2 -- FIGURE: 2 -- ref=\ref{c2:f2}}
\caption{chapter 2 -- figure 2}
\label{c2:f2}
\end{figure}
\lipsum[6]
\end{document}
答案1
您修补了错误的命令。
\documentclass{book}
\usepackage{lipsum}
\usepackage{etoolbox}
\usepackage[nomarkers,nofiglist]{endfloat}
\usepackage[floatperchapter]{classicthesis} % ,manychapters
\makeatletter
\AtBeginDocument{%
\@ifpackageloaded{endfloat}{%
\efloat@condopen{fff}%
\pretocmd\caption@chapter@ORI{\immediate\write\efloat@postfff{\noexpand\stepcounter{chapter}}}{}{}%
\AtBeginFigures{\setcounter{chapter}{0}}%
}{}%
}
\makeatother
\begin{document}
\chapter{First Chapter}
\lipsum[1-1]
\begin{figure}
\centering
\fbox{CHAPTER: 1 -- FIGURE: 1 -- ref=\ref{c1:f1}}
\caption{chapter 1 -- figure 1}
\label{c1:f1}
\end{figure}
\lipsum[2-2]
\begin{figure}
\centering
\fbox{CHAPTER: 1 -- FIGURE: 2 -- ref=\ref{c1:f2}}
\caption{chapter 1 -- figure 2}
\label{c1:f2}
\end{figure}
\lipsum[3-3]
\chapter{Second Chapter}
\lipsum[4-4]
\begin{figure}
\centering
\fbox{CHAPTER: 2 -- FIGURE: 1 -- ref=\ref{c2:f1}}
\caption{chapter 2 -- figure 1}
\label{c2:f1}
\end{figure}
\lipsum[5]
\begin{figure}
\centering
\fbox{CHAPTER: 2 -- FIGURE: 2 -- ref=\ref{c2:f2}}
\caption{chapter 2 -- figure 2}
\label{c2:f2}
\end{figure}
\lipsum[6]
\end{document}
没有公鸡因施展黑魔法而受到伤害。