我在 tabularx 中使用多列命令,但效果并不理想。我想组织它,使顶行跨越两个单独的列并适当地换行,但我无法让它工作。
\def\tabularxcolumn#1{m{#1}}
\begin{table}[htbp]
{\small
\hfill{} \centering
\caption{Add caption}
\begin{tabularx}{\linewidth}{*{12}{>{\centering\arraybackslash}X}}
\toprule
\multicolumn{2}{X}{} & \multicolumn{2}{X}{Experimental Frequency (Hz) \citep{Saiidi1994}} & \multicolumn{2}{X}{\cite{Kim2004} Analytical Model Predicted Frequency (Hz)} & \multicolumn{2}{X}{} & \multicolumn{2}{X}{\cite{Kim2004} FE Model Predicted Frequency (Hz)} &\multicolumn{2}{X}{} \\
\cline{3-12}
Case & In-situ prestress force (kN) & Mode 1 & Mode 2 & Mode 1 & Mode 2 & Mode 1 (\% diff) & Mode 2 (\% diff) & Mode 1 & Mode 2 & Mode 1 (\% diff) & Mode 2 (\% diff) \\
\midrule
1 & 0.00 & 11.41 & 43.99 & 11.41 & 45.64 & 0.0\% & -3.7\% & 11.20 & 44.05 & 1.9\% & -0.1\% \\
2 & 15.71 & 12.09 & 44.11 & 11.83 & 46.06 & 2.1\% & -4.4\% & 11.69 & 44.55 & 3.3\% & -1.0\% \\
3 & 27.05 & 13.47 & 44.89 & 12.13 & 46.37 & 10.0\% & -3.3\% & 12.03 & 44.89 & 10.7\% & 0.0\% \\
4 & 36.49 & 12.89 & 44.69 & 12.37 & 46.63 & 4.0\% & -4.3\% & 12.31 & 45.16 & 4.5\% & -1.1\% \\
5 & 57.25 & 13.63 & 45.62 & 12.89 & 47.18 & 5.5\% & -3.4\% & 12.90 & 45.74 & 5.3\% & -0.3\% \\
6 & 81.81 & 14.49 & 45.57 & 13.47 & 47.83 & 7.1\% & -5.0\% & 13.57 & 46.40 & 6.4\% & -1.8\% \\
7 & 91.26 & 14.72 & 46.32 & 13.69 & 48.07 & 7.0\% & -3.8\% & 13.82 & 46.65 & 6.1\% & -0.7\% \\
8 & 121.46 & 14.72 & 45.86 & 14.36 & 48.85 & 2.4\% & -6.5\% & 14.58 & 47.40 & 1.0\% & -3.4\% \\
9 & 130.91 & 14.97 & 46.10 & 14.57 & 49.10 & 2.7\% & -6.5\% & 14.81 & 47.62 & 1.1\% & -3.3\% \\
10 & 132.80 & 15.07 & 45.87 & 14.61 & 49.15 & 3.1\% & -7.1\% & 14.86 & 47.67 & 1.4\% & -3.9\% \\
\bottomrule
\end{tabularx}%
\label{tab:addlabel}
}
\end{table}%
答案1
我认为tabularx
这里没有什么好处,大多数表格数据都是数字,因此无法换行到不同的长度。我想我会做更多这样的事,也许会进行一些改进,但是...
\documentclass{article}
\usepackage{tabularx,booktabs}
\def\citep#1{#1}
\begin{document}
\def\tabularxcolumn#1{m{#1}}
\begin{table}[htbp]
\small \setlength\tabcolsep{2pt}
\centering
\caption{Add caption}
\hspace*{-1cm}\begin{tabular}{*{12}{r}}
\toprule
Case &
\multicolumn{1}{p{1.5cm}}{\centering In-situ prestress force (kN)}&
\multicolumn{2}{p{3cm}}{\centering Experimental Frequency (Hz) \citep{Saiidi1994}} &
\multicolumn{4}{p{5cm}}{\centering \cite{Kim2004} Analytical Model Predicted Frequency (Hz)} &
\multicolumn{4}{p{5cm}}{\cite{Kim2004} FE Model Predicted Frequency (Hz)} \\
\cline{3-12}
& & Mode 1 & Mode 2 & Mode 1 & Mode 2 & Mode 1 & Mode 2 & Mode 1 & Mode 2 & Mode 1 & Mode 2 \\
& & & & & & (\% diff) &(\% diff) & & & (\% diff) & (\% diff) \\
\midrule
1 & 0.00 & 11.41 & 43.99 & 11.41 & 45.64 & 0.0\% & -3.7\% & 11.20 & 44.05 & 1.9\% & -0.1\% \\
2 & 15.71 & 12.09 & 44.11 & 11.83 & 46.06 & 2.1\% & -4.4\% & 11.69 & 44.55 & 3.3\% & -1.0\% \\
3 & 27.05 & 13.47 & 44.89 & 12.13 & 46.37 & 10.0\% & -3.3\% & 12.03 & 44.89 & 10.7\% & 0.0\% \\
4 & 36.49 & 12.89 & 44.69 & 12.37 & 46.63 & 4.0\% & -4.3\% & 12.31 & 45.16 & 4.5\% & -1.1\% \\
5 & 57.25 & 13.63 & 45.62 & 12.89 & 47.18 & 5.5\% & -3.4\% & 12.90 & 45.74 & 5.3\% & -0.3\% \\
6 & 81.81 & 14.49 & 45.57 & 13.47 & 47.83 & 7.1\% & -5.0\% & 13.57 & 46.40 & 6.4\% & -1.8\% \\
7 & 91.26 & 14.72 & 46.32 & 13.69 & 48.07 & 7.0\% & -3.8\% & 13.82 & 46.65 & 6.1\% & -0.7\% \\
8 & 121.46 & 14.72 & 45.86 & 14.36 & 48.85 & 2.4\% & -6.5\% & 14.58 & 47.40 & 1.0\% & -3.4\% \\
9 & 130.91 & 14.97 & 46.10 & 14.57 & 49.10 & 2.7\% & -6.5\% & 14.81 & 47.62 & 1.1\% & -3.3\% \\
10 & 132.80 & 15.07 & 45.87 & 14.61 & 49.15 & 3.1\% & -7.1\% & 14.86 & 47.67 & 1.4\% & -3.9\% \\
\bottomrule
\end{tabular}\hspace*{-1cm}
\label{tab:addlabel}
\end{table}%
\end{document}