# tabu: adding struts before and after cell content

I am using tabu package to easily typeset my tables. So, there are few problems that i have solved:

• vertical spacing (from cell content to borders) is less than line height and line depth, so i use \struts before and after content;
• LaTeX does not break line at the beginning, so i use \hspace{0pt} at the very beginning of cell content to make LaTeX break line and add hyphenation;
• LaTeX does not hyphenate words with macro, so i have to add \hspace{0pt} between end of cell content and \strut.

Column spec looks like:

\begin{tabu} to \linewidth {|>{\strut\hspace{0pt}}X[0.4,L]<{\hspace{0pt}\strut}|%
>{\strut\hspace{0pt}}X[0.115,C]<{\hspace{0pt}\strut}|%
>{\strut\hspace{0pt}}X[0.115,C]<{\hspace{0pt}\strut}|%
>{\strut\hspace{0pt}}X[0.2,C]<{\hspace{0pt}\strut}|%
>{\strut\hspace{0pt}}X[0.17,C]<{\hspace{0pt}\strut}|}\hline


How can i declare a new column type (for example, Y) with these features using X type? Like this (but this does not work):

\newcolumntype{Y}{>{\strut\hspace{0pt}}X<{\hspace{0pt}\strut}}
\tabucolumn Y

• Add \nolinebreak before \hspace{0pt}\strut in the "end part" or you'll get an empty line in many occasions. – egreg Oct 17 '13 at 10:34

## 1 Answer

Your way of defining a new column type is not incorrect. But I guess you miss the possibility of passing arguments to the X specifier. This can be done as follows with a format requiring an argument:

\documentclass{article}

\usepackage{tabu}
\newcolumntype{Y}[1]{>{\strut\hspace{0pt}}X[#1]<{\hspace{0pt}\strut}}
\tabucolumn Y

\begin{document}
\begin{tabu} to \linewidth{Y{.5,C} Y{.5}}
Text text and longer words with extra line&  Text text
and longer words with indisputably elegant hyphenation algorithm\\
\end{tabu}
\end{document}