Saturday, 1 June 2013

Making rotated adjustbox fit into cell

Making rotated adjustbox fit into cell

I tried \rotatebox, but was unable to make the rotated text vertically fit into one cell so I opted for \adjustbox instead.
\documentclass{article}
\usepackage{float}
\usepackage{multirow}
\usepackage{adjustbox}
\usepackage{tabularx}
\usepackage{rotating}
\usepackage{ragged2e}

\begin{document}
\begin{table}[h!]
  \label{tab:container}
  \caption{Some fancy table}
  \centering

  \begin{tabularx}{\textwidth}{|cl|X|X|X|X|}
    \hline
    \multirow{2}{*}{
      \adjustbox{minipage=1cm,angle=90,raise={1pt}{0pt}{0pt}}{% raise by 1pt, set height and depth to 0pt.
        \RaggedRight
        Long rotated row title
      }
    }
    & Row 1 & & & &\\

    & Row 2 &&&&\\
    \hline
  \end{tabularx}
\end{table}
\end{document}
With \adjustbox, the above code yields:
I would like the text to be "centered" so that it "fits" between the \hlines of row 1 and 2.

No comments:

Post a Comment