How to make table with different columns per row?

Try this:

\documentclass{article}
\usepackage{sans}
\renewcommand{\arraystretch}{1.3}
\begin{document}
\begin{table}
    \begin{tabular}{|c|c|c|c|c|c|}
    \hline
    & \multicolumn{4}{|c|}{Display Format}& \\ \cline{2-5}
    &\multicolumn{2}{|c|}{High information density}& \multicolumn{2}{|c|}{Low information density} &\\ \hline
    Cookie type & Noticeable& Non-noticeable& Noticeable& Non-noticeable& Total \\ \hline
    1\textsuperscript{st} - party cookies&29&17&27&20&93\\ \hline
    1\textsuperscript{st}/3\textsuperscript{rd} party cookies&19&22&23&20&84\\ \hline
    Total& 48&39&50&40&177\\ \hline

    \end{tabular}
    \caption{Number of respondants for treatment}
 \end{table}
\end{document}

and image of table obtained by above code:

enter image description here


Your table is going to be very huge ... 24 cm wide :)- See if the following is what you looking for:

\documentclass{article}
\usepackage{array}

\begin{document}
    \begin{table}[h]
    \renewcommand\arraystretch{1.3}
\begin{tabular}{|l | *{4}{>{\centering}p{2cm}|}c|}
%{|m{4cm}|m{4cm}|m{4cm}|m{4cm}|m{4cm}|m{4cm}}
\hline
    & \multicolumn{4}{c|}{Display Format} 
        &                                                   \\
    \hline
Cookie type
    & \multicolumn{2}{c|}{High information-density} 
        & \multicolumn{2}{c|}{Low information-density} 
            &   Total                                       \\
    \hline
1\textsuperscript{st} party cookies
    & 29    &   17  &   27  &   20  &   93                  \\
    \hline  
\end{tabular}
\caption{Number of respondents per treatment}
\label{table:3}
    \end{table}
\end{document}

enter image description here

Tags:

Tables