3

I have made a table in my document and the everything looks quite good to me. The issue is that when numbers with mixed signs appear in a column they are not aligned.

\documentclass{article}
\usepackage{caption}
\usepackage{subcaption}
\usepackage{booktabs}
\begin{document}
{\footnotesize 
\begin{table}
\caption{ A table here for some values of energies ($cm^{-1}$)
\label{Energy_table} }
\begin{tabular}{p{0.25cm}   p{1.60cm}   p{1.0cm}    p{1.0cm} p{1.0cm} p{0.001cm} p{1.60cm}  p{1.1cm}    p{1cm}p{1cm}}
\toprule
&\multicolumn{3}{c}{$A_{0}$} & &  \multicolumn{3}{c}{$B_{1}$}\\ \cline{2-5} \cline{7-10}
$m$ & Theory & $\Delta^{a}$ & $\Delta^{b}$& $\Delta^{c}$ & & This work& $\Delta^{a}$ & $\Delta^{b}$& $\Delta^{c}$ \\ \cline{1-5} \cline{7-10}
 1 & 297.4623 & -0.072 & -0.071 & -0.071 &  &           &  5.667 &  2.625       &        \\
 2 & 984.5495 & -0.092 & -0.059 & -0.099 &  & 2814.507  & -0.032 & -0.043  & -0.039 \\
    \multicolumn{8}{c}{} \\
    &\multicolumn{3}{c}{$C_{0}$} & &  \multicolumn{3}{c}{$D_{1}$}\\ \cline{2-5} \cline{7-10}
    $n$ & This work & $\Delta^{a}$ & $\Delta^{b}$& $\Delta^{c}$ & & This work& $\Delta^{a}$ & $\Delta^{b}$& $\Delta^{c}$ \\ \cline{1-5} \cline{7-10}          
 0 & 46.5495 & -0.099 & -0.099 & -0.099 &  & 2814.507  & -0.032 & -0.043  & -0.039 \\
    & & & & &   & & & &\\
    & & & & &  & & & &\\
    & & & & &  & & & & \\
\bottomrule
\end{tabular}
\end{table}}
\end{document}

In the image this is visible in the B1 sub-table (right top).Image showing table

How to properly align based on the decimal.

(I tried to follow this answer but I could not compile. I do not understand the commands in this answer about how to set the number of columns ! Aligning numeric values in table)

0

1 Answer 1

2

By including the siunitx package, you can use the S column instead of p.

\begin{table}
    \caption{ A table here for some values of energies (\si{\per\centi\meter})
    \label{Energy_table} }
    \begin{tabular}{SSSSSSSSSS}
    \toprule
    &\multicolumn{3}{c}{$A_{0}$} & &  \multicolumn{3}{c}{$B_{1}$}\\ \cline{2-5} \cline{7-10}
            {$m$} & {Theory} & {$\Delta^{a}$} & {$\Delta^{b}$} & {$\Delta^{c}$} & & {This work} & {$\Delta^{a}$} & {$\Delta^{b}$} & {$\Delta^{c}$} \\ \cline{1-5} \cline{7-10}
            1 & 297.4623 & -0.072 & -0.071 & -0.071 &  &           &  5.667 &  2.625       &        \\
            2 & 984.5495 & -0.092 & -0.059 & -0.099 &  & 2814.507  & -0.032 & -0.043  & -0.039 \\
            \multicolumn{8}{c}{} \\
            &\multicolumn{3}{c}{$C_{0}$} & &  \multicolumn{3}{c}{$D_{1}$}\\ \cline{2-5} \cline{7-10}
            {$n$} & {This work} & {$\Delta^a$} & {$\Delta^b$} & {$\Delta^c$} & & {This work} & {$\Delta^{a}$} & {$\Delta^{b}$} & {$\Delta^{c}$} \\ 
    \cline{1-5} \cline{7-10}          
            0 & 46.5495 & -0.099 & -0.099 & -0.099 &  & 2814.507  & -0.032 & -0.043  & -0.039 \\
            & & & & &  & & & &\\
            & & & & &  & & & &\\
            & & & & &  & & & & \\
    \bottomrule
    \end{tabular}
\end{table}

table

Note the {} around the text. I think the table can be made a lot prettier, but in order to avoid confusion, I have not changed too much. Also, I am not sure exactly what you are trying to show, so I might end up doing more damage than good.

I have used the siunitx package in the caption too, such that the unit is properly formatted and not typeset in italic.

Follow-up question for someone else: When is it necessary to specify the table-format?

2
  • Thank you very much. What improvements can be made in the table ?
    – ankit7540
    Commented Jun 8, 2016 at 10:35
  • @ankit7540: It is difficult to improve properly since I do not know what the numbers mean and what you are trying to convey, but some things come to mind. I would remove some of the white space. A, B, C, and D are not placed similarly in the sub-tables. You use a lot of digits (might be relevant in your case, but if not, think about significant digit/uncertainties), some of which can be removed by using factors of 10 (e.g. '-7.2e-2') which can also be aligned by the S column. Finally, some of the superscript letters are cut by the cline.
    – Thomas
    Commented Jun 8, 2016 at 11:46

You must log in to answer this question.

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