我想使用 让表格的最后一行显示跨越所有列的注释\multicolumn{#}{p{\textwidth}}{}
。这在与调整大小结合使用时无法正常工作,因为textwidth
保持相同的值但测量值会向下缩放。
这是我的代码:
\documentclass{article}%
\usepackage{graphicx}
\begin{document}
\resizebox{\textwidth}{!}{%
\begin{tabular}{rrrrrrrrr} \hline
aaaaaaaa & aaaaaaaa & aaaaaaaa & aaaaaaaa & aaaaaaaa & aaaaaaaa & aaaaaaaa & aaaaaaaa & aaaaaaaa\\ \hline
\multicolumn{9}{p{\textwidth}}{Notes: Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et.}
\end{tabular}%
}
\end{document}
输出:
答案1
最好使用threeparttablex
,尽管它并不完美(右边有点太宽)
\documentclass{article}%
\usepackage{graphicx}
\usepackage[referable]{threeparttablex}
\begin{document}
\noindent
\rule{\textwidth}{1mm}
\noindent
\resizebox{\textwidth}{!}{%
\begin{threeparttable}
\begin{tabular}{rrrrrrrrr} \hline aaaaaaaa & aaaaaaaa & aaaaaaaa &
aaaaaaaa & aaaaaaaa & aaaaaaaa & aaaaaaaa & aaaaaaaa &
aaaaaaaa\\ \hline
\end{tabular}%
\begin{tablenotes}
\note Lorem ipsum dolor sit amet, consetetur sadipscing elitr,
sed diam nonumy eirmod tempor invidunt ut labore et.
\end{tablenotes}
\end{threeparttable}
}
\end{document}
答案2
您首先需要保存/计算真实的桌子的宽度
\newsavebox\tableBox
\sbox\tableBox{\begin{tabular}{rrrr...}...\end{tabular}} % without the \multicolumn line
然后
\resizebox{\textwidth}{!}{%
\begin{tabular}{rrrr...}
...
\multicolumn{9}{p{\wd\tableBox}}{...}
\end{tabular}%
}
完整示例:
\documentclass{article}%
\usepackage{graphicx}
\begin{document}
\newsavebox\tableBox
\sbox\tableBox{%
\begin{tabular}{rrrrrrrrr} \hline
aaaaaaaa & aaaaaaaa & aaaaaaaa & aaaaaaaa & aaaaaaaa & aaaaaaaa & aaaaaaaa & aaaaaaaa & aaaaaaaa\\ \hline
\end{tabular}%
}
\resizebox{\textwidth}{!}{%
\begin{tabular}{rrrrrrrrr} \hline
aaaaaaaa & aaaaaaaa & aaaaaaaa & aaaaaaaa & aaaaaaaa & aaaaaaaa & aaaaaaaa & aaaaaaaa & aaaaaaaa\\ \hline
\multicolumn{9}{p{\wd\tableBox}}{Notes: Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et.}
\end{tabular}%
}
\end{document}