8

Does anyone know how to align the figure along dot within the tabular environment? I would like the figures to be under each other sharing the decimal dot as a common point of alignment.

  \begin{table}[H]
    \caption{My table}
    \centering 
    \begin{tabular}{lccc}
    \toprule
            &  A            & B         & C         \\ \midrule
    D       & 0.00      & +171.00   &  +135.00   \\ 
    E               & +233.00   & +123.00   &  0.00   \\    
    F       & $-240.00$     & $-20.00$      & $-1590.00$ \\
    G               & $-56.00$      & +68.00        & $-95.00$   \\ \bottomrule
    \end{tabular}
    \end{table} 

Thank you very much for your help!

3
  • 1
    all of them have 2 decimals, why noch use r instead of c for tabular alignment?
    – Rico
    Aug 25, 2013 at 10:47
  • You might also have a look at tex.stackexchange.com/q/85229/27635 Aug 25, 2013 at 11:02
  • I initially wanted the head of the table to remain centered but by and large simply replacing c with r is ok. Thanks!
    – ajafarov
    Aug 25, 2013 at 11:07

2 Answers 2

12

Use »siunitx« and its S column type.

\documentclass[11pt]{article}
\usepackage[T1]{fontenc}
\usepackage{caption}
\usepackage{booktabs}
\usepackage{siunitx}

\begin{document}
  \begin{table}[!ht]
    \caption{My table}
    \centering
    \begin{tabular}{
      l
      S[table-format=-3.2]
      S[table-format=-3.2]
      S[table-format=-4.2]
    }\toprule
        & {A}     & {B}    & {C}      \\ \midrule
      D &    0.00 & 171.00 &   135.00 \\
      E &  233.00 & 123.00 &     0.00 \\
      F & -240.00 & -20.00 & -1590.00 \\
      G &  -56.00 &  68.00 &   -95.00 \\ \bottomrule
    \end{tabular}
  \end{table}
\end{document}

More formatting options are shown in the package manual.


enter image description here

1

http://www.stat.unipg.it/tex-man/ltx-68.html :

\begin{tabular}{r@{.}l}
3&14159\\                        
16&2\\                          
123$456\\ \end{tabular}          

produces:

  3.14159
 16.2
123.456

You must log in to answer this question.

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