# Fit a page to table

How can I fit a page to show an entire table (all I've seen here is the opposed, fit the table size to the page size. But, as I'll not print the result, I want to do the opposite)

This is a sample of my table (I need use longtable because it uses 2 pages)

\documentclass[landscape, letter]{report}
\usepackage{ltxtable}
\usepackage[table]{xcolor}
\usepackage{colortbl}
\usepackage{multirow}
\usepackage[latin1]{inputenc}
\usepackage[left=0cm,top=.5cm,right=0cm]{geometry}
\usepackage{longtable}
\title{titulo}
\author{Rodrigo Coster - 1141783-01}
\begin{document}
\begin{center}\textbf{{\LARGE Relação de vagas autorizadas, providas e disponíveis}}\end{center}
\tiny
\begin{longtable}{cccccccccccccccccccccccccccccccccccccc}
\hline
\multirow{3}*{Cod.} & \multirow{3}*{Sec.} & \multicolumn{12}{c}{Categoria A} & \multicolumn{12}{c}{Categoria B} & \multicolumn{12}{c}{Categoria G} \\
& & \multicolumn{3}{c}{4h}  & \multicolumn{3}{c}{5h}  & \multicolumn{3}{c}{6h}  & \multicolumn{3}{c}{Total} & \multicolumn{3}{c}{4h}  & \multicolumn{3}{c}{5h}  & \multicolumn{3}{c}{6h}  & \multicolumn{3}{c}{Total} & \multicolumn{3}{c}{4h}  & \multicolumn{3}{c}{5h}  & \multicolumn{3}{c}{6h}  & \multicolumn{3}{c}{Total} \\
& & A & P & D & A & P & D & A & P & D & A & P & D & A & P & D & A & P & D & A & P & D & A & P & D & A & P & D & A & P & D & A & P & D & A & P & D \\
\rowcolor{yellow} 187 & GP & \cellcolor{red} 5 & \cellcolor{red} 6 & \cellcolor{red} -1 &  0 &  0 &  0 &  0 &  0 &  0 & \cellcolor{red} 5 & \cellcolor{red} 6 & \cellcolor{red} -1 &  6 &  4 &  2 &  0 &  0 &  0 &  23 &  20 &  3 &  29 &  25 &  4 &  0 &  0 &  0 &  0 &  0 &  0 &  0 &  0 &  0 &  0 &  0 &  0 \\
\rowcolor{yellow} 912 & SMA &  46 &  35 &  11 &  0 &  0 &  0 &  24 &  15 &  9 &  70 &  50 &  20 &  10 &  8 &  2 &  0 &  0 &  0 &  26 &  10 &  16 &  36 &  22 &  14 & \cellcolor{red} 0 & \cellcolor{red} 6 & \cellcolor{red} -6 &  0 &  0 &  0 & \cellcolor{red} 0 & \cellcolor{red} 6 & \cellcolor{red} -6 & \cellcolor{red} 0 & \cellcolor{red} 12 & \cellcolor{red} -12 \\
825 & SMACIS &  0 &  0 &  0 &  0 &  0 &  0 &  0 &  0 &  0 &  0 &  0 &  0 &  0 &  0 &  0 &  0 &  0 &  0 &  0 &  0 &  0 &  0 &  0 &  0 &  0 &  0 &  0 &  0 &  0 &  0 &  0 &  0 &  0 &  0 &  0 &  0 \\
\rowcolor{yellow} 925 & SMACIS & \cellcolor{red} 0 & \cellcolor{red} 2 & \cellcolor{red} -2 &  0 &  0 &  0 &  0 &  0 &  0 & \cellcolor{red} 0 & \cellcolor{red} 2 & \cellcolor{red} -2 & \cellcolor{red} 0 & \cellcolor{red} 2 & \cellcolor{red} -2 &  0 &  0 &  0 &  0 &  0 &  0 & \cellcolor{red} 0 & \cellcolor{red} 2 & \cellcolor{red} -2 &  0 &  0 &  0 &  0 &  0 &  0 &  0 &  0 &  0 &  0 &  0 &  0 \\
\rowcolor{yellow} 83 & SMED &  151 &  8 &  143 &  0 &  0 &  0 &  0 &  0 &  0 &  151 &  8 &  143 & \cellcolor{red} 0 & \cellcolor{red} 2 & \cellcolor{red} -2 &  0 &  0 &  0 & \cellcolor{red} 0 & \cellcolor{red} 1 & \cellcolor{red} -1 & \cellcolor{red} 0 & \cellcolor{red} 3 & \cellcolor{red} -3 & \cellcolor{red} 0 & \cellcolor{red} 37 & \cellcolor{red} -37 &  0 &  0 &  0 & \cellcolor{red} 0 & \cellcolor{red} 6 & \cellcolor{red} -6 & \cellcolor{red} 0 & \cellcolor{red} 44 & \cellcolor{red} -44 \\
\rowcolor{yellow} 913 & SMF & \cellcolor{red} 0 & \cellcolor{red} 73 & \cellcolor{red} -73 &  0 &  0 &  0 &  0 &  0 &  0 & \cellcolor{red} 0 & \cellcolor{red} 73 & \cellcolor{red} -73 & \cellcolor{red} 0 & \cellcolor{red} 35 & \cellcolor{red} -35 &  0 &  0 &  0 & \cellcolor{red} 0 & \cellcolor{red} 37 & \cellcolor{red} -37 & \cellcolor{red} 0 & \cellcolor{red} 73 & \cellcolor{red} -73 & \cellcolor{red} 0 & \cellcolor{red} 10 & \cellcolor{red} -10 &  0 &  0 &  0 & \cellcolor{red} 0 & \cellcolor{red} 5 & \cellcolor{red} -5 & \cellcolor{red} 0 & \cellcolor{red} 15 & \cellcolor{red} -15 \\
\rowcolor{yellow} 7 & SMED &  0 &  0 &  0 &  0 &  0 &  0 &  67 &  0 &  67 &  67 &  0 &  67 & \cellcolor{red} 0 & \cellcolor{red} 8 & \cellcolor{red} -8 &  0 &  0 &  0 &  124 &  63 &  61 &  124 &  71 &  53 & \cellcolor{red} 0 & \cellcolor{red} 10 & \cellcolor{red} -10 &  0 &  0 &  0 & \cellcolor{red} 0 & \cellcolor{red} 51 & \cellcolor{red} -51 & \cellcolor{red} 0 & \cellcolor{red} 61 & \cellcolor{red} -61 \\
\rowcolor{yellow} 918 & SMS &  138 &  93 &  45 &  0 &  0 &  0 & \cellcolor{red} 2 & \cellcolor{red} 3 & \cellcolor{red} -1 &  140 &  97 &  43 &  93 &  43 &  50 &  0 &  0 &  0 &  13 &  2 &  11 &  106 &  47 &  59 & \cellcolor{red} 0 & \cellcolor{red} 17 & \cellcolor{red} -17 &  0 &  0 &  0 & \cellcolor{red} 0 & \cellcolor{red} 1 & \cellcolor{red} -1 & \cellcolor{red} 0 & \cellcolor{red} 19 & \cellcolor{red} -19 \\
\rowcolor{yellow} 166 & SMS &  0 &  0 &  0 & \cellcolor{red} 2 & \cellcolor{red} 5 & \cellcolor{red} -3 &  0 &  0 &  0 & \cellcolor{red} 2 & \cellcolor{red} 5 & \cellcolor{red} -3 &  0 &  0 &  0 &  103 &  52 &  51 &  0 &  0 &  0 &  103 &  54 &  49 &  0 &  0 &  0 & \cellcolor{red} 0 & \cellcolor{red} 2 & \cellcolor{red} -2 &  0 &  0 &  0 & \cellcolor{red} 0 & \cellcolor{red} 2 & \cellcolor{red} -2 \\
\end{longtable}
\end{document}


As you can see, after using \tiny, one column is still missing.

-
Do you need it to be tight to the table, or simply make it wider, putting \advance\pdfpagewidth1in just before \begin{longtable} works for example, or do you want to measure the table? –  David Carlisle Mar 18 '13 at 13:05
@DavidCarlisle: That's perfect! –  Rcoster Mar 18 '13 at 13:15

Do you need it to be tight to the table, or simply make it wider, putting

\addtolength\pdfpagewidth{1in}


just before \begin{longtable} works for example. It would be possible to measure the table exactly on a later run. but usually it is sufficient to just increase by a fixed amount.

Note that \pdfpagewidth just affects the size the pdf viewer uses to clip the view, the table will still be overfull for TeX, if you want to change that then you might also want

Of course it doesn't have to be 1in any TeX length will work.