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.
\documentclass[fleqn,12pt,a4paper]{article}
\usepackage{tabularx}
\begin{document}
  \begin{table}[ht]
    \begin{minipage}[b]{1 \linewidth}\centering
      \begin{tabular}{|c|c|c|c|c|}
      \hline
        Tri Sankhya & Vihbakti & Ekavachana & Dvivachana & Bahuvachana \\
      \hline
        Pra Trik    & Prathama & Su (s)     & Au &  \\
        Dvi Trik    & Dvitiya  & Am         & Aut (Au) &  \\
        Tri Trik    & Trutiya  & Ta (A)     & Bhyam & \\ 
        Cha Trik    & Chaturthi& Ne (E)     & Bhyam & \\
        Pan Trik    & Panchami & Nasi (as)  & Bhyam &   \\
        Shas Trik   & Shashthi & Nas (as)   & Os &   \\
        Sap Trik    & Saptami  & Ni (ee)    & Os &   \\
      \hline
      \end{tabular}
      \caption{Subanta Pratyaya}
    \end{minipage}
  \end{table}
\end{document} 

In the attached image, I would like to place text in the last column at 90 degree rotation but do not know how to do it. Also, how can I color the background of that entire column only.

.

share|improve this question
2  
The question about colouring the background of a column is unrelated to the main question, I'd suggest asking it as a separate question. –  Seamus Jan 29 '11 at 16:16
add comment

2 Answers 2

up vote 14 down vote accepted

Use nested tabulars:

\documentclass[12pt]{article}
\usepackage[table]{xcolor}
\usepackage{graphicx}
\usepackage{array}
\def\Tab#1{\tabular[t]{>{\rule[-1ex]{0pt}{3ex}}c}#1\endtabular}
\newcolumntype{C}{@{}c@{}}

\begin{document}
\begin{table}[ht]
\centering
 \begin{tabular}{|C|C|C|C|C|}\hline
\Tab{Tri Sankhya \\\hline 
     Pra Trik\\Dvi Trik\\Tri Trik\\Cha Trik\\ Pan Trik\\ Shas Trik\\ Sap Trik}
&
\Tab{Vihbakti\\\hline 
     Prathama\\ Dvitiya\\Trutiya\\Chaturthi\\Panchami\\Shashthi\\Saptami}
&
\Tab{Ekavachana \\\hline
     Su (s)\\Am\\Ta (A)\\Ne (E)\\Nasi (as)\\Nas (as)\\Ni (ee)}
&
\Tab{Dvivachana\\\hline
     Au\\Aut (Au)\\Bhyam\\Bhyam\\Bhyam\\Os\\ Os}
& 
\Tab{Bahuvachana\\\hline
 \cellcolor{blue!20}
  \rotatebox{90}{~\parbox{3.5cm}{%
  Here comes the rotated text, which can also be 
  typeset in several lines.
}~}}  \\\hline
\end{tabular}
\caption{Subanta Pratyaya}
\end{table}

\end{document} 

enter image description here

Another possibility, regarding to your question is:

\tabular{@{}|CC|@{}}\hline% the outer one
\begin{tabular}[t]{c|c|c|c|}
 Tri Sankhya& Vihbakti & Ekavachana & Dvivachana \\\hline
  Pra Trik  & Prathama & Su (s)     & Au         \\
  Dvi Trik  & Dvitiya  & Am         & Aut (Au)   \\
  Tri Trik  & Trutiya  & Ta (A)     & Bhyam      \\ 
  Cha Trik  & Chaturthi& Ne (E)     & Bhyam      \\
  Pan   Trik& Panchami & Nasi (as)  & Bhyam      \\
  Shas Trik & Shashthi & Nas (as)   & Os         \\
  Sap Trik  & Saptami  & Ni (ee)    & Os         \\ 
\end{tabular}
&
\begin{tabular}[t]{c}
Bahuvachana\\\hline
 \cellcolor{blue!20}
  \rotatebox{90}{~\parbox{3.2cm}{%
  Here comes the rotated text, which can also be 
  typeset in several lines.
}~}
\end{tabular}\\\hline
\endtabular

but this needs to find the correct column height for the \parbox which is done in first example automatically

enter image description here

and a third solution, which also needs a manual setting of the parbox width:

\begin{tabular}{|c|c|c|c|>{\columncolor{blue!20}}c|}\hline
          Tri Sankhya & Vihbakti    & Ekavachana & Dvivachana & \multicolumn{1}{@{}c|}{Bahuvachana} \\
       \hline
          Pra Trik  & Prathama   & Su (s)& Au &  \\
          Dvi Trik & Dvitiya & Am & Aut (Au) &  \\
          Tri Trik  & Trutiya  & Ta (A) & Bhyam & \\ 
          Cha Trik  & Chaturthi  & Ne (E) & Bhyam & \\
          Pan   Trik & Panchami  & Nasi (as)& Bhyam &   \\
          Shas Trik & Shashthi  & Nas (as)& Os &   \\
          Sap Trik & Saptami & Ni (ee) & Os &   
  \rotatebox{90}{\makebox(0,0)[lc]{~\parbox{3.2cm}{%
  Here comes the rotated text, which can also be 
  typeset in several lines.}~}}
\\\hline
\end{tabular}
share|improve this answer
    
I see that you removed the table cells and put tab in there. I was wondering if there is a way achieve the same leaving the table structure intact? –  Aku Jan 29 '11 at 17:22
1  
@Aku: yes, but then you have to find out the column height manually, which is no real fun ... in the first example it is done automatically. See also my edit –  Herbert Jan 29 '11 at 17:38
    
@Aku I added a third solution –  Herbert Jan 29 '11 at 17:50
    
Thanks a lot for your help –  Aku Jan 29 '11 at 18:04
add comment

You can rotate a multi-line text using the adjustbox package. It also allows you too set the official height to zero so that you can place it in the last cell of the column where it also covers the upper cells, without interfering with the cell sizes.

For such small boxes you should use left alignment of text, best using \RaggedRight from the ragged2e package as shown.

\documentclass[fleqn,12pt,a4paper]{article}
\usepackage{tabularx}
\usepackage[table]{xcolor}
\usepackage{adjustbox}
\usepackage{ragged2e}
\begin{document}
  \begin{table}[ht]
    \def\C{\cellcolor{blue!50}}
    \begin{minipage}[b]{1 \linewidth}\centering
      \begin{tabular}{|c|c|c|c|c|}
      \hline
        Tri Sankhya & Vihbakti & Ekavachana & Dvivachana & Bahuvachana \\
      \hline
        Pra Trik    & Prathama & Su (s)     & Au & \C  \\
        Dvi Trik    & Dvitiya  & Am         & Aut (Au) & \C  \\
        Tri Trik    & Trutiya  & Ta (A)     & Bhyam & \C \\ 
        Cha Trik    & Chaturthi& Ne (E)     & Bhyam & \C \\
        Pan Trik    & Panchami & Nasi (as)  & Bhyam & \C  \\
        Shas Trik   & Shashthi & Nas (as)   & Os & \C  \\
        Sap Trik    & Saptami  & Ni (ee)    & Os & \C
        \adjustbox{minipage=3.2cm,angle=90,raise={1pt}{0pt}{0pt}}{% raise by 1pt, set height and depth to 0pt.
            \RaggedRight
            Here comes the rotated text, which can also be 
            typeset in several lines.
        }
        \\
      \hline
      \end{tabular}
      \caption{Subanta Pratyaya}
    \end{minipage}
  \end{table}
\end{document} 

Result

share|improve this answer
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.