4

I have a tabu-table and my default row-style is and has to be p. But I want the head-row (Column 1 and Column 2 in the MWE) to be vertically centered. How can I achieve that?

MWE:

\documentclass{article}
\usepackage{array}
\usepackage{tabu}
\usepackage{blindtext}
\usepackage{ragged2e}
\tabulinesep =0.5em
\newcommand*{\mytext}{\RaggedRight This is some blindtext with words and letters.}

\begin{document}
\begin{tabu} to\textwidth{|X[1,l,p]|X[1,l,p]|X[1,l,p]|}% m is not allowed!!!
    \hline
    Column 1 & Column 2 & Long Long very long caption, more than one line \\
    \hline
    \mytext & \mytext & \mytext \\
    \mytext & \mytext & \mytext \\
    \mytext & \mytext & \mytext \\
    \hline
\end{tabu}
\end{document}

output

1
  • See my edited answer @musicman Commented Apr 27, 2014 at 17:11

1 Answer 1

2

Since, for some reason, changing from p type columns to m type is not allowed, you can use \raisebox:

\documentclass{article}
\usepackage{array}
\usepackage{tabu}
\usepackage{blindtext}
\usepackage{ragged2e}
\tabulinesep =0.5em
\newcommand*{\mytext}{\RaggedRight This is some blindtext with words and letters.}

\begin{document}
\begin{tabu} to\textwidth{|X[1,l,p]|X[1,l,p]|X[1,l,p]|}
    \hline
    \raisebox{-\baselineskip}[0pt][0pt]{Column 1} 
      & \raisebox{-\baselineskip}[0pt][0pt]{Column 2} 
      & Long Long very long caption, more than one line \\
    \hline
    \mytext & \mytext & \mytext \\
    \mytext & \mytext & \mytext \\
    \mytext & \mytext & \mytext \\
    \hline
\end{tabu}
\end{document}

enter image description here

7
  • @musicman please see my updated answer. Commented Apr 27, 2014 at 16:55
  • Thank you. This is not so bad, but very "manually". I had to recalculate the first raisebox-param everytime the number of lines changes. Any way to automate this?
    – musicman
    Commented Apr 27, 2014 at 17:01
  • @musicman without using "m", I don't know if there's a better way. Commented Apr 27, 2014 at 17:03
  • See my edited answer @GonzaloMedina Commented Apr 27, 2014 at 17:12
  • @subhamsoni I already did? What's the point on giving the same answer I gave? Commented Apr 27, 2014 at 17:13

You must log in to answer this question.

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