4

I stumbled across an hyphenation problem which I cannot explain or solve. When I use a narrow box containing a long word with a width longer than the box width, this word is not hyphenated.

The following MWE uses the long word Rechnungsadjunktentochter with an explicit hyphenation pattern in the preamble. This word is hyphenated in a long text, also when the break points are given in a narrow box locally, but it is not hyphenated automatically.

What happens here? And, more important, how can I get my words hyphenated automatically as expected?

UPDATE: @egregs comments explain what happens. But, still, I would have to insert \hspace{0pt} at every first word of every paragraph of every narrow box (and I have MANY of them, partly automatically generated). How can I force TeX to hyphenate the first word of EVERY paragraph (inside an environment) automatically?

UPDATE 2: The solving answer is given by the latter comments of @egreg to this question.

\documentclass{article}

\hyphenation{%
  Rech-nungs-ad-junk-ten-toch-ter
}

\begin{document}

\textit{Works even without the special hyphenation pattern:}\\
bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla Rechnungsadjunktentochter

\bigskip
\textit{Local hyphenation pattern works as expected:}\\
\fbox{\begin{minipage}{3cm}
Rech\-nungs\-ad\-junk\-ten\-toch\-ter
\end{minipage}}

\bigskip
\textit{\bfseries Hyphenation pattern from the preamble does not work as expected:}\\
\fbox{\begin{minipage}{3cm}
Rechnungsadjunktentochter
\end{minipage}}

\end{document}

enter image description here

Moriambar
  • 11,466
  • 7
    TeX doesn't automatically hyphenate the first word of a paragraph; just insert \hspace{0pt} before it so that it's not (TeXnically) the first word any more. – egreg Dec 09 '13 at 08:27
  • @egreg Would you like to turn your comment into an answer? Can I force TeX to hyphenate the first word automatically for every paragraph inside my narrow box ... maybe, be redefining \par (?) – Thomas F. Sturm Dec 09 '13 at 08:36
  • I've pointed to another question where the problem is basically the same – egreg Dec 09 '13 at 08:55
  • @egreg Thank you for your help which explains what happens. I did not know that. Nevertheless, your linked answer does not solve my problem totally, since now I have to add \hspace{0pt} before every first word in every paragraph inside the box manually. That's better than to hyphenate manually. But is there no automatic way? – Thomas F. Sturm Dec 09 '13 at 09:11
  • One way to avoid having to insert \hspace{0pt} at the start of every narrow-measure paragraph would be to switch from pdfLaTeX to LuaLaTeX. Lua(La)TeX has no problems with hyphenating the first word of a paragraph. – Mico Dec 09 '13 at 10:04
  • 1
    \everypar=\expandafter{\the\everypar\hspace{0pt}} – egreg Dec 09 '13 at 10:09
  • @egreg I fear, this does not work. The first paragraph is hyphenated but the next paragraph is not hyphenated. – Thomas F. Sturm Dec 09 '13 at 12:20
  • @Mico At the moment, I have to stay with pdfLaTeX. I'm a little bit surprised that such a basic question cannot be solved with pdfLaTeX :-( – Thomas F. Sturm Dec 09 '13 at 12:26
  • 1
    @ThomasF.Sturm minipage acts on \everypar, unfortunately. A first approximation is \everypar=\expandafter{\the\everypar\everypar{\hspace{0pt}}\hspace{0pt}} (but this is only for minipage. – egreg Dec 09 '13 at 12:53
  • @egreg Yes, that's it! Thank you! Since I had this problem with a minipage, this solves my problem. I played a little bit around and found that \everypar={\hspace{0pt}} alone also works (on the cost of any predefined values). By the way, I still think that I didn't ask a duplicate question and that you finally provided another solution than you gave before on the other question. I would accept your comment as an answer :-) – Thomas F. Sturm Dec 09 '13 at 13:04
  • @ThomasF.Sturm - The inability of TeX engines prior to pdfTeX to hyphenate the very first word of a paragraph has been known for a long time. Fixing this issue required a major revision of the underlying engine... – Mico Dec 09 '13 at 13:23

0 Answers0