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?
2 Answers
You can use the adjustbox
package with:
\begin{adjustbox}{width=\textwidth,totalheight=\textheight,keepaspectratio}
% your table
\end{adjustbox}
You can also use the graphicx
package with:
\setkeys{Gin}{keepaspectratio}
\resizebox*{\textwidth}{\textheight}{your table}
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. Sep 22, 2011 at 15:12
-
-
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)? Dec 8, 2011 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). Dec 8, 2011 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? Dec 9, 2011 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.
-
great post, do you also know how to fit a sidewaystable exacly on a page, by scaling down the fontsize (and/or any other parameters)? Apr 29, 2017 at 15:47
-
@user3032689 - Scaling down the font size in order to make a table fit inside the text block is almost always a dreadful idea, typographically speaking. Really. Don't do it unless you want to signal to your readers that you disdain them and couldn't care less if they'll actually bother to read what's in the table. (Even if that's not your explicit intent, do rest assured that that's exactly what your readers will think your intent is.) The advisability and suitability of other adjustment possibilities depends strongly on the material being typeset. Please post a new query with your table.– MicoApr 29, 2017 at 16:04