wspr/herries-press — Issue #16: hyphenat: Feature Request: Breakable ZWNJ and Nothing
Author: Wrzlprmft
Created: 2012-01-01 02:15:56+00:00
State: open

While in the English language word compositions without any joining character (such as a hyphen or space) such as “catfish” or “breakthrough” are very rare, this is the predominant case in German. This alone can often leads to long words, which break the hyphenation algorithm. Additionally, on the composing boundary you do not want ligatures to happen, e.g., for lack of a better example for English: If using a font with a kt-ligature, you do not want it to be used in “breakthrough”. In such cases you want to use a zero-width non-joiner (ZWNJ) at the boundary, which is a sure way to break hyphenation. Finally the composing boundary is (little surprisingly) a place, where hyphenation may (even should) happen. So you usually want to place a command there that tells LaTeX that:

* it must not use a ligature here
* it should hyphenate, whatever comes before and after, as if it they were words of their own
* it may hyphenate here

Such a command is like hyphenat’s `\colonhyp{}`, just that the colon is replaced by a ZWNJ. I succeeded in creating such a command myself by adding the following lines to hyphenat’s code at the appropriate place, however mainly copying without understanding:

\newcommand{\BreakableZWNJ}{\leavevmode%
\prw@zbreak {\kern0pt}\discretionary{-}{}{}\prw@zbreak}
\DeclareRobustCommand{\ZWNJhyp}{%
\ifmmode {\kern0pt}\else\BreakableZWNJ\fi}

(I used `{\kern0pt}` as a ZWNJ here, since `\/` and `"|` (as supplied by babel/polyglossia) did not work as intended. I am not entirely happy with this ZWNJ either, so if there is a better solution …)

Furthermore, I found a “`\nothinghyp{}`” to be useful for some odd purposes (really short justified lines with intials), so I think it may not do any harm to supply such a command too. My code for this was:

\newcommand{\BreakableNothing}{\leavevmode%
\prw@zbreak\discretionary{-}{}{}\prw@zbreak}
\DeclareRobustCommand{\nothinghyp}{%
\ifmmode\else\BreakableNothing\fi}

Sorry for not going the Git way here, but as I already mentioned: I do understand very little of the pasted code, so I preferred to thouroughly explain my intentions.