1

I just cannot get the third column alignment right, does anyone know how, please?

\documentclass[a4paper,12pt]{report}
\usepackage{multirow}
\usepackage{siunitx,booktabs}%for table decimals number
\usepackage[export]{adjustbox}
  \begin{table}[!htbp]
\centering
\begin{tabular}{>{\bfseries}l S[table-format=-1.2(2)] S[table-format=-1.1e1]}   
\toprule
 {\textbf{Res.}}    & {$\boldsymbol{\beta}$}    & {$\boldsymbol{\chi^{2}}$}    \\
\midrule
4           & -0.60(14)         & 1738 \\
5           & -0.39(11)     & 1348\\
6           & -0.32(10)     & 612 \\
7           & -0.54(17)     & 1159  \\
8a          & -0.36(10)     & 621  \\
9           & -0.50(14)     & 800  \\
10          & -0.26(14)     & 544  \\
11a         & -0.54(16)     & -1140  \\
11b         & -0.50(15)     & 867  \\
\bottomrule
\end{tabular}
\caption[]{}
\end{table}
  • If your numbers do not have a floating value why do you use -1.1e1? – TeXnician Jul 9 '17 at 10:32
  • I actually dont know, I do not really understand how format tables with siunitx. However, does it affect the third column alignment? – yoyo Jul 9 '17 at 10:34
0

I'll try to explain the formatting of numbers with siunitx from your code:

table-format=-1.1e1 means it uses scientific notation (the e is for exponent), with a mantissa having possibly a sign, 1 digit before the decimal dot (1.), and 1 digit after the decimal dot (.1). The exponent use 1 digit (that's the e1 part of the format).

table-format=-1.2(2) does not use scientific notation, but has an uncertainty part which uses 2 digits.

Thus for your last column, you should have

table-format=-4.0 (four digits with possibly a — sign, and no decimal part).

  • What about if my last column is a mix of words and number. Example : for the first row:Inf and the rest rows: 3X10^6? – yoyo Jul 9 '17 at 10:59
  • For cell contents not fitting the format, you get it centred putting it within a pair of braces. – Bernard Jul 9 '17 at 11:04
  • This is the new code, where should I change? \begin{table}[!htbp] \centering \begin{tabular}{>{\bfseries}l S[table-format=-1.2(2)] S[table-format=-4]} \toprule {\textbf{Res.}} & {$\boldsymbol{\beta}$} & {$\boldsymbol{\chi^{2}}$} \\ \midrule 1 & -0.61(17) & Inf. \\ 2 & -0.60(17) & Inf. \\ 3 & -0.59(18) & 3$\times$10$^6$\\ 4 & -0.56(20) & Inf. \\ \bottomrule \end{tabular} \caption[]{} \label{} \end{table} – yoyo Jul 9 '17 at 11:07
1

Change S[table-format=-1.1e1] to S[table-format=-4.0]. -4.0 means: "Set aside enough space for four-digit numbers prefaced by a - symbol, and don't set aside any space for digits after the decimal marker" (since we're dealing with whole numbers). Why set -4.0? It's because the largest number in the third column (in absolute value terms) is "-1140".

enter image description here

\documentclass[a4paper,12pt]{report}
\usepackage{bm,siunitx,booktabs}%for table decimals number
\begin{document}
\begin{table}[!htbp]
\centering
\begin{tabular}{>{\bfseries}l 
                S[table-format=-1.2(2)] 
                S[table-format=-4.0] }   
\toprule
{\textbf{Res.}} & {$\bm{\beta}$} & {$\bm{\chi^{2}}$}  \\
\midrule
4           & -0.60(14)     & 1738 \\
5           & -0.39(11)     & 1348\\
6           & -0.32(10)     & 612 \\
7           & -0.54(17)     & 1159  \\
8a          & -0.36(10)     & 621  \\
9           & -0.50(14)     & 800  \\
10          & -0.26(14)     & 544  \\
11a         & -0.54(16)     & -1140  \\
11b         & -0.50(15)     & 867  \\
\bottomrule
\end{tabular}
\caption[]{}
\end{table}
\end{document}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.