GeneralPlacing a table at the end of chapter

LaTeX specific issues not fitting into one of the other forums of this category.
Post Reply
meho_r
Posts: 823
Joined: Tue Aug 07, 2007 5:28 pm

Placing a table at the end of chapter

Post by meho_r »

Hi,

I need to place a single table at the end of chapter (or section), but other tables should remain at their places (so, endfloat isn't a solution). How to achieve this?

And one more question: how to apply empty or plain page style on the page on which table appears ?

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

Stefan Kottwitz
Site Admin
Posts: 10345
Joined: Mon Mar 10, 2008 9:44 pm

Placing a table at the end of chapter

Post by Stefan Kottwitz »

Hi meho_r,

you could put the table already in the source code at the end of the chapter or section. To prevent floating before or after you could use the H option with the float package or the \FloatBarrier command from the placeins package, in that case you could write \FloatBarrier a the end of the chapter or section, place the figure code and write \FloatBarrier again before the next section. Chapters would make \clearpage automatically, \FloatBarrier wouldn't be necessary before the next chapter. You can reach similar by using \clearpage before/after the figure.
For some more details and examples have a look here: Prevent floating of figures or tables.

Stefan
LaTeX.org admin
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Placing a table at the end of chapter

Post by localghost »

meho_r wrote:[...] I need to place a single table at the end of chapter (or section), but other tables should remain at their places (so, endfloat isn't a solution). How to achieve this? [...]
Declare the table at the end of the chapter and put a simple \clearpage (or \cleardoublepage) right behind the table environment to force its output. This should already be sufficient.
meho_r wrote:[...] And one more question: how to apply empty or plain page style on the page on which table appears? [...]
You can use either fancyhdr or titlesec to declare page styles. Both allow to declare a special page layout for float pages. Refer to the documentation of fancyhdr (Section 14 - Special page layout for float pages, p. 14f) or titlesec (Section 5.3 - Running heads with floats, p. 13f) to see how to realise this. Perhaps both versions require that you place the figure with a special parameter on a separate (float) page.

Code: Select all

\begin{figure}[!p]
  \centering
  ...
  \caption{Figure on a separate page}\label{fig:sep}
\end{figure}

Best regards
Thorsten¹
meho_r
Posts: 823
Joined: Tue Aug 07, 2007 5:28 pm

Re: Placing a table at the end of chapter

Post by meho_r »

Thank you guys for both solution and references :) I have one more question though. When the table is on that last page and it's alone on it, it is placed right on the center (vertically). How to make it appears on the top of the page?
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Placing a table at the end of chapter

Post by localghost »

meho_r wrote:[...] When the table is on that last page and it's alone on it, it is placed right on the center (vertically). How to make it appears on the top of the page?
It's not possible to comprehend that without any code. So, please provide a minimal working example (MWE) that shows this effect.

Edit: Somehow I confused two topics hence this post makes no sense.
meho_r
Posts: 823
Joined: Tue Aug 07, 2007 5:28 pm

Placing a table at the end of chapter

Post by meho_r »

Oh, sorry :oops:

Here it is:

Code: Select all

\documentclass[a4paper,10pt]{book}
\usepackage{lipsum}

\begin{document}
\lipsum[1-5]

\begin{table}[hb]
\centering
\caption{Test table}
\begin{tabular}{lll}
\hline
Text 1 & Text 2 & Text 3 \\
Text 4 & Text 5 & Text 6 \\
Text 1 & Text 2 & Text 3 \\
Text 4 & Text 5 & Text 6 \\
Text 1 & Text 2 & Text 3 \\
Text 4 & Text 5 & Text 6 \\
\hline
\end{tabular}
\end{table}
\end{document}
As you can see, the table is alone on the last page and vertically centered. Is there a way to make it appear at top of that page?
User avatar
Stefan Kottwitz
Site Admin
Posts: 10345
Joined: Mon Mar 10, 2008 9:44 pm

Placing a table at the end of chapter

Post by Stefan Kottwitz »

Hi,

it could be achieved by:

Code: Select all

\makeatletter
\setlength{\@fptop}{0pt}
\makeatother
If you put this into your preamble, floats on pages of their own will appear at the top of the page. If it's too high just take a different value than 0pt.

Stefan
LaTeX.org admin
meho_r
Posts: 823
Joined: Tue Aug 07, 2007 5:28 pm

Re: Placing a table at the end of chapter

Post by meho_r »

Thanks a lot. It works. You are really invaluable source of informations. How did you learn all that stuff? :) Impressive
User avatar
Stefan Kottwitz
Site Admin
Posts: 10345
Joined: Mon Mar 10, 2008 9:44 pm

Placing a table at the end of chapter

Post by Stefan Kottwitz »

To answer this: generally by reading a lot, beside documentation also source codes like cls and sty files, no magic ;). It also comes by the way when helping others like in this forum. But above is just a frequently asked question, see UK TeX FAQ: Vertical layout of float pages, I've seen this requirement several times myself.

Stefan
LaTeX.org admin
meho_r
Posts: 823
Joined: Tue Aug 07, 2007 5:28 pm

Re: Placing a table at the end of chapter

Post by meho_r »

Thanks for your patience. And thank you for trying to make us understand "why", not only "how" to do things with LaTeX and for mentioning relevant sources to discover new areas of LaTeX world. We appreciate that. Thank all of you :)
Post Reply