I'm using this code snippet to create a table with multicolumn. Since the headers of the columns are long, I've rotated them 90 degrees.
\begin{table}[H]
\centering
\caption{Accuracy of Bayesian networks, only for setting 2. Values depict percentage of correct classification for the different ALSFRS values.}
\begin{tabular}{@{} cl*{10}c @{}}
\toprule
& & \multicolumn{10}{}{} \\[2ex]
& Learning algorithm & \rot{Speech} & \rot{Respiratory} & \rot{Salivation} & \rot{Swallowing}
& \rot{Handwriting} & \rot{Cutting} & \rot{\shortstack[l]{Dressing\\Hygiene}}
& \rot{\shortstack[l]{Turning\\in Bed}} & \rot{Walking} & \rot{\shortstack[l]{Climbing\\Stairs}} \\
\cmidrule{2-12}
& PC & $81.4$ & $82.3$ & $82.0$ & $82.2$ & $75.0$ & $78.8$ & $80.1$ & $77.3$ & $79.2$ & $82.3$ \\
& RMCV (empty initialization) & $82.5$ & $83.2$ & $84.7$ & $82.4$ & $80.1$ & $79.7$ & $83.8$ & $82.9$ & $82.3$ & $83.7$ \\
& RMCV (naive Bayes initialization) & $79.5$ & $74.5$ & $75.9$ & $78.3$ & $71.0$ & $71.6$ & $78.8$ & $73.3$ & $78.4$ & $77.8$ \\
\cmidrule[1pt]{2-12}
\end{tabular}
\end{table}
However, now I have some long text in the first entries, and the table keeps spilling out of the page. I want to wrap the text in the first column, but I can't seem to find the right place to put the p{Xcm} command, and I also don't know how to correctly limit the width of the column. I'm kind of new to LaTeX
, so maybe this is a newbie question, but I'd really appreciate some help. Thanks!
Best Answer
It is my impression that almost all people strongly dislike having to crane their necks to read rotated material -- including header cells of a table. Fortunately, there's no need to make your readers crane their necks: Just transpose the table's rows and columns.
Addendum: if you prefer having the table spanning the full width of the text block (and placing more information in the header cells, then the following approach may be of interest to you. It uses a
tabularx
environment along with a centered version of theX
column type.