# Resize longtable to width of landscape page [duplicate]

\documentclass[a4paper,12pt]{article}

\usepackage{longtable}
\usepackage{pdflscape}
\usepackage{graphicx}

\begin{document}
\begin{landscape}
% \resizebox{\textwidth}{!}{  }
\begin{longtable}{|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|}
\hline
A & very & wide & and & long & table & here & ! & A & very & wide & and & long & table & here & ! & A & very & wide & and & long & table & here & ! \\
\hline
A & very & wide & and & long & table & here & ! & A & very & wide & and & long & table & here & ! & A & very & wide & and & long & table & here & ! \\
\hline
A & very & wide & and & long & table & here & ! & A & very & wide & and & long & table & here & ! & A & very & wide & and & long & table & here & ! \\
\hline
A & very & wide & and & long & table & here & ! & A & very & wide & and & long & table & here & ! & A & very & wide & and & long & table & here & ! \\
\hline
A & very & wide & and & long & table & here & ! & A & very & wide & and & long & table & here & ! & A & very & wide & and & long & table & here & ! \\
\hline
A & very & wide & and & long & table & here & ! & A & very & wide & and & long & table & here & ! & A & very & wide & and & long & table & here & ! \\
\hline
A & very & wide & and & long & table & here & ! & A & very & wide & and & long & table & here & ! & A & very & wide & and & long & table & here & ! \\
\hline
A & very & wide & and & long & table & here & ! & A & very & wide & and & long & table & here & ! & A & very & wide & and & long & table & here & ! \\
\hline
A & very & wide & and & long & table & here & ! & A & very & wide & and & long & table & here & ! & A & very & wide & and & long & table & here & ! \\
\hline
A & very & wide & and & long & table & here & ! & A & very & wide & and & long & table & here & ! & A & very & wide & and & long & table & here & ! \\
\hline
A & very & wide & and & long & table & here & ! & A & very & wide & and & long & table & here & ! & A & very & wide & and & long & table & here & ! \\
\hline
A & very & wide & and & long & table & here & ! & A & very & wide & and & long & table & here & ! & A & very & wide & and & long & table & here & ! \\
\hline
A & very & wide & and & long & table & here & ! & A & very & wide & and & long & table & here & ! & A & very & wide & and & long & table & here & ! \\
\hline
A & very & wide & and & long & table & here & ! & A & very & wide & and & long & table & here & ! & A & very & wide & and & long & table & here & ! \\
\hline
A & very & wide & and & long & table & here & ! & A & very & wide & and & long & table & here & ! & A & very & wide & and & long & table & here & ! \\
\hline
A & very & wide & and & long & table & here & ! & A & very & wide & and & long & table & here & ! & A & very & wide & and & long & table & here & ! \\
\hline
A & very & wide & and & long & table & here & ! & A & very & wide & and & long & table & here & ! & A & very & wide & and & long & table & here & ! \\
\hline
A & very & wide & and & long & table & here & ! & A & very & wide & and & long & table & here & ! & A & very & wide & and & long & table & here & ! \\
\hline
A & very & wide & and & long & table & here & ! & A & very & wide & and & long & table & here & ! & A & very & wide & and & long & table & here & ! \\
\hline
A & very & wide & and & long & table & here & ! & A & very & wide & and & long & table & here & ! & A & very & wide & and & long & table & here & ! \\
\hline
A & very & wide & and & long & table & here & ! & A & very & wide & and & long & table & here & ! & A & very & wide & and & long & table & here & ! \\
\hline
A & very & wide & and & long & table & here & ! & A & very & wide & and & long & table & here & ! & A & very & wide & and & long & table & here & ! \\
\hline
A & very & wide & and & long & table & here & ! & A & very & wide & and & long & table & here & ! & A & very & wide & and & long & table & here & ! \\
\hline
A & very & wide & and & long & table & here & ! & A & very & wide & and & long & table & here & ! & A & very & wide & and & long & table & here & ! \\
\hline
A & very & wide & and & long & table & here & ! & A & very & wide & and & long & table & here & ! & A & very & wide & and & long & table & here & ! \\
\hline
A & very & wide & and & long & table & here & ! & A & very & wide & and & long & table & here & ! & A & very & wide & and & long & table & here & ! \\
\hline
A & very & wide & and & long & table & here & ! & A & very & wide & and & long & table & here & ! & A & very & wide & and & long & table & here & ! \\
\hline
A & very & wide & and & long & table & here & ! & A & very & wide & and & long & table & here & ! & A & very & wide & and & long & table & here & ! \\
\hline
A & very & wide & and & long & table & here & ! & A & very & wide & and & long & table & here & ! & A & very & wide & and & long & table & here & ! \\
\hline
A & very & wide & and & long & table & here & ! & A & very & wide & and & long & table & here & ! & A & very & wide & and & long & table & here & ! \\
\hline
A & very & wide & and & long & table & here & ! & A & very & wide & and & long & table & here & ! & A & very & wide & and & long & table & here & ! \\
\hline
A & very & wide & and & long & table & here & ! & A & very & wide & and & long & table & here & ! & A & very & wide & and & long & table & here & ! \\
\hline
A & very & wide & and & long & table & here & ! & A & very & wide & and & long & table & here & ! & A & very & wide & and & long & table & here & ! \\
\hline
A & very & wide & and & long & table & here & ! & A & very & wide & and & long & table & here & ! & A & very & wide & and & long & table & here & ! \\
\hline
A & very & wide & and & long & table & here & ! & A & very & wide & and & long & table & here & ! & A & very & wide & and & long & table & here & ! \\
\hline
A & very & wide & and & long & table & here & ! & A & very & wide & and & long & table & here & ! & A & very & wide & and & long & table & here & ! \\
\hline
A & very & wide & and & long & table & here & ! & A & very & wide & and & long & table & here & ! & A & very & wide & and & long & table & here & ! \\
\hline
A & very & wide & and & long & table & here & ! & A & very & wide & and & long & table & here & ! & A & very & wide & and & long & table & here & ! \\
\hline
A & very & wide & and & long & table & here & ! & A & very & wide & and & long & table & here & ! & A & very & wide & and & long & table & here & ! \\
\hline
A & very & wide & and & long & table & here & ! & A & very & wide & and & long & table & here & ! & A & very & wide & and & long & table & here & ! \\
\hline
A & very & wide & and & long & table & here & ! & A & very & wide & and & long & table & here & ! & A & very & wide & and & long & table & here & ! \\
\hline
A & very & wide & and & long & table & here & ! & A & very & wide & and & long & table & here & ! & A & very & wide & and & long & table & here & ! \\
\hline
\end{longtable}
\end{landscape}
\end{document}


I want to use something like \resizebox{\textwidth}{!} to shrink the longtable to the width of the page. It should scale the table as a whole and not just padding/margin of the cells.

-

## marked as duplicate by Martin Schröder, Stefan Kottwitz♦Feb 22 '13 at 9:26

A longtable inside a \resizebox will not be broken across pages. –  egreg May 4 '12 at 14:01
Sorry, isn't this the same question as your question How to fit landscape multi-page table to textwidth? Note that you can update existing questions and duplicate questions are not wanted here. If the answer you got for your first question isn't good enough, simply state there what is still missing. –  Martin Scharrer May 4 '12 at 14:06
The previous question I posted sorta had two requirements but wasn't very well construted in my opinion so after they helped me with the table spanning over multiple pages I figured I would reformulate the next problem (scaling the table to page width) and add a better example of the code I was at. Sorry for this, next time I will add this to the existing question –  Pizzaguru May 4 '12 at 14:26
Mico's code as posted in the previous question answers this exactly: set LTleft and LTright and use \extracolsep to add fill glue. –  David Carlisle May 4 '12 at 15:12

This question is very similar to the one you posted yesterday, How to fit landscape multi-page table to textwidth. Hence, the answer I provided there will also work for your reworked example. (The main difference, AFAICT, between the two MWEs is that the first piece contains a 15-column table whereas the second piece contains a 24-column table.)

For your new example, do note that if you specify both the 12pt and a4paper options (and margins of 1in all around), there simply is not enough room in the textblock to hold your table without exceeding the maximum available width of the textblock. Your best bet, I think, is to switch to a 11pt font size for the table; you can achieve this (if the main document font size is 12pt) by issuing the directive \small. This is what I've done in the reworked MWE below.

\documentclass[a4paper,12pt]{article}
% 1-inch margins all around -- adjust this setting to suit your needs
\usepackage[margin=1in]{geometry}
\usepackage{longtable}
\usepackage{pdflscape}
\usepackage{graphicx}

\begin{document}
\begin{landscape}
\small  % Switch from 12pt to 11pt; otherwise, table won't fit
\setlength\LTleft{0pt}            % default: \parindent
\setlength\LTright{0pt}           % default: \fill
\begin{longtable}{@{\extracolsep{\fill}}|*{24}{c|}}
\hline
A & very & wide & and & long & table & here & ! &
A & very & wide & and & long & table & here & ! &
A & very & wide & and & long & table & here & ! \\
\hline
A & very & wide & and & long & table & here & ! &
A & very & wide & and & long & table & here & ! &
A & very & wide & and & long & table & here & ! \\
\hline
A & very & wide & and & long & table & here & ! &
A & very & wide & and & long & table & here & ! &
A & very & wide & and & long & table & here & ! \\
\hline
A & very & wide & and & long & table & here & ! &
A & very & wide & and & long & table & here & ! &
A & very & wide & and & long & table & here & ! \\
\hline
...
\hline
\end{longtable}
\end{landscape}
\end{document}


-

This seems to work for your example

\begin{document}
\begin{landscape}
\tiny
\setlength\LTleft{0pt}
\setlength\LTright{0pt}
\begin{longtable}{@{\extracolsep{\fill}}|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|@{}}
\hline

-