Search code examples
latexword-wrap

Wrapping a word in LaTeX


How can you wrap the word longWord_anotherLongWord_long_again to many lines in the tabular environment?

The word should be

LongWord_
anotherLongWord_
long_again

Solution

  • \bgroup
      \catcode`\_=13%
      \def_{\textunderscore\hskip0pt}%
      \begin{tabular}{|l|l|p{4.5cm}}
        test_444 & 555 & longWord_anotherLongWord_long_again_too_long_very_long_ha_ha_ha_ha\\\hline
      \end{tabular}
    \egroup
    

    Be careful though; this will produce the desired result, but TeX will complain about underfull boxes.