Add extra space only between two specific columns of a tabular without adding extra columns

Using the array package you can specify a command to be executed before each element with >{\command} and after each element <{command}. So, the following should close to what you want.

\documentclass{article}
\usepackage{array}

\newcolumntype{R}{@{\extracolsep{3cm}}r@{\extracolsep{0pt}}}%

\begin{document}
\begin{tabular}{llRr}
  \multicolumn{2}{r}{Spans} & \multicolumn{2}{l}{Spans} \\
  \cline{1-2} \cline{3-4}
  X & Y & X & Y
\end{tabular}
\end{document}

Maybe you can use the trim option of booktabs's \cmidrule to trim the cline. Add the additional space also to the \multicolumn.

\documentclass{article}
\usepackage{array}
\usepackage{booktabs}

\newlength\tbspace
\setlength\tbspace{3cm}
\newcolumntype{L}{l<{\hspace{\tbspace}}}

\begin{document}
    \begin{tabular}{lLrr}
      \multicolumn{2}{L}{Spans} & \multicolumn{2}{r}{Spans} \\
      \cmidrule(r{\tbspace}){1-2} \cmidrule{3-4}
      X & Y & X & Y
    \end{tabular}
\end{document}

enter image description here


Well, the following seems to work but needs some size adjustments and I am not good at it to do it properly. As required there are no column additions, but I really don't know why it works either. I tend to hack things rather than to code them. Probably one of the gurus here can tell us how to make things robust.

\documentclass{article}
 \usepackage{tabularx}


 \begin{document}

 \begin{tabular*}{\textwidth}{c @{\extracolsep{1cm}}c  c c}
  \multicolumn{2}{c}{Spans} &\multicolumn{2}{c}{Spans} \\
  \cline{1-2} \cline{3-4}
  X & Y & X & Y\\
  XZZZZZZ &YSSSSSS & XZ & RANDOMLETTERCOMBO
\end{tabular*}

\end{document}

Here is a snapshot with a few more letters.

enter image description here

EDIT: I have realized that vertical lines between columns look quite bad and needs more tweaks if you insist using them.

Tags:

Spacing

Tables