I am doing this table, but my the phrases are out of the limits of the cells. How can I adjust them in two or three lines instead of one?
\documentclass[12pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{rotfloat}
\usepackage{multirow}
\begin{document}
\begin{sidewaystable}
\begin{tabular}{|p{5cm}|p{1.2cm}|p{1.2cm}|p{1.7cm}|p{1.7cm}|p{1.2cm}|p{1.2cm}|p{1.2cm}|p{1.7cm}|p{1.7cm}|p{1.2cm}|}
\hline
\multirow{3}{*}{University} & \multicolumn{4}{c|}{Year 1996} & \multirow{3}{*}{Total} & \multicolumn{4}{c|}{Year 2010} & \multirow{3}{*}{Total} \\
\cline{2-5} \cline{7-10}
& \multicolumn{2}{c|}{Students} & \multirow{2}{*}{Docentes universitarios} & \multirow{2}{*}{Personal administrativo y de servicio} & & \multicolumn{2}{c|}{Students} & \multirow{2}{*}{Docente universitario} & \multirow{2}{*}{Personal administrativo y de servicio}& \\
\cline{2-3} \cline{7-8}
& Pre grade & Post grade & & & & Pre grade & Post grade & & & \\
\hline
National University & 3225 & 268 & 453 & 498 & 4434 & 4903 &976 & 445 & 802 & 7126 \\
\hline
\end{tabular}
\end{sidewaystable}
\end{document}
As I am using \multirow{...}
and |p{Xcm}|
, the words are not centered, how can I fixed this?
Best Answer
This stays as close as possible to your original table. I don't recommend doing it this way, but it works. I fiddled with the text block height to get it to fit, since I'm assuming it fits in your actual page. I've also faked hyphenation because I wasn't sure which language to tell Babel. (Obviously, you should take my hyphenation points out and let Babel do its thing in your real document.)
defines a new column type,
C{<width>}
which is just likep
but centred. If you want vertical centring as well, substitutem
forp
.This alters the default formatting for
\multirow
content from\raggedright
to\centering
.Code:
However, this is not the best way to set tabular material. In particular, the use of vertical rules is not recommended and some horizontal rules should be heavier than others. In addition, more spacing is needed so that cell contents do not look squashed and are easier to read.
booktabs has a good discussion of best practice for typesetting professional-quality tabular material. It is worth reading. Even if it is occasionally perhaps a little overly dogmatic, it is a very useful antidote to the kind of formatting encouraged by word processors!
I would think about something more like this: