I'm trying to get a big table to fit into my document using the booktabs package, but it is too wide. An example of a couple of rows of the table is given below. I'm using the \noindent\makebox[\textwidth]{%
line because that seemed to work for me before, but its not helping now.
Example:
\usepackage{graphicx}
\usepackage{booktabs}
\begin{document}
\begin{table}
\small
\begin{center}
\noindent\makebox[\textwidth]{%
\begin{tabular}{lcccccccccccccccccc}
\toprule
Event & \multicolumn{2}{c}{Counts}& \multicolumn{8}{c}{Genres} &\multicolumn{8}{c}{Genres blabla} \\
\cmidrule(r){1-1} \cmidrule(r){2-3} \cmidrule(r){4-11}\cmidrule(r){12-19}
&&&&&&&&&&&&&&&&&&\\
\midrule
Test1 & 138 & 8 & 0 & 0 & 60 & 4 & 61 & 4 & 0 & 0 & 0 & 0 & 1 & 0 & 0 & 0 & 16 & 0\\
Test2 & 162 & 136 & 0 & 0 & 71 & 63 & 89 & 72 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 2 & 1\\
Test3 & 161 & 120 & 0 & 0 & 66 & 40 & 85 & 77 & 0 & 0 & 0 & 0 & 0 & 0 & 6 & 3 & 4 & 0\\
Test4 & 122 & 109 & 0 & 0 & 55 & 48 & 63 & 61 & 1 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 3 & 0\\
Test5 & 126 & 3 & 1 & 0 & 45 & 1 & 36 & 1 & 0 & 0 & 0 & 0 & 0 & 0 & 1 & 0 & 43 & 1\\
\bottomrule
\end{tabular}
}
\end{center}
\end{table}
\end{document}
And secondly, on the &&&&&&&&&&&&&&&&&&\\
line, I need to add the column names. But these are quite long, so i would like to have them rotated about 45 degrees and close to eachother. I tried \rotatebox{45}{sentence1} & \rotatebox{45}{sentence2} & ... ,
but that doesn't do exactly what I want. Using \rotatebox
, the head of sentence2
will start where the tail of sentence1
ended. I would like the head of sentence2
to be right next to the head of sentence1
.
Below is an example of what i mean. When this code is compiled, there is a big spacing between the 3 headings. I would like the word "this" of the second heading to be right next to the "this" of the first one. etc.
\documentclass[12pt]{article}
\usepackage{graphicx}
\begin{document}
\begin{table}
\begin{tabular}{ccc}
\rotatebox{45}{This is a very long heading} & \rotatebox{45}{This is a very long heading} & \rotatebox{45}{This is a very long heading}
\end{tabular}
\end{table}
\end{document}
I hope that makes sense