0

In German, abbreviations can be part of compound words that need to be hyphenated, like "Java-API".

My problem is that when I write Java-\gls{api}, I never get a line break after the hyphen. I managed to find out that the problem is not the abbreviation, but the hyperlink, and that it occurs with all kinds of links and is reproducable without glossaries.

MWE:

\documentclass[a4paper]{article}
\usepackage{showframe}
\overfullrule=1mm
\usepackage{hyperref}
\usepackage[nogroupskip,toc=true]{glossaries}
\usepackage[abbreviations]{glossaries-extra}
\newabbreviation{api}{API}{Application Programming Interface}
\begin{document}
    \gls{api}

    xxxxxx xxxxxxx xxxxxxx xxxxx xxxxxx xxxxxxxx xxxxx xxxxxxxxxx Java-\gls{api} xxxxxx

    xxxxxx xxxxxxx xxxxxxx xxxxx xxxxxx xxxxxxxx xxxxx xxxxxxxxxx Java-API xxxxxx

    xxxxxx xxxxxxx xxxxxxx xxxxx xxxxxx xxxxxxxx xxxxx xxxxxxxxxx Java-\url{xxx} xxxxxx
\end{document}

enter image description here

How can I allow a line break between Java- and the hyperlink?

I'm using hyperref 2019/09/28 v7.00a with LuaLaTeX 1.10.0 from TexLive 2019.52579 on Arch Linux.

4
  • 1
    I get a line break with your example. How do you compile and is your tex system up-to-date? May 20 '20 at 12:51
  • @UlrikeFischer please see the edit
    – corvus_192
    May 20 '20 at 13:08
  • If you are writing in German, you are probably loading \usepackage[ngerman]{babel}, in which case Java"=\gls{api} apparently works. "= instead of - may be a good idea anyway, in case you have longer compounds like Dampfschifffahrts"=API. (Cf. tex.stackexchange.com/q/2706/35864, tex.stackexchange.com/q/63232/35864)
    – moewe
    May 20 '20 at 15:53
  • I'm using babel, but without the shorthands (they cause too many issues with other packages for me). I can confirm that it works with \hyp from the hyphenat package, but it's not really satisfactory.
    – corvus_192
    May 20 '20 at 20:57

Your Answer

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

Browse other questions tagged or ask your own question.