![[endfloat][classicthesis] 强制浮动至 pdf 末尾,但保留每章的编号(两个版本的文档 pdf)](https://linux22.com/image/425713/%5Bendfloat%5D%5Bclassicthesis%5D%20%E5%BC%BA%E5%88%B6%E6%B5%AE%E5%8A%A8%E8%87%B3%20pdf%20%E6%9C%AB%E5%B0%BE%EF%BC%8C%E4%BD%86%E4%BF%9D%E7%95%99%E6%AF%8F%E7%AB%A0%E7%9A%84%E7%BC%96%E5%8F%B7%EF%BC%88%E4%B8%A4%E4%B8%AA%E7%89%88%E6%9C%AC%E7%9A%84%E6%96%87%E6%A1%A3%20pdf%EF%BC%89.png)
像这个问题,我想将图片推迟到文档末尾(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}
没有公鸡因施展黑魔法而受到伤害。