1

Consider the following table:

enter image description here

\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}

Is there a way to ensure that the table fits within the textblock? E.g., how should I adjust (simplify?) the information in the header cells? Is there a way to instruct LaTeX to round the numbers to show fewer decimal digits?

Mico
  • 506,678
DJA
  • 167
  • 2
    I'd delete Ground Energy since it is same in every column, or write it in a single spanning entry or write each heading on two lines, this is really a duplicate of https://tex.stackexchange.com/questions/332902/my-table-doesnt-fit-what-are-my-options – David Carlisle Aug 17 '21 at 17:04
  • 2
    also why use a p column to force an over-wide first column? – David Carlisle Aug 17 '21 at 17:09
  • 4
    Unrelated to the issue, but you may want to use a package dedicated to typesetting chemical formulae, such as chemformula or mhchem instead of using math mode. – leandriis Aug 17 '21 at 17:22
  • @Werner -- I've taken the liberty of reopening this posting as some of the issues presented by the table (such as the need to round numbers to show fewer digits and thereby economize on horizontal space) are not well covered by earlier postings on the topic of how to make a table fit inside the text block. – Mico Aug 18 '21 at 05:10

2 Answers2

2

Some suggestions, some of which have already been voiced in the comments below your posting:

  • Since the string "Ground Energy" occurs in the headers of all 3 data cells, you can reduce the header widths by moving the common header component to a new header line that spans all three data columns.

  • Drop the bold-facing of the header cells. A well-designed table does not need such a crude and borderline vulgar visual crutch.

  • Load the siunitx package and use its S column type to impose automatic rounding to, say, two decimal digits in the three data columns.

  • Get rid of all vertical rules and most horizontal rules to give the table a more open and inviting "look". And, use the macros of the booktabs package -- \toprule, \cmidrule, \midrule, and \bottomrule -- as replacements for \hline and \cline.

  • Replace p{3cm} with l as the specification for the first column.

  • Optional: Load the mhchem package and use its \ce macro to format the names of all chemical compounds. Ideally, you would do this throughout the document, not just in a table.

enter image description here

\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}

Mico
  • 506,678
2

An alternative using a transposed table in order to help compare the values:

enter image description here

\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}

leandriis
  • 62,593