3

I am having issues with the following table. There should be a space appearing between UC and CC. Unfortunately, it does not and thus the content in the columns thereafter is also not aligned. Any tips would be great!

\documentclass{article}      
\usepackage{booktabs,siunitx}
\sisetup{table-format=1.3} % default numerical column spec
\begin{document}

\begin{table}
\sisetup{table-format=1.3}
\centering
\begin{tabular}{@{}*{2}{l S[table-format=1.0] S[table-format=5.0] SS} @{}}
\toprule   % center non-numerical info (A, B, ...) by placing them in braces
 & {s} & {UC} & {IND} & {CC} &  & {UC} & {IND} & {CC} \\
\cmidrule(r){3-5} \cmidrule(r){7-9}  % leave gap between the two rules
Normal & 1 & 1000 &  & 0.999 &  & 1000 & 1000 &  0.999  \\
  & 2 & 1100 &  & 0.826  &  & 1000 & 1000 &  0.999     \\
  & 3 & 1100 &  & 0.826  &  & 1000 & 1000 &  0.999       \\[1ex]
Student-t & 1 & 1000 & 0.010 & 1.000 &  & 1000 & 1000 &  0.999   \\
  & 2 & 1100 & 0.010 & 0.866  &  & 1000 & 1000 &  0.999       \\
  & 3 & 1000 & 0.008 & 0.818   &  & 1000 & 1000 &  0.999      \\[1ex]
GED & 1 & 1000 &  & 0.998 &  & 1000 & 1000 &  0.999   \\
  & 2 & 1100 &  & 0.812  &  & 1000 & 1000 &  0.999  \\
  & 3 & 1100 &  & 0.811 &  & 1000 & 1000 &  0.999  \\
\bottomrule
\end{tabular}
\end{table}

\end{document}

enter image description here

1
  • By "There should be a space appearing between UC and CC" I assume you mean between columns 5 and 6? If so then it works for me? Can you add a screen-shot to show what you are getting.
    – user30471
    Oct 4, 2016 at 11:12

2 Answers 2

4

With fixed column specifications:

\documentclass{article}
\usepackage{booktabs,siunitx}
\sisetup{table-format=1.3} % default numerical column spec
\begin{document}

\begin{table}
\sisetup{table-format=1.3}
\centering
\begin{tabular}{
  l
  S[table-format=1.0]
  S[table-format=4.0]
  S
  S
  l
  S[table-format=4.0]
  S[table-format=4.0]
  S
}
\toprule   % center non-numerical info (A, B, ...) by placing them in braces
 & {s} & {UC} & {IND} & {CC} & & {UC} & {IND} & {CC} \\
\cmidrule(lr){3-5} \cmidrule(lr){7-9}  % leave gap between the two rules
Normal
  & 1 & 1000 &       & 0.999 & & 1000 & 1000 & 0.999 \\
  & 2 & 1100 &       & 0.826 & & 1000 & 1000 & 0.999 \\
  & 3 & 1100 &       & 0.826 & & 1000 & 1000 & 0.999 \\
\addlinespace
Student-t
  & 1 & 1000 & 0.010 & 1.000 & & 1000 & 1000 & 0.999 \\
  & 2 & 1100 & 0.010 & 0.866 & & 1000 & 1000 & 0.999 \\
  & 3 & 1000 & 0.008 & 0.818 & & 1000 & 1000 & 0.999 \\
\addlinespace
GED
  & 1 & 1000 &       & 0.998 & & 1000 & 1000 & 0.999 \\
  & 2 & 1100 &       & 0.812 & & 1000 & 1000 & 0.999 \\
  & 3 & 1100 &       & 0.811 & & 1000 & 1000 & 0.999 \\
\bottomrule
\end{tabular}
\end{table}

\end{document}

Result

4
  • Could you extend on why they have to be like that? For example what is the difference between 'SS' and 'S' alignment.
    – Josh
    Oct 4, 2016 at 11:28
  • SS is the specification for two columns, S is the specification for one column. Options are not given, table-format is taken from the previous \sisetup{table-format=1.3}. I update the answer to use two lines for SS to be more consistent in formatting the source. Oct 4, 2016 at 11:39
  • Thanks for the answer! If I change one of the "1000" entrys to "0.001" for example the alignment of that entry messes up. Is there anyway to avoid this? Oct 4, 2016 at 12:00
  • 2
    @MellyDonald If you want to have an alignment at the decimal marker, then: S[table-format=4.3] to fit both 1000 and .001. Oct 4, 2016 at 12:03
2

You forgot one & in the first row. I slightly changed the table preamble, as columns with integer numbers don't really need S column type, at least from what you show us. Also modified the cropping of the \cmidrules:

\documentclass{article}
\usepackage{booktabs,siunitx}
\sisetup{table-format=1.3,table-number-alignment=center} % default numerical column spec
\begin{document}

\begin{table}
\sisetup{table-format=1.3}
\centering
\begin{tabular}{@{}lccSScccS@{\,}}%{@{}
\toprule % center non-numerical info (A, B, ...) by placing them in braces
 & {s} & {UC} & {IND} & {CC} & & {UC} & {IND} & {CC} \\
\cmidrule(lr){3-5} \cmidrule(l){7-9} % leave gap between the two rules
Normal & 1 & 1000 & & 0.999 & & 1000 & 1000 & 0.999 \\
  & 2 & 1100 & & 0.826 & & 1000 & 1000 & 0.999 \\
  & 3 & 1100 & & 0.826 & & 1000 & 1000 & 0.999 \\[1ex]
Student-t & 1 & 1000 & 0.010 & 1.000 & & 1000 & 1000 & 0.999 \\
  & 2 & 1100 & 0.010 & 0.866 & & 1000 & 1000 & 0.999 \\
  & 3 & 1000 & 0.008 & 0.818 & & 1000 & 1000 & 0.999 \\[1ex]
GED & 1 & 1000 & & 0.998 & & 1000 & 1000 & 0.999 \\
  & 2 & 1100 & & 0.812 & & 1000 & 1000 & 0.999 \\
  & 3 & 1100 & & 0.811 & & 1000 & 1000 & 0.999 \\
\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 .