4

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.

  • a) captions are possible outside floats; see the capt-of package and its \captionof{<type>}{<caption text>} command. b) Is there a special reason why you don't want to use positioning arguments? – lockstep Aug 9 '12 at 17:03
  • Try \floatpagefraction=0 -- I don't know exactly. – Marco Daniel Aug 9 '12 at 17:10
  • Should the table appear on its own page? – Gonzalo Medina Aug 9 '12 at 17:26
  • @GonzaloMedina Yes. Although, it is already big enough to do so. lockstep: Thanks for the tip. There is no real reason. It just makes sense for the table to occur at one point in the source, but at the end of the chapter in the typeset document. MarcoDaniel: The problem with solutions like these is that they apply to ALL floats. I only wish to change the placement of a single float. – Dan Aug 9 '12 at 17:36
  • And if you simply use [p] as the placement specifier, asin \begin{table}[p]...\end{table}? – Gonzalo Medina Aug 9 '12 at 17:43
1

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

\documentclass{book}
\usepackage{lipsum}% http://ctan.org/pkg/lipsum
\usepackage{environ}% http://ctan.org/pkg/environ
\let\chapendfigure\relax
\let\oldchapter\chapter
\renewcommand{\chapter}{\chapendfigure\oldchapter}
\AtEndDocument{\chapendfigure}
\NewEnviron{chapendfig}{%
  \global\let\chapendfigureBODY\BODY%
  \gdef\chapendfigure{%
      \begin{figure}\chapendfigureBODY\end{figure}%
        \let\chapendfigure\relax%
    }%
}
\begin{document}
\chapter{A chapter}
\begin{figure}
  \centering\rule{.8\textwidth}{.2\textwidth}\caption{A figure}
\end{figure}
\begin{chapendfig}
  \centering\rule{.8\textwidth}{.2\textwidth}\caption{Another figure}
\end{chapendfig}
%\show\chapendfigure
%\show\chapendfigureBODY
\lipsum[1-25]
\chapter{Another chapter}
\end{document}

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.

0

In the body of your chapter, put the tabular in a \savebox

\newsavebox{\abcd}
\savebox{\abcd}{%
\begin{tabular}{|c|c|}
\hline
a & b \\
c & d \\
\hline
\end{tabular}
}

Use the saved box at the end of the chapter in a table environment

\begin{table}
\centering
\usebox{\abcd}
\caption{a table}\label{t:abc}
\end{table}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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