# How to wrap the 90 degrees rotated text in a table cell

in Microsoft word I have a table which has the following structure.

Now, I need to make a similar table in LaTex to submit a publication, I tried with the following code,

%%***************************************************************
\documentclass[twoside,12pt]{article}%                         *
\usepackage{graphicx}%                                           *

\begin{document}
%===============Table Starts====================================
Table 1. This is a table
\begin{center}%[htbp]
\begin{tabular}{l rrrrrrrr}\hline
\rotatebox{90}{Number of
Married Years}  & \rotatebox{90}{Observed Frequency (Year 1)}   & \rotatebox{90}{Expected Poisson Frequency (Year 1)} &
\rotatebox{90}{Expected Binomal Frequency (Year 1)} & \rotatebox{90}{Expected Normal Frequency (Year 1)}    & \rotatebox{90}{Observed Frequency (Year 2)} & \rotatebox{90}{Expected Poisson Frequency (Year 2)} & \rotatebox{90}{   Expected Binomial
Frequency (Year 2) } & \rotatebox{90}{Expected Normal Frequency (Year 2)}\\\hline
0     & x     & y     & z     & a     & b     & c     & d     & e \\
1     & x     & y     & z     & a     & b     & c     & d     & e \\
2     & x     & y     & z     & a     & b     & c     & d     & e \\
3     & x     & y     & z     & a     & b     & c     & d     & e \\\hline
\end{tabular}
\label{tab1}
\end{center}
\end{document}


This code produces a table like the below,

It would be a great help if you could guide me in wrapping the rotated text in the first row of the table.

-
–  Claudio Fiandrino Feb 5 '13 at 17:28

\parbox is an obvious choice here. I've wrapped this in a command \spheading[<width>]{<stuff>} (default of width is 10em), to avoid duplication of angles:

\documentclass{article}
\usepackage{graphicx}% http://ctan.org/pkg/graphicx
\rotatebox{90}{\parbox{#1}{\raggedright #2}}}
\begin{document}
%===============Table Starts====================================
Table 1. This is a table
\begin{center}%[htbp]
\begin{tabular}{l *{8}{r}}
\hline
\spheading{Expected Poisson Frequency (Year 1)} &
\spheading{Expected Binomal Frequency (Year 1)} &
\spheading{Expected Normal Frequency (Year 1)} &
\spheading{Expected Poisson Frequency (Year 2)} &
\spheading{Expected Binomial Frequency (Year 2)} &
\spheading{Expected Normal Frequency (Year 2)} \\
\hline
0     & x     & y     & z     & a     & b     & c     & d     & e \\
1     & x     & y     & z     & a     & b     & c     & d     & e \\
2     & x     & y     & z     & a     & b     & c     & d     & e \\
3     & x     & y     & z     & a     & b     & c     & d     & e \\
\hline
\end{tabular}
\end{center}
\end{document}


Without more information, I've kept the column alignment as-is. However, a centred display would look better here.

-
Very simple answer @Werner.... how can we have it in the center? :) –  karathan Feb 5 '13 at 17:30
@karathan - To center-set the columns, you could replace *{8}{r} with *{8}{c} in the argument of the tabular environment. –  Mico Feb 5 '13 at 17:33
Really with LaTeX sometimes laugh at myself ... the solution is in my legs and I look at the stars.:) I tried to do it with, \centering and the result was something else, thanks @Mico –  karathan Feb 5 '13 at 17:39
The ascenders of the b and d nearly touch the rule, so I think you might want a little more space between the rule and the entries. –  Benjamin McKay Feb 5 '13 at 17:42
Thank you very much for the timely answer Werner. Yes, a center display looks better. –  Manoj Bose Feb 5 '13 at 17:55