Much like this question, I want to force a table to fit within the vertical page margins.
Any ideas?
Edit:
Margin size: \usepackage[left=3cm,right=3cm,textheight=23.5cm]{geometry}
Present situation:

Much like this question, I want to force a table to fit within the vertical page margins.
Any ideas?
Edit:
Margin size: \usepackage[left=3cm,right=3cm,textheight=23.5cm]{geometry}
Present situation:

In my comment, I advocated something like:
\newsavebox\mybox
\sbox{\mybox}{your table goes here}
\scalebox{scale factor}{\usebox{\mybox}}
where scalefactor is a number and your table is something like a tabular. In this illustrative example below, I first set the text height shorter (2.8") just so it is easier to see what is going on. The first thing I do I set a large tabular without any changes. Because it exceeds the length of page 1, it ends up on page 2, and you see that it stretches down to the page number.
So, after clearing a page, I show how placing the table into a box and scaling it to a size smaller than unity can resolve the height issue (page 3). Of course, the font size is no longer uniform through the document.
On page 4, I show how this approach can be incorporated into a float, such as a table.
\documentclass[12pt]{article}
\usepackage{graphicx}
\textheight 2.8in
\begin{document}
{\centering
\begin{tabular}{|l|l|}
\hline
Variable & description of the variable\\
\hline
Variable & description\\
\hline
Variable & description\\
\hline
Variable & description\\
\hline
Variable & description\\
\hline
Variable & description\\
\hline
Variable & description\\
\hline
Variable & description\\
\hline
Variable & description\\
\hline
Variable & description\\
\hline
Variable & description\\
\hline
Variable & description\\
\hline
Variable & description\\
\hline
Variable & description\\
\hline
Variable & description\\
\hline
\end{tabular}\par
}
\clearpage
\newsavebox\mybox
\sbox{\mybox}{%
\begin{tabular}{|l|l|}
\hline
Variable & description of the variable\\
\hline
Variable & description\\
\hline
Variable & description\\
\hline
Variable & description\\
\hline
Variable & description\\
\hline
Variable & description\\
\hline
Variable & description\\
\hline
Variable & description\\
\hline
Variable & description\\
\hline
Variable & description\\
\hline
Variable & description\\
\hline
Variable & description\\
\hline
Variable & description\\
\hline
Variable & description\\
\hline
Variable & description\\
\hline
\end{tabular}
}
{\centering\scalebox{.9}{\usebox{\mybox}}\par}
\clearpage
\begin{table}
\caption{My caption}
{\centering\scalebox{.85}{\usebox{\mybox}}\par}
\end{table}
\end{document}

If the table to be scaled is not a float, but merely a tabular, it can be scaled exactly to the \textheight using the \scaleto{object}{height} feature of the scalerel package:
\documentclass[12pt]{article}
\textheight 6in
\usepackage{scalerel}
\begin{document}
\newsavebox\mybox
\sbox{\mybox}{%
\begin{tabular}{|l|l|}
\hline
Variable & description of the variable\\
\hline
Variable & description\\
\hline
Variable & description\\
\hline
Variable & description\\
\hline
Variable & description\\
\hline
Variable & description\\
\hline
Variable & description\\
\hline
Variable & description\\
\hline
Variable & description\\
\hline
Variable & description\\
\hline
Variable & description\\
\hline
Variable & description\\
\hline
Variable & description\\
\hline
Variable & description\\
\hline
Variable & description\\
\hline
\end{tabular}
}
{\centering\scaleto{\usebox{\mybox}}{\textheight}\par}
\end{document}
\newsavebox\mybox\sbox{\mybox}{your table goes here}\scalebox{scale factor}{\usebox{\mybox}}, where\scaleboxis part of thegraphicxpackage.scale factoris a number. The picture helps, but the code you used to get there would be more helpful, so that those who are willing to help you don't have to retype it all from scratch. – Steven B. Segletes Jan 31 '14 at 14:37\noindent\resizebox{\textwidth}{!}{ table here }to make the table fit within the vertical margins. Anyway, your answer seem to work, thank you, but you have written it as a comment. – SplitteMineBramsejl Jan 31 '14 at 14:49It just frustrates me that I can't get the
– SplitteMineBramsejl Jan 31 '14 at 15:06geometrypackage to work my way. From the LyX wiki it is described how to fit the table horizontally by keeping the aspect ratio of your table, using!as the height parameter:\resizebox{\textwidth}{!}{argument}.\textheight, but is within the horizontal extent of\textwidth, then the\resizeboxmacro you cite will not shrink the table, since it is already less wide than\textwidth. – Steven B. Segletes Jan 31 '14 at 15:14\resizeboxwithingeometryis able of resizing tables vertically? I.e. tables breaking the vertical but not hortizontal extent of\textwidth. – SplitteMineBramsejl Jan 31 '14 at 15:21tabularyou need resized, then myscalerelpackage has a macro\scaleto{tabular material goes here}{\textheight}– Steven B. Segletes Jan 31 '14 at 15:34