11

***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

1
  • 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.
    – user1834300
    Commented Nov 18, 2012 at 23:03

2 Answers 2

10

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}
3
  • Any idea how to adapt this for within LyX longtables? Commented Mar 14, 2013 at 20:54
  • inser the longtable as usual, then mark the whole table and choose the size footnotesize from the menu
    – user2478
    Commented Mar 14, 2013 at 20:59
  • Ah... sorry, I was after another solution/Q&A, i.e. after tex.stackexchange.com/a/54304/8272 Commented Mar 14, 2013 at 21:04
-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.

1
  • I have tried this unsuccessfully and am hoping you can take a quick look and tell me where I went wrong. thank you
    – user1834300
    Commented Nov 20, 2012 at 4:09

You must log in to answer this question.