Sideways label for table with alternating row colours

I have a multirow column in a longtable with alternating coloured rows. The alternating colour overflows into the multirow. Colouring the first column white wipes out the specialrule but doesn't seem to make a difference to the row colour. I am not sure how to deal with this. Would you have any pointers?

Here is my MWE:

\documentclass[10pt]{article}
\usepackage{longtable, booktabs, rotating, multirow}
\usepackage[table]{xcolor}
\definecolor{tblue}{HTML}{F1F5FA}
\definecolor{tgrey}{HTML}{dddddd}
\renewcommand{\arraystretch}{1.6}
\usepackage{arydshln}
\arrayrulecolor{tgrey}
\begin{document}
\rowcolors{1}{tblue}{white}\centering
\begin{longtable}{>{\columncolor{white}}l !{\color{white}\vrule width 4pt}>{\raggedright}p{3in} p{2.4in}}
\hiderowcolors
&\textbf{Selected representative vars}&\textbf{Correlated vars ($\rho \ge$ 0.8)}\\
\specialrule{0.01em}{0.02em}{0.02em}
\endhead
\specialrule{0.01em}{0.0em}{0em}
\endfoot
\specialrule{0.01em}{0.0em}{0em}
&\multicolumn{2}{l}{\textbf{Subheading}}\\
\specialrule{0.01em}{0.0em}{0em}
\showrowcolors
& Something & Something else
\\
& Something & Something else
\\
& Something & Something else
\\
\hiderowcolors
\specialrule{0.01em}{0.0em}{0em}
&\multicolumn{2}{l}{\textbf{Subheading}}\\
\specialrule{0.01em}{0.0em}{0em}
\showrowcolors
& Something & Something else
\\
& Something & Something else
\\
& Something & Something else
\\
\multirow{-9}{*}{\begin{sideways}\centering \textbf{A long line of sideways text}\end{sideways}}
\end {longtable}
\end{document}


Here is what the table looks like currently:

-

1 Answer

A different way of thinking: Insert the vertical text using zero-width boxes, rather than giving its own column.

\documentclass[10pt]{article}
\usepackage{longtable, booktabs, graphicx, multirow}
\usepackage[table]{xcolor}
\definecolor{tblue}{HTML}{F1F5FA}
\definecolor{tgrey}{HTML}{dddddd}
\renewcommand{\arraystretch}{1.6}
\usepackage{arydshln}
\arrayrulecolor{tgrey}
\begin{document}
\rowcolors{1}{tblue}{white}\centering
\begin{longtable}{!{\color{white}\vrule width 4pt}>{\raggedright}p{3in} p{2.4in}}
\hiderowcolors
\textbf{Selected representative vars}&\textbf{Correlated vars ($\rho \ge$ 0.8)}\\
\specialrule{0.01em}{0.02em}{0.02em}
\endhead
\specialrule{0.01em}{0.0em}{0em}
\endfoot
\specialrule{0.01em}{0.0em}{0em}
\multicolumn{2}{l}{\textbf{Subheading}}\\
\specialrule{0.01em}{0.0em}{0em}
\showrowcolors
Something & Something else \\
Something & Something else \\
Something & Something else \\
\hiderowcolors
\specialrule{0.01em}{0.0em}{0em}
\multicolumn{2}{l}{%
\llap{\smash{\rotatebox[origin=c]{90}{%
\hspace*{2\normalbaselineskip}% Vertical adjustment
\textbf{A long line of sideways text}}}%
\hspace*{\dimexpr\tabcolsep+2em}}% Horizontal adjustment
\textbf{Subheading}}\\
\specialrule{0.01em}{0.0em}{0em}
\showrowcolors
Something & Something else \\
Something & Something else \\
Something & Something else \\
%\multirow{-9}{*}{\begin{sideways}\centering \textbf{A long line of sideways text}\end{sideways}}
\end{longtable}
\end{document}


The sideways text is rotated using \rotatebox[origin=c]{90}{..} from graphicx (also included when using rotating). origin=c pivots the rotation around the centre of the object. \llap create a left overlap, pushed outward by \tabcolsep+2em. This effectively places the sideways text 2em from the left margin of the longtable. Also, since I chose an element not exactly in the middle (vertically) of the table, pushing it upward by 2\normalbaselineskip allows for proper vertical alignment with the rest of the table's body (8 rows).

\smash removes all vertical height + depth from an object, thereby not affecting the row height.

-
It works most beautifully! With your code, I added several sideways labels without the need for adding a whole column and altering my pre-existing tables! Thanks so very much for this solution!! :-) –  Ariel May 21 '12 at 16:21