\documentclass{article}
\usepackage{graphicx}
\usepackage{multirow}
\usepackage{threeparttable}
\begin{document}
\begin{table}
\begin{threeparttable}[b]
\caption{Title}
\label{tab1}
\resizebox{\textwidth}{!}{%
\begin{tabular}{rlrr}
\hline
Group & XXXXXXXXX XXXXXXXXX & XXXXXXXX \tnote{1} & XXXXXXX XXXXXXXXX XXXXXXXX (XXX) \\
\hline
\multirow{3}{*}{1} & XX XXXXXXXXX & \\ & (0 years) & 9 years & -XXXXXX (XX: -0.XXX, -0.XXX, 0.XXX) \\
\hline
\multirow{3}{*}{2} & XX XX XXX XXXXXXXXX XXXXXXX XXXX & \\ & (1-6 years) & 1-6 years & -0.XXX (XX: -0.XXX, -0.XXX, 0.XXX) \\
\hline
\multirow{3}{*}{3} & XXXXX XXXXXXXX XXXXXXXXX & \\ & (7-$<$9 years) & 7-$<$9 years & -0.XXX (XX: -0.XXX, -0.XXX, 0.XXX) \\
\hline
\multirow{3}{*}{4} & XXXXXXXX XXXXX XXXXXXXXX XXXXXXXX & \\ & (9 years, XXXXXX's XXXXXXXXXX XXX) & 9 years & -0.XXX (XX: -0.XXX, -0.XXX, 0.XXX) \\
\hline
\multirow{3}{*}{5} & XX XX XXX XXXXXXXXX XXXXXXX XXXX & \\ & (10-12 years) & 10-12 years & -0.XXX (XX: -0.XXX, -0.XXX, 0.XXX) \\
\hline
\multirow{3}{*}{6} & XXXXXXX XXX XXXXXX & \\ & ($>$ 12 years) & $>$12 years & -0.XXX (XX: -0.XXX, -0.XXX, 0.XXX) \\
\hline
\end{tabular}%
}
\begin{tablenotes}
\item[1] The note
\end{tablenotes}
\end{threeparttable}
\end{table}
\end{document}
- 问题:我需要调整表格大小(编辑:我现在添加了原始大小)以适合页面。当我不使用 threeparttable 时,它可以工作,但我需要这个,因为我需要在表格下方直接添加脚注。当我不使用 resizebox 时,它也可以工作。有人知道如何获得既调整到页面大小又在表格下方直接添加脚注的表格吗?
答案1
如果您的实际表格并不比问题中的表格更宽,则以下措施适合您的表格的文本宽度(因此不需要使用\scalebox
):
\documentclass{article}
% \usepackage{graphicx}
\usepackage{multirow}
\usepackage{threeparttable}
%---------------- show page layout. don't use in a real document!
\usepackage{showframe}
\renewcommand\ShowFrameLinethickness{0.15pt}
\renewcommand*\ShowFrameColor{\color{red}}
%---------------------------------------------------------------%
\begin{document}
\begin{table}
\begin{threeparttable}[b]
\caption{Title}
\label{tab1}
\setlength\tabcolsep{0pt}
\begin{tabular*}{\linewidth}{@{\extracolsep{\fill}} rlrr}
\hline
Ipsum lorum dolor & Ipsum lorum dolor & Ipsum lorum dolor\tnote{1} & Ipsum lorum dolor \\
\hline
\multirow{2}{*}{1} & Ipsum lorum dolor & \\ & Ipsum lorum dolor & Ipsum lorum dolor & Ipsum lorum dolor\\
\hline
\multirow{2}{*}{2} & Ipsum lorum dolor & \\ & Ipsum lorum dolor & Ipsum lorum dolor & Ipsum lorum dolor \\
\hline
\end{tabular*}
\begin{tablenotes}[flushleft]\footnotesize
\item[1] The note
\end{tablenotes}
\end{threeparttable}
\end{table}
\end{document}
(红线表示文字边框)
您还可以减小字体大小,例如\small
,获得更好的表格外观。