[Tex/LaTex] Place table at end of chapter


I have a very large tabular which I want placed at the end of my chapter. I need it inside a float because I want a caption. I could simply put the code at the end of the chapter and use [h] or even [h!] placement modifier. But I'd prefer to keep the code at a different location in the text. I do not want to use a package like endfloat since this is the only float I wish to stick at the end of a chapter.

Best Answer

The following setup delays the placement of a single float to the end of a chapter. The environ package allows to capture the contents of an environment into a macro (see How can one pass the contents of a LaTeX environment to a macro?). Making sure that any banked/stored float is flushed \AtEndDocument.

enter image description here

\usepackage{lipsum}% http://ctan.org/pkg/lipsum
\usepackage{environ}% http://ctan.org/pkg/environ
\chapter{A chapter}
  \centering\rule{.8\textwidth}{.2\textwidth}\caption{A figure}
  \centering\rule{.8\textwidth}{.2\textwidth}\caption{Another figure}
\chapter{Another chapter}

The final figure positioning can be changed inside the \chapendfigure macro (defined inside the chapendfig environment. Even though the above example delays a figure, it can be used for table (or any other float) as well.

Related Question