# Language switch for glossaries acronyms

I use the glossaries package for acronyms of different languages. The problem I face now is that when my main text is e.g. german and I have an english acronym used for the first time within the text it sometimes happen that the hyphenation of the long form is wrong.

Is there a way to state the language on a per-acronym basis like the langid field in biblatex?

Edit:

MWE 1 (main language ngerman, and english acronym). In this MWE you see that the word Application gets hyphenated as Applicati-on which is wrong. Correct hyphenation would be Ap•pli•ca•tion. One workaround would be to write \newacronym{am}{AM}{\foreignlanguage{english}{Application Management}}. However, this is a bit bothersome.

\documentclass[a4paper]{article}

\usepackage[english,ngerman]{babel}

\usepackage{glossaries}

\makeglossaries

\setacronymstyle{long-short}
\newacronym{am}{AM}{Application Management}

\begin{document}

\rule{0.82\textwidth}{1pt} \gls{am}.

\printglossaries
\end{document}


MWE 2 (main language English, and English acronym). Here no hyphenation occurs, which is a bit strange, because an overfull hbox is the result. My expectation was that the word would be hyphenated as Applica-tion. However, this is better than a wrong hyphenation, because it is obvious and visible.

\documentclass[a4paper]{article}

\usepackage[english]{babel}

\usepackage{glossaries}

\makeglossaries

\setacronymstyle{long-short}
\newacronym{am}{AM}{Application Management}

\begin{document}

\rule{0.82\textwidth}{1pt} \gls{am}.

\printglossaries
\end{document}

• Could you give us an MWE please? Have you tried changing the language in the acronym's declaration? Dec 23, 2015 at 8:28
• @LaRiFaRi I've added the MWE. I hope it's clearer now. Dec 23, 2015 at 10:49
• Much clearer. Thanks. This should work: \newacronym{am}{AM}{\foreignlanguage{english}{Application Management}} Dec 23, 2015 at 10:52
• @LaRiFaRi I've just complement your suggestion at the same time ;). It works, but I'm searching for a solution which is less verbose. For example just writing newacronym{am}{AM}{Application Management}{english} would be nice. Dec 23, 2015 at 10:54
• I would not change the existing commands for that. Just do a new one. \newcommand\newforeignacronym[5][]{\newacronym[#1]{#2}{#3}{\foreignlanguage{#5}{#4}}} and then \newforeignacronym{am}{AM}{Application Management}{english}. You can name your new command whatever you like in order to make it short. Dec 23, 2015 at 11:04

If you do not want to type \foreignlanguage every time as I have suggested above, you have to define a new command or redefine the existing (which I would not recommend).

% arara: pdflatex
% arara: pdflatex

\documentclass[a4paper]{article}
\usepackage[english,ngerman]{babel}

\usepackage{glossaries}
\newcommand\newforeignacronym[5][]{\newacronym[#1]{#2}{#3}{\foreignlanguage{#5}{#4}}}
\newforeignacronym{am}{AM}{Application Management}{english}

\begin{document}
\rule{0.82\textwidth}{1pt} \gls{am}.
\end{document}