1

I have a table with a rotated header, and some makecells afterwards to fit the rotated header on one line:

\documentclass{article}
\usepackage{makecell}
\usepackage{graphicx}
\usepackage{booktabs}
\usepackage{rotating}

\renewcommand\theadfont{\normalsize}

\begin{document}
\begin{table}[t]
\centering
\begin{tabular}{cccc}
    \toprule
     & & \multicolumn{2}{c}{\textbf{Condition A}} \\
     & & A1 & A2 \\
    \cmidrule{3-4}
    \settowidth\rotheadsize{\theadfont \textbf{Condition B}}
    \rothead{\textbf{Sampling}} & \makecell{B1 \\ B2} & \makecell{xx/xx \\ xx/xx} & \makecell{xx/xx \\ xx/xx} \\
    \bottomrule
\end{tabular}
\caption{Results under different conditions}
\end{table}
\end{document}

I'd like the text in the makecells to be evenly vertically spaced in the cell, rather then centred in the middle. Is there an easy way to do this?

2
  • What do you mean with ‘vertically distributed’? – Bernard Mar 18 '19 at 14:34
  • As in, so they fill the cell with the same amount of space above, between and below the two lines of text rather than being clustered in the center. – Kris Mar 18 '19 at 14:46
1

If I've well understood what you want, \rotatebox[origin=c] does the job:

\documentclass{article}
\usepackage{makecell}
\usepackage{graphicx}
\usepackage{booktabs}
\usepackage{rotating}

\renewcommand\theadfont{\normalsize}

\begin{document}

\begin{table}[t]
\centering
\renewcommand{\cellset}{\renewcommand{\arraystretch}{1.6}}
\begin{tabular}{cccc}
    \toprule
     & & \multicolumn{2}{c}{\textbf{Condition A}} \\
     & & A1 & A2 \\
    \cmidrule{3-4}
   \rotatebox[origin=c]{90}{\textbf{Sampling}} & \makecell{B1 \\ B2} & \makecell{xx/xx \\ xx/xx} & \makecell{xx/xx \\ xx/xx} \\
    \bottomrule
\end{tabular}
\caption{Results under different conditions}
\end{table}

\end{document} 

enter image description here

2
  • Ah, sorry, I meant I wanted the lines B1 // B2 etc to be evenly spaced inside the box created by the rotatebox. – Kris Mar 18 '19 at 14:57
  • @Kris: I've updated my code. The value of \arraystretch was found by trial and error (so you can't change it within the same table). – Bernard Mar 18 '19 at 15:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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