Graphics, Figures & Tablessiunitx | Align Numbers (with Parenthesis) in Table

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
upani1982
Posts: 43
Joined: Wed May 12, 2010 11:42 am

siunitx | Align Numbers (with Parenthesis) in Table

Post by upani1982 »

Hi All,

I want to format a table where some numbers are in parenthesis. I have learned from this forum to use siunitx package to format the table but in this table i am not able to format in order to align the numbers at the decimal marker. I am using the following code:

Code: Select all

\documentclass[12pt,a4paper]{article}
\hbadness=10000 \hfuzz=50pt % to control bad h boxes%
\usepackage[T1]{fontenc} %for times roman font%
\usepackage{setspace} % Controlling line spacing%
\usepackage{geometry} % for page control%
% Packages for Creating Tables
\usepackage{booktabs}
\usepackage{ctable}
\usepackage{multirow}
\usepackage{threeparttable}
\usepackage{caption}
%\usepackage[tableposition=top]{caption} % Not sure how it works%
\usepackage{siunitx} % For formatting the numbers in a table%
% Global Settings for Tables
\captionsetup{margin=10pt,font=normal,labelfont=normal}
\sisetup{table-number-alignment=center}
\begin{document}
% Table-1 Exchange Wise Share of Trade%%
 \begin{table}[htbp]
 \centering
 \begin{threeparttable}
\centering \caption{Exchange-wise Turnover (In thousand crores of
rupees)} \label{tab:Exchange}
 {
 \renewcommand{\arraystretch}{1.1}
\begin{tabular}{lccccc}
\toprule
  Exchange Name &  2006 &  2007 &  2008 &  2009 & 2010  \\
\midrule
 \multirow{2}[0]{*}{BCEXL} &  0.28 &  0.57 &  0.20 &  0.55 & 0.55 \\
  &  (0.01) &  (0.01) &  (0.00) &  (0.01) & (0.01) \\
\hline
 \multirow{2}[0]{*}{BCEXM} &  0.03 &  0.02 &  0.07 &  0.06 & 0.55 \\
  &  (0.00) &  (0.00) &  (0.00) &  (0.00) & (0.01) \\
\hline

 \multirow{2}[0]{*}{CICEXG} &  0.26 &  0.27 &  0.00 &  0.04 & 0.03 \\
  &  (0.01) &  (0.01) &  (0.00) &  (0.00) & (0.00) \\
\hline
 \multirow{2}[0]{*}{COCH} &  9.17 &  17.39 &  8.83 &  8.83 & 6.69 \\
  &  (0.28) &  (0.44) &  (0.17) &  (0.12) & (0.06) \\
\hline
 \multirow{2}[0]{*}{FCEXIL} &  0.48 &  0.19 &  0.19 &  0.07 & 0.12 \\
  &  (0.01) &  (0.00) &  (0.00) &  (0.00) & (0.00) \\
\hline
 \multirow{2}[0]{*}{HCLHI} &  0.39 &  1.55 &  0.55 &  0.41 & 0.13 \\
  &  (0.01) &  (0.04) &  (0.01) &  (0.01) & (0.00) \\
\hline
 \multirow{2}[0]{*}{IPSTAK} &  0.05 &  0.28 &  0.52 &  0.25 & 0.42 \\
  &  (0.00) &  (0.01) &  (0.01) &  (0.00) & (0.00) \\
\hline
 \multirow{2}[0]{*}{MCX} &  2093.65 &  3086.17 &  4512.44 &  6339.10 & 9255.07 \\
  &  (63.53) &  (78.05) &  (88.29) &  (84.82) & (86.64) \\
\hline
 \multirow{2}[0]{*}{NBOTI} &  72.03 &  95.31 &  34.33 &  60.45 & 47.30 \\
  &  (2.19) &  (2.41) &  (0.67) &  (0.81) & (0.44) \\
\hline
 \multirow{2}[0]{*}{NCDEX} &  1002.18 &  706.13 &  494.15 &  875.70 & 1226.18 \\
  &  (30.41) &  (17.86) &  (9.67) &  (11.72) & (11.48) \\
\hline
 \multirow{2}[0]{*}{NMCEIL} &  100.60 &  22.58 &  43.45 &  171.85 & 134.52 \\
  &  (3.05) &  (0.57) &  (0.85) &  (2.30) & (1.26) \\
\hline
 \multirow{2}[0]{*}{ROAOED} &  0.88 &  1.32 &  0.68 &  0.51 & 0.42 \\
  &  (0.03) &  (0.03) &  (0.01) &  (0.01) & (0.00) \\
\hline
 \multirow{2}[0]{*}{RSOBMA} &  3.46 &  6.24 &  6.66 &  5.73 & 5.45 \\
  &  (0.10) &  (0.16) &  (0.13) &  (0.08) & (0.05) \\
\hline
 \multirow{2}[0]{*}{SCOAOAL} &  3.35 &  3.71 &  2.31 &  4.18 & 4.28 \\
  &  (0.10) &  (0.09) &  (0.05) &  (0.06) & (0.04) \\
\hline
 \multirow{2}[0]{*}{TACEXL} &  6.60 &  10.60 &  5.98 &  5.98 & 0.00 \\
  &  (0.20) &  (0.27) &  (0.12) &  (0.08) & (0.00) \\
\hline
 \multirow{2}[0]{*}{TSOELS} &  0.11 &  0.13 &  0.00 &  0.00 & 0.00 \\
  &  (0.00) &  (0.00) &  (0.00) &  (0.00) & (0.00) \\
\hline
 \multirow{2}[1]{*}{VBCL} &  1.92 &  1.13 &  0.21 &  0.01 & 0.00 \\
  &  (0.06) &  (0.03) &  (0.00) &  (0.00) & (0.00) \\
\bottomrule
\end{tabular}
}
        \begin{tablenotes}[normal,flushleft]\setlength{\itemsep}{-4mm}
        \item [1] {Note: Figures in Parenthesis shows the percentage of total trade.}\\
        \item [2] {Source: Forward Market Commission, Government of India.}\\
        \end{tablenotes}
         \end{threeparttable}
         \end{table}
Hope i have posted my problem clearly. After running the code the table is not looking uniform as the numbers are not correctly aligned.

Any help in this regard is highly appreciated

With sincere regards,
Upananda

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

justdeath
Posts: 69
Joined: Mon Sep 05, 2011 10:27 am

siunitx | Align Numbers (with Parenthesis) in Table

Post by justdeath »

You can use the package "dcolumn", and modify as follows:

Code: Select all

\begin{tabular}{l *{5}{D{.}{.}{4.3}}}
\toprule
  Exchange Name &  \multicolumn{1}{r}{2006} &  \multicolumn{1}{r}{2007} &
  \multicolumn{1}{r}{2008} &  \multicolumn{1}{r}{2009} & \multicolumn{1}{r}{2010}  \\
Otherwise the years are aligned with the other numbers.
See here http://www.tug.org/pracjourn/2007-1/mori/mori.pdf at page 21.

Nikolay
Post Reply