Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

What is the easiest way to have all floats forcibly appear at the end of the document, one per page? The endfloat package is not an option, see below. The following questions are related but not helpful:

How to place all floats (tables in particular) at a certain point in the document

Place all floats last without changing numbering

Details

In our environment we have wrappers for creating figures, tables etc.. The wrappers are implemented as environments to allow "everything" inside and furthermore accept, among others, the long and short caption name, the label and the contens of the figure. The implementation of the wrappers can be altered for different document layouts (caption above/below, figure separated by rule yes/no, ...).

One particular layout requires each figure to be placed on a separate page after the main document.

Own attempts

The endfloat package comes to mind. However, I was unable to get it to work, as the figures are created by a wrapper.

I have tried implementing this using \gappto: The figure-creating command would be just appended to a global hook which is executed just before \end{document}. This worked when the figure-creating wrapper was just a command, but now it's an environment to allow "everything" inside. I have added my attempt to the MnWE below, but this results in the following error message:

! Extra }, or forgotten \endgroup.
\environment_richfigure_end_aux:w ...gure}\egroup 

l.39       \end{richfigure}

How would you implement this?

MnWE

\documentclass{scrartcl}
\pagestyle{empty}
\usepackage{caption}
\usepackage{xparse}
\usepackage{etoolbox}

\newcommand{\delayedfigures}{}

% Comment the following line to get working code
\newcommand{\dofigure}[1]{\gappto{\delayedfigures}{\clearpage#1}}

% The example works with the default implementation of \dofigure
\providecommand{\dofigure}[1]{#1}

%%   \begin{richfigure}
%%     [<placement>, e.g. htp (h=here, t=top, p=page)]
%%     {<short caption>}
%%     {<long caption>}
%%     {<\label{label}>}
%%       <\includegraphics[...]{figure}>
%%   \end{richfigure}
\NewDocumentEnvironment{richfigure}{O{tbp} m m m}{%
  \dofigure\bgroup%{%
    \begin{figure}[#1]%
      \caption[#2]{#3}#4%
        }{% Here, the contents of the environment are placed
    \end{figure}%
  \egroup%{
}

\gpreto{\enddocument}{\delayedfigures}

% Usage example
\begin{document}
  Main document contents.

  \begin{richfigure}{Short caption}{Long caption}{\label{fig:1}}
    Figure contents.
  \end{richfigure}

  All figures are to appear on separate pages, one per page.
\end{document}
share|improve this question

1 Answer 1

up vote 4 down vote accepted

here is an example which modies the floatcheck and uses [p] as placement. The floats appear at the end of the sections, one per page.

\documentclass{scrartcl}
\pagestyle{empty}
\usepackage{caption}
\usepackage{lipsum}
\makeatletter
\def \@largefloatcheck{\ht\@currbox 0.5\textheight}
\makeatother

\begin{document}
\section{baz}
  Main document contents.
\lipsum
\begin{figure}[p]
 \centerline{ Figure contents. }
\caption[Short caption]{Long caption of fig 1}\label{fig:1}
\end{figure}

\lipsum

All figures are to appear on separate pages, one per page.
\lipsum

\section{foo}
\lipsum
\begin{figure}[p]
 \centerline{ Figure contents. }
\caption[Short caption]{Long caption  of fig 2}\label{fig:2}
\end{figure}

\lipsum

\end{document}
share|improve this answer
    
That's great, I think I'll be able to use it since I can override placement in my wrapper macro. However, I don't fully understand the semantics of \def \@largefloatcheck{\ht\@currbox 0.5\textheight}. To me it compares the height of the @currbox to half the textheight -- why does that work? –  krlmlr Aug 30 '12 at 12:06
    
with the default check you get more than one floats per page. and only with 0.5 they appear at the end and one per page. With \textheight they appear as a single page but inside the text and not at the end. If you want more infos see latex.ltx –  Herbert Aug 30 '12 at 12:11
    
This doesn't work with htlatex, I forgot this requirement. Posted a follow-up question: tex.stackexchange.com/q/69440/8057 –  krlmlr Aug 30 '12 at 12:48

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.