我有下表:
\begin{table}[]
\centering
\begin{tabular}{SSSSSSSS}
\toprule
{Method} & {Number of windows} & {Size of windows} \\ \midrule
{Window warping} & 45 & 2 seconds \\
{Windowed magnitude warping} & 40 & 3 seconds \\ \bottomrule
\end{tabular}
\caption{Fixed hyperparameters}
\label{tab:fixed_hyperparameters}
\end{table}
并显示下表:
我现在有不同的路线,我必须为这些路线定义值,并希望实现这样的目标(伪代码):
\begin{table}[]
\centering
\begin{tabular}{SSSSSSSS}
\toprule
{Method} & {Number of windows} & {Size of windows} \\ \midrule
{Route 1} \\ \midrule % should be aligned in the middle
{Window warping} & 45 & 2 seconds \\
{Windowed magnitude warping} & 40 & 3 seconds \\ \midrule
{Route 2} \\ \midrule % should be aligned in the middle
{Window warping} & 30 & 5 seconds \\
{Windowed magnitude warping} & 25 & 2 seconds \\ \midrule
{Route 3} \\ \midrule % should be aligned in the middle
{Window warping} & 55 & 1 seconds \\
{Windowed magnitude warping} & 40 & 5 seconds \\ \bottomrule
\end{tabular}
\caption{Fixed hyperparameters}
\label{tab:fixed_hyperparameters}
\end{table}
答案1
为什么是S
列?为什么只用三列就定义八列?第一列肯定不是S
,因为它包含文本。我对第三列也有疑问:尺寸怎么能用秒来衡量?无论如何,你不应该每次都重复“秒”。
\documentclass{article}
\usepackage{siunitx,booktabs}
\begin{document}
\begin{table}[htp] % <--- NOT []
\centering
\begin{tabular}{
@{}
l
S[table-format=2.0]
S[table-format=1.0]
@{}
}
\toprule
\multicolumn{1}{@{}c}{Method} & \multicolumn{2}{c@{}}{Windows} \\
\cmidrule{2-3}
& {Number} & {Size (seconds)} \\
\midrule
\multicolumn{1}{@{}c}{\itshape Route 1} \\
Window warping & 45 & 2 \\
Windowed magnitude warping & 40 & 3 \\
\midrule
\multicolumn{1}{@{}c}{\itshape Route 2} \\
Window warping & 30 & 5 \\
Windowed magnitude warping & 25 & 2 \\
\midrule
\multicolumn{1}{@{}c}{\itshape Route 3} \\
Window warping & 55 & 1 \\
Windowed magnitude warping & 40 & 5 \\
\bottomrule
\end{tabular}
\caption{Fixed hyperparameters}
\label{tab:fixed_hyperparameters}
\end{table}
\begin{table}[htp] % <--- NOT []
\centering
\begin{tabular}{
@{}
l
S[table-format=2.0]
S[table-format=1.0]
@{}
}
\toprule
\multicolumn{1}{@{}c}{Method} & \multicolumn{2}{c@{}}{Windows} \\
\cmidrule{2-3}
& {Number} & {Size (seconds)} \\
\midrule
\qquad\itshape Route 1 \\
Window warping & 45 & 2 \\
Windowed magnitude warping & 40 & 3 \\
\midrule
\qquad\itshape Route 2 \\
Window warping & 30 & 5 \\
Windowed magnitude warping & 25 & 2 \\
\midrule
\qquad\itshape Route 3 \\
Window warping & 55 & 1 \\
Windowed magnitude warping & 40 & 5 \\
\bottomrule
\end{tabular}
\caption{Fixed hyperparameters}
\label{tab:fixed_hyperparameters-again}
\end{table}
\end{document}
我不会将“Route n”移到表格中间,而是将其放在第一列的中央或者稍微靠右一点,并使用不同的字体形状。