I have data (generated from a database, not manually typed in) that mostly fits into a table cell with fixed width, but sometimes overflows because there are long words for which no hyphenation is found.
The problem can be demonstrated with the following example:
\documentclass{article}
\usepackage[utf8]{inputenc}
\begin{document}
\begin{tabular}{|p{1cm}|p{4cm}|}
1 & Cell where normal hyphenation is possible ÄÖÜ \\
2 & CellwherenormalhyphenationisnotpossiblebutshouldwrapinsteadofoverflowÄÖÜ
\end{tabular}
\end{document}
My requirements are:
- Text never overflows the cell (assuming some minimum width such that at least a handful characters have place)
- First priority measure to achieve 1. is the normal hyphenation
- If 2. fails, it is allowed to break the word at any character, so fill the line and break just before overflow would happen (disregarding normal hyphenation rules)
In the example, the overflow in cell 1 is prevented by measure 2., the normal hyphenation. The second cell overflows. I would like to have this cell treated by measure 3.
For the answer please consider:
- Package seqsplit didn't help me
- The custom macro \wrap proposed in the answer to seqsplit - keep spaces comes near my wish, but can't handle the non-ascii characters ÄÖÜ (independent if they are input with utf8 input encoding or with \"A\"O\"U)
- As the text comes from a database, no manual editing of the cell content is wanted.
One of my ideas was to insert \linebreak[0]
after every character, to tell LaTeX that a break can be made if no better opportunities exist. But this doesn't work like intended.
Thanks for your suggestions!