2

I have the following text

\documentclass[a4paper,11pt]{article}
\usepackage[a4paper,includeheadfoot,margin=2.54cm]{geometry} % for margins on a A4paper
\usepackage{fontspec}
\usepackage[english, ngerman]{babel}
\begin{document}
Auch wenn Ghor als eine der unterentwickelten Provinzen Afghanistans angesehen
wird (IWPR 19.1.2017; vgl. auch: Pajhwok o.D.p), haben 6.131 Frauen einen
neun-monatigen Alphabetisierungs- und Ausbildungskurse absolviert. ...

Auch wenn Ghor als eine der unterentwickelten Provinzen Afghanistans angesehen
wird (IWPR 19.1.2017; vgl. auch: Pajhwok o.D.p), haben 6.131 Frauen einen
neun-moatigen Gesäß-Muskulatur und Ausbildungskurse absolviert. ...

\end{document}

which produces the following output:

missing hyphen for Alphabetisierung

But somehow the word Alphabetisierung cannot be hyphenated according to Duden. Is there a way to fix it in a way that it is done automatically by using some proper packages?

Since I receive this content automatically any manual change might be overwritten next time.

UPDATE Update the text

egreg
  • 1,121,712
LeO
  • 1,451

1 Answers1

1

Following the hints and the different links I found the solution to add the following code from

\exhyphenchar -1 %required for the first paragraph
\usepackage{luacode}

%%% Lua-side code
\begin{luacode}
    function dash_to_breakable_dash ( s )
    s = unicode.utf8.gsub ( s, '(%w)"=(%a)',   '%1XYZYX%2' )
    s = unicode.utf8.gsub ( s, '(%w)%-(%a)',   '%1"=%2' ) 
    s = unicode.utf8.gsub ( s, '(%w)XYZYX(%a)', '%1-%2' )
    return s
    end
\end{luacode}

%%% TeX-side code
\newcommand\ConvertDashOn{\directlua{ 
    luatexbase.add_to_callback ( "process_input_buffer" , 
    dash_to_breakable_dash , "dash_to_breakable_dash" )}}
\newcommand\ConvertDashOff{\directlua{ 
    luatexbase.remove_from_callback ( "process_input_buffer" , 
    "dash_to_breakable_dash" )}}
\AtBeginDocument{\ConvertDashOn} 

For me that sounds magic cause I do not have an idea whats the purpose of \exhyphenchar -1 cuz without this the very first paragraph doesn't break properly. This command only hyphens Gesäß-Muskulatur badly. Gesä-ß-Muskulatur is definitely wrong!

The other approach with "= fails cause I do not get any longer the terminating - in Alphabetiesierungs-.

I have no clue if this is THE solution or if there exisits easier. At least this one works in the current scenario.

LeO
  • 1,451