我发现第二行和第一行的线长度不相等。是否可以使它们的长度相同?
\documentclass{article}
\usepackage{tabularx, caption} % Load package caption for decent foramtting and spacing
\usepackage{booktabs, ragged2e} % Use booktabs rules and get rid og vertical rules, ragged2e to ragged text
\setlength\extrarowheight{1pt} % Both line necessary for decent spacing, unless you are using booktabs rules.
\renewcommand{\arraystretch}{1.2}
\begin{document}
\newcolumntype{A}{>{\RaggedRight\arraybackslash\hsize=0\hsize\linewidth=\hsize}X}
\newcolumntype{B}{>{\RaggedRight\arraybackslash\hsize=0.65\hsize\linewidth=\hsize}X}
\begin{table}[!ht]
\begin{tabularx}{\textwidth}{@{}A*{5}{B}@{}}
\toprule
& & \multicolumn{3}{c}{\textbf{ATest Combination}} \\
\cmidrule(lr){3-5}
& & \small Mean (\%)
& \small Std. Deviation (\%)& \small Std. Error Mean(\%) \\
\midrule
\multicolumn{1}{l}{Pair 1} & Transpor Example Dataset (AA) - Transpor Example Dataset (BB)
& 312314.20\% & 321321.36\% & 4.321354\% \\
\bottomrule
\end{tabularx}
\caption{dsadsa dsadasd%
\label{tab:test123}%
}
\end{table}
\end{document}
结果:
而且,如何使单词的结果以完整的单词形式显示而不使用“-”自动中断?
例如:
Transpor Example
Dataset (AA) -
Transpor Example
Dataset (BB)
并不是
Transpor Exam-
ple Data -
set (AA) -
Trans-
por Example
Dataset (BB)
答案1
以下是表格的三个不同版本:
在以下所有示例中,我都修正了cmidrule
命令的修剪命令((lr)
,,,有关详细说明,请参阅手册第 4 页(l)
。)(r)
booktabs
{@{}A*{5}{B}@{}}
在第一个例子中,我还用更合理的替换了列说明符{l>{\raggedright\arraybackslash}Xccc}
。
在第二个表中,我选择使用包S
中的类型列siunitx
,以便数字相对于小数分隔符居中。此外,我还删除了多余的重复%
符号,因为它们已经在列标题中提到过。
在最后一个例子中,我使用了略小的字体大小,并减少了相邻列之间的水平空白。这样,第二列的内容甚至可以容纳两行,而不是四行。
\documentclass{article}
\usepackage{tabularx, caption}
\usepackage{booktabs, ragged2e}
\usepackage{makecell,siunitx}
\begin{document}
\begin{table}
\begin{tabularx}{\textwidth}{l>{\raggedright\arraybackslash}Xccc}
\toprule
& & \multicolumn{3}{c}{\textbf{ATest Combination}} \\
\cmidrule{3-5}
& & \small Mean (\%)
& \makecell{\small Std. Deviation\\ (\%)}& \makecell{\small Std. Error \\ Mean (\%)} \\
\midrule
\multicolumn{1}{l}{Pair 1} & Transpor Example Dataset (AA) - Transpor Example Dataset (BB)
& 312314.20\% & 321321.36\% & 4.321354\% \\
\bottomrule
\end{tabularx}
\caption{dsadsa dsadasd%
\label{tab:test123}%
}
\end{table}
\begin{table}
\begin{tabularx}{\textwidth}{l>{\raggedright\arraybackslash}XS[table-format=6.2]S[table-format=6.2]S[table-format=1.6]}
\toprule
& & \multicolumn{3}{c}{ATest Combination} \\
\cmidrule{3-5}
& & {Mean (\%)}
& {\makecell{ Std. Deviation\\ (\%)}}& {\makecell{ Std. Error \\ Mean (\%)}} \\
\midrule
\multicolumn{1}{l}{Pair 1} & Transpor Example Dataset (AA) - Transpor Example Dataset (BB)
& 312314.20 & 321321.36 & 4.321354 \\
\bottomrule
\end{tabularx}
\caption{dsadsa dsadasd%
\label{tab:test123}%
}
\end{table}
\begin{table}
\small \setlength{\tabcolsep}{3.5pt}
\begin{tabularx}{\textwidth}{l>{\raggedright\arraybackslash}Xccc}
\toprule
& & \multicolumn{3}{c}{ATest Combination} \\
\cmidrule{3-5}
& & Mean (\%)
& \makecell{ Std. Deviation\\ (\%)}& \makecell{ Std. Error \\ Mean (\%)} \\
\midrule
\multicolumn{1}{l}{Pair 1} & Transpor Example Dataset (AA) - Transpor Example Dataset (BB)
& 312314.20 & 321321.36 & 4.321354 \\
\bottomrule
\end{tabularx}
\caption{dsadsa dsadasd%
\label{tab:test123}%
}
\end{table}
\end{document}