[Tex/LaTex] Rotated Text in Table Extending into Rows in Lyx

floatsformattinglyxspacingtables

I'm trying to create a table with some rotated text in it, but the rotated text is extending into the rows below the cell, as shown here:

enter image description here

Here is what my screen looks like in Lyx:

enter image description here

I've tried using multirow, multicolumn, and rotatetext to no avail. Right now the cells in the left-most column are rotated by using the Rotate cell by 90 function in Lyx.

Best Answer

Here is a way. I use the makecell and rotating packages, plus hhline (the ordinary horizontal last line and vertical first line do not join well) and caption (for a correct vertical spacing between caption and table):

\documentclass{article}%
\usepackage{graphicx}
\usepackage[ margin = 2.5cm]{geometry}
\usepackage{tabularx, booktabs, array, rotating, multirow}
\ usepackage{hhline}
\usepackage{makecell}
\renewcommand\theadfont{\bfseries}
\setcellgapes{3pt}

\begin{document}

\noindent\setlength\tabcolsep{4pt}\footnotesize\makegapedcells
\begin{tabularx}{\linewidth}{l|l*{3}{|X}|}
\cline{3-5}
 \multicolumn{2}{c|}{} & \thead{Lorem Ipsum Lorem Ipsum} & \thead{Lorem Ipsum Lorem Ipsum} & \thead{Lorem Ipsum Lorem Ipsum}\\
\cline{2-5}
\multirowcell{9}[-2pt]{ \rotatebox{90}{{Lorem Ipsum}}} & Lorem Ipsum & & & \\
\cline{2-5}
 & Lorem Ipsum & & & \\
\cline{2-5}
 & Lorem Ipsum & & & \\
\cline{2-5}
 & Lorem Ipsum & & & \\
\cline{2-5}
 & Lorem Ipsum & & & \\
\cline{2-5} & Lorem Ipsum & & & \\
\hhline{~|----|}
    \end{tabularx}
\end{document} 

enter image description here