Splitting a wide table or a longtable into two blocks
whenever you use a \multicolumn
that ends in a column that has any |
or @{...}
material in its right hand edge, you need to re-insert it so if you have
|ll||ll|
then typically you will need
\multicolumn{2}{|c||}{heading for 1st 2 columns}&
\multicolumn{2}{c|}{heading for 2nd 2 columns}\\
This applies to all LaTeX tabular environments.
Based on David Carlisle's answer and comments, this hack gives a better impression of the longtable being split into two distinct blocks. It uses a wide vertical white rule to split the parts of the table. Hence it looks better if the all the table rows (or just alternate rows) are coloured with a different colour other than white.
\begin{longtable}{lp{0.3cm}p{0.3cm}p{0.3cm}p{0.3cm}p{0.3cm}p{0.3cm}p{0.3cm}p{0.3cm}p{0.3cm}!{\color{white}\vrule width 5pt}p{0.3cm}p{0.3cm}p{0.3cm}p{0.3cm}p{0.3cm}p{0.3cm}p{0.3cm}p{0.3cm}p{0.3cm}p{0.3cm}}
lead to:
One more interesting fact I learnt through this question is that it is possible to make vertical rules play well with multicolumns as well as the tricky booktabs package by using the vrule
option.
For example, this code
\begin{longtable}{lp{0.3cm}!{\color{tableShade3}\vrule}
p{0.3cm}!{\color{tableShade3}\vrule}
p{0.3cm}!{\color{tableShade3}\vrule}
p{0.3cm}!{\color{tableShade3}\vrule}
p{0.3cm}!{\color{tableShade3}\vrule}
p{0.3cm}!{\color{tableShade3}\vrule}
p{0.3cm}!{\color{tableShade3}\vrule}
p{0.3cm}!{\color{tableShade3}\vrule}
p{0.3cm}!{\color{white}\vrule width 4pt}
p{0.3cm}!{\color{white}\vrule}
p{0.3cm}!{\color{white}\vrule}
p{0.3cm}!{\color{white}\vrule}
p{0.3cm}!{\color{white}\vrule}
p{0.3cm}!{\color{white}\vrule}
p{0.3cm}!{\color{white}\vrule}
p{0.3cm}!{\color{white}\vrule}
p{0.3cm}!{\color{white}\vrule}
p{0.3cm}!{\color{white}\vrule}}
leads to:
Not perfect, but functional and somewhat less ugly than the the | or || solution.