The simplest method is to use the glossaries-extra
package. The translation is stored in the user1
key. The long-short-user
abbreviation style is designed to include additional information in the parenthetical material on first use. By default it picks up the information from the user1
field.
\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[colorlinks]{hyperref}
\usepackage[acronym,
nomain,% don't create "main" glossary
postdot% put a period after the description
]{glossaries-extra}
\makeglossaries
% \glscurrentfieldvalue only works with glossaries v4.23 (and above)
\renewcommand{\glsxtrpostdescacronym}{%
\ifglshasfield{\glsxtruserfield}{\glscurrententrylabel}%
{ (\glscurrentfieldvalue)}%
{}%
}
\setabbreviationstyle[acronym]{long-short-user}
\newacronym[user1=Phase Shift Keying]{psk}{PSK}{Phasenumtastung}
\newacronym{aa}{AA}{Another Acronym}
\begin{document}
First use: \gls{psk}. Subsequent use: \gls{psk}.
First use: \gls{aa}. Subsequent use: \gls{aa}.
\printglossaries
\end{document}
The post-description hook (\glsxtrpostdesc
category) appends information after the description in the glossary. This is a convenient way of making a minor adjustment without having to define a new glossary style.
If you prefer to use \newabbreviation
instead of \newacronym
, you need to redefine \glsxtrpostdescabbreviation
instead of \glsxtrpostdescacronym
and use \setabbreviationstyle{long-short-user}
instead of \setabbreviationstyle[acronym]{long-short-user}
. (\newacronym
implicitly sets category=acronym
and \newabbreviation
implicitly sets category=abbreviation
.)
If you want to stick with just the base glossaries
package, it's slightly more complicated. The translation is still provided in the user1
field:
\documentclass{article}
\usepackage{glossaries}
\makeglossaries
% define an acronym style for the acronyms with a translation:
\newacronymstyle{acronymslang}%
{%
\GlsUseAcrEntryDispStyle{long-short}%
}
{%
\GlsUseAcrStyleDefs{short-long}%
\renewcommand*{\genacrfullformat}[2]{%
\glsentrylong{##1}##2\space
(\protect\firstacronymfont{\glsentryshort{##1}}%
\ifglshasfield{useri}{##1}%
{, \glsentryuseri{##1}}{})%
}%
\renewcommand*{\Genacrfullformat}[2]{%
\Glsentrylong{##1}##2\space
(\protect\firstacronymfont{\glsentryshort{##1}}%
\ifglshasfield{useri}{##1}%
{, \glsentryuseri{##1}}{})%
}%
\renewcommand*{\genplacrfullformat}[2]{%
\glsentrylongpl{##1}##2\space
(\protect\firstacronymfont{\glsentryshortpl{##1}}%
\ifglshasfield{useri}{##1}%
{, \glsentryuseri{##1}}{})%
}%
\renewcommand*{\Genplacrfullformat}[2]{%
\Glsentrylongpl{##1}##2\space
(\protect\firstacronymfont{\glsentryshortpl{##1}}%
\ifglshasfield{useri}{##1}%
{, \glsentryuseri{##1}}{})%
}%
}
\setacronymstyle{acronymslang}
\newacronym[user1=Phase Shift Keying]{psk}{PSK}{Phasenumtastung}
\newacronym{aa}{AA}{Another Acronym}
% glossary style for acronyms with a translation
\newglossarystyle{acronymslang}
{%
\setglossarystyle{long}%
\renewcommand*{\glsgroupskip}{}%
\renewcommand{\glossentry}[2]{%
\glsentryitem{##1}\glstarget{##1}{\glossentryname{##1}} &
\glossentrydesc{##1}\glspostdescription
\ifglshasfield{useri}{##1}{ (\glsentryuseri{##1})}{}%
\space ##2\tabularnewline
}%
}
\setglossarystyle{acronymslang}
\begin{document}
First use: \gls{psk}. Subsequent use: \gls{psk}.
First use: \gls{aa}. Subsequent use: \gls{aa}.
\printglossaries
\end{document}
This doesn't have the benefit of the post-description hook so a custom glossary style is required. The difference between the two methods can be seen from the position of the period (full-stop) inserted after the description through the postdot
or postpunc=dot
(glossaries-extra
only) or nopostdot=false
package options. With the glossaries-extra
post-description hook the terminating punctuation is placed after the hook.
My original answer used an old version of glossaries
and had to use internal commands, which isn't desirable. It's better to update to a newer version and use one of the above methods instead. There's no custom glossary style as it uses a hack to append the user1
contents to the description
field.
\documentclass{article}
\usepackage{glossaries}
\usepackage{etoolbox}
\newtoks\customtok
\renewcommand*{\newacronymhook}{%
\edef\dosetkeys{\noexpand\setkeys{glossentry}{user1={},\the\glskeylisttok}}%
\dosetkeys
\ifcsempty{@glo@useri}%
{%
\expandafter\customtok\expandafter{\the\glsshorttok}%
}%
{%
\edef\custom{\the\glsshorttok, \csexpandonce{@glo@useri}}%
\expandafter\customtok\expandafter{\custom}%
}%
}
\newcommand*{\custompostdesc}[1]{%
\ifcsempty{glo@#1@useri}{}{ (\glsentryuseri{#1})}%
}
\renewcommand*{\CustomAcronymFields}{%
user1={},%
name={\the\glsshorttok},%
description={\the\glslongtok\noexpand\custompostdesc{\the\glslabeltok}},%
first={\the\glslongtok\space(\the\customtok)},%
firstplural={\the\glslongtok\noexpand\acrpluralsuffix
\space (\the\customtok)}%
text={\the\glsshorttok},%
plural={\the\glsshorttok\noexpand\acrpluralsuffix}%
}
\SetCustomStyle
\makeglossaries
\newacronym[user1=Phase Shift Keying]{psk}{PSK}{Phasenumtastung}
\newacronym{aa}{AA}{Another Acronym}
\begin{document}
First use: \gls{psk}. Subsequent use: \gls{psk}.
First use: \gls{aa}. Subsequent use: \gls{aa}.
\printglossaries
\end{document}
If you know it's definitely the first occurrence, you can explicitly use \glsfirst
instead of \gls
. Something like this:
\documentclass{beamer}
\usepackage[acronym]{glossaries}
\newacronym{AMA}{AMA}{a meaningless acronym}
\begin{document}
\begin{frame}
\begin{itemize}
\item<1-> The first occurrence of the acronym \glsfirst{AMA}.
\item<1-> The second occurrence of the acronym \glstext{AMA}.
\item<2-> Something else.
\end{itemize}
\end{frame}
\glsunset{AMA}
\end{document}
Edit: Here's another approach:
\documentclass{beamer}
\usepackage[acronym]{glossaries}
\newacronym{AMA}{AMA}{a meaningless acronym}
\begin{document}
\ifglsused{AMA}
{\newcommand{\doAMA}{\gls{AMA}}}
{\newcommand{\doAMA}{\glsfirst{AMA}\glsunset{AMA}}}
\begin{frame}
\begin{itemize}
\item<1-> The first occurrence of the acronym \doAMA.
\item<1-> The second occurrence of the acronym \gls{AMA}.
\item<2-> Something else.
\end{itemize}
\end{frame}
\end{document}
Best Answer
To override the default plural forms you can use the
shortplural
key for the short plural andlongplural
for the long plural. These should go in the optional argument: