# Variable column spacing in a table

I have a relatively complex table with quite a few sub headings. I am trying to adjust the column spacing so that the separate "groups" are more visible.

Here is a bit of my current table:

\documentclass[8pt,a4paper]{extreport}

\usepackage{etoolbox,siunitx,booktabs,threeparttable,multirow,array,graphicx}
\usepackage[margin=2.5cm]{geometry}
\robustify\bfseries
\setlength{\tabcolsep}{2pt}
\setlength\extrarowheight{3pt}
\sisetup{
detect-weight           = true,
detect-inline-weight    = math,
table-align-text-post   = false,
input-open-uncertainty  = ,
input-close-uncertainty = ,
tight-spacing           = true,
table-figures-integer   = 2,
}

\begin{document}
\begin{table}
\caption{}
\centering
\begin{threeparttable}[b]
\begin{tabular}{cc S[table-format=+2.1]S S[table-format=+2.1]S S[table-format=+2.1]S S[table-format=+2.1]S}
\toprule
&& \multicolumn{8}{c}{La Ni\~{n}a}\\ \cmidrule(l){3-10}
ENSO & Time & \multicolumn{4}{c}{First} & \multicolumn{4}{c}{Second}\\ \cmidrule(lr){3-6}\cmidrule(l){7-10}
Index & Period & \multicolumn{2}{c}{Terciles} & \multicolumn{2}{c}{Quartiles} & \multicolumn{2}{c}{Terciles} & \multicolumn{2}{c}{Quartiles}\\
\midrule
\multicolumn{10}{l}{\textit{Annual (Jan-Dec) data}}\\
SOI & 1901--2011 & 1.6 & (24) & 3.0 & (17) & \bfseries 7.3 & (13) & \bfseries 8.5 & (11)\\
SOI & 1901--1950 & 3.2 & (12) & \bfseries 4.0 & (9) & \bfseries 8.0 & (5) & \bfseries 9.7 & (4)\\
\bottomrule
\end{tabular}
\begin{tablenotes}[flushleft]
\item Insert notes here
\end{tablenotes}
\end{threeparttable}
\end{table}
\end{document}


Ideally, I want 3 different sized column gaps (in ascending order):

1. Gap between number and following bracketed number
2. Gap separating the "Terciles" and "Quartiles" groups (and the gap separating cols 1 & 2)
3. Gap separating the "First" and "Second" groups (and the gap separating the "Time Period" column from column 3)

I did find another example on here of how to do something similar (Improve intercolumn spacing of this table), but it looked awful when I tried to apply it to my table!! I would really grateful if anyone could help :)

• Just a friendly suggestion :-) The rules in the headers part of the table seemingly serve no information-carrying purpose, maybe you could consider dropping them off? Combined with the rules from above and below the whole table, and the one separating table headers and content, it becomes such a rule-fest ;-D – morbusg Feb 13 '14 at 13:39
• I am not really sure what you mean, sorry! I have spent such a long time fiddling around with the siunitx stuff to get things to work, that I am not sure what I do and don't need any more! – emmalgale Feb 13 '14 at 13:50
• Oh, I meant the \cmidrule's, but it's only a suggestion :-) Hang in there; at the end of the day, try printing out a couple of pages of your work and just admire the results :-) I find it calming when I'm having a hard time figuring something out with TeX. – morbusg Feb 13 '14 at 13:59
• The headers serve more of a purpose if the whole table is included. There are a lot more columns, but it wasn't necessary to include them for my question :) – emmalgale Feb 13 '14 at 14:04

If you change your preamble to

        \begin{tabular}{c@{b}c@{c} S[table-format=+2.1]@{a}S
@{b}S[table-format=+2.1]@{a}S
@{c}S[table-format=+2.1]@{a}S
@{b}S[table-format=+2.1]S}


Then you get

Then just change a b and c to \hspace{...} for whatever space you want.

• oh there is one a space missing from the final column of bracked numbers... – David Carlisle Feb 13 '14 at 13:09
• That is kinda what I tried. However, looking at your example above, the data isn't centred under the headings any more. This is what happened when I tried using the \hspace stuff before. Is there any way to fix that? – emmalgale Feb 13 '14 at 13:53
• @emmalgale you need to put the (right hand) space in any multicolumn so not \multicolumn{2}{c}{Terciles} & but \multicolumn{2}{c@\hspace...}}{Terciles} & so it is centred over the data rather than the data+padding – David Carlisle Feb 13 '14 at 14:45
• I now have it so that the headings are centred over the data, but the \cmidrules are not aligned now. Is there anyway to add the padding either side of the data in the column, rather than shifting it all left? – emmalgale Feb 14 '14 at 10:41
• @emmalgale it is, but easier (starting from here) would be to use the optional argument to \cmidrule to trim one end of the rule to recover alignment see the booktabs documentation – David Carlisle Feb 14 '14 at 10:53

So, it seems like the best way to sort out this problem is (for me anyway) to add empty columns using p{...pt} (where the ... is replaced with the space I want, and set the column separation to \setlength{\tabcolsep}{0pt}.

This makes it easier to get the \cmidrule to be in the right place with the header centred over the line.

I had previously tried adding blank columns using the c option, but this didn't do what I wanted. I hadn't tried using the p{...}` option before asking the question.

Thanks for the other suggestions - I am sure they will work for other people :)