10

***Further to my earlier post, I am now getting errors and no output from latex simply by inserting: %\resizebox{.88\hsize}{!}{ } into my code. I have edited the code below to show where I am inserting it. Am I missing something incredibly simple here?! - any assistance would be appreciated as I am truly at a loss. thank you! R************

I am new here and will try to be as specific as possible. I have searched everywhere to try and figure out how to resize or scale a table spanning several pages using \longtable. I have added the \usepackage{longtable} in the preamble and have coded as follows:

\documentclass[12pt]{article}
\usepackage{longtable}
\begin{document}
\begin{center}
\resizebox{.88\hsize}{!}{
\begin{longtable}{|c|c|c|c|}
\caption{A simple longtable example}\\
\hline
\textbf{First entry} & \textbf{Second entry} & \textbf{Third entry} & \textbf{Fourth entry} \\
\hline
\endfirsthead
\multicolumn{4}{c}%
{\tablename\ \thetable\ -- \textit{Continued from previous page}} \\
\hline
\textbf{First entry} & \textbf{Second entry} & \textbf{Third entry} & \textbf{Fourth entry} \\
\hline
\endhead
\hline \multicolumn{4}{r}{\textit{Continued on next page}} \\
\endfoot
\hline
\endlastfoot
1 & 2 & 3 & 4 \\ 1 & 2 & 3 & 4 \\ 1 & 2 & 3 & 4 \\ 1 & 2 & 3 & 4 \\
1 & 2 & 3 & 4 \\ 1 & 2 & 3 & 4 \\ 1 & 2 & 3 & 4 \\ 1 & 2 & 3 & 4 \\
1 & 2 & 3 & 4 \\ 1 & 2 & 3 & 4 \\ 1 & 2 & 3 & 4 \\ 1 & 2 & 3 & 4 \\
1 & 2 & 3 & 4 \\ 1 & 2 & 3 & 4 \\ 1 & 2 & 3 & 4 \\ 1 & 2 & 3 & 4 \\
1 & 2 & 3 & 4 \\ 1 & 2 & 3 & 4 \\ 1 & 2 & 3 & 4 \\ 1 & 2 & 3 & 4 \\
1 & 2 & 3 & 4 \\ 1 & 2 & 3 & 4 \\ 1 & 2 & 3 & 4 \\ 1 & 2 & 3 & 4 \\
1 & 2 & 3 & 4 \\ 1 & 2 & 3 & 4 \\ 1 & 2 & 3 & 4 \\ 1 & 2 & 3 & 4 \\
1 & 2 & 3 & 4 \\ 1 & 2 & 3 & 4 \\ 1 & 2 & 3 & 4 \\ 1 & 2 & 3 & 4 \\
1 & 2 & 3 & 4 \\ 1 & 2 & 3 & 4 \\ 1 & 2 & 3 & 4 \\ 1 & 2 & 3 & 4 \\
1 & 2 & 3 & 4 \\ 1 & 2 & 3 & 4 \\ 1 & 2 & 3 & 4 \\ 1 & 2 & 3 & 4 \\
1 & 2 & 3 & 4 \\ 1 & 2 & 3 & 4 \\ 1 & 2 & 3 & 4 \\ 1 & 2 & 3 & 4 \\
1 & 2 & 3 & 4 \\ 1 & 2 & 3 & 4 \\ 1 & 2 & 3 & 4 \\ 1 & 2 & 3 & 4 \\
\end{longtable}
}
\end{center}
\end{document}

The table reacts as it should, meaning, it does not go into the margins, it continues from one page to the next until all rows have been displayed.

My problem is that I am trying to reduce the size of the table: shorter row heights, smaller font, etc, in order to scale my table down a page or two. I would be happy with a simple scaling just to make the entire thing smaller.

Any ideas?

I have searched through the questions and answers on here already - but no luck.

Thanks, R

David Carlisle
  • 757,742
  • I am bound by my report's specifications and cannot turn the table 90degrees and/or make it landscape. Any other suggestions? Sidenote - the four columns are rather narrow and do not require the landscape in any case. –  Nov 18 '12 at 23:03

2 Answers2

9

you cannot put a longtable into a box. Use a font macro for setting the textwidth down to \tiny. Example for \footnotesize:

\documentclass[12pt]{article}
\usepackage{longtable}
\begin{document}
\footnotesize%%%%%%%%%%%  smaller font size %%%%%%%%
\begin{longtable}{|c|c|c|c|}
\caption{A simple longtable example}\\\hline
\textbf{First entry} & \textbf{Second entry} & \textbf{Third entry} & \textbf{Fourth entry} \\\hline
\endfirsthead
\multicolumn{4}{c}%
{\tablename\ \thetable\ -- \textit{Continued from previous page}} \\    \hline
\textbf{First entry} & \textbf{Second entry} & \textbf{Third entry} & \textbf{Fourth entry} \\    \hline
\endhead
\hline \multicolumn{4}{r}{\textit{Continued on next page}} \\
\endfoot
\hline
\endlastfoot
1 & 2 & 3 & 4 \\ 1 & 2 & 3 & 4 \\ 1 & 2 & 3 & 4 \\ 1 & 2 & 3 & 4 \\
1 & 2 & 3 & 4 \\ 1 & 2 & 3 & 4 \\ 1 & 2 & 3 & 4 \\ 1 & 2 & 3 & 4 \\
1 & 2 & 3 & 4 \\ 1 & 2 & 3 & 4 \\ 1 & 2 & 3 & 4 \\ 1 & 2 & 3 & 4 \\
\end{longtable}

\normalsize
\end{document}
David Carlisle
  • 757,742
-1

Here is some variants how to modify horizontal and vertical size of your table: at tex.stackexchange.com.

But, if you don't care of scaling text in table, I point you to command \resizebox -- it really works as you want, but it scales text respectively.

NG_
  • 105
  • I have tried this unsuccessfully and am hoping you can take a quick look and tell me where I went wrong. thank you –  Nov 20 '12 at 04:09