2

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.

4
  • Well, a solution depends on the text to be rotated. You can increase the rows height, or rotate some multiline \parbox (easy to do with the makecell package).
    – Bernard
    Commented Dec 11, 2014 at 23:20
  • @Bernard, Thanks for your comment. My text is roughly the same width as that shown in the figures above. So any commands you have should be helpful. Please let me know.
    – Veridian
    Commented Dec 11, 2014 at 23:43
  • Could you post a minimal example. The solutions can be very specific, or be a blend of several techniques.
    – Bernard
    Commented Dec 12, 2014 at 0:05
  • @Bernard, my example is posted in my question. I put it there to help and show what I've done. I'm using Lyx.
    – Veridian
    Commented Dec 12, 2014 at 0:13

1 Answer 1

2

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

3
  • Thanks for your response. It's insane to me that no one has written a basic table generation package that can center text properly like is done in Excel. I'm sure the problem isn't trivial, but it boggles my mind this doesn't exist.
    – Veridian
    Commented Dec 12, 2014 at 5:14
  • Do you mean centre a rotated text in a table? The problem comes mainly from multirow, which very often requires some manual adjustment.
    – Bernard
    Commented Dec 12, 2014 at 11:21
  • Yes, and that is what I had to do in my code eventually, I had to use a bunch of manual adjustment. I had to use these commands get the rotated text on two lines and the ~ symbol for spacing \rotatebox[origin=c]{90}{ Lorem Ipsum ~~~} \rotatebox[origin=c]{90}{ Lorem Ipsum Ipsum ~~~}
    – Veridian
    Commented Dec 12, 2014 at 16:20

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .