[Tex/LaTex] Prevent header hyphenation in tabulary

hyphenationtablestabulary

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.

Best Answer

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.

enter image description here

\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}
Related Question