# Prevent header hyphenation in tabulary

How is it possible to prevent tabulary environment hyphenating table headers?

Perhaps redefining \tyformat, but I can't find any reference to this command.

## EDIT

As suggested in comments, I tried with: \newcolumntype{}

\documentclass{article}
\usepackage{tabulary}
\begin{document}

\newcolumntype{Y}{>{\raggedright\arraybackslash}J}
\begin{tabulary}{\textwidth}{YYYYY}
\hline
& label 1 with much more text than is needed & label 2 is also very long & label 3 & label 4 \\
\hline
1 & item 1 & item 2 & item 3 & item 4 but again with too much text \\
2 & A & B & C & D \\
\hline
\end{tabulary}

\end{document}

Unfortunately The fourth column gets hyphenated, while I'd like only line breaks. I don't see differences with an ordinary {JJJJJ} in place of the custom column type.

• as in anywhere else in latex \mbox{my heading} if you want to prevent linebreaking altogether, or \raggedright (or \centering) will prevent hyphenation unless the word is wider than the box or add \hypenpenalty=10000 to prevent hyphenation even then – David Carlisle Feb 4 '14 at 15:21
• In general I'd like line-breaking without hyphenation. Anyway, wrapping a table header in \mbox causes it to overlap the following one. As for \raggedright, I tried \newcolumntype{Y}{>{\raggedright\arraybackslash}J} \begin{tabulary}{\textwidth}{YYYY} ... and hyphenation persists. – antonio Feb 4 '14 at 15:53
• If you get hyphenation in raggedright the word is longer than the column? As I said you can also set hyphenpenalty, but then it will be overful and overprint as for mbox. This is why you should always include a complete small document in your question that shows the problem. If you edit your question to have such an example, it will be much easier to answer – David Carlisle Feb 4 '14 at 16:30

If using \raggedright then latex will only hyphenate if the word is longer than the line width, so you just need to make sure that you don't get ridiculously small columns. I set tymin as 1cm here. Note you don't need to define Y for ragged right columns as tabulary pre-defines L for essentially the same thing.

\documentclass{article}
\usepackage{tabulary}
\begin{document}

\setlength\tymin{1cm}
\noindent
\begin{tabulary}{\textwidth}{LLLLL}
\hline
& label 1 with much more text than is needed & label 2 is also very long & label 3 & label 4 \\
\hline
1 & item 1 & item 2 & item 3 & item 4 but again with too much text \\
2 & A & B & C & D \\
\hline
\end{tabulary}

\end{document}