我怎样才能使这两个表格顶部对齐,并尽可能防止它们互相重叠?
\documentclass[12pt]{article}
\usepackage{booktabs}
\usepackage{siunitx}
\usepackage{subcaption}
\begin{document}
\begin{table}[h]
\centering
\renewcommand{\arraystretch}{1.25}%
\begin{subtable}[t]{0.4\textwidth}
\begin{tabular}{cc}
\toprule
Numero d'onda ($\unit{cm^{-1}}$) & Classificazione \\ \midrule
3204 & weak \\
3183 & weak \\
3167 & weak \\ \midrule
3139 & weak \\ \midrule
3087 & weak \\
3072 & weak \\ \midrule
1856 & strong \\ \midrule
1511 & weak \\
1493 & weak \\ \midrule
1415 & strong \\ \midrule
1257 & strong \\ \midrule
1128 & weak \\ \midrule
938 & weak \\ \midrule
525 & medium \\ \midrule
378 & weak \\
\bottomrule
\end{tabular}
\end{subtable}
\quad
\begin{tabular}{cc}
\toprule
Numero d'onda ($\unit{cm^{-1}}$) & Classificazione \\ \midrule
3204 & medium \\
3183 & medium \\
3167 & medium \\
3139 & medium \\ \midrule
3097 & strong \\
3072 & strong \\ \midrule
1856 & weak \\ \midrule
1511 & medium \\
1510 & medium \\
1493 & weak \\ \midrule
1411 & weak \\
1089 & weak \\ \midrule
938 & weak \\ \midrule
891 & weak \\ \midrule
799 & medium \\
\bottomrule
\end{tabular}
\end{table}
\end{document}
答案1
默认情况下,表格单元格的内容不会中断,这会导致表格太宽。您无法以subtable
这种方式使用 来限制表格的宽度。
tabular
通过在左列的标题中插入换行符(甚至不使用s)来减少两个 s 的宽度的简单解决方案subtable
可能是:
\documentclass[12pt]{article}
\usepackage{booktabs}
\usepackage{siunitx}
\begin{document}
\begin{table}[h]
\centering
\renewcommand{\arraystretch}{1.25}%
\begin{tabular}[t]{cc}
\toprule
\shortstack{Numero d'onda \\ ($\unit{cm^{-1}}$)} & Classificazione \\ \midrule
3204 & weak \\
3183 & weak \\
3167 & weak \\ \midrule
3139 & weak \\ \midrule
3087 & weak \\
3072 & weak \\ \midrule
1856 & strong \\ \midrule
1511 & weak \\
1493 & weak \\ \midrule
1415 & strong \\ \midrule
1257 & strong \\ \midrule
1128 & weak \\ \midrule
938 & weak \\ \midrule
525 & medium \\ \midrule
378 & weak \\
\bottomrule
\end{tabular}
\quad
\begin{tabular}[t]{cc}
\toprule
\shortstack{Numero d'onda \\ ($\unit{cm^{-1}}$)} & Classificazione \\ \midrule
3204 & medium \\
3183 & medium \\
3167 & medium \\
3139 & medium \\ \midrule
3097 & strong \\
3072 & strong \\ \midrule
1856 & weak \\ \midrule
1511 & medium \\
1510 & medium \\
1493 & weak \\ \midrule
1411 & weak \\
1089 & weak \\ \midrule
938 & weak \\ \midrule
891 & weak \\ \midrule
799 & medium \\
\bottomrule
\end{tabular}
\end{table}
\end{document}
另一个解决方案可能是使用tabularx
:
\documentclass[12pt]{article}
\usepackage{tabularx}
\usepackage{booktabs}
\usepackage{siunitx}
\begin{document}
\begin{table}[h]
\centering
\renewcommand{\arraystretch}{1.25}%
\begin{tabularx}{0.475\textwidth}[t]{ *{2}{>{\centering\arraybackslash}X} }
\toprule
Numero d'onda ($\unit{cm^{-1}}$) & Classificazione \\ \midrule
3204 & weak \\
3183 & weak \\
3167 & weak \\ \midrule
3139 & weak \\ \midrule
3087 & weak \\
3072 & weak \\ \midrule
1856 & strong \\ \midrule
1511 & weak \\
1493 & weak \\ \midrule
1415 & strong \\ \midrule
1257 & strong \\ \midrule
1128 & weak \\ \midrule
938 & weak \\ \midrule
525 & medium \\ \midrule
378 & weak \\
\bottomrule
\end{tabularx}
\quad
\begin{tabularx}{0.475\textwidth}[t]{ *{2}{>{\centering\arraybackslash}X} }
\toprule
Numero d'onda ($\unit{cm^{-1}}$) & Classificazione \\ \midrule
3204 & medium \\
3183 & medium \\
3167 & medium \\
3139 & medium \\ \midrule
3097 & strong \\
3072 & strong \\ \midrule
1856 & weak \\ \midrule
1511 & medium \\
1510 & medium \\
1493 & weak \\ \midrule
1411 & weak \\
1089 & weak \\ \midrule
938 & weak \\ \midrule
891 & weak \\ \midrule
799 & medium \\
\bottomrule
\end{tabularx}
\end{table}
\end{document}