# Fit a table into one page

I have a table that is very wide. Now I want to force it into one landscape page. I already set the page orientation to landscape but now I don't know how to force it into one page with scaling. Any hints?

-
–  Martin Scharrer Jun 13 '12 at 8:52

You can use the adjustbox package with:

\begin{adjustbox}{width=\textwidth,totalheight=\textheight,keepaspectratio}


You can also use the graphicx package with:

\setkeys{Gin}{keepaspectratio}


but adjustbox is more recommended. It doesn't read the whole table as an argument.

You can also add \rotatebox{90}{..} or the angle=90 option to the adjustbox environment to implement the rotation.

You might need to exchange \textwidth and \textheight because of the landscape mode. Also you should use an approximate font size first, e.g. try \tiny or \scriptsize and let the rest be done by scaling. You shouldn't scale the normal font size to a very small size. Many fonts are differently designed in different sizes, so using the closest possible size yields the best results.

-
Thanks the adjustbox solution works. I just exchanged \textwidth and \textheight. But I don't know why but I had to use width = 0.9999 * \textheight to avoid an empty page before the table. –  RoflcoptrException Sep 22 '11 at 15:12
Maybe you have a hidden space somewhere? –  Martin Scharrer Sep 22 '11 at 15:27
What about fitting a table/figure (outside of a float) in a page along with the Section or Sub-Section title? I can see no success using \enlargethispage and \enlargethispage*, negative and positive \vspace(s) before and after the table/figure, \Needspace*{} and others. Is it possible to just subtract the "vertical space" occupied by the Section title and automatically scale the table/figure to the remaining height (by keeping, of course, its aspect ratio intact)? –  Nikos Alexandris Dec 8 '11 at 11:41
@NikosAlexandris: You can use \dimexpr\textheight-2\baselineskip\relax instead of only \textheight to reduce the height by about two lines (or any other length). –  Martin Scharrer Dec 8 '11 at 11:50
@MartinScharrer: The desired effect concerning the size of the table(s), for example, is achieved. Visually my two (sub-)tables within one (rotated) float seem to fit along with the Section title. However, pdflatex prefers to push the tables in the next page leaving a body-less heading. Also, the rotated caption of the figure-float is as long as the textheight! Should I just use \captionof and forget floating? –  Nikos Alexandris Dec 9 '11 at 12:20

I assume you want to scale down just the contents of the tabular environment, while leaving the fontsize of the caption unchanged. If you use the rotating package, you can avail yourself of its sidewaystable environment, which automatically rotates its contents by 90 degrees. (Internally, the package relies on the graphics/x package.) With this environment, you needn't keep track of whether \textheight and \textwidth need to be interchanged or not.

\begin{sideswaystable}
\caption{A very wide table}\label{tab:verywide}
\centering
\scriptsize %% or \tiny -- see remark below
\begin{tabul...
...
\end{tabul...
\end{sidewaystable}


Remark: If the tabular material has so many columns that it won't fit on a rotated page even if the fontsize has been set to either \scriptsize or \tiny, you may want to consider seriously breaking up the table into two subtables and displaying them separately. Realistically, very few readers are going to bother reading something in a font size smaller than 5 or 6pt. Hence, if you have to use both the \tiny fontsize instruction as well as the \adjustbox command with a shrinkage factor of well below 1, chances that anyone is going to read your carefully designed tabular material are, well, smaller than tiny.

-