1

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!

4
  • Welcome to the site! How about: after your \end{tabular} putting a blank line and then \includegraphics{piechart.eps}?
    – cmhughes
    Commented Jan 28, 2016 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
    Commented Jan 28, 2016 at 14:38
  • 1
    \include _always forces a page break, use \input Commented Jan 28, 2016 at 14:43
  • then you need \begin{figure}[htp] to allow the figure to be in the page rather than float to top Commented Jan 28, 2016 at 14:44

2 Answers 2

5

\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}
1
  • Great! Works perfect! Thank you very much! :)
    – Citylime
    Commented Feb 1, 2016 at 7:49
0

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.

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .