[Tex/LaTex] Acronym first use – footnote in glossary description

acronymsfootnotesglossaries

I use the glossaries package and have a list of acronyms as well as a glossary. The acronyms are set to have a footnote at first use. For the glossary I use longtable format (actually I build my own style based on longtable but the following problem also occurs with the predefined style 'long').

Want I want to do is to refer to an (before unused) acronym inside the description of the glossary. Unfortunately, the footnote appears wrong. The footnote does not refer to the used acronym in the glossary description but to the last referred acronym before the glossaries.

The following example produces the error:

\documentclass{scrreprt}

\usepackage{ragged2e}
\usepackage[table, dvipsnames]{xcolor}
\usepackage[backref=page,plainpages=false,pdfpagelabels,colorlinks]{hyperref}
\usepackage[style=listgroup,footnote,acronym,toc,hyperfirst]{glossaries}

\setglossarystyle{long}
\makeglossaries

% arconyms
\newacronym{FPGA}{FPGA}{Field-Programmable Gate Array}
\newacronym{DD}{DD}{\glslink{displacement damage}{Displacement Damage}}
\newacronym{DDD}{DDD}{Displacement Damage Dose}

% glossary
\newglossaryentry{displacement damage}{
name = {Displacement Damage},
description = {Displacement damage description}
}
\newglossaryentry{displacement damage dose}{
name = {Displacement Damage Dose},
description = {\Gls{DD} dose description}
}
\newglossaryentry{interconnect}{
name = {Interconnect},
description = {The wiring resources in an \gls{FPGA}}
}

%\glsaddall
\begin{document}

page 1

\clearpage
\newpage

page 2\\
What does \gls{interconnect} mean?
\Gls{DDD}, \gls{displacement damage dose} and again \gls{DDD}.\\

\clearpage
\newpage

page 3

%\glsunsetall
\glsaddall
\printglossary[type=\acronymtype, title=Abbreviations]
\printglossary[type=main, title=Glossary]

\end{document}

On page 5:

page 5

You can see that both acronyms have the same footnote text and wrong hyperlink. I assume that there is a problem to have a footnote inside a longtable but I do not know how to fix it.
I can use \glsunsetall to suppress any footnotes but this is not what I want.

Another problem is that all glossary entries have page 3 as a reference, which is not correct. If I place \glsaddall before \begin{document}, all entries have page 1 as a reference. How can I suppress this entry produced by \glsaddall, e.g. some entries do not have any page reference but those used do have?

EDIT1:

after compiling with:

- pdflatex
- makeglossaries
- pdflatex

I get two warnings:

name{Hfootnote.3} has been referenced but does not exist, replaced by a fixed one
name{Hfootnote.2} has been referenced but does not exist, replaced by a fixed one

Best Answer

The problem is caused by the fact that internally the footnote is using \glslabel to reference the entry but the definition of this command has changed by the time the footnote is processed. The simplest thing to do is to modify the style to ensure the label is expanded first, as in the modified example below:

\documentclass{scrreprt}

\usepackage{ragged2e}
\usepackage[table, dvipsnames]{xcolor}
\usepackage[backref=page,plainpages=false,pdfpagelabels,colorlinks]{hyperref}
\usepackage[style=listgroup,acronym,toc,hyperfirst]{glossaries}

\setglossarystyle{long}

\newacronymstyle{ex-footnote}%
{%
  \GlsUseAcrEntryDispStyle{footnote}%
}%
{%
  \GlsUseAcrStyleDefs{footnote}%
  \renewcommand*{\genacrfullformat}[2]{%
   \firstacronymfont{\glsentryshort{##1}}##2%
   \expandafter\footnote\expandafter{\expandafter\glsentrylong\expandafter{##1}}%
  }%
  \renewcommand*{\Genacrfullformat}[2]{%
   \firstacronymfont{\Glsentryshort{##1}}##2%
   \expandafter\footnote\expandafter{\expandafter\glsentrylong\expandafter{##1}}%
  }%
  \renewcommand*{\genplacrfullformat}[2]{%
   \firstacronymfont{\glsentryshortpl{##1}}##2%
   \expandafter\footnote\expandafter{\expandafter\glsentrylongpl\expandafter{##1}}%
  }%
  \renewcommand*{\Genplacrfullformat}[2]{%
   \firstacronymfont{\Glsentryshortpl{##1}}##2%
   \expandafter\footnote\expandafter{\expandafter\glsentrylongpl\expandafter{##1}}%
  }%
}

\setacronymstyle{ex-footnote}

\makeglossaries

% arconyms
\newacronym{FPGA}{FPGA}{Field-Programmable Gate Array}
\newacronym{DD}{DD}{\glslink{displacement damage}{Displacement Damage}}
\newacronym{DDD}{DDD}{Displacement Damage Dose}

% glossary
\newglossaryentry{displacement damage}{
name = {Displacement Damage},
description = {Displacement damage description}
}
\newglossaryentry{displacement damage dose}{
name = {Displacement Damage Dose},
description = {\Gls{DD} dose description}
}
\newglossaryentry{interconnect}{
name = {Interconnect},
description = {The wiring resources in an \gls{FPGA}}
}

\begin{document}
page 1

\clearpage
\newpage

page 2\\
What does \gls{interconnect} mean?
\Gls{DDD}, \gls{displacement damage dose} and again \gls{DDD}.\\

\clearpage
\newpage

page 3

\glsaddall

\printglossary[type=\acronymtype, title=Abbreviations]
\printglossary[type=main, title=Glossary]

\end{document}
Related Question