4

I have this code:

\documentclass[11pt]{article}
\usepackage[margin=2.5cm, showframe]{geometry}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{caption}
\usepackage{setspace}
\usepackage{lipsum}
\usepackage{booktabs}
\usepackage{siunitx}
\usepackage[skip=0.33\baselineskip]{caption}
\captionsetup[table]{
    font=bf,
    size=normalsize,
    justification=centerlast,
    labelsep=newline
    }
\renewcommand\thetable{\Roman{table}}

\begin{document}
\begin{spacing}{1.5}
\noindent
\def\arraystretch{1.25}
\begin{table}[ht]
\centering
\setlength\tabcolsep{0pt}
\sisetup{table-format=2.2}
\caption{\large{Fancy Table Header}}
\parbox{\linewidth}{\small\lipsum[1]\vspace{2ex}}
\medskip
\begin{tabular*}{\linewidth}{@{\extracolsep{\fill}}
                l
                S[table-format=-2.2]
           *{6}{S}
                }
\toprule
\multicolumn{1}{c}{Description}
            & {Column 1} & {Column 2} & {Column 3}
            & {Column 4} & {Column 5} & {Column 6}\\
\midrule
Variable 1   &626 &293.00 &1,349.65   &1.75   &64.04  &0.68\\
\midrule
Variable 2\\
Sub--variable 2.1       &325 &150.98 &1,677.02   &1.72   &71.92  &0.66\\
Sub--variable 2.2       &169 &81.27  &872.07     &1.85   &56.76  &0.72\\
Sub--variable 2.3       &132 &60.75  &1,155.07   &1.70   &53.96  &0.69\\
\midrule
Variable 3\\
Sub--variable 3.1       &360 &154.02 &81.16      &1.94   &71.73  &0.61\\
Sub--variable 3.2       &155 &76.97  &557.67     &1.64   &60.52  &0.70\\
Sub--variable 3.3       &111 &62.01  &6,569.60   &1.27   &44.00  &0.84\\
\midrule
Variable 4\\
Sub--variable 4.1       &190 &90.15  &3,263.74   &0.92   &57.98  &0.77\\
Sub--variable 4.2       &202 &92.31  &545.90     &1.50   &75.23  &0.72\\
Sub--variable 4.3       &234 &110.54 &489.31     &2.63   &59.30  &0.58\\
\midrule
Variable 5\\
Sub--variable 5.1       &229 &115.50 &2,050.25   &1.87   &15.54  &0.69\\
Sub--variable 5.2       &185 &78.23  &1,498.76   &1.58   &43.13  &0.71\\
Sub--variable 5.3       &212 &99.26  &462.76     &1.76   &134.68 &0.65\\
\bottomrule
\end{tabular*}
\end{table}
\end{spacing}
\end{document}

which produces this table:

Table

In column 3, some of the numbers are above 1,000, but they are not being shown for some reason, and I can't figure out why. Does anyone have an idea?

Thanks in advance!

2
  • Is the , allowed as separator? Is the format correct ?
    – albert
    Apr 30, 2018 at 10:16
  • @albert: it seems not, apparently, as Troy has pointed out. Thank you for your comment.
    – Andreas
    Apr 30, 2018 at 10:25

1 Answer 1

3

I would suggest leaving out the commas and letting siunitx do the job for you.

\documentclass[11pt]{article}
\usepackage[margin=2.5cm, showframe]{geometry}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{caption}
\usepackage{setspace}
\usepackage{lipsum}
\usepackage{booktabs}
\usepackage{siunitx}
\usepackage[skip=0.33\baselineskip]{caption}
\captionsetup[table]{
    font=bf,
    size=normalsize,
    justification=centerlast,
    labelsep=newline
    }
\renewcommand\thetable{\Roman{table}}

\begin{document}
\begin{spacing}{1.5}
\noindent
\def\arraystretch{1.25}
\begin{table}[ht]
\centering
\setlength\tabcolsep{0pt}
\sisetup{table-format=2.2, group-separator={,}, group-minimum-digits=4}
\caption{\large{Fancy Table Header}}
\parbox{\linewidth}{\small\lipsum[1]\vspace{2ex}}
\medskip
\begin{tabular*}{\linewidth}{@{\extracolsep{\fill}}
                l
                S[table-format=-2.2]
           *{6}{S}
                }
\toprule
\multicolumn{1}{c}{Description}
            & {Column 1} & {Column 2} & {Column 3}
            & {Column 4} & {Column 5} & {Column 6}\\
\midrule
Variable 1   &626 &293.00 &1349.65   &1.75   &64.04  &0.68\\
\midrule
Variable 2\\
Sub--variable 2.1       &325 &150.98 &1677.02   &1.72   &71.92  &0.66\\
Sub--variable 2.2       &169 &81.27  &872.07     &1.85   &56.76  &0.72\\
Sub--variable 2.3       &132 &60.75  &1155.07   &1.70   &53.96  &0.69\\
\midrule
Variable 3\\
Sub--variable 3.1       &360 &154.02 &81.16      &1.94   &71.73  &0.61\\
Sub--variable 3.2       &155 &76.97  &557.67     &1.64   &60.52  &0.70\\
Sub--variable 3.3       &111 &62.01  &6569.60   &1.27   &44.00  &0.84\\
\midrule
Variable 4\\
Sub--variable 4.1       &190 &90.15  &3263.74   &0.92   &57.98  &0.77\\
Sub--variable 4.2       &202 &92.31  &545.90     &1.50   &75.23  &0.72\\
Sub--variable 4.3       &234 &110.54 &489.31     &2.63   &59.30  &0.58\\
\midrule
Variable 5\\
Sub--variable 5.1       &229 &115.50 &2050.25   &1.87   &15.54  &0.69\\
Sub--variable 5.2       &185 &78.23  &1498.76   &1.58   &43.13  &0.71\\
Sub--variable 5.3       &212 &99.26  &462.76     &1.76   &134.68 &0.65\\
\bottomrule
\end{tabular*}
\end{table}
\end{spacing}
\end{document}

enter image description here

3
  • Perfect, thank you very much, Mr. @Troy! Would you by any chance know how to right align all the numbers within the current table environment? It seems that, for example, the numbers in column 1 are more centred than those in the other columns.
    – Andreas
    Apr 30, 2018 at 10:28
  • @Andreas I'm not quite too sure what you mean (I don't really see it, sorry). Since it's not related to the question at hand, feel free to ask a new question (perhaps draw some lines using Paint etc. to illustrate your point?).
    – Troy
    Apr 30, 2018 at 10:29
  • Mr. @Troy: No problem. I will try to figure it out by my self, and if not, I'll post another question. Thank you for your time, and have a nice day.
    – Andreas
    Apr 30, 2018 at 10:34

You must log in to answer this question.

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