I answered a question about hyphenating already-hyphenated words (like “already-hyphenated”, or “often-hungry”), and this came up. Consider the following input file (uncomment the first three lines if you prefer to run with LaTeX instead of plain TeX):
% \documentclass{article}
% \newcommand{\bye}{\end{document}}
% \begin{document}
\hsize = 0pt
\overfullrule = 0pt
\parindent = 0pt
\parskip=3\baselineskip
a often\penalty10000-\penalty10000\hskip0pt hungry
b often\penalty10000-\hskip0pt hungry
c often-\penalty10000\hskip0pt hungry
d often-\penalty0\hskip0pt hungry
\bye
(I know it's good practice to end \hskip 0pt
with \relax
in case the next word starts with plus
or something, but I've left it out here to avoid clutter.) The output is as below — the left side is what results with TeX / pdfTeX / XeTeX, and the right side with LuaTeX. There is a difference in the “a” and “b” cases:
Are these two differences (in the “a” and “b” cases) documented somewhere for LuaTeX? What explains the difference?
In the “a” case, with penalty 10000 both before and after the hyphen, and an empty glue after them, at first glance the behaviour of LuaTeX seems to make sense to me: we specified
\penalty10000
(aka\nobreak
) after the hyphen, so LuaTeX does not break there. But TeX does break there. Is this a bug in LuaTeX, or something that LuaTeX considers an improvement?In the “b” case, all engines other than LuaTeX somehow introduce a blank line… is that correct?
The “c” and “d” cases behave similarly: there's a blank line in the “d” case. Note that the “d” case is actually what is recommended in the (usually excellent) TeX FAQ, but it simply doesn't work: it doesn't hyphenate the first word, and it leaves a blank line.
The desired output is that of the “a” case on the left, or the “b” case on the right. Is there some sequence of boxes, glue, and penalties that will work for both non-LuaTeX and for LuaTeX?
\hsize = 0pt
to even\hsize = 0.00001pt
(or directly\hsize = 1sp
), then there are no blank lines anymore, and the discrepancy in the “b” case goes away. (The one in the “a” case is still there.) So the answer to the final question may be that we can use the “b” case, except with literally zero hsize.\hsize=0pt
is very artificial. For details see “4.4 Applying hyphenation” of the LuaTeX manual.