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

  • See my edited answer @musicman – subham soni Apr 27 '14 at 17:11
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

  • @musicman please see my updated answer. – Gonzalo Medina Apr 27 '14 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 Apr 27 '14 at 17:01
  • @musicman without using "m", I don't know if there's a better way. – Gonzalo Medina Apr 27 '14 at 17:03
  • See my edited answer @GonzaloMedina – subham soni Apr 27 '14 at 17:12
  • @subhamsoni I already did? What's the point on giving the same answer I gave? – Gonzalo Medina Apr 27 '14 at 17:13

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.