# \hyphenrules does not break words

Following the code used both here and here, using \hyphenrules should inform polyglossia about breaking points within a word. The following code does not break the word in question. Why not? What can I do? I'm using version 1.43 of polyglossia.

\documentclass{article}

\usepackage{polyglossia}
\setmainlanguage{english}

\begin{hyphenrules}{english}
\hyphenation{de-ri-va-tio-nal}
\hyphenation{non-de-ri-va-tio-nal}
\end{hyphenrules}

\begin{document}

\parbox{0pt}{\hspace{0pt}non-derivational}

\end{document}


• Isn't this the standard 'LaTeX won't hyphenate words already containing a hyphen' issue (cf. tex.stackexchange.com/q/2706/35864)? If you try nonderivational you get all the break points you wish for. – moewe Feb 16 at 20:03

TeX doesn't hyphenate words that contain a hyphen (precisely the current \hyphenchar for the current font).

You can define a macro for this:

\newcommand{\hy}{-\nobreak\hspace{0pt}}


The \nobreak (that is, \penalty10000) disallows a break at the \hspace, which on the other hand allows hyphenation for the following word part.

\documentclass{article}

\usepackage{polyglossia}
\setmainlanguage{english}

\makeatletter % babel has allowhyphens
\providecommand{\allowhyphens}{\ifvmode\else\nobreak\hskip\z@skip\fi}
\makeatother

\newcommand{\hy}{-\allowhyphens}

\begin{document}

\parbox{0pt}{\hspace{0pt}non\hy derivational}

\end{document}


Here I use a safer definition, that does nothing if \allowhyphens happens to be found in vertical mode. It is essentially the same as in babel.

Note that de-ri-va-tio-nal is very wrong for English hyphenation rules.

• I looked up in Bringhurst to find out about hyphenation rules in English, but he doesn't give them. What is wrong about it, by the way? – Sverre Feb 18 at 16:30
• In AmEnglish derivation hyphenates as der-i-va-tion, according to Merriam-Webster. In BrEnglish it should be de-riv-a-tion – egreg Feb 18 at 16:50

In German language this is a well known problem, because german language contains a lot of concatenated words, single words divided by -. For example: Baden-Württemberg.

If you need hyphenation in the single words you need to add local hyphenations with \-.

In your case change non-derivational to non-de\-ri\-va\-tio\-nal.

\documentclass{article}

\usepackage{polyglossia}
\setmainlanguage{english}

\begin{hyphenrules}{english}
\hyphenation{de-ri-va-tio-nal}
\hyphenation{non-de-ri-va-tio-nal}
\end{hyphenrules}

\begin{document}

\parbox{0pt}{\hspace{0pt}non-derivational}

No - in word:
\parbox{0pt}{\hspace{0pt}nonderivational}

With local hyphenations \texttt{\-}:
\parbox{0pt}{\hspace{0pt}non-de\-ri\-va\-tio\-nal}

\end{document}
`

and its result: