请考虑下表:
\begin{table}
\centering
\caption{cc-pVTZ was used for $NO_2H$. Ground staet energies}
\renewcommand{\arraystretch}{1.2}
\begin{tabular}{|p{3cm}||c|c|c|}
\hline
\multirow{2}{5cm}{\textbf{Molecule}} & \multicolumn{2}{c|}{\textbf{UKRMol+ Integrals}} & \textbf{Molpro Integrals}\\
% \hline
% \textbf{Inactive Modes} & \textbf{Description}\\
\cline{2-4}
& \textbf{Molpro Ground Energy} & \textbf{UKRMol+ Ground Energy} & \textbf{UKRMol+ Ground Energy }\\
%\hhline{~--}
\hline
$ \mathrm{C_4H_8N_2}$ & -264.84232294 & -264.8423229345 & -264.8423248314 \\ \hline
$ \mathrm{H_2O}$ & -76.02677205 & -76.0267720532 & -76.0267721310 \\ \hline
$ \mathrm{He_2}$ & -5.71032232 & -5.7103223179 & -5.7103223229 \\ \hline
$ \mathrm{NO_2H}$ & -204.6040946252 & -204.6040107299 & -204.6040951267 \\ \hline
$ \mathrm{N_2}$ & -108.95555875 & -108.9555587520 & -108.9555589593 \\ \hline
$ \mathrm{H_2O_2}$ & -150.78066093 & -150.7806609345 & -150.7806612050 \\ \hline
$ \mathrm{HF}$ & -100.01970689 & -100.0197068851 & -100.0197069270 \\
\hline \hline
\end{tabular}
\end{table}
有没有办法确保表格适合文本块?例如,我应该如何调整(简化?)标题单元格中的信息?有没有办法指示 LaTeX 对数字进行四舍五入以显示更少的小数位?
答案1
另一种方法是使用转置表来帮助比较值:
\documentclass{article}
\usepackage{booktabs}
\usepackage{chemformula}
\usepackage{siunitx}
\usepackage{caption}
\usepackage{makecell}
\renewcommand{\theadfont}{\normalsize}
\begin{document}
\begin{table}
\centering
\setlength{\tabcolsep}{0pt}
\sisetup{table-format=-3.5,round-mode=places,round-precision=5}
\caption{cc-pVTZ was used for \ch{NO2H}. Ground staet energies}
\begin{tabular*}{\linewidth}{@{\extracolsep{\fill}} ll SSSS }
\toprule
\thead[l]{Integrals} & \thead[l]{Ground\\ Energy} & \ch{C4H8N2} & \ch{H2O} & \ch{He2} & \ch{NO2H} \\
\midrule
UKRMol+ & Molpro & -264.84232294 & -76.02677205 & -5.71032232 & -204.6040946252 \\
UKRMol+ & UKRMol+ & -264.8423229345 & -76.0267720532 & -5.7103223179 & -204.6040107299 \\
Molpro & UKRMol+ & -264.8423248314 & -76.0267721310 & -5.7103223229 & -204.6040951267 \\
\midrule
\thead{Integrals} & \thead{Ground\\ Energy} & \ch{N2} & \ch{H2O2} & \ch{HF} \\
\midrule
UKRMol+ & Molpro & -108.95555875 & -150.78066093 & -100.01970689 \\
UKRMol+ & UKRMol+ & -108.9555587520 & -150.7806609345 & -100.0197068851 \\
Molpro & UKRMol+ & -108.9555589593 & -150.7806612050 & -100.0197069270 \\
\bottomrule
\end{tabular*}
\end{table}
\end{document}
答案2
一些建议,其中一些已在您的帖子下面的评论中提出:
由于字符串“Ground Energy”出现在所有 3 个数据单元的标题中,因此您可以通过将公共标题组件移动到跨越所有三个数据列的新标题行来减小标题宽度。
放下大胆的标题单元格。设计良好的表格应该不是需要这样一种粗糙甚至近乎粗俗的视觉拐杖。
加载
siunitx
包并使用其S
列类型对三个数据列强制自动四舍五入为小数点后两位。删除所有垂直线和大多数水平线,使表格看起来更加开放和吸引人。并且,使用
booktabs
包 --\toprule
、\cmidrule
、\midrule
和\bottomrule
-- 的宏来替换\hline
和\cline
。p{3cm}
将其替换l
为第一列的规范。可选:加载
mhchem
包并使用其\ce
宏来格式化所有化合物的名称。理想情况下,您会在整个文档中执行此操作,而不仅仅是在表格中。
\documentclass{article}
\usepackage{booktabs,mhchem,siunitx}
\begin{document}
\begin{table}
\centering
\sisetup{table-format=-3.2,round-mode=places,round-precision=2}
\caption{cc-pVTZ was used for \ce{NO2H}. Ground staet energies\strut}
\begin{tabular}{@{} l SSS @{}}
\toprule
Molecule & \multicolumn{3}{c}{Ground Energies} \\
\cmidrule(l){2-4}
& \multicolumn{2}{c}{UKRMol+ Integrals} & {Molpro Integrals}\\
\cmidrule(lr){2-3} \cmidrule(l){4-4}
& {Molpro} & {UKRMol+} & {UKRMol+} \\
\midrule
\ce{C4H8N2} & -264.84232294 & -264.8423229345 & -264.8423248314 \\
\ce{H2O} & -76.02677205 & -76.0267720532 & -76.0267721310 \\
\ce{He2} & -5.71032232 & -5.7103223179 & -5.7103223229 \\
\ce{NO2H} & -204.6040946252 & -204.6040107299 & -204.6040951267 \\
\ce{N2} & -108.95555875 & -108.9555587520 & -108.9555589593 \\
\ce{H2O2} & -150.78066093 & -150.7806609345 & -150.7806612050 \\
\ce{HF} & -100.01970689 & -100.0197068851 & -100.0197069270 \\
\bottomrule
\end{tabular}
\end{table}
\end{document}