Table with gap between cmidrule's (extra space between two columns)

The only way to break the horizontal rule would be to insert a separate column (as you suggest), or to marginally trim the \cmidrules using the optional (..) specification:

enter image description here

\documentclass{article}

\usepackage{booktabs}

\begin{document}

\begin{tabular}{l c c c c}
  \toprule
  & \multicolumn{2}{c}{Text1} & \multicolumn{2}{c}{Text2} \\
  \cmidrule{2-3} \cmidrule{4-5}
  & A & B & A & B \\
  \midrule
  Foo & 1 & 2 & 3 & 4 \\
  \bottomrule
\end{tabular}

\bigskip

\begin{tabular}{l c c c c}
  \toprule
  & \multicolumn{2}{c}{Text1} & \multicolumn{2}{c}{Text2} \\
  \cmidrule(lr){2-3} \cmidrule(lr){4-5}
  & A & B & A & B \\
  \midrule
  Foo & 1 & 2 & 3 & 4 \\
  \bottomrule
\end{tabular}

\bigskip

\begin{tabular}{l c c c c c}
  \toprule
  & \multicolumn{2}{c}{Text1} & & \multicolumn{2}{c}{Text2} \\
  \cmidrule{2-3} \cmidrule{5-6}
  & A & B & & A & B \\
  \midrule
  Foo & 1 & 2 & & 3 & 4 \\
  \bottomrule
\end{tabular}

\end{document}

Adding space in the column specification using

\begin{tabular}{l c c@{\hspace{1cm}} c c}

inserts 1cm between columns 3 and 4, but would require you to correct alignment when using \multicolumn without providing the gap.

I don't think inserting an empty column is that bad. You could actually control the width of the column to provide a finely-tuned spacing of the \cmidrule separation. Something like

\begin{tabular}{l c c c@{\hspace{1cm}} c c}

Would give a gap of exactly 1cm between columns 3 and (now) 5.

Tags:

Tables