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}
4
  • Have you tried loading classicthesis just before \begin{document}? Commented Dec 16, 2020 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
    Commented Dec 17, 2020 at 8: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. Commented Dec 17, 2020 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
    Commented Dec 18, 2020 at 10:04

1 Answer 1

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.

1
  • Great. Thank you very much.
    – Marc Boyer
    Commented Dec 18, 2020 at 11:10

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .