1

I'm working on a table with underlined headings, where each heading spans over two columns.

I'm trying to understand how to use the \extracolsep function to create space between the lines for every second coloumn.

Can someone help?

Here is the relevant part of my code:

\begin{table}[htbp]\centering
\def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi}
\caption{Price model effects}
\begin{tabular}{l*{6}{c}}

\hline\hline

             &\multicolumn{2}{c}{{Residual waste}}&\multicolumn{2}{c}{{Plastic}}&\multicolumn{2}{c}{{Paper}} \\ \cline{2-3} \cline{4-5} \cline{5-6} \cline{6-7}

            &\multicolumn{1}{c}{Kg per capita}&\multicolumn{1}{c}{Ratio}&\multicolumn{1}{c}{Kg per capita}&\multicolumn{1}{c}{Ratio}&\multicolumn{1}{c}{Kg per capita}&\multicolumn{1}{c}{Ratio}\\

Thanks a lot!

  • 1
    Welcome to TeX.SX! Please make your code compilable (if possible), or at least complete it with \documentclass{...}, the required \usepackage's, \begin{document}, and \end{document}. That may seem tedious to you, but think of the extra work it represents for TeX.SX users willing to give you a hand. Help them help you: remove that one hurdle between you and a solution to your problem. – Stefan Pinnow Apr 5 at 11:44
  • Consider wswitching to the booktabs packages and its special lines, they have much better build in spacing. – daleif Apr 5 at 11:57
1

Using \extracolsep doesn't make much sense when using a tabular environment. You should be using a tabular* environment.

enter image description here

\documentclass{article}
\usepackage{array}  % for "\extrarowheight" macro
\usepackage[skip=0.333\baselineskip]{caption} % optional
\begin{document}
\begin{table}[htbp]
    %% \centering
    \setlength\tabcolsep{0pt}
    \setlength\extrarowheight{2pt} for a more open "look"
    \caption{Price model effects}

    \begin{tabular*}{\textwidth}{@{\extracolsep{\fill}}*{6}{c}}

    \hline 
    \multicolumn{2}{c}{Residual waste} & 
    \multicolumn{2}{c}{Plastic} & 
    \multicolumn{2}{c}{Paper} \\ 
    \cline{1-2} \cline{3-4} \cline{5-6} 
    Kg per capita & Ratio & 
    Kg per capita & Ratio & 
    Kg per capita & Ratio \\
    \hline
    \end{tabular*}
\end{table}
\end{document}
  • Thanks a lot! This was super helpful. – Mia Hansen Apr 5 at 12:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.