# Acronym first use - footnote in glossary description

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[style=listgroup,footnote,acronym,toc,hyperfirst]{glossaries}

\setglossarystyle{long}
\makeglossaries

% arconyms
\newacronym{FPGA}{FPGA}{Field-Programmable Gate Array}
\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

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

\end{document}


On 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

• (Thank you for providing a mwe!) As far as I can tell, the problem seems to stem from using \footnote inside a tabular-like environment. Switching to a different style (such as list) seems to fix the problem. I'm not sure of a workaround if you really need to use a style that uses longtable. – Nicola Talbot Jul 18 '15 at 11:56
• @NicolaTalbot - Thanks for your comment. As I mentioned, I build a custom glossary style with a table since I was not satisfied with the pre-defined ones. Therefore I do not want to change the style. – Pauli Jul 18 '15 at 12:32
• I realise you want to use your own style, I was just trying to point out that the problem must be related to using the footnote option specifically within the longtable environment. So really, I was just thinking out loud ;-) Your hyperref warnings may be due to a related problem of having \footnote within a longtable, but I'm not sure. – Nicola Talbot Jul 18 '15 at 13:20

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[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{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


• Thank you very much. This solves the first problem. Do you have any clue about the problem with \glsaddall? – Pauli Jul 18 '15 at 13:01
• @Paul Try \glsaddallunused at the end of the document. – Nicola Talbot Jul 18 '15 at 13:09
• With \glsaddallunused just before \end{document}, it works with the compilation pdflatex - makeglossaries - pdflatex. But if I compile with makeglossaries - pdflatex again, then wrong page numbers appear again. – Pauli Jul 18 '15 at 13:32
• Although your acronym stile works fine within the glossary, it somehow removed the hyperfirst option. In the text, the entries are not hyperlinked any more ... you have an idea why? – Pauli Jul 18 '15 at 14:03
• The hyperlink problem can be solved by adding hyperfirstinto the list of \GlsUseAcrEntryDispStyle, e.g. \GlsUseAcrEntryDispStyle{hyperfirst, footnote} – Pauli Jul 18 '15 at 16:26