Sideways label for table with alternating row colours

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

enter image description here

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


The latest version of nicematrix (v 5.8 of 2021-01-01) has dedicated tools to deal with that problem.

\documentclass[10pt]{article}
\usepackage{nicematrix}
\usepackage{xcolor}
\definecolor{tblue}{HTML}{F1F5FA}
\definecolor{tgrey}{HTML}{dddddd}
\renewcommand{\arraystretch}{1.6}

\begin{document}
\centering
\begin{NiceTabular}{l>{\raggedright\arraybackslash}p{3in}p{2.4in}}%
  [rules/color=tgrey, code-before = {\rowcolors{3-5,7-9}{tblue}{}[restart,cols=2-]} ]
&\textbf{Selected representative vars}&\textbf{Correlated vars ($\rho \ge$ 0.8)}\\
\Hline
\Block{*-1}<\rotate\bfseries>{A long line of sideways text}
&\Block[l]{1-2}{\textbf{Subheading}}\\
& Something & Something else \\
& Something & Something else \\
& Something & Something else \\
\Hline
&\Block[l]{1-2}{\textbf{Subheading}}\\
& Something & Something else \\
& Something & Something else \\
& Something & Something else \\
\Hline
\end{NiceTabular}
\end{document}

You need several compilations (because nicematrix uses PGF/Tikz nodes).

Output of the above code