I use longtabu package for creating tables, because the table can be very long (several pages) and i need automatic linebreak(or wordbreak) if the sentence(or a single word) in certain cell is too long.

In most cases, longtabu works well for my purpose. But, if a long word contains underscore, for example, AAA_BB_CCC_D_EEEEEE_FFF_GGGGG_HHHHHH (I replace _ as \\_ in latex), then the word can not be linebreaked and it cross out of the border of the cell to the next cell.

How can longtabu automatically break a long word with underscore? I want the very long word can automatically fit the length of a cell.


You can add some potential breaking points to the long word by adding \- (if you want a hyphen when breaking} or \allowbreak (if you don't).


\fbox{\parbox[b]{5cm}{AAA\_BB\_CCC\_D\_EEEEEE\allowbreak \_FFF\_GGGGG\_HHHHHH}}

resulting in

enter image description here

more information at this related question


You can also have a look at the hyphenat package which redefines the underscore \_ so that hyphenation can automatically occur. This adds a hyphen at the end of the line. This has the advantage that you don't have to manually add \- in every word with an underscore.



Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.