# Tabulary = bad vertical alignment?

I am trying to make a table and I am using the tabulary package to have nice column widths. But here the 2nd and 3rd column values are top aligned while I would want them to be vertically centered. How can I do that ?

My current code is :

\PassOptionsToPackage{setpagesize=false}{hyperref}
\documentclass[a4paper,11pt,twoside]{article}
\usepackage{amsmath,amssymb}
\usepackage[frenchb]{babel}
\usepackage[utf8x]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{amsfonts}
\renewcommand{\baselinestretch}{1.05}
\usepackage{tabulary}

\begin{document}

\begin{table}
\noindent
\begin{tabulary}{\textwidth}{ | L | C | C | }
\hline
\centering A long title that is wrapped on several lines & A long title that is wrapped on several lines & A long title that is wrapped on several lines \\
\hline
A random text & 2 & 0.025 \\
\hline
A quite long random text (wrapped on 2 lines) : $\varepsilon=0.25$ & 2 & ? \\
\hline
A quite long random text (wrapped on 2 lines) : $\varepsilon=0.5$ & 2 & 1 \\
\hline
A quite long random text (wrapped on 2 lines) : $\varepsilon=0.75$ & 2 & A \\
\hline
A very very very very very very very very very very very very very long random text : $\varepsilon=0.75$ & 2 & A \\
\hline
\end{tabulary}
\caption{A random caption.}
\end{table}
\end{document}


Thanks !

EDIT : complete code

• please always post a complete document not just a fragment – David Carlisle May 30 '14 at 19:50
• sorry, I edited and added everything. – StormRider May 30 '14 at 21:12

\PassOptionsToPackage{setpagesize=false}{hyperref}
\documentclass[a4paper,11pt,twoside]{article}
\usepackage{amsmath,amssymb}
\usepackage[frenchb]{babel}
\usepackage[utf8x]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{amsfonts}
\renewcommand{\baselinestretch}{1.05}
\usepackage{tabulary}

\setlength\extrarowheight{4pt}

\def\zz{\ifx\[$\else\aftergroup\zzz\fi} \def\zzz{\setbox0\lastbox \dimen0\dimexpr\extrarowheight + \ht0-\dp0\relax \setbox0\hbox{\raise-.5\dimen0\box0}% \ht0=\dimexpr\ht0+\extrarowheight\relax \dp0=\dimexpr\dp0+\extrarowheight\relax \box0 } \begin{document} \begin{table} \noindent \begin{tabulary}{\textwidth}{ | >{\zz}L | >{\zz}C | >{\zz}C | } \hline \centering A long title that is wrapped on several lines & A long title that is wrapped on several lines & A long title that is wrapped on several lines \\ \hline A random text & 2 & 0.025 \\ \hline A quite long random text (wrapped on 2 lines) :$\varepsilon=0.25$& 2 & ? \\ \hline A quite long random text (wrapped on 2 lines) :$\varepsilon=0.5$& 2 & 1 \\ \hline A quite long random text (wrapped on 2 lines) :$\varepsilon=0.75$& 2 & A \\ \hline A very very very very very very very very very very very very very long random text :$\varepsilon=0.75$& 2 & A \\ \hline \end{tabulary} \caption{A random caption.} \end{table} \end{document} \documentclass{article} \usepackage{tabulary} \setlength\extrarowheight{4pt} \def\zz{\ifx\[$\else\aftergroup\zzz\fi}
\def\zzz{\setbox0\lastbox
\dimen0\dimexpr\extrarowheight + \ht0-\dp0\relax
\raise-.5\dimen0\box0
}

\begin{document}

\noindent
\begin{tabulary}{\textwidth}{ | L | >{\zz}C | >{\zz}C | }
\hline
\centering Long column title .......... & Long column title .......... & Long column title .......... \\
\hline
A random text & 2 & 0.025 \\
\hline
A random quite long text : $\varepsilon=0.25$ & 2 & ABC \\
\hline
A random quite long text : $\varepsilon=0.5$ & 2 & 123 \\
\hline
A random quite long text : $\varepsilon=0.75$ & 2 & A1B \\
\hline
\end{tabulary}

\end{document}

• Thanks! But I would prefere something more automatic because here you define the spaces manually and it does not work any more if there is a row on 3 lines while others are on 2. I updated the minimal example to show that. – StormRider May 30 '14 at 21:17
• @user52730 it was more or less vertically centred, taking account of the extra height padding, I'll look at your MWE – David Carlisle May 30 '14 at 21:26
• @user52730 I'd missed zz from one column which was why it wasn't working, updated with a few other improvements – David Carlisle May 30 '14 at 21:34
• Indeed this one seems to work perfectly ! Thank you very much :) I still have 2 questions : is it possible to do it without changing the row height? And I have a problem to insert a multirow in a cell (it is no more vertically centered ...), do you know how to deal with it ? Thanks again – StormRider May 30 '14 at 21:53
• @DavidCarlisle How can I learn about \usepackage{tabulary} \setlength\extrarowheight{4pt} \def\zz{\ifx[\$\else\aftergroup\zzz\fi}\def\zzz{\setbox0\lastbox\dimen0\dimexpr\extrarowheight + \ht0-\dp0\relax\raise-.5\dimen0\box0} and configure with my self?(Is there any reference) – Hoseyn Heydari Jan 2 '15 at 11:15