# Hyphenat not hyphenating words with hyphens

I'm using the hyphenat package but it seems that it doesn't work with all words. I have a document with a lot of foreign Arabic words and this functionality is important.

My MWE,

\documentclass{article}
\usepackage{testhyphens}
\usepackage{hyphenat}

\hyphenation{
ha-kimm
sugh-ra
}

\begin{document}

\begin{checkhyphens}{}
al\-Hakimm
al\hyp{}Hakimm
\textit{al\hyp{}Hakimm}\\

al\-Sughra
al\hyp{}Sughra
\textit{al\hyp{}Sughra}\\

complication
\textit{complication}
\end{checkhyphens}

\end{document}


The output,

I expect al-Sughra to hyphenate as al-Sugh-ra but it doesn't. What could be the problem?

I will be using XeLaTeX in the end, so I would prefer a solution that will work there as well.

• TeX never applies hyphenation rules on words already containing an explicit hyphen. – egreg Jul 14 '17 at 8:10
• @egreg, please lookup the \hyp{} command in the hyphenat manual. It deals with this scenario specifically. Also, the first word example shows that it does indeed hyphenate words with a hyphen in them already. – Khalid Hussain Jul 14 '17 at 8:44

TeX doesn't apply hyphenation rules to words that explicitly contain a hyphen.

The \hyp command essentially produces a hyphen that's followed by a glob of glue, making it possible to apply hyphenation rules on the next word part.

Technical note. A word, in this context, is a run of characters having nonzero \lccode, starting from a glob of glue and ending at anything that doesn't fit the criterion.

Why isn't Sughra hyphenated in al\hyp{}Sughra? Because the default language is English, which has \righthyphenmin (minimum number of characters following an implicit hyphen) set to 3.

You might set \righthyphenmin to 2, but this will most likely produce wrong hyphenation of English words.

You can typeset your document and add, where necessary, \- in the needed places. Chances are you won't need to add many of these tokens. Otherwise, do

\newcommand{\alsughra}{Al-Sugh\-ra}


and use \alsughra{} in your document.

• The part about \righthyphenmin is exactly what I was looking for. Setting it to 2 fixed the problem. Please add a snippet that shows how to change the value of \righthyphenmin so that I may accept your answer. – Khalid Hussain Jul 14 '17 at 9:03
• @KhalidHussain No, setting \righthyphenmin to 2 will produce wrong hyphenation of English words. – egreg Jul 14 '17 at 9:11