4

I have the following table, with the decimal aligning handled by siunitx (MWE):

\documentclass{scrartcl}


\usepackage{booktabs}
\usepackage{multirow}

\usepackage{siunitx}
    \sisetup{
        detect-mode,
        group-digits            = false,
        input-symbols           = ( ) [ ] - +,
        table-align-text-post   = false,
        input-signs             = ,
        decimalsymbol=comma,
        locale = DE,
        }   \usepackage{siunitx}
\begin{document}
\begin{table}
\centering
\begin{tabular}{ccS[table-format = 2.8]S[table-format = 2.8]}
\toprule
& Parameter & {Estimate} & {Standard Error} \\
\midrule
EUR/USD model & $\hat \sigma_{X}$ & 0,0315 \\
[\defaultaddspace]
\multirow{4}{*}{GBP/USD model} & $\hat \omega$ & 0,000050 & 0,000045 \\ 
& $\hat \alpha_{Y}$ & 0,0860 & 0,0454 \\
& $\hat \beta_{Y}$ & 0,8585 & 0,0838 \\
& $\hat \nu$ & 7,6367 & 2,4094 \\
\bottomrule
\end{tabular}
\end{table}
\end{document}

This gives me:

table

What I would like is for the entries in the "Estimate" and "Standard Error" columns to be centered under the column titles (with the decimals still aligned properly). I suspect that I have to change the table-format but I haven't been able to figure out the right options.

Thanks!

4
  • ccS[table-format = 1.6]S[table-format = 1.6] 1 for integers and 6 for decimals.
    – LaRiFaRi
    Jun 6, 2014 at 14:29
  • table-format = 1.6 doesn't seem to change anything for me, i. e. the columns and column headers are still not aligned properly. Jun 6, 2014 at 14:35
  • does the picture of Svend and me does look aligned for you? If not, take a closer look on the second row, which is perfectly aligned. If you still don't like it, get rid of the last zero and change to 1.5 or leave it and change to 2.6 or 3.6 which moves everything more to the right. But I wouldn't do that.
    – LaRiFaRi
    Jun 6, 2014 at 14:43
  • Basically your columns look wrong because of the 2.8 which should be 1.6 to accommodate the actual data.
    – daleif
    Jun 6, 2014 at 14:45

3 Answers 3

6

If you want the decimal marker placed at the center of the column -- and generate lots of wasted whitespace to the left of the leading digit -- then specify a symmetric table-format option, e.g., table-format = 6.6.

enter image description here

\documentclass{scrartcl}
\usepackage{booktabs}
%%\usepackage{multirow} % not needed
\usepackage{siunitx}
    \sisetup{
        detect-mode,
        group-digits            = false,
        input-symbols           = ( ) [ ] - +,
        table-align-text-post   = false,
        input-signs             = ,
        %%decimalsymbol=comma, %% not needed, as implied by `locale=DE` option
        locale = DE,
        }  
\begin{document}
\begin{table}
\centering
\begin{tabular}{@{} cc *{2}{S[table-format = 6.6]} @{}}
\toprule
& Parameter & {Estimate} & {Std.\ Error} \\
\midrule
EUR/USD model & $\hat \sigma_{X}$ & 0,0315 \\
[\defaultaddspace]
GBP/USD model & $\hat \omega$ & 0,000050 & 0,000045 \\ 
& $\hat \alpha_{Y}$ & 0,0860 & 0,0454 \\
& $\hat \beta_{Y}$ & 0,8585 & 0,0838 \\
& $\hat \nu$ & 7,6367 & 2,4094 \\
\bottomrule
\end{tabular}
\end{table}
\end{document}

I think the table looks much better if you set table-format = 1.6:

enter image description here

3
  • That's what I was after but now that I see it, I think you are right. It looks much better with the table-format = 1.6 as has been suggested by you and the other users. Thank! Jun 6, 2014 at 14:58
  • The decimal points should be changed to .. Otherwise there is no point in invoking decimalsymbol=comma. Jun 6, 2014 at 15:00
  • @SvendTveskæg - Thanks for this. I've commented out the decimalsymbol=comma option as it's implied by the locale=DE option. (If you comment out locale=DE, though, siunitx will generate . as the output decimal marker.)
    – Mico
    Jun 6, 2014 at 15:04
5

You have at most 1 digit before the decimal marker and 6 after it. Therefore, you should do as follows to get the desired output:

\documentclass{scrartcl}

\usepackage{multirow}
\usepackage{booktabs}
\usepackage[
  decimalsymbol = comma,
  group-digits = false
]{siunitx}

\begin{document}

\begin{table}
 \centering
  \begin{tabular}{l c *{2}{S[table-format = 1.6]}
  }
   \toprule
                                   & Parameter        & {Estimate} & {Standard Error} \\
   \midrule
    EUR/USD model                  & $\hat\sigma_{X}$ & 0.0315                        \\[1ex]
    \multirow{4}{*}{GBP/USD model} & $\hat\omega$     & 0.000050   & 0.000045         \\ 
                                   & $\hat\alpha_{Y}$ & 0.0860     & 0.0454           \\
                                   & $\hat\beta_{Y}$  & 0.8585     & 0.0838           \\
                                   & $\hat\nu$        & 7.6367     & 2.4094           \\
   \bottomrule
  \end{tabular}
\end{table}

\end{document}

output

9
  • Thanks for your answer but it still doesn't look centered to me the way the "Parameter" column and the greek letters are. Jun 6, 2014 at 14:38
  • @user2249626 Well, they are centered. :) Jun 6, 2014 at 14:41
  • Perhaps the OP should add (temporary) vertical lines to realize that the columns are centered
    – daleif
    Jun 6, 2014 at 14:42
  • 1
    @user2249626 This is exactly how it is. The numbers are both aligned and vertically centered (relative to the longest string of digits before and after the decimal marker). Jun 6, 2014 at 14:44
  • 2
    @user2249626 That definitely doesn't look good at all. Trust me. :) Jun 6, 2014 at 14:53
3
% arara: pdflatex

\documentclass{scrartcl}
\usepackage{booktabs}
\usepackage{multirow}
\usepackage{siunitx}
    \sisetup{%
        detect-mode,
        group-digits            = false,
        input-symbols           = ( ) [ ] - +,
        table-align-text-post   = false,
        input-signs             = ,
        output-decimal-marker   =comma,
        locale                  = DE,
        }

\begin{document}
\begin{table}
\centering
\begin{tabular}{ccS[table-format = 1.6]S[table-format = 1.6]}
\toprule
& Parameter & {Estimate} & {Standard Error} \\
\cmidrule(){2-4}
EUR/USD model & $\hat \sigma_{X}$ & 0,0315 \\
[\defaultaddspace]
\multirow{4}{*}{GBP/USD model} & $\hat \omega_{\phantom{Y}}$ & 0,000050 & 0,000045 \\ 
& $\hat \alpha_Y$ & 0,0860 & 0,0454 \\
& $\hat \beta_Y$ & 0,8585 & 0,0838 \\
& $\hat \nu_{\phantom{Y}}$ & 7,6367 & 2,4094 \\
\bottomrule
\end{tabular}
\end{table}
\end{document}

enter image description here

You must log in to answer this question.

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