# Why does \lefthyphenmin sometimes escape its containing group?

In the following example, subsequently is hyphenated in the first two cases as well as in the fourth one, but not in the third.

\documentclass{article}

\usepackage{fontspec}
\begin{document}

\begin{itemize}
\item \texttt{Lorem ipsum dolor sit amet, consectetur adipiscing} elit subsequently.
\item \texttt{\lefthyphenmin=62 Lorem ipsum dolor sit amet, consectetur adipiscing} elit subsequently.
\item {\ttfamily\lefthyphenmin=62 Lorem ipsum dolor sit amet, consectetur adipiscing} elit subsequently.
\item {\ttfamily Lorem ipsum dolor sit amet, consectetur adipiscing} elit subsequently.
\end{itemize}
\end{document}


What makes the third line different? Using \showthe\lefthyphenmin in the third line shows that it has properly reverted to 2 after the \ttfamily group, so it must be something else; but what?

The difference is whether the setting is in horizontal or vertical mode, ie before or in the paragraph, compare the 3rd and 4th versions below. I adjusted the example slightly so pdftex or xetex can be used.

\documentclass{article}
%\usepackage{fontspec}
\begin{document}

\begin{itemize}
\item \texttt{Lorem ipsum dolor sit amet, consectetur adipiscing} elit subsequently.
\item \texttt{\lefthyphenmin=62 Lorem ipsum dolor sit amet, consectetur adipiscing} elit subsequently.
\item {\ttfamily\lefthyphenmin=62 Lorem ipsum dolor sit amet, consectetur adipiscing} elit subsequently.
\item \leavevmode{\ttfamily\lefthyphenmin=62 Lorem ipsum dolor sit amet, consectetur adipiscing} elit subsequently.
\item {\ttfamily Lorem ipsum dolor sit amet, consectetur adipiscing} elit subsequently.
\end{itemize}
\end{document}

• Fascinating, thanks! But what causes the third line to be in vertical mode, while the fifth one is not? – Clément Aug 8 '16 at 23:42
• @Clément it's where the nodes setting lefthyphenmin end up, the fith doesn't set it at all, \texttt starts with an implicit \leavevmode and the extra one i added has explicit \leavevmode I may see if I can track down some documentation for this behaviour later, was too late last night:-) – David Carlisle Aug 9 '16 at 6:56
• Neat, thanks! Documentation would be great; I couldn't find much before asking here. – Clément Aug 9 '16 at 8:27
• @Clément see chat.stackexchange.com/transcript/message/31564688#31564688 (ongoing..) – David Carlisle Aug 9 '16 at 9:03