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

  • 2
    TeX does normally not hyphenate words that include an explicit hyphen. See tex.stackexchange.com/q/2706/35864 – moewe Jan 15 at 13:39
  • 1
    you have not said if you are using luatex or xetex – David Carlisle Jan 15 at 13:56
  • Sorry, missed that part :-/ luatex... And the q is if the problem appears due to the - ... Should it be treated diff? – LeO Jan 15 at 14:05
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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.