# Resizing a table by textheight

Say, I have a table which doesn't fit on one page. Say, I don't want to use any special table types or so but want to solve the problem by using the \resizebox-command and keep my ratio.

If by using \resizebox{\texwidth}{!}{...} the table fits, then my problem is solved. But if the table is still too long, my instinct would be to use \resizebox{!}{\textheight}{...} instead. Allowing some space for my caption I would have to adjust the height to about 0.9\textheight to be sure for a single line caption. But in my example I have ta adjust to approx. 0.48\textheight to get rid of all warnings and fit the table on the page. This seems very odd to me. What am I missing?

\documentclass{article}
\usepackage{graphicx}

\begin{document}
\begin{table}[htbp]
\centering
%   \resizebox{\textwidth}{!}{
\resizebox{!}{0.48\textheight}{
\begin{tabular}{|lll|}\hline
TextTextTextTextTextText & TextTextTextTextText & TextTextTextTextText\\
TextTextTextTextTextText & TextTextTextTextText & TextTextTextTextText\\
TextTextTextTextTextText & TextTextTextTextText & TextTextTextTextText\\
TextTextTextTextTextText & TextTextTextTextText & TextTextTextTextText\\
TextTextTextTextTextText & TextTextTextTextText & TextTextTextTextText\\
TextTextTextTextTextText & TextTextTextTextText & TextTextTextTextText\\
TextTextTextTextTextText & TextTextTextTextText & TextTextTextTextText\\
TextTextTextTextTextText & TextTextTextTextText & TextTextTextTextText\\
TextTextTextTextTextText & TextTextTextTextText & TextTextTextTextText\\
TextTextTextTextTextText & TextTextTextTextText & TextTextTextTextText\\
TextTextTextTextTextText & TextTextTextTextText & TextTextTextTextText\\
TextTextTextTextTextText & TextTextTextTextText & TextTextTextTextText\\
TextTextTextTextTextText & TextTextTextTextText & TextTextTextTextText\\
TextTextTextTextTextText & TextTextTextTextText & TextTextTextTextText\\
TextTextTextTextTextText & TextTextTextTextText & TextTextTextTextText\\
TextTextTextTextTextText & TextTextTextTextText & TextTextTextTextText\\
TextTextTextTextTextText & TextTextTextTextText & TextTextTextTextText\\
TextTextTextTextTextText & TextTextTextTextText & TextTextTextTextText\\
TextTextTextTextTextText & TextTextTextTextText & TextTextTextTextText\\
TextTextTextTextTextText & TextTextTextTextText & TextTextTextTextText\\
TextTextTextTextTextText & TextTextTextTextText & TextTextTextTextText\\
TextTextTextTextTextText & TextTextTextTextText & TextTextTextTextText\\
TextTextTextTextTextText & TextTextTextTextText & TextTextTextTextText\\
TextTextTextTextTextText & TextTextTextTextText & TextTextTextTextText\\
TextTextTextTextTextText & TextTextTextTextText & TextTextTextTextText\\
TextTextTextTextTextText & TextTextTextTextText & TextTextTextTextText\\
TextTextTextTextTextText & TextTextTextTextText & TextTextTextTextText\\
TextTextTextTextTextText & TextTextTextTextText & TextTextTextTextText\\
TextTextTextTextTextText & TextTextTextTextText & TextTextTextTextText\\
TextTextTextTextTextText & TextTextTextTextText & TextTextTextTextText\\
TextTextTextTextTextText & TextTextTextTextText & TextTextTextTextText\\
TextTextTextTextTextText & TextTextTextTextText & TextTextTextTextText\\
TextTextTextTextTextText & TextTextTextTextText & TextTextTextTextText\\
TextTextTextTextTextText & TextTextTextTextText & TextTextTextTextText\\
TextTextTextTextTextText & TextTextTextTextText & TextTextTextTextText\\
TextTextTextTextTextText & TextTextTextTextText & TextTextTextTextText\\
TextTextTextTextTextText & TextTextTextTextText & TextTextTextTextText\\
TextTextTextTextTextText & TextTextTextTextText & TextTextTextTextText\\
TextTextTextTextTextText & TextTextTextTextText & TextTextTextTextText\\
TextTextTextTextTextText & TextTextTextTextText & TextTextTextTextText\\
TextTextTextTextTextText & TextTextTextTextText & TextTextTextTextText\\
TextTextTextTextTextText & TextTextTextTextText & TextTextTextTextText\\
TextTextTextTextTextText & TextTextTextTextText & TextTextTextTextText\\
TextTextTextTextTextText & TextTextTextTextText & TextTextTextTextText\\
TextTextTextTextTextText & TextTextTextTextText & TextTextTextTextText\\
TextTextTextTextTextText & TextTextTextTextText & TextTextTextTextText\\
TextTextTextTextTextText & TextTextTextTextText & TextTextTextTextText\\ \hline
\end{tabular}}
\caption{test}
\end{table}
\end{document}
-

You are running into the common problem of confusing the height and the totalheight of things in TeX. For some reason which also surprised me the baseline of the table is the the middle of the table, so that the lower half is part of the depth of the resulting TeX box. The \resizebox scales the box height, not the totalheight (height+depth) to the given value. To scale the totalheight use the * version. You can also use \dimexpr (see also Doing maths with distance values in LaTeX source code) or the calc package to subtract e.g. two lines from the height:

\resizebox*{!}{\dimexpr\textheight-2\baselineskip\relax}{%

Also note that placing a large table in a macro argument is very inefficient and doesn't allow the usage of \verb etc. in the table. You can use the \adjustbox macro or adjustbox environment from the relative new adjustbox package (written by me) to scale any content instead. Both read the content as box not as argument and avoid the mentioned drawbacks:

% [...]