3

How can rotated table headers be left justified?

Currently have this:

current, wrong situation

\documentclass[a4paper,8pt,twocolumn]{extarticle}
\usepackage{graphicx,multirow}
\begin{document}
    \begin{tabular}{l r c c c c c c c}
        \textbf{bla1}&\multirow{2}{*}{\textbf{bla2}}&\multirow{2}{*}{\textbf{\rotatebox{90}{bla3}}}&\multirow{2}{*}{\textbf{\rotatebox{90}{blablablablablabalbal4}}}\\
        \textbf{\textit{bla5}}\\
    \end{tabular}
\end{document}

Would ideally obtain the following: Ideal result

2

You could use something like the following:

\documentclass[a4paper,8pt,twocolumn]{extarticle}
\usepackage{graphicx}
\usepackage{makecell}
\begin{document}
    \begin{tabular}{l r c c c c c c c}
       \makecell[bc]{\textbf{bla 1} \\ \textbf{\textit{bla 5}}} &\textbf{bla2}&\textbf{\rotatebox{90}{bla3}}&\rotatebox{90}{\textbf{blablablablablabalbal4}}&\\
    \end{tabular}
\end{document}

enter image description here

Instead of the multirow commands, I have used the makecell package.

To vertically center bla 2 with respect to bla 1and bla 5 , you could use \raisebox{5pt}{\textbf{bla2}}

enter image description here

4

with use of thead and \rothead from makecell package is simple:

\documentclass{article}
\usepackage{makecell, rotating}
\renewcommand\theadfont{\normalsize\bfseries}
\renewcommand\theadalign{lb}

\begin{document}
\settowidth\rotheadsize{\theadfont blablablablablabalbal4}
    \begin{tabular}{l r c c }
\thead{bla1\\ bla5} & \thead{bla2}  & \rothead{bla3} & \rothead{blablablablablabalbal4}
    \\  \hline
a                   &   b           &   c            & d    
    \end{tabular}

\bigskip
    \begin{tabular}{l r c c }
\thead{bla1\\ bla5} & \thead[t]{\raisebox{1.2ex}{bla2}} & \rothead{bla3} & \rothead{blablablablablabalbal4}
    \\  \hline
a                   &   b           &   c            & d
    \end{tabular}

\bigskip
\settowidth\rotheadsize{\theadfont blablabalbal4}
    \begin{tabular}{l r c c }
\thead{bla1\\ bla5} & \thead[t]{bla2} & \rothead{bla3} & \rothead{blablabla blablabalbal4}
    \\  \hline
a                   &   b           &   c            & d
    \end{tabular}
\end{document}

enter image description here

personally i prefer solution on the top and on the bottom (if you can break header title into two lines).

2

One might use the \rothead command from makecell. Unfortunately you generally have to specify the value of \rotheadsize if you don't want untimely line breaks in the rotated head. Furthermore, you can't use the placement specifiers [bc] and similar. So I defined a \myrothead command which takes two optional arguments: the placement of the rotated cell (cc by default), and the rotation angle (90 by default):

\documentclass[a4paper,8pt,twocolumn]{extarticle}
\usepackage{graphicx, rotating}
\usepackage{caption, booktabs, makecell}
\usepackage{xparse}
\renewcommand{\theadfont}{\normalsize\bfseries}
\DeclareDocumentCommand{\myrothead}{O{cc}O{90}m}{\renewcommand{\theadalign}{#1}\renewcommand{\cellrotangle}{#2}
\settowidth{\rotheadsize}{\theadfont#3} \rothead{#3}}

\begin{document}

\begin{table}
  \centering
  \caption{Rotated heads}
  \begin{tabular}{l r c c c c c c c}
    \toprule
    \thead[bc]{bla 1 \\ \textit{bla 5}} &\thead[bc]{bla2}& \myrothead[bc]{bla3}& \myrothead[bc]{blablablablablabalbal4} \\
    \midrule
  \end{tabular}
\end{table}

\end{document} 

enter image description here

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.