How to make a table with multiple rows and colums

I would reorganize the table so that the cells contain less repeated information and, instead, put that information in the table's header. I would also rearrange the header material to reduce the widths of the columns; this, in turn, will permit the use of a larger font size, which will be much appreciated by your readers. By the way, if the header is designed well, there's no need to use bold to draw attention to some of the header cells. Finally, I'd the table a more open look (by omitting all vertical bars and most horizontal bars).

enter image description here

\documentclass[11pt]{article}
\usepackage{rotating,booktabs}
\begin{document}
\begin{sidewaystable}[t!]
\centering
\small % no need for \tiny or \scripsize
\begin{tabular}{@{}l *{10}{c}@{}}
\toprule
Cookies & Information density & Noticeable? % ?
& \multicolumn{2}{c}{Age} 
& \multicolumn{2}{c}{Gender (Count)}  
& \multicolumn{4}{c@{}}{Education (Count)}\\
\cmidrule(lr){4-5} \cmidrule(lr){6-7} \cmidrule(l){8-11}
&& & Mean & SD & Male & Female 
   & High  & Under- & Master's  & Other\\
   &&&&&&& school & graduate & or higher \\
\midrule
1st party 
& High & Yes & 35 & 12 & 12 & 17 & 9 & 11 & 9 & 0\\
&      & No  & 35 & 12 & 12 & 17 & 9 & 11 & 9 & 0\\
\addlinespace
& Low  & Yes & 35 & 12 & 12 & 17 & 9 & 11 & 9 & 0\\
&      & No  & 35 & 12 & 12 & 17 & 9 & 11 & 9 & 0\\
\addlinespace
1st/3rd party
& High & Yes & 35 & 12 & 12 & 17 & 9 & 11 & 9 & 0\\
&      & No  & 35 & 12 & 12 & 17 & 9 & 11 & 9 & 0\\
\addlinespace
& Low  & Yes & 35 & 12 & 12 & 17 & 9 & 11 & 9 & 0\\
&      & No  & 35 & 12 & 12 & 17 & 9 & 11 & 9 & 0\\ 
\bottomrule
\end{tabular}
\end{sidewaystable}
\end{document}

To change the texsize, you can use \tiny, \small or other sizes. No need to use environments for this here, as the table-environment would group the fontsize to only that table, and not effect the rest of your document. Other fontsizes, along with some information about them can be found in the post What point (pt) font size are \Large etc.?

When creating multiple columns of the same type, it is easier to write *{11}{l}instead of lllllllllll, and it is much easier to read it. You can of course combine the methods and write `c*{4}{l}rr.

Note that I have not input the numbers as represented in your image, I just copied the first line.

I would advice against using a table this way. I'd try to make it less wide, so that it doesn't have as much white space and could be typeset in portrait mode, remove vertical lines, possible split that data into multiple tables. Mico also suggests a differemt fontsize, along with reduced spacing between columns, and I agree. I have made these suggestions into an example. Further improvements could be made of course.

Output

enter image description here

Suggested output

enter image description here

Code without suggestions

\documentclass[11pt]{article}
\usepackage{lscape}
\usepackage{multirow}
\begin{document}
\begin{landscape}
\begin{table}[ht]
\centering
\tiny
\begin{tabular}{*{11}{|l}|}
\hline
\multicolumn{3}{|c|}{} & \multicolumn{2}{c|}{\bfseries  Age} &\multicolumn{2}{c|}{\bfseries  Gender}  & \multicolumn{4}{|c|}{\bfseries  Education}\\
\cline{4-11}
\multicolumn{3}{|c|}{}& Mean & SD & Male & Female & High school & Undergraduate & Master or higher & Other\\
\cline{6-11}
\multicolumn{3}{|c|}{}&& & Count & Count & Count & Count & Count & Count\\
\hline
1st party & High information& Noticable & 35 & 12 & 12 & 17 & 9 & 11 & 9 & 0\\
cookies & density & Non-noticable & 35 & 12 & 12 & 17 & 9 & 11 & 9 & 0\\
\cline{2-11}
    & \multirow{2}{*}{Low information density}& Noticable & 35 & 12 & 12 & 17 & 9 & 11 & 9 & 0\\
&& Non-noticable & 35 & 12 & 12 & 17 & 9 & 11 & 9 & 0\\
\hline
1st/3rd party& High information & Noticable & 35 & 12 & 12 & 17 & 9 & 11 & 9 & 0\\
cookies & density & Non-noticable & 35 & 12 & 12 & 17 & 9 & 11 & 9 & 0\\
\cline{2-11}
    & \multirow{2}{*}{Low information density}& Noticable & 35 & 12 & 12 & 17 & 9 & 11 & 9 & 0\\
&& Non-noticable & 35 & 12 & 12 & 17 & 9 & 11 & 9 & 0\\
\hline
\end{tabular}
\end{table}
\end{landscape}
\end{document}

Suggested code

\documentclass[11pt]{article}
\usepackage{lscape}
\usepackage{multirow}
\usepackage{caption}
\usepackage{booktabs}
\usepackage{threeparttable}


\newcommand{\minitab}[2][l]{\begin{tabular}{#1}#2\end{tabular}}

\newcommand{\tableHeader}[1]{{\bfseries #1}}
\begin{document}
\begin{table}[ht]
\centering
\setlength{\tabcolsep}{3pt}
\scriptsize

\caption{Number of students enjoying cookies}

\begin{tablenotes}
    \item Abbreviations: HS: Highschool, U: Undergratuate, M+: Master degree or higher
\end{tablenotes}

\begin{tabular}{*{3}{l}*{8}{c}}
\addlinespace
\toprule
\multicolumn{3}{c}{} & \multicolumn{2}{c}{\tableHeader{Age}} &\multicolumn{2}{c}{\tableHeader{Gender}}  & \multicolumn{4}{l}{\tableHeader{Education}}\\
\cmidrule{4-11}
& && & & M & F & HS & U & M+ & O\\
\cmidrule{6-11}
\tableHeader{Cookies} & \parbox[b][1ex]{2cm}{\tableHeader{Information Density}} & \tableHeader{Noticable} & \tableHeader{Mean} & \tableHeader{SD} & \multicolumn{5}{l}{\tableHeader{Number of students}} \\
\midrule
\multirow{4}{*}{\bfseries 1st party} & High & Yes & 35 & 12 & 12 & 17 & 9 & 11 & 9 & 0\\
& & No & 35 & 12 & 12 & 17 & 9 & 11 & 9 & 0\\
\addlinespace
    & Low & Yes & 35 & 12 & 12 & 17 & 9 & 11 & 9 & 0\\
&& No & 35 & 12 & 12 & 17 & 9 & 11 & 9 & 0\\
\hline
\multirow{4}{*}{\bfseries 1st/3rd party} & High & Yes & 35 & 12 & 12 & 17 & 9 & 11 & 9 & 0\\
&  & No & 35 & 12 & 12 & 17 & 9 & 11 & 9 & 0\\
\addlinespace
    & Low & Yes & 35 & 12 & 12 & 17 & 9 & 11 & 9 & 0\\
&  & No & 35 & 12 & 12 & 17 & 9 & 11 & 9 & 0\\
\bottomrule
\end{tabular}
\begin{tablenotes}
    \item *Records may not be correct as it was reported that many students thought the survey was regarding consumable cookies, and not internet-cookies
\end{tablenotes}
\end{table}
\end{document}

Another variant, with some commands as shortcuts, and the makecell package. The font size is the more readable \footnotesize:

        \documentclass[11pt]{article}
        \usepackage[showframe]{geometry} %
        \usepackage{multirow, array, rotating, makecell, cellspace}
        \setlength\cellspacetoplimit{4pt}
        \setlength\cellspacebottomlimit{4pt}


            \newcommand\HighInf{\makecell[lc]{High information\\ density}}
            \newcommand\LowInf{\makecell[lc]{Low information\\ density}}
            \newcommand\NonNot{\ensuremath{\biggl[\begin{tabular}{l@{}}Noticeable \\[0.5ex] Non-noticeable\end{tabular}}}

        \begin{document}

        \begin{sidewaystable}[!ht]
        \centering
        \setlength\tabcolsep{3.5pt}
        \footnotesize
        \begin{tabular}{|lcc*{8}{|Sc}|}
        \hline
        \multicolumn{3}{|c|}{} & \multicolumn{2}{Sc|}{\bfseries Age} &\multicolumn{2}{c|}{\bfseries Gender} & \multicolumn{4}{c|}{\bfseries Education}\\
        \cline{4-11}
        \multicolumn{3}{|c|}{}& Mean & SD & Male & Female & High school & \makecell{Undergraduate\\ level} & \makecell{Master degree\\ or higher} & Other\\
        \cline{6-11}
        \multicolumn{3}{|c|}{}&& & Count & Count & Count & Count & Count & Count\\
        \hline
        \makecell{1st party\\ cookies} & \HighInf & \NonNot & \makecell{35\\35} & \makecell{12\\12} & \makecell{12\\12} & \makecell{17\\17} & \makecell{9\\9} & \makecell{11\\11} & \makecell{9\\9} & \makecell{0\\0} \\[2ex]
            & \LowInf & \NonNot & \makecell{35\\35} & \makecell{12\\12} & \makecell{12\\12} & \makecell{17\\17} & \makecell{9\\9} & \makecell{11\\11} & \makecell{9\\9} & \makecell{0\\0} \\%
             & & & & & & & & & & \\[-2ex]
        \hline & & & & & & & & & & \\[-2ex]
        \makecell{1st/3rd party\\ cookies}& \HighInf & \NonNot & \makecell{35\\35} & \makecell{12\\12} & \makecell{12\\12} & \makecell{17\\17} & \makecell{9\\9} & \makecell{11\\11} & \makecell{9\\9} & \makecell{0\\0} \\
            & \LowInf & \NonNot & \makecell{35\\35} & \makecell{12\\12} & \makecell{12\\12} & \makecell{17\\17} & \makecell{9\\9} & \makecell{11\\11} & \makecell{9\\9} & \makecell{0\\0} \\
        \hline
        \end{tabular}
        \end{sidewaystable}

        \end{document} 

enter image description here

Tags:

Tables