[Tex/LaTex] Hyphenat not hyphenating words with hyphens

hyphenationpunctuation

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,

Hyphenation 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.

Best Answer

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.

Related Question