[Tex/LaTex] How to Rotate Text in Table across column spanning many rows

rotatingtables

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

.

Best Answer

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}