0

I really like to use adjustbox package with my numerical data which often is too wide and when \tiny font is still too large. However, the problem is when my table is too high. Can I somehow use both adjustbox and longtable? This is my current code:

\documentclass{article}

\usepackage{adjustbox}
\begin{document}

\begin{table} 
\begin{adjustbox}{max width=\textwidth}
\begin{tabular}[tbph]{cccccc}   
  &     Homer J. Simpson &     Marge Simpson &     Bart Simpson &     Lisa Simpson &     Maggie Simpson  \\ 
       Age &     38 &     34 &     10 &     8  &     1 \\
       Age &     38 &     34 &     10 &     8  &     1 \\
       Age &     38 &     34 &     10 &     8  &     1 \\       
       Age &     38 &     34 &     10 &     8  &     1 \\       
       Age &     38 &     34 &     10 &     8  &     1 \\       
       Age &     38 &     34 &     10 &     8  &     1 \\       
       Age &     38 &     34 &     10 &     8  &     1 \\       
       Age &     38 &     34 &     10 &     8  &     1 \\       
       Age &     38 &     34 &     10 &     8  &     1 \\       
       Age &     38 &     34 &     10 &     8  &     1 \\       
       Age &     38 &     34 &     10 &     8  &     1 \\       
       Age &     38 &     34 &     10 &     8  &     1 \\       
       Age &     38 &     34 &     10 &     8  &     1 \\       
       Age &     38 &     34 &     10 &     8  &     1 \\       
       Age &     38 &     34 &     10 &     8  &     1 \\       
       Age &     38 &     34 &     10 &     8  &     1 \\       
       Age &     38 &     34 &     10 &     8  &     1 \\       
       Age &     38 &     34 &     10 &     8  &     1 \\       
       Age &     38 &     34 &     10 &     8  &     1 \\       
       Age &     38 &     34 &     10 &     8  &     1 \\       
       Age &     38 &     34 &     10 &     8  &     1 \\       
       Age &     38 &     34 &     10 &     8  &     1 \\       
       Age &     38 &     34 &     10 &     8  &     1 \\       
       Age &     38 &     34 &     10 &     8  &     1 \\       
       Age &     38 &     34 &     10 &     8  &     1 \\       
       Age &     38 &     34 &     10 &     8  &     1 \\       
       Age &     38 &     34 &     10 &     8  &     1 \\       
       Age &     38 &     34 &     10 &     8  &     1 \\       
       Age &     38 &     34 &     10 &     8  &     1 \\       
       Age &     38 &     34 &     10 &     8  &     1 \\       
       Age &     38 &     34 &     10 &     8  &     1 \\       
       Age &     38 &     34 &     10 &     8  &     1 \\       
       Age &     38 &     34 &     10 &     8  &     1 \\       
       Age &     38 &     34 &     10 &     8  &     1 \\       
       Age &     38 &     34 &     10 &     8  &     1 \\      
       Age &     38 &     34 &     10 &     8  &     1 \\       
       Age &     38 &     34 &     10 &     8  &     1 \\       
       Age &     38 &     34 &     10 &     8  &     1 \\       
       Age &     38 &     34 &     10 &     8  &     1 \\       
       Age &     38 &     34 &     10 &     8  &     1 \\ 
       
       Age &     38 &     34 &     10 &     8  &     1 \\       
       Age &     38 &     34 &     10 &     8  &     1 \\       
       Age &     38 &     34 &     10 &     8  &     1 \\       
       Age &     38 &     34 &     10 &     8  &     1 \\       
       Age &     38 &     34 &     10 &     8  &     1 \\       
       
       Age &     38 &     34 &     10 &     8  &     1 \\       
       Age &     38 &     34 &     10 &     8  &     1 \\       
       Age &     38 &     34 &     10 &     8  &     1 \\
       Age &     38 &     34 &     10 &     8  &     1 \\       
       Age &     38 &     34 &     10 &     8  &     1 \\       
       Age &     38 &     34 &     10 &     8  &     1 \\ 
       
       Age &     38 &     34 &     10 &     8  &     1 \\       
       Age &     38 &     34 &     10 &     8  &     1 \\       
       Age &     38 &     34 &     10 &     8  &     1 \\       
       Age &     38 &     34 &     10 &     8  &     1 \\       
       Age &     38 &     34 &     10 &     8  &     1 \\       
       
       Age &     38 &     34 &     10 &     8  &     1 \\       
       Age &     38 &     34 &     10 &     8  &     1 \\       
       Age &     38 &     34 &     10 &     8  &     1 \\       
       Age &     38 &     34 &     10 &     8  &     1 \\          
       Age &     38 &     34 &     10 &     8  &     1 \\       
       Age &     38 &     34 &     10 &     8  &     1 \\             
       
       
\end{tabular} 
\end{adjustbox} 
\end{table}

\end{document}
3
  • The short answer is no. Longtable interacts directly with \output and cannot be inside anything else. May 27 at 15:59
  • scaling tables never gives a usable result, so the fact that it doesn't work with longtable isn't an issue. Use \footnotesize or, if you must, \tiny. if that is too large re-arrange the data so that it fits on the page. May 27 at 16:17
  • tabular does not have a [tbph] argument, as you show in the question, did you mean to put that on the table environment? May 27 at 16:19

1 Answer 1

2
  • what is your problem? That table is to wide to be fin on page? Use of adjustbox for this is not a solution ...
  • you should use a longrable that table can be broken between pages
  • longtable had not be enclosed in table float nor in any kind of box
  • you should find a way to make your columns headers shorter or written in two lines, tat table be narrower from \textwidth, for examples as:
\documentclass{article}
%---------------- Show page layout. Don't use in a real document!
\usepackage{showframe}
\renewcommand\ShowFrameLinethickness{0.15pt}
\renewcommand*\ShowFrameColor{\color{red}}
%---------------------------------------------------------------%
\usepackage{lipsum}% For dummy text. Don't use in a real document

\usepackage{longtable, makecell}

\begin{document}

\begin{longtable}[htbp]{cccccc}
    \hline
    & \makecell{Homer J.\\ Simpson} 
            & \makecell{Marge\\ Simpson}
                    & \makecell{Bart\\ Simpson} 
                            & \makecell{Lisa\\ Simpson}
                                    & \makecell{Maggie\\ Simpson}   \\
    \hline
\endhead
\multicolumn{6}{r}{\footnotesize\emph{Continued on the next page}}
\endfoot
    \hline
Age &   38  &   34  &   10  &   8   &   1                           \\
Age &   38  &   34  &   10  &   8   &   1                           \\
Age &   38  &   34  &   10  &   8   &   1                           \\
Age &   38  &   34  &   10  &   8   &   1                           \\
Age &   38  &   34  &   10  &   8   &   1                           \\

Age &   38  &   34  &   10  &   8   &   1                           \\
Age &   38  &   34  &   10  &   8   &   1                           \\
Age &   38  &   34  &   10  &   8   &   1                           \\
Age &   38  &   34  &   10  &   8   &   1                           \\
Age &   38  &   34  &   10  &   8   &   1                           \\

Age &   38  &   34  &   10  &   8   &   1                           \\
Age &   38  &   34  &   10  &   8   &   1                           \\
Age &   38  &   34  &   10  &   8   &   1                           \\
Age &   38  &   34  &   10  &   8   &   1                           \\
Age &   38  &   34  &   10  &   8   &   1                           \\

Age &   38  &   34  &   10  &   8   &   1                           \\
Age &   38  &   34  &   10  &   8   &   1                           \\
Age &   38  &   34  &   10  &   8   &   1                           \\
Age &   38  &   34  &   10  &   8   &   1                           \\
Age &   38  &   34  &   10  &   8   &   1                           \\

Age &   38  &   34  &   10  &   8   &   1                           \\
Age &   38  &   34  &   10  &   8   &   1                           \\
Age &   38  &   34  &   10  &   8   &   1                           \\
Age &   38  &   34  &   10  &   8   &   1                           \\
Age &   38  &   34  &   10  &   8   &   1                           \\

Age &   38  &   34  &   10  &   8   &   1                           \\
Age &   38  &   34  &   10  &   8   &   1                           \\
Age &   38  &   34  &   10  &   8   &   1                           \\
Age &   38  &   34  &   10  &   8   &   1                           \\
Age &   38  &   34  &   10  &   8   &   1                           \\

Age &   38  &   34  &   10  &   8   &   1                           \\
Age &   38  &   34  &   10  &   8   &   1                           \\
Age &   38  &   34  &   10  &   8   &   1                           \\
Age &   38  &   34  &   10  &   8   &   1                           \\
Age &   38  &   34  &   10  &   8   &   1                           \\

Age &   38  &   34  &   10  &   8   &   1                           \\
Age &   38  &   34  &   10  &   8   &   1                           \\
Age &   38  &   34  &   10  &   8   &   1                           \\
Age &   38  &   34  &   10  &   8   &   1                           \\
Age &   38  &   34  &   10  &   8   &   1                           \\

Age &   38  &   34  &   10  &   8   &   1                           \\
Age &   38  &   34  &   10  &   8   &   1                           \\
Age &   38  &   34  &   10  &   8   &   1                           \\
Age &   38  &   34  &   10  &   8   &   1                           \\
Age &   38  &   34  &   10  &   8   &   1                           \\

Age &   38  &   34  &   10  &   8   &   1                           \\
Age &   38  &   34  &   10  &   8   &   1                           \\
Age &   38  &   34  &   10  &   8   &   1                           \\
Age &   38  &   34  &   10  &   8   &   1                           \\
Age &   38  &   34  &   10  &   8   &   1                           \\

Age &   38  &   34  &   10  &   8   &   1                           \\
Age &   38  &   34  &   10  &   8   &   1                           \\
Age &   38  &   34  &   10  &   8   &   1                           \\
Age &   38  &   34  &   10  &   8   &   1                           \\
Age &   38  &   34  &   10  &   8   &   1                           \\

Age &   38  &   34  &   10  &   8   &   1                           \\
Age &   38  &   34  &   10  &   8   &   1                           \\
Age &   38  &   34  &   10  &   8   &   1                           \\
Age &   38  &   34  &   10  &   8   &   1                           \\
Age &   38  &   34  &   10  &   8   &   1                           \\
    \hline
\end{longtable}

\end{document}

enter image description here

(red lines indicate page layout) Is this what you looking for?

Edit: To table are added are column heads on each page and table foot (Continue on the next page).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.