1

I made a table using siunitx package. In one of the column there is text depicting chemical formulae. Is it possible to align only this column to the left.

\documentclass{article}
\usepackage{caption}
\usepackage{subcaption}
\usepackage{booktabs}
\usepackage{siunitx}
\begin{document}
\begin{table}
\caption{ Comparison of new data to previously reported \label{Transition_delG_HD} }
\begin{tabular}{SSSSSSSS}
    \toprule

    &   \multicolumn{3}{c}{${\alpha}$} & & \multicolumn{3}{c}{$\beta$}   \\ \cline{2-4} \cline{6-8} 
    &   \multicolumn{1}{c}{$Our$} & \multicolumn{1}{c}{$Ref. $} &  {$\Delta$} & & \multicolumn{1}{c}{$Our$} & \multicolumn{1}{c}{$Ref. $} & {$\Delta$}\\  \cline{2-4} \cline{6-8}

         {C\textsubscript{2}H\textsubscript{5}OH}     & 25    & 25.5  & -0.5  &       & 25    & 25.5  & -0.5 \\
            {CH\textsubscript{3}OH}       & 26    & 26.12 & -0.12 &       & 26    & 26.12 & -0.12 \\
          {H\textsubscript{2}O}        & 24    & 24.23 & -0.23 &       & 24    & 24.23 & -0.23 \\
            {HF}        & 24    & 24.23 & -0.23 &       & 24    & 24.23 & -0.23 \\


    \bottomrule
    \multicolumn{6}{l}{$\Delta^{a}$ : From Ref. 5} \\

\end{tabular}
\end{table} 
\end{document}

Following image shows the issue. Table made by siunitx

The left-most column with the chemical formulae, I was hoping it can be left aligned.

6
  • 1
    Whya re you even using S for that column, there is only text, just use l
    – daleif
    Jun 14, 2016 at 15:17
  • 1
    @daleif : Oh, I did not know that. Thanks. Solved .
    – ankit7540
    Jun 14, 2016 at 15:22
  • Also why is Our and Ref. in math mode in the headers? That looks odd. Plus use \cmidrule instead of \cline better spacing (just forget about \hline and \cline)
    – daleif
    Jun 14, 2016 at 15:27
  • also, if you are using a lot of chemical formulas in your paper, I would suggest you look into the mhchem package.
    – ArTourter
    Jun 14, 2016 at 15:32
  • Thank you for the very very useful suggestions. I am new to latex and learning. yay !
    – ankit7540
    Jun 14, 2016 at 15:34

1 Answer 1

4

Here are some improvements to your table: you don't need an empty column to have distinct \clines if you replace them with \cmidrules and crop them on both sides. Also, as daleif pointed, the first column can to be left-aligned rather than S type. You have three different number formats for your S columns, and it's better to differentiate them. Last, don't end a tabular by a \\: it adds an unwanted vertical spacing.

I loaded the cellspace package to give some vertical padding to cells in the first column; the column specifier has to be prefixed with the letter S in general, and Cif siunitx, as here, is loaded. I aalso loade the chemformula to simplify typing of chemical compounds.

\documentclass{article}
\usepackage{caption}
\usepackage{subcaption}
\usepackage{array, booktabs, cellspace}
\setlength\cellspacetoplimit{3pt}
\setlength\cellspacebottomlimit{3pt}
\usepackage{siunitx}
\usepackage{chemformula}

\begin{document}

\begin{table}
\centering
\caption{ Comparison of new data to previously reported \label{Transition_delG_HD} }
\begin{tabular}{Cl*{2}{S[table-format=2.0]S[table-format=2.2]S[table-format=-1.2]}}
    \toprule
    & \multicolumn{3}{c}{${\alpha}$} & \multicolumn{3}{c}{$\beta$} \\
 \cmidrule(lr){2-4} \cmidrule(lr){5-7}
    & {Our} & {Ref. } & {$\Delta$} & {Our} & {Ref.} & {$\Delta$}\\
 \cmidrule(lr){2-4} \cmidrule(lr){5-7}
         \ch{C2H5OH} & 25 & 25.5 & -0.5 & 25 & 25.5 & -0.5 \\
            \ch{CH3OH} & 26 & 26.12 & -0.12 & 26 & 26.12 & -0.12 \\
          \ch{H2O} & 24 & 24.23 & -0.23 & 24 & 24.23 & -0.23 \\
            HF & 24 & 24.23 & -0.23 & 24 & 24.23 & -0.23 \\
    \bottomrule
    \addlinespace
    \multicolumn{6}{l}{\footnotesize$\Delta^{a}$ : From Ref. 5}
    \end{tabular}
\end{table}

\end{document} 

enter image description here

6
  • Thank you. I have questions. First. \begin{tabular}{Cl*{2}{S[table-format=2.0]S[table-format=2.2]S[table-format=-1.2]}} what does the number after table-format defines ? Second question. What is defined by the (lr) in \cmidrule(lr){5-7} ?
    – ankit7540
    Jun 14, 2016 at 16:03
  • 1
    First question: in the preamble of a table, *{2}{…}` denotes the number of repetitions of a pattern (note I mention only 3S). Second question: (lr) stipulates cropping the rule on the left and on the right. The amount of cropping can be changed (see the documentation of booktabs for details).
    – Bernard
    Jun 14, 2016 at 16:09
  • Not really an issue but I'd also write \ch{HF}
    – cgnieder
    Jun 15, 2016 at 8:03
  • @clemens: I wondered, but as there was no index… I know, I may be inconsistent at times ;o)
    – Bernard
    Jun 15, 2016 at 8:31
  • 1
    @MorZahavi: It is explained in the answer: the specifier is actually the usual l, and there's a pre-specifier to ensure a minimal vertical padding of the cells in this column. This pre-specifer, defined by the cellspace package, is by default the letter S, but as the siunitx package is also loaded and it already defines an S column type, the pre-specifier is by default changed to the letter C, but you can use another letter, loading the package with the option [column=some other letter]. An example is given in the (short) documentation.
    – Bernard
    Feb 18, 2020 at 12:56

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .