如何使用 Adjustbox 和 Longtable

如何使用 Adjustbox 和 Longtable

我非常喜欢使用adjustbox包来处理数字数据,因为数字数据通常太宽,而且\tiny字体也太大。但是,问题是我的表格太高了。我能以某种方式同时使用adjustboxlongtable吗?这是我当前的代码:

\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}

答案1

  • 你的问题是什么?表格太宽,无法在页面上显示?使用adjustbox不是解决方案...
  • 你应该使用longrable可以在页面之间拆分的表格
  • longtable没有被table浮点数或任何类型的盒子包围
  • 您应该找到一种方法来使您的列标题更短或写成两行,以使表格更窄\textwidth,例如:
\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}

在此处输入图片描述

(红线表示页面布局)这是您要找的吗?

编辑: 表格中添加了每页的列标题和表脚(下页继续)。

相关内容