[Tex/LaTex] Using glossaries (acronyms) with Beamer

acronymsbeamerglossariesoverlays

I would like to use the glossaries package for acronyms in Beamer presentations. However, when using Beamer's overlay mechanisms, I run into trouble.

An acronym (used for the first time) on a slide with overlays will have its long form printed on the first overlay but then be shown in its short form on the following overlays of that slide. This looks wrong, as it changes text between overlays that was supposed to appear static for the entire slide (across overlays). So, I guess what I would like is for glossaries to print the long form of an acronym on its first occurrence, but for all consecutive overlays displaying that first occurrence.

I include a minimal example of what I mean:

\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 \gls{AMA}.
  \item<1-> The second occurence of the acronym \gls{AMA}.
  \item<2-> Something else.
  \end{itemize}
\end{frame}

\end{document}

As you can see, the problem is that the first occurrence of the acronym gets printed in short on the second overlay.
I guess it may be difficult to keep track of since the acronym (here) effectively has to be printed in "long-short-long-short" form across the two overlays.

Can this be done? And hopefully, how?

Best Answer

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}