TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I would like to create a table that is labelled like the axis of a plot, i.e. a vertical orientation of the y-axis' label. This is what I have

&&\multicolumn{3}{|c|}{Category A}\\
&&little&some&a lot\\
Category B&some&&\\
&a lot&&&\\\hline

But I would like the text 'Category B', to be vertical spanning from row 3-5 instead of being horizontal in row 4.

How do I achieve that?

share|improve this question
have a look at rotate+table+labels‌​, it seems like there are quite a few questions that have dealt with similar issues – cmhughes Apr 18 '12 at 11:32
up vote 6 down vote accepted

enter image description here

Depending on exactly what you need, you may wish to adjust the spacing, but something like this:

Here I have added extra \hline to the table to make the spacing clearer, also the heading is backspaced by the depth of a table row so that it exactly fits (The first version got this wrong) this spacing may be adjusted in individual cases to gain better visual spacing if that is needed.

enter image description here




\savebox\zzz{Category B}
&&\multicolumn{3}{|c|}{Category A}\\
&&little&some&a lot\\\hline
\mystrut\rotatezzz&a lot&&&\\\hline

share|improve this answer
Thanks, this works. Is there a way to measure the width of the rotated box and give each of the last 3 rows 1/3 of that as height? And then to vertically center the text in those rows? – D.Roepo Apr 20 '12 at 15:12
see updated answer – David Carlisle Apr 20 '12 at 15:31
Nice, applied that to all tables! Imagine 'Category B' is 'Category LongName'. Is it possible to get something like \savebox\zzz{Category\\LongName}? Also is the vertical text closer to the bottom of the last than to the top of the first row. Can that be centred? – D.Roepo Apr 20 '12 at 16:03
as always with savebox if you want multiple lines you need to put it in a parbox (or better here a tabular as then you can still measure so \savebox\zzz{\begin{tabular}{l}Category\\ LongName\end{tabular}} you can use \rlap{\hspace{10pt}\usebox\zzz} to raise it a bit, you need to choose the value by eye.... centering row spans automatically is tricky unless you re-implement almost all of latex table internals – David Carlisle Apr 20 '12 at 16:13
The arithmetic in that mystrut is nonsense I will update in a bit (I am adding not subtracting for a start: you should do what I meant not what I wrote:-) – David Carlisle Apr 20 '12 at 16:15

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.