![将文本放在由三部分组成的表格的一行中间](https://linux22.com/image/396340/%E5%B0%86%E6%96%87%E6%9C%AC%E6%94%BE%E5%9C%A8%E7%94%B1%E4%B8%89%E9%83%A8%E5%88%86%E7%BB%84%E6%88%90%E7%9A%84%E8%A1%A8%E6%A0%BC%E7%9A%84%E4%B8%80%E8%A1%8C%E4%B8%AD%E9%97%B4.png)
我正在尝试将一些文本放在仅跨越表格一部分的水平线中间。以下是我目前的表格
\documentclass{article}
\usepackage{amssymb, amsmath, bm}
\usepackage[flushleft]{threeparttable}
\begin{document}
\begin{table}[H]
\caption{\textbf{Filtered errors}}
\label{table:summary_statistics}
\begin{threeparttable}
\footnotesize
\renewcommand{\TPTminimum}{\linewidth}
\makebox[\linewidth]{%
\begin{tabular}{lccccccccc}
\toprule
\hline
& DNS & & & MS-DNS & & & MS-DRA \\ \cline{2-3} \cline{5-6} \cline{8-9}
\thead{Maturity \\} & \thead[l]{Mean \\ } & \thead{Std. dev. \\ } & &
\thead[l]{Mean \\ } & \thead{Std. dev. \\ } & & \thead[l]{Mean \\ } &
\thead{Std. dev. \\ } \\
\midrule
3 & 3.285 & 2.573 & & 0.000 & 9.230 & & 0.993 & 0.845 \\
6 & 3.432 & 2.613 & & 0.030 & 9.540 & & 0.993 & 0.850 \\
12 & 3.617 & 2.635 & & 0.099 & 9.658 & & 0.993 & 0.863 \\
24 & 3.874 & 2.611 & & 0.188 & 9.566 & & 0.991 & 0.877 \\
36 & 4.108 & 2.543 & & 0.306 & 9.459 & & 0.990 & 0.885 \\
60 & 4.511 & 2.398 & & 0.627 & 9.317 & & 0.988 & 0.891 \\
84 & 4.837 & 2.285 & & 1.007 & 9.406 & & 0.987 & 0.892 \\
120 & 5.195 & 2.174 & & 1.498 & 9.642 & & 0.986 & 0.890 \\
Median & 1.910 & 1.205 & & -0.616& 4.376 & & 0.966 & 0.442 \\
Mean & -0.731& 0.900 & & -2.691& 1.634 & & 0.949 & 0.596 \\
#Lower \\
\bottomrule
\end{tabular}
}
\begin{tablenotes}\footnotesize
\item Note: This table reports \par
\end{tablenotes}
\end{threeparttable}
\end{table}
\end{document}
我还将表格的截图放在下面。
如何将文本(例如 DNS/MS-DNS/MS-DRA)显示在行中间而不是左侧?
先感谢您。
答案1
\thead
对于手头的表格来说,这种机制似乎有点过度了。我建议使用\multicolumn{2}{c}{...}
指令来代替居中标题单元格,以及 而\cmidrule
不是\cline
。
我还建议将数字与各自的小数点对齐,并在数学模式下排版,以便使用印刷上适当的数学减号符号而不是文本模式破折号来表示负数。
然而,请不要将\footnotesize
其用作主表,除非您想故意惹恼您的读者。
\documentclass{article}
\usepackage{siunitx, booktabs, lipsum}
\usepackage[flushleft]{threeparttable}
\begin{document}
\begin{table}
\centering
\begin{threeparttable}
\caption{\textbf{Filtered errors}}
\label{table:summary_statistics}
%\footnotesize
%%\renewcommand{\TPTminimum}{\linewidth}
\begin{tabular}{@{} l *{6}{S[table-format=1.3]} @{}}
\toprule
& \multicolumn{2}{c}{DNS}
& \multicolumn{2}{c}{MS-DNS}
& \multicolumn{2}{c@{}}{MS-DRA} \\
\cmidrule(lr){2-3} \cmidrule(lr){4-5} \cmidrule(l){6-7}
Maturity & {Mean} & {Std.\ dev.}
& {Mean} & {Std.\ dev.}
& {Mean} & {Std.\ dev.} \\
\midrule
3 & 3.285 & 2.573 & 0.000 & 9.230 & 0.993 & 0.845 \\
6 & 3.432 & 2.613 & 0.030 & 9.540 & 0.993 & 0.850 \\
12 & 3.617 & 2.635 & 0.099 & 9.658 & 0.993 & 0.863 \\
24 & 3.874 & 2.611 & 0.188 & 9.566 & 0.991 & 0.877 \\
36 & 4.108 & 2.543 & 0.306 & 9.459 & 0.990 & 0.885 \\
60 & 4.511 & 2.398 & 0.627 & 9.317 & 0.988 & 0.891 \\
84 & 4.837 & 2.285 & 1.007 & 9.406 & 0.987 & 0.892 \\
120 & 5.195 & 2.174 & 1.498 & 9.642 & 0.986 & 0.890 \\
\addlinespace
Median & 1.910 & 1.205 & -0.616& 4.376 & 0.966 & 0.442 \\
Mean & -0.731& 0.900 & -2.691& 1.634 & 0.949 & 0.596 \\
Lower \\
\bottomrule
\end{tabular}
\smallskip
\begin{tablenotes}
\footnotesize
\item[]Note: \lipsum*[2]
\end{tablenotes}
\end{threeparttable}
\end{table}
\end{document}
答案2
就在这里。我使用 、 和siunitx
改进booktabs
了 布局。正如 @Mico 在他的评论中所建议的那样,表格没有必要适合边距,而应该在环境中进行编码。tabularx
caption
\footnotesize
\caption
threeparttable
\documentclass{article}
\usepackage{amssymb, amsmath, bm}
\usepackage[flushleft]{threeparttable}
\usepackage{float, booktabs, makecell, caption, tabularx}
\usepackage{siunitx}
\begin{document}
\begin{table}%[H]
\begin{threeparttable}
\caption{\textbf{Filtered errors}}
\label{table:summary_statistics}
\sisetup{table-format=-1.3, table-number-alignment=center}
\renewcommand{\theadalign}{lc}
\renewcommand{\TPTminimum}{\linewidth}
\begin{tabularx}{\linewidth}{X*{2}{SSc}SS}
\toprule
\midrule[0.3pt]
& \multicolumn{2}{c}{DNS} & & \multicolumn{2}{c}{MS-DNS} & & \multicolumn{2}{c}{MS-DRA} \\
\cmidrule(lr){2-3} \cmidrule{5-6} \cmidrule{8-9}
\thead{Maturity \\} & {\thead[l]{Mean \\ }} & {\thead{Std. dev. \\ }} & &
{\thead[l]{Mean \\ }} & {\thead{Std. dev. \\ }} & & {\thead[l]{Mean \\ }} &
{\thead{Std. dev. \\ }} \\
\midrule
3 & 3.285 & 2.573 & & 0.000 & 9.230 & & 0.993 & 0.845 \\
6 & 3.432 & 2.613 & & 0.030 & 9.540 & & 0.993 & 0.850 \\
12 & 3.617 & 2.635 & & 0.099 & 9.658 & & 0.993 & 0.863 \\
24 & 3.874 & 2.611 & & 0.188 & 9.566 & & 0.991 & 0.877 \\
36 & 4.108 & 2.543 & & 0.306 & 9.459 & & 0.990 & 0.885 \\
60 & 4.511 & 2.398 & & 0.627 & 9.317 & & 0.988 & 0.891 \\
84 & 4.837 & 2.285 & & 1.007 & 9.406 & & 0.987 & 0.892 \\
120 & 5.195 & 2.174 & & 1.498 & 9.642 & & 0.986 & 0.890 \\
Median & 1.910 & 1.205 & & -0.616& 4.376 & & 0.966 & 0.442 \\
Mean & -0.731& 0.900 & & -2.691& 1.634 & & 0.949 & 0.596 \\
\#Lower \\
\bottomrule
\end{tabularx}
\begin{tablenotes}\footnotesize
\item Note: This table reports \par
\end{tablenotes}
\end{threeparttable}
\end{table}
\end{document}
答案3
\documentclass{article}
\usepackage{booktabs}
\usepackage[flushleft]{threeparttable}
\begin{document}
\newcommand{\MC}[1]{\multicolumn{2}{@{}c@{}}{#1}}
\begin{table}[htb]
\begin{threeparttable}
\caption{\textbf{Filtered errors}}
\label{table:summary_statistics}
\footnotesize
\renewcommand{\TPTminimum}{\linewidth}
\begin{tabular}{@{}l*8{c}@{}}
\toprule
& \MC{DNS} & & \MC{MS-DNS} & & \MC{MS-DRA} \\ \cmidrule{2-3} \cmidrule{5-6} \cmidrule{8-9}
Maturity & Mean & Std. dev. & & Mean & Std. dev. & & Mean & Std. dev. \\
\midrule
3 & 3.285 & 2.573 & & 0.000 & 9.230 & & 0.993 & 0.845 \\
6 & 3.432 & 2.613 & & 0.030 & 9.540 & & 0.993 & 0.850 \\
12 & 3.617 & 2.635 & & 0.099 & 9.658 & & 0.993 & 0.863 \\
24 & 3.874 & 2.611 & & 0.188 & 9.566 & & 0.991 & 0.877 \\
36 & 4.108 & 2.543 & & 0.306 & 9.459 & & 0.990 & 0.885 \\
60 & 4.511 & 2.398 & & 0.627 & 9.317 & & 0.988 & 0.891 \\
84 & 4.837 & 2.285 & & 1.007 & 9.406 & & 0.987 & 0.892 \\
120 & 5.195 & 2.174 & & 1.498 & 9.642 & & 0.986 & 0.890 \\
Median & 1.910 & 1.205 & & -0.616& 4.376 & & 0.966 & 0.442 \\
Mean & -0.731& 0.900 & & -2.691& 1.634 & & 0.949 & 0.596 \\
Lower & & & & & & & & \\
\bottomrule
\end{tabular}
\begin{tablenotes}\footnotesize
\item Note: This table reports \par
\end{tablenotes}
\end{threeparttable}
\end{table}
\end{document}