# How to avoid page break after table?

I have a small LaTeX table (tabular) created in R with the xtable package and I would like to place a figure underneath the table on the SAME page. I have tried various things (using packages float, needspace, etoolbox, etc etc), but I don't seem to get it completely right... It also doesn't work if I just put random text after the table.

How can I force to not have a page break after the table?

My code looks like this (omitting the packages) :

\documentclass[a4paper, 11pt]{article}

\begin{document}

\include{small_table}

\begin{figure}
\includegraphics{piechart.eps}
\end{figure}

\end{document}


Because I make the small table file from R, I want to avoid altering that file. However it looks something like this:

\begin{table}[ht]
\centering
\begin{tabular}{lc}
bla & bla
\end{tabular}
\end{table}


Thank you!

• Welcome to the site! How about: after your \end{tabular} putting a blank line and then \includegraphics{piechart.eps}? – cmhughes Jan 28 '16 at 14:33
• Because I am making lots of tables in R I would like a solution where I don't need to edit the small table file... So I would like a solution where the first code part is altered to achieve the result. I edited my questions now. Hope it makes sense... – Citylime Jan 28 '16 at 14:38
• \include _always forces a page break, use \input – David Carlisle Jan 28 '16 at 14:43
• then you need \begin{figure}[htp] to allow the figure to be in the page rather than float to top – David Carlisle Jan 28 '16 at 14:44

\include _always forces a page break, use \input, and then allow the figure to be on the same page by including h in its option.

\documentclass[a4paper, 11pt]{article}

\begin{document}

\input{small_table}

\begin{figure}[htp]
\includegraphics{piechart.eps}
\end{figure}

\end{document}

• Great! Works perfect! Thank you very much! :) – Citylime Feb 1 '16 at 7:49

One could also extent David's solution by adding a \nopagebreak between the table and the figure:

\documentclass[a4paper, 11pt]{article}

\begin{document}

\input{small_table}
\nopagebreak
\begin{figure}[htp]
\includegraphics{piechart.eps}
\end{figure}

\end{document}


You can also specify an optional value between 0 and 4 to \nopagebreak. The higher the value, the less likely is a pagebreak at that position.