4

I have a table that has some vertical column headers, but they keep colliding with the table title. I've tried making the top row taller but that did not help the solution, simply moved all the text higher but they were still colliding

A simple example is given below

\documentclass[12pt,leftblank]{article}
\usepackage{amsmath, amsthm, amssymb, mathtools}
\usepackage{adjustbox}
\usepackage{rotating}

\begin{document}
\begin{table}[H]
\centering
\caption{Table Title}
\footnotesize
\begin{tabular}{lll}
    & \begin{rotate}{60}Long Column Title 1\end{rotate} & \begin{rotate}{60}Long Column Title 2\end{rotate} \\
    Row 1 & Data & Data\\
    Row 2 & Data & Data\\
\end{tabular}
\end{table}

\end{document}

2 Answers 2

4

From the documentation of the rotating package:

rotate prints the contents turned through an arbitrary angle but does not leave any space for the result

You have to use turn, but this would leave the horizontal space. I propose a new command that only makes zero width, but keeps the height.

\documentclass[12pt,leftblank]{article}
\usepackage{amsmath, amsthm, amssymb, mathtools}
\usepackage{adjustbox}
\usepackage{rotating}

\newcommand{\zwturn}[2]{%
  \makebox[0pt][l]{\begin{turn}{#1}#2\end{turn}}%
}

\begin{document}
\begin{table}
\centering
\caption{Table Title}
\medskip

\footnotesize
\begin{tabular}{lll}
  & \zwturn{60}{Long Column Title 1}
  & \zwturn{60}{Long Column Title 2} \\
Row 1 & Data & Data\\
Row 2 & Data & Data\\
\end{tabular}
\end{table}

\end{document}

enter image description here

However, it's better to avoid rotated headers.

3

You ca also use \rotatebox macro provided by graphicx package.

\documentclass[12pt,leftblank]{article}
\usepackage{amsmath, amsthm, amssymb, mathtools}
\usepackage{adjustbox}
%\usepackage{rotating}

\newcommand{\zwturn}[2]{%
  \rotatebox[origin=c]{#1}{#2}%
}

\begin{document}
\begin{table}
\centering
\caption{Table Title}
\medskip

\footnotesize
\begin{tabular}{lll}
  & \zwturn{60}{Long Column Title 1}
  & \zwturn{60}{Long Column Title 2} \\
Row 1 & Data & Data\\
Row 2 & Data & Data\\
\end{tabular}
\end{table}

\end{document}

enter image description here

You must log in to answer this question.

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