结合 sidewaystable、a​​djustbox 和 threeparttablex

结合 sidewaystable、a​​djustbox 和 threeparttablex

我需要一张表格,它 1) 是横向的 2) 重新缩放以适合页面 3) 有tablenotes。我试图结合sidewaystableadjustboxthreeparttablex来实现这一点,但遇到了三个问题:

  1. 我不知道在哪里/如何添加表格标题。我尝试了环境中的几个位置,但一直出现编译错误。
  2. 的宽度tablenotes不正确,即使包括了\renewcommand\TPTminimum{\linewidth}
  3. 标签“b”和“c”在第一行的第三个单元格中重叠。

这是我当前的 MWE 尝试的样子(实际的表格要大得多,因此采用了 sidewaystable/adjustbox 组合):

\documentclass[]{article}
\usepackage{adjustbox}
\usepackage{caption}
\usepackage{multirow}
\usepackage[style=apa,sortcites=true,sorting=nyt,backend=biber]{biblatex}
\usepackage{rotating}
\usepackage{longtable}
\usepackage{threeparttablex}

\begin{document}

\begin{sidewaystable}
\begin{adjustbox}{width=\linewidth}
\begin{ThreePartTable}
\renewcommand{\TPTminimum}{\linewidth}
\begin{TableNotes}
\small
\item [a] Note note note note note note note note note note note note note note note note note note note note note note note note note note
\item [b] Note note note note note note note note note note note note note note note note note note note note note note note note note note
\item [c] Note note note note note note note note note note note note note note note note note note note note note note note note note note
\end{TableNotes}
\begin{tabular}{lllllll}
%\caption{My table caption.} \\
\hline
\multirow{2}{*}{Model} & \multirow{2}{*}{Specification\tnote{a}} & \multirow{2}{*}{Covariance structure\tnote{a}\tnote{b}} & \multicolumn{2}{l}{Number of fixed effects\tnote{c}} & \multicolumn{2}{l}{Number of variance components\tnote{c}} \\ \cline{4-7} 
&                                &                                  & ES approach          & RD approach          & ES approach             & RD approach             \\ \hline
$1$                      &     Model 1                           & Covariance 1                                      & $1$                    & $2$                    & $2$                       & $7$                       \\
$2$                      &     Model 2                           & Covariance 2                                      & $2$                    & $4$                    & $6$                       & $21$                      \\
$3 $                     &     Model 3                           & Covariance 3                                      & $3$                    & $6$                    & $12$                      & $43$                      \\ \hline
\insertTableNotes
\end{tabular}
\end{ThreePartTable}
\end{adjustbox}
\end{sidewaystable}
\end{document}

enter image description here

答案1

只有在万不得已的情况下才可以缩放表格(即使这样也不要这样做),因为您使用的是 threeepartx 而不是 threepart,我认为您想要 longtable 而不是 tabular

enter image description here

\documentclass[]{article}
\usepackage{adjustbox}
\usepackage{caption}
\usepackage{multirow}
\usepackage{longtable}
\usepackage{threeparttablex}
\usepackage{pdflscape}
\begin{document}

\begin{landscape}
\begin{ThreePartTable}
\begin{TableNotes}
\small
\item [a] Note note note note note note note note note note note note note note note note note note note note note note note note note note
\item [b] Note note note note note note note note note note note note note note note note note note note note note note note note note note
\item [c] Note note note note note note note note note note note note note note note note note note note note note note note note note note
\end{TableNotes}
\begin{longtable}{lllllll}
%\caption{My table caption.}
\hline
\multirow{2}{*}{Model} & \multirow{2}{*}{Specification\tnote{a}} & \multirow{2}{*}{Covariance structure\tnote{a}\tnote{b}} & \multicolumn{2}{l}{Number of fixed effects\tnote{c}} & \multicolumn{2}{l}{Number of variance components\tnote{c}} \\ \cline{4-7} 
&                                &                                  & ES approach          & RD approach          & ES approach             & RD approach             \\ \hline
$1$                      &     Model 1                           & Covariance 1                                      & $1$                    & $2$                    & $2$                       & $7$                       \\
$2$                      &     Model 2                           & Covariance 2                                      & $2$                    & $4$                    & $6$                       & $21$                      \\
$3 $                     &     Model 3                           & Covariance 3                                      & $3$                    & $6$                    & $12$                      & $43$                      \\ \hline
\insertTableNotes
\end{longtable}
\end{ThreePartTable}
\end{landscape}
\end{document}

答案2

由于表格(包括表格脚注)必须适合一页,因此我不会使用longtableThreePartTable环境的机制。此外,我也不会使用adjustbox机制,因为它几乎肯定会导致文档各部分的字体大小极不一致。

我看不出使用sidewaystablethreeparttabletabularxtablenotes环境会有什么错误。特别是,使用tabularx环境并允许单元格中的换行符应该可以消除诉诸adjustbox大锤的任何需要。对于间距适当的水平线或“规则”,请考虑加载包booktabs并使用其\toprule\cmidrule\midrule\bottomrule宏。并且,\tnote{a}\tnote{b}不要写 ,而要写\tnote{a,b}

enter image description here

\documentclass[]{article}
\usepackage[skip=0.333\baselineskip]{caption}
%\usepackage[letterpaper,margin=1in]{geometry} % select the appropriate page parameters
\usepackage{rotating}
\usepackage{tabularx,ragged2e}
\newcolumntype{C}{>{\Centering\arraybackslash}X}
\newcolumntype{E}{>{\hsize=\dimexpr2\hsize+2\tabcolsep\relax}C}
\usepackage[flushleft]{threeparttable}
\usepackage{booktabs}
\newcommand\minitab[1]{\smash{%
   \begin{tabular}[t]{@{}c@{}}#1\end{tabular}}}

\begin{document}
\begin{sidewaystable}
\begin{threeparttable}
\caption{My table caption.}
\begin{tabularx}{\textwidth}{@{} l *{6}{C} @{}}
\toprule
Model & 
Specification\tnote{a} & 
\minitab{Covariance\\structure\tnote{a,b}} & 
\multicolumn{2}{E}{Number of fixed effects\tnote{c}} & 
\multicolumn{2}{E@{}}{Number of variance components\tnote{c}} \\ 
\cmidrule(lr){4-5} \cmidrule(l){6-7} 
& & & ES approach & RD approach & ES approach & RD approach \\ 
\midrule
$1$ & Model 1 & Covariance 1 & $1$ & $2$ & $2$ &  $7$ \\
$2$ & Model 2 & Covariance 2 & $2$ & $4$ & $6$ & $21$ \\
$3$ & Model 3 & Covariance 3 & $3$ & $6$ & $12$& $43$ \\ 
\bottomrule
\end{tabularx}

\medskip % or "\smallskip"
\begin{tablenotes}
\small
\item [a] Note note note note note note note note note note note note note 
          nnote note note note note note note note note note note note note
\item [b] Note note note note note note note note note note note note note 
          note note note note note note note note note note note note note
\item [c] Note note note note note note note note note note note note note 
          note note note note note note note note note note note note note
\end{tablenotes}
\end{threeparttable}
\end{sidewaystable}
\end{document}

答案3

threeparttablex用于longtable非常规tabular。使用threeparttable命令tabular

Sample output

\documentclass[]{article}
\usepackage{adjustbox}
\usepackage{caption}
\usepackage{multirow}
\usepackage[style=apa,sortcites=true,sorting=nyt,backend=biber]{biblatex}
\usepackage{rotating}
\usepackage{longtable}
\usepackage{threeparttable}
\usepackage{booktabs}

\begin{document}

\begin{sidewaystable}
\begin{adjustbox}{width=\linewidth}
\begin{threeparttable}
\renewcommand{\TPTminimum}{.9\linewidth}
\caption{My table caption.}
\begin{tabular}{*{7}{l}}
  \toprule
  \multirow{2}{*}{Model}
  & \multirow{2}{*}{Specification\tnote{a}}
  & \multirow{2}{*}{Covariance structure\tnote{a,b}\ }
  & \multicolumn{2}{l}{Number of fixed effects\tnote{c}}
  & \multicolumn{2}{l}{Number of variance components\tnote{c}} \\
  \cmidrule(lr){4-7}
  & & & ES approach & RD approach & ES approach & RD approach \\
  \midrule
  $1$ & Model 1 & Covariance 1 & $1$ & $2$ & $2$ & $7$ \\
  $2$ & Model 2 & Covariance 2 & $2$ & $4$ & $6$ & $21$ \\
  $3$ & Model 3 & Covariance 3 & $3$ & $6$ & $12$ & $43$ \\
  \bottomrule
\end{tabular}
\begin{tablenotes}
\small
\item [a] Note note note note note note note note note note note note note note note note note note note note note note note note note note
\item [b] Note note note note note note note note note note note note note note note note note note note note note note note note note note
\item [c] Note note note note note note note note note note note note note note note note note note note note note note note note note note
\end{tablenotes}
\end{threeparttable}
\end{adjustbox}
\end{sidewaystable}
\end{document}

注意,加载threeparttablex将同样有效,它会加载threeparttable,您只需使用来自的命令threeparttable

我用\tnote{a,b}它来表示两个相邻的音符。\之后我添加了一个手动空格以提供更多空间。

我已经使用了booktabs更好的规则包,包括\cmidrule 可以在两侧稍微缩短的

相关内容