# (Why) does enumitem cause poor hyphenation?

I have noticed some cases of poor hyphenation in my document. Specifically, LaTeX is breaking hyphenated words like "large-scale" somewhere other than the hyphen. (I thought that this was something that LaTeX famously refuses to do!)

So far I've noticed the problem only in inline lists produced with the enumitem package. Perhaps this is just a coincidence, but I never see the problem in similarly worded text that doesn't use inline lists. Here's a minimal example:

\documentclass[a4paper,11pt]{article}
\usepackage[inline]{enumitem}
\begin{document}
% This paragraph is hyphenated correctly
Foo bar f:
(i)~Foo bar foo bar foo bar foo foo bar foo bar foo bar large-scale foo bar foo bar.

% This paragraph is hyphenated poorly
Foo bar f:
\begin{enumerate*}[label=(\roman*)]
\item Foo bar foo bar foo bar foo foo bar foo bar foo bar large-scale foo bar foo bar.
\end{enumerate*}
\end{document}


Output:

What's going on here? Is it enumitem that is at fault? Regardless, is there any way of fixing it? I tried changing large-scale to \mbox{large}-\mbox{scale} but LaTeX refuses to break the line at the hyphen. (In any case, I would prefer a global solution rather than one that requires me to manually locate and fix every mishyphenated word.)

• Interesting question. I can reproduce this problem when compiling the above with pdflatex or xelatex, but not with lualatex. (That is, LuaTeX, unlike XeTeX and pdfTeX, seems to hyphenate correctly, and not have this problem… in a way it's a shame, as I was hoping LuaTeX callbacks may be useful for peeking into the internal data-structures and seeing what's going on.) – ShreevatsaR Feb 12 '18 at 20:25
• Inline enumerations are hard to read and hard to recognize. I wouldn't use them at all, regardless whether done with enumitem or any other package or the manual way – user31729 Feb 12 '18 at 21:37
• @ChristianHupfer Well, even Knuth uses them in The TeXbook: in texbook.tex there are 32 instances of (1)~ (inline enumerations done manually). (Corresponding to pages 10, 27, 34, 39, 60, 80, 81, …, 403, 454 of The TeXbook.) (I doubt he uses them in TAOCP though, because there equations have labels, and so using something like “(1)” in a paragraph can be misleading as it usually means a reference to Equation 1.) – ShreevatsaR Feb 12 '18 at 22:10
• @ShreevatsaR: Yes, but it still does not look nice ;-) – user31729 Feb 13 '18 at 4:35

It is due to the fact that enumerate* boxes the contents and then does \unhbox. No wonder it doesn't happen with XeLaTeX (with nonlegacy fonts) and LuaLaTeX.

\documentclass[a4paper,11pt]{article}
\usepackage[inline]{enumitem}

\begin{document}

% This paragraph is hyphenated correctly
Foo bar f:
(i)~Foo bar foo bar foo bar foo foo bar foo bar foo bar large-scale foo bar foo bar.

% This paragraph is hyphenated poorly
Foo bar f:
\begin{enumerate*}[label=(\roman*)]
\item Foo bar foo bar foo bar foo foo bar foo bar foo bar large-scale foo bar foo bar.
\end{enumerate*}

% This paragraph is hyphenated poorly
\setbox0=\hbox{Foo bar f:
(i)~Foo bar foo bar foo bar foo foo bar foo bar foo bar large-scale foo bar foo bar.}
\leavevmode\unhbox0

\end{document}


Boxing text loses the reference to the current language and mysterious things can happen. Use mode=unboxed.

\documentclass[a4paper,11pt]{article}
\usepackage[inline]{enumitem}

\begin{document}

% This paragraph is hyphenated correctly
Foo bar f:
(i)~Foo bar foo bar foo bar foo foo bar foo bar foo bar large-scale foo bar foo bar.

% This paragraph is hyphenated poorly
Foo bar f:
\begin{enumerate*}[label=(\roman*),mode=unboxed]
\item Foo bar foo bar foo bar foo foo bar foo bar foo bar large-scale foo bar foo bar.
\end{enumerate*}

\end{document}


Another example:

\documentclass[twocolumn]{article}

\begin{document}
\parbox{0pt}{\hspace{0pt}supercalifragilistic-expialidocious test}

\vfill\eject

\setbox0=\hbox{supercalifragilistic-expialidocious}
\parbox{0pt}{\hskip0pt\unhbox0\relax\space test}

\end{document}


• Great!!!! +1 for your amazing answer. – Sebastiano Feb 12 '18 at 21:48
• Thanks, am not the OP, but natural follow-up questions: Why does \unhbox result in these poor hyphenations? Why does enumitem do things this way? Is there anything better about mode=boxed, as reason why mode=unboxed is not the default (or even only) option? – ShreevatsaR Feb 12 '18 at 21:50
• @ShreevatsaR The boxed mode allows for itemjoin*. Boxing text and unboxing it has been a weak point of TeX since the beginning. – egreg Feb 12 '18 at 21:59
• Thank you, the itemjoin* explains the need for boxed (though I guess it may still make sense to use unboxed by default, and print the warning asking to use boxed when itemjoin* is requested). Separately, I've been trying to reproduce the \setbox0=\hbox … \unhbox0 example in plain TeX (to understand it better), but not quite able to get the line-break after the s: is there some trick that happens in LaTeX that I'm missing? – ShreevatsaR Feb 12 '18 at 23:05
• I especially like how TeX threw in a hyphen after tic- to make it tic-- and thus give an en dash in the right-hand output. – Jan Feb 13 '18 at 6:04