结合adjustbox实现多页复杂表格

结合adjustbox实现多页复杂表格

问题陈述

我对 Latex 中的表格还不太熟悉,目前正努力使用该longtable软件包。关于如何制作跨多页表格的问题已经在 Stackexchanges 上被问过好几次了。但是,我似乎找不到解决我的具体问题的方法:

我有以下横向模式的表格(仅显示前两行),并使用adjustbox将表格大小调整为 23 厘米,并threeparttable在表格中添加注释:

\usepackage{booktabs}
\usepackage[flushleft]{threeparttable}
\usepackage{lscape} 
\usepackage{amsmath}
\usepackage{adjustbox}
%%%%%

\begin{landscape}
\begin{table}[]
\caption{Study characteristics.}
\begin{adjustbox}{max width=23cm}
\begin{threeparttable}

\begin{tabular}{>{\raggedright}p{2.5cm} >{\raggedright}p{0.25\linewidth} >{\raggedright}p{0.2\linewidth} >{\raggedright}p{0.25\linewidth} c c c l}

\toprule
Study                            &      
\multicolumn{1}{l}{Intervention} &      
\multicolumn{1}{l}{Population}   &
\multicolumn{1}{l}{Outcome}      &
k                                & 
n                                & 
\begin{tabular}[c]{c}Effect size \\ measure\end{tabular} & 
\multicolumn{1}{c}{\begin{tabular}[c]{c}Effect size \\ {[}95\% CI{]}\end{tabular}}  \\ 
\midrule

Alford \& Derzon (2012)         &
School-based interventions to reduce violence and antisocial behavior &
School-aged children and youths & 
Physical aggression, antisocial behavior, aggressive/disruptive behavior, and delinquent behavior         & 
41      &       --              &       
g       &       
0.133 {[}0.082, 0.184{]}\tnote{**} \\ \addlinespace[0.2cm]

Anderson \& Whiston (2005)      &
Sexual assault college education programs                             &
College students                &
Incidence of sexual assault perpetration &
--      &       --              &       
d       &
0.101 {[}0.036, 0.167{]}\tnote{*} \\ \addlinespace[0.2cm]

\bottomrule
\end{tabular}

\begin{tablenotes}[para,flushleft]
{\small
\textit{Note.} My notes. \\
\item[*] $p$ \textless{} 0.05. \item[**] $p$ \textless{} 0.01. 
}
\end{tablenotes}
\end{threeparttable}
\end{adjustbox}
\end{table}
\end{landscape}

问题

在这种特殊情况下我该如何实现longtable?如果我简单地用 替换,\begin{tabular}\begin{longtable}会开始弄乱我的笔记(我只希望它们显示在最后一页)。我想我必须摆脱adjustbox,但在这种情况下我该如何将表格大小调整为 23 厘米?

任何帮助都感激不尽!

答案1

无论如何,您都不应该将adjustbox和表格一起使用,因为这会导致字体大小不一致。这里有一个使用包的解决方案,它将xltabular的功能带到,因此可以控制表格的总宽度。我还使用了包,它将 带到longtables ,并增加了对表格注释进行交叉引用的可能性。请注意,表格注释的语法与原始表格注释的语法略有不同。longtabletabularxthreeparttablexthreeparttable

\documentclass{article}
\usepackage{geometry}%
\usepackage{xltabular}
\usepackage{makecell}
\setcellgapes{6pt}

\usepackage{booktabs, caption}
\usepackage[flushleft]{threeparttablex}
\usepackage{ragged2e}
\usepackage{lscape}
\usepackage{amsmath}
\usepackage{adjustbox}
%%%%%

\begin{document}

\begin{landscape}
%\keepXColumns
\setlength{\tabcolsep}{4pt}
\begin{ThreePartTable}
\begin{TableNotes}[para,flushleft]
\small
\textit{Note.} My notes. \\
\item[*] $p$ \textless{} 0.05. \item[**] $p$ \textless{} 0.01.
\end{TableNotes}
\begin{xltabular}{\linewidth}{@{}*{4}{>{\RaggedRight\arraybackslash}X} c c c l}
\caption{Study characteristics.} \\
\endfirsthead
\toprule%
Study &
\multicolumn{1}{l}{Intervention} &
\multicolumn{1}{l}{Population} &
\multicolumn{1}{l}{Outcome} &
k &
n &
\makecell{Effect size \\ measure} &
\makecell{Effect size \\ {[}95\% CI]} \\
\midrule
%
Alford \& Derzon (2012) &
School-based interventions to reduce violence and antisocial behavior &
School-aged children and youths &
Physical aggression, antisocial behavior, aggressive/disruptive behavior, and delinquent behavior &
41 & -- &
g &
0.133 {[}0.082, 0.184{]}\tnote{**} \\ \addlinespace[0.2cm]
%
Anderson \& Whiston (2005) &
Sexual assault college education programs &
College students &
Incidence of sexual assault perpetration &
-- & -- &
d &
0.101 {[}0.036, 0.167{]}\tnote{*} \\ \addlinespace[0.2cm]
\bottomrule
\insertTableNotes
\end{xltabular}
\end{ThreePartTable}
\hfill
\end{landscape}

\end{document} 

在此处输入图片描述

相关内容