# hyphenation of abbreviation using the glossaries package

As I have unfortunately recognized, using the abbreviation functionality of the glossaries package leads to undesired hyphenation of longer abbreviation at the end of lines.

The following code is an mwe to demonstrate this behaviour:

\documentclass{scrreprt}
\usepackage[acronyms,shortcuts]{glossaries}

\newacronym{RuPhos}{RuPhos}{abbreviation with more than three letters}

\begin{document}

\noindent
this is a random text to ensure hyphenation of the abbreviation  word fills the linei
\acs{RuPhos}
this is a random text to ensure hyphenation of the abbreviation
this is a random text to ensure hyphenation of the abbreviation
this is a random text to ensure hyphenation of the abbreviation

\end{document}


Compiling this code with either pdflatex or latex, dvips, ps2pdf leads to "RuP-hos".

I am aware of the possibility to enclose the short form in an mbox to prevent hyphenation

\newacronym{RuPhos}{\mbox{RuPhos}}{abbreviation with more than three letters}


or to manually specify the hyphenation using the following command

\hyphenation{RuPhos}


but I would like to know if there is a more convenient and maybe even automatized way to achieve this.

• I don't get the unwanted hyphenation with your MWE. You could redefine the \newacronym command to automatically include an \mbox or to call the \hyphenationcommand. – Georg May 20 '17 at 16:53

Since the abbreviation is formatted using \acronymfont you can just do:

\renewcommand*{\acronymfont}[1]{\mbox{#1}}


If you're using a style that changes the formatting (for example, smallcaps) then include the font changing command as well. For example:

\documentclass{scrreprt}
\usepackage[acronyms,shortcuts]{glossaries}

\setacronymstyle{long-sc-short}
\renewcommand*{\acronymfont}[1]{\mbox{\textsc{#1}}}

\newacronym{RuPhos}{RuPhos}{abbreviation with more than three letters}

\begin{document}

\noindent
this is a random text to ensure hyphenation of the abbreviation  word fills the
linei
\acs{RuPhos}
this is a random text to ensure hyphenation of the abbreviation
this is a random text to ensure hyphenation of the abbreviation
this is a random text to ensure hyphenation of the abbreviation

\end{document}

• A crucial point of this solution is, that it only works with the use of \acs, if you use \gls instead, \acronymfont is not used and hence it will still break the line beeing hyphenated. Check my example at tex.stackexchange.com/questions/550652/… – TobiBS Jun 22 at 22:03

If you are satisfied with the solutions you gave and just want to automate them then you could add

\let\oldnewacronym\newacronym
\renewcommand\newacronym[3]{\oldnewacronym{#1}{\mbox{#2}}{#3}}


or

\let\oldnewacronym\newacronym
\renewcommand\newacronym[3]{\hyphenation{#2}\oldnewacronym{#1}{#2}{#3}}


after you loaded the glossaries package but before you define the acronyms.

• Thank you for this solutions, I have a modified alternative to make use of the optional argument: tex.stackexchange.com/questions/550652/… Be aware however that with you first approach, the \mbox in the acronym you break the ability of capitalization through \Gls! – TobiBS Jun 22 at 22:05