2

Like in this question, I would like to postpone figures to the end of the document (the aim of endfloat) but to have a chapter-based numbering of Figures. The solution given as answer works on simple document, but if I use classicthesis.sty, I loose chapter numbers in Figure numbering/caption.

Here is a minimal code.

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

  • Have you tried loading classicthesis just before \begin{document}? – PhilipPirrip Dec 16 '20 at 21:52
  • @PhilipPirrip Yes I tried loading classicthesis before loading endfloat (as in the example), just after loading endfloat, and just before \begin{document}. – Marc Boyer Dec 17 '20 at 08:06
  • I've just tested your ME: I do see chapter numbers on pages 1 and 3, and four "figures" on pages 4-7. Using classicthesis v4.6, TeX Live on Fedora Linux 33. – PhilipPirrip Dec 17 '20 at 17:37
  • @PhilipPirrip My description of the problem was unclear. Sorry. I have updated it. The problem is to have chapter numbering in caption of Figures. – Marc Boyer Dec 18 '20 at 10:04

1 Answers1

3

You're patching the wrong command.

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

No rooster was harmed to perform the black magic.

egreg
  • 1,121,712