5

I've got the following table:

\documentclass{report}

\usepackage[intlimits]{amsmath}          
\usepackage{floatflt}
\usepackage{caption}
\usepackage{listliketab}
\usepackage{tabularx}
\usepackage{booktabs}
\usepackage{siunitx}

\begin{document}
\begin{table}[htmb]
\caption{Koeffizienten und Exponenten der Gl. \ref{eq:BG_T_ps}} \label{tab_koeff_T_ps}
\begin{tabular}{ccclcccl}
\toprule
$i$ & $I_i$ & $J_i$ & \multicolumn{1}{c}{$n_i$} & $i$ & $I_i$ & $J_i$ & \multicolumn{1}{c}{$n_i$}\\ \midrule
\num{1} & \num{0} & \num{0} & \num{0.1747826805830} $\times 10^3$ & \num{11} & \num{1} & \num{12} & \num{0.3567211060736} $\times 10^{-9}$ \\
\num{2} & \num{0} & \num{1} & \num{0.3480693089287} $\times 10^2$ & \num{12} & \num{1} & \num{31} & \num{0.1733249699489} $\times 10^{-23}$ \\
\num{3} & \num{0} & \num{2} & \num{0.6529258497845} $\times 10$ & \num{13} & \num{2} & \num{0} & \num{0.5660890065483} $\times 10^{-3}$ \\
\num{4} & \num{0} & \num{3} & \num{0.33039981775489} & \num{14} & \num{2} & \num{1} & \num{-0.3263548313971} $\times 10^{-3}$ \\
\num{5} & \num{0} & \num{11} & \num{-0.1928138292319} $\times 10^{-6}$ & \num{15} & \num{2} & \num{2} & \num{0.4477828669063} $\times 10^{-4}$ \\
\num{6} & \num{0} & \num{31} & \num{-0.2490919724457} $\times 10^{-22}$ & \num{16} & \num{2} & \num{9} & \num{-0.5132215690850} $\times 10^{-9}$ \\
\num{7} & \num{1} & \num{0} & \num{-0.26107636489332} & \num{17} & \num{2} & \num{31} & \num{-0.4252265704220} $\times 10^{-25}$ \\
\num{8} & \num{1} & \num{1} & \num{0.22592965981586} & \num{18} & \num{3} & \num{10} & \num{0.2640044136068} $\times 10^{-12}$ \\
\num{9} & \num{1} & \num{2} & \num{-0.6425646339522} $\times 10^{-1}$ & \num{19} & \num{3} & \num{32} & \num{0.7812460045972} $\times 10^{-28}$ \\
\num{10} & \num{1} & \num{3} & \num{0.7887628927052} $\times 10^{-2}$ & \num{20} & \num{4} & \num{32} & \num{-0.3073219990366} $\times 10^{-30}$ \\
\bottomrule
\end{tabular}
\end{table}
\end{document}

Result

How can I make it so that:

  • first zeroes in columns n_i are aligned below each other
  • all \times (X) in column n_i are aligned below each other
  • tailing zeroes aren't omitted by \num{}

at the same time? I suspect it's possible with align's ampersand &, but the tables can get quite large and I wouldn't know how to do that most effectively.

3
  • i'm sure this has come up before, but i can't find an example. siunitx can handle floating point numbers, and is usually recommended for such uses. May 13, 2015 at 17:24
  • Sorry, I forgot to include it in the MWE. I am using siunitx.
    – Phil Nope
    May 13, 2015 at 17:31
  • Just put the scientific notation inside \num not separate (\num{0.1747826805830e3} for example) and search for table-format and S column type in the siunitx manual. May 13, 2015 at 17:40

1 Answer 1

6

Package siunitx comes with support for columns with numbers via the column specifier S:

\documentclass{report}

\usepackage{caption}
\usepackage{booktabs}
\usepackage{siunitx}

\begin{document}
\begin{table}
\centering
\caption{Koeffizienten und Exponenten}
\label{tab_koeff_T_ps}
\begin{tabular}{
  S[table-format=2.0]
  S[table-format=1.0]
  S[table-format=2.0]
  S[table-format=1.13,
    table-figures-exponent=2,
    table-sign-mantissa,
    table-sign-exponent]
  S[table-format=2.0]
  S[table-format=1.0]
  S[table-format=2.0]
  S[table-format=1.13,
    table-figures-exponent=2,
    table-sign-mantissa,
    table-sign-exponent]}
\toprule
\multicolumn{1}{c}{$i$}
& \multicolumn{1}{c}{$I_i$}
& \multicolumn{1}{c}{$J_i$}
& \multicolumn{1}{c}{$n_i$}
& \multicolumn{1}{c}{$i$}
& \multicolumn{1}{c}{$I_i$}
& \multicolumn{1}{c}{$J_i$}
& \multicolumn{1}{c}{$n_i$}\\
\midrule
 1 & 0 &  0 &  0.1747826805830e3   & 11 & 1 & 12 &  0.3567211060736e-9  \\
 2 & 0 &  1 &  0.3480693089287e2   & 12 & 1 & 31 &  0.1733249699489e-23 \\
 3 & 0 &  2 &  0.6529258497845e10  & 13 & 2 &  0 &  0.5660890065483e-3  \\
 4 & 0 &  3 &  0.33039981775489    & 14 & 2 &  1 & -0.3263548313971e-3  \\
 5 & 0 & 11 & -0.1928138292319e-6  & 15 & 2 &  2 &  0.4477828669063e-4  \\
 6 & 0 & 31 & -0.2490919724457e-22 & 16 & 2 &  9 & -0.5132215690850e-9  \\
 7 & 1 &  0 & -0.26107636489332    & 17 & 2 & 31 & -0.4252265704220e-25 \\
 8 & 1 &  1 &  0.22592965981586    & 18 & 3 & 10 &  0.2640044136068e-12 \\
 9 & 1 &  2 & -0.6425646339522e-1  & 19 & 3 & 32 &  0.7812460045972e-28 \\
10 & 1 &  3 &  0.7887628927052e-2  & 20 & 4 & 32 & -0.3073219990366e-30 \\
\bottomrule
\end{tabular}
\end{table}
\end{document}

Result

2
  • Great! Is there some way to macro this (after {tabular}) so I don't have to write this huge header for every table? I have many tables like this.
    – Phil Nope
    May 13, 2015 at 19:45
  • @PhilNope When the exact same table header is used several times, then you can define a new environment and put the header there. Package array provides support for new column specifications, where you can put a column specification or a group of them. May 13, 2015 at 20:30

You must log in to answer this question.

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