I use the style provided in this answer by @NicolaTalbot to emphasise the long form of acronyms in combination with an additional protected whitespace and support for foreign acronyms (see here). Recently I found the command \glsenableentrycount
and \cgls
which are quite useful.
However, when I have an acronym which is only used once it's long form is not emphasized. This is a problem for the foreign acronyms as I emphasize text in foreign languages. So what I like to achieve in the MWE is that:
Application Management
should be emphasized likeSupport Vector Machine
, because it's in a foreign languageDeutsches Institut für Normung
should not be emphasized, because it's not in a foreign language and only used once.Zum Beispiel
should be emphasized even if it's not in a foreign language, because it's the long form of an acronym which is used more than once.
How can I achieve this?
MWE:
\documentclass[a4paper]{article}
\usepackage[english,ngerman]{babel}
\usepackage{glossaries}
\newacronymstyle{emfirst-long-sp-short}
{%
\GlsUseAcrEntryDispStyle{long-sp-short}%
}%
{%
\GlsUseAcrStyleDefs{long-sp-short}%
\renewcommand*{\genacrfullformat}[2]{%
\emph{\glsentrylong{##1}}##2\glsacspace{##1}%
(\protect\firstacronymfont{\glsentryshort{##1}})%
}%
\renewcommand*{\Genacrfullformat}[2]{%
\emph{\Glsentrylong{##1}}##2\glsacspace{##1}%
(\protect\firstacronymfont{\glsentryshort{##1}})%
}%
\renewcommand*{\genplacrfullformat}[2]{%
\emph{\glsentrylongpl{##1}}##2\glsacspace{##1}%
(\protect\firstacronymfont{\glsentryshortpl{##1}})%
}%
\renewcommand*{\Genplacrfullformat}[2]{%
\emph{\Glsentrylongpl{##1}}##2\glsacspace{##1}%
(\protect\firstacronymfont{\glsentryshortpl{##1}})%
}%
}
\renewcommand*{\glsacspace}[1]{~}
\setacronymstyle{emfirst-long-sp-short}
\newcommand\newforeignacronym[5][]{\newacronym[#1]{#2}{#3}{\foreignlanguage{#5}{#4}}}
\makeglossaries
\glsenableentrycount
\newforeignacronym{am}{AM}{Application Management}{english}
\newforeignacronym{svm}{SVM}{Support Vector Machine}{english}
\newacronym{din}{DIN}{Deutsches Institut für Normung}
\newacronym{zb}{z.\,B.}{Zum Beispiel}
\begin{document}
\rule{0.82\textwidth}{1pt} \cgls{am}.
\rule{0.82\textwidth}{1pt} \gls{svm}.
\rule{0.82\textwidth}{1pt} \cgls{din}.
\rule{0.82\textwidth}{1pt} \cgls{zb} \cgls{zb}.
\printglossaries
\end{document}
\newcommand\newforeignacronym[5][]{\newacronym[#1]{#2}{#3}{\foreignlanguage{#5}{\myemph{#4}}}}
,\newcommand*\myemph[1]{\emph{#1}}
. Then, before printing the list of acronyms,\renewcommand*\myemph[1]{#1}
??