Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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

enter image description here

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,

enter image description here

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

share|improve this question
1  
Welcome to TeX.SX. –  Claudio Fiandrino Feb 5 '13 at 17:28
add comment

1 Answer

\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:

enter image description here

\documentclass{article}
\usepackage{graphicx}% http://ctan.org/pkg/graphicx
\newcommand{\spheading}[2][10em]{% \spheading[<width>]{<stuff>}
  \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{Number of Married Years} & 
    \spheading{Observed Frequency (Year 1)} & 
    \spheading{Expected Poisson Frequency (Year 1)} & 
    \spheading{Expected Binomal Frequency (Year 1)} & 
    \spheading{Expected Normal Frequency (Year 1)} & 
    \spheading{Observed Frequency (Year 2)} & 
    \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.

share|improve this answer
    
Very simple answer @Werner.... how can we have it in the center? :) –  karathan Feb 5 '13 at 17:30
2  
@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
1  
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
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.