4

I use the cloze package to create cloze texts. The documentation states specifically (p. 4):

The command \cloze doesn’t change the behavior of the hyphenation.

But when I try the given example, I see that words are not properly hyphenated anymore:

\documentclass{article}
\usepackage{cloze}
\begin{document}
Telekommunikationsüberwachung geht Unternehmenssteuerfortentwicklungsgesetz
\cloze{Telekommunikationsüberwachung} geht \cloze{Unternehmenssteuerfortentwicklungsgesetz}
\end{document}

Compilation result

Can someone confirm this? Is this "fixable"? What worries me is that I kind of remember that hyphenation worked when I tested it a while ago.

  • 1
    I tried the example enabling German hyphenation; the result is the same (no hyphenation) with TeX Live 2015, 2016 and 2017/pretest. – egreg Apr 30 '17 at 19:33
  • 1
    The source code of the documentation shows that you have to insert hyphenation points: \cloze{Unter\-nehmens\-steuer\-fort\-entwicklungs\-gesetz} – Ulrike Fischer Apr 30 '17 at 19:37
4

If I look in the source for the documentation (file cloze.dtx), I see

\begin{clozeexample}
es
\cloze{Te\-le\-kom\-mu\-ni\-ka\-tions\-ü\-ber\-wach\-ung}
geht
\cloze{Un\-ter\-neh\-mens\-steu\-er\-fort\-ent\-wick\-lungs\-ge\-setz}
\cloze{Ab\-teil\-ungs\-lei\-ter\-in}
\cloze{Ober\-kom\-mi\-sar\-in}
auch
\cloze{Fil\-lial\-lei\-ter\-in}
kurz
\cloze{Ober\-kom\-mi\-sar\-in}
\cloze{Un\-ter\-neh\-mens\-steu\-er\-fort\-ent\-wick\-lungs\-ge\-setz}
\cloze{Fil\-lial\-lei\-ter\-in}
\cloze{Metz\-ger\-mei\-ster\-in}
in
\cloze{Ab\-teil\-ungs\-lei\-ter\-in}
der
\cloze{Ober\-kom\-mi\-sar\-in}
\cloze{Hoch\-lei\-stungs\-flüs\-sig\-keits\-chro\-ma\-to\-gra\-phie}
\cloze{Fil\-lial\-lei\-ter\-in}
Kürze
\cloze{Un\-ter\-neh\-mens\-steu\-er\-fort\-ent\-wick\-lungs\-ge\-setz}
\cloze{Metz\-ger\-mei\-ster\-in}
liegt
\cloze{Ab\-teil\-ungs\-lei\-ter\-in}
die
\cloze{Metz\-ger\-mei\-ster\-in}
\cloze{Ab\-teil\-ungs\-lei\-ter\-in}
Würze
\cloze{Ober\-kom\-mi\-sar\-in}
\end{clozeexample}

and indeed, when this is compiled, hyphenation is OK.

On the other hand, this seems to reproduce your problem:

\documentclass{article}

\usepackage{cloze}

\begin{document}

\parbox{2cm}{
  \cloze{supercalifragilisticexpialidocious}
}

\bigskip

\parbox{2cm}{
  supercalifragilisticexpialidocious
  \cloze{supercalifragilisticexpialidocious}
}

\bigskip

\parbox{2cm}{
 x
 \cloze{supercalifragilisticexpialidocious}
}

\end{document}

enter image description here

It seems that if \cloze comes after a space, it doesn't allow hyphenation. If I change the second example into

\parbox{2cm}{
  supercalifragilisticexpialidocious
  \cloze{\hspace{0pt}supercalifragilisticexpialidocious}
}

then the result is as expected:

enter image description here

A possible fix, but it works only with TeX Live 2017 (pretest, LuaTeX 1.0.4)

\documentclass{article}

\usepackage{cloze}
\usepackage{xpatch}

\xpatchcmd{\cloze}{#2}{\hspace{0pt}#2}{}{}

\begin{document}

\parbox{2cm}{
  \cloze{supercalifragilisticexpialidocious}
}

\bigskip

\parbox{2cm}{
  supercalifragilisticexpialidocious
  \cloze{supercalifragilisticexpialidocious}
}

\bigskip

\parbox{2cm}{
 x
 \cloze{supercalifragilisticexpialidocious}
}

\end{document}

enter image description here

  • Thanks for your post! Unfortunately, neither the patch nor inserting \hspace{0pt} manually into the argument (i.e. \cloze{\hspace{0pt}Unternehmenssteuerfortentwicklungsgesetz}) works with my minimal example. – FlorianL Apr 30 '17 at 20:47
  • @FlorianL It works for me, but unfortunately only with TL 2017/pretest. I added the information. – egreg Apr 30 '17 at 21:20

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.