Recent news (2017-04-18): glossaries-extra v1.14 released.

# Gallery (glossaries): Citations in Glossary Sample

This example has citations associated with some entries. For simplicity I've just used the sample xampl.bib file that should be available on all TeX distributions.

The citation labels are stored in the user1 field (one of the custom fields). Since none of the predefined glossary styles are suitable, this example defines and uses its own custom style. The style is based on the list style (\setglossarystyle{list}) but it's modified to check if the useri field is set (useri is the internal field name corresponding to the user1 key). To allow for the possibility of a comma-separated list of citations, the value of the useri is fetched and stored in a control sequence using \glsletentryfield which is then expanded before being processed by \cite.

Remember that since the citations are in the glossary, the glossary has to be created before the bibliography.

The comment lines below are arara directives. You can remove them if you don't use arara.

% arara: pdflatex
% arara: makeglossaries
% arara: pdflatex
% arara: bibtex
% arara: pdflatex
% arara: pdflatex
\documentclass{report}

\usepackage[nopostdot,toc]{glossaries}

\makeglossaries

\newglossarystyle{cites}
{% based on list style
\setglossarystyle{list}%
\renewcommand*{\glossentry}[2]{%
\item[\glsentryitem{##1}%
\glstarget{##1}{\glossentryname{##1}}]
\glossentrydesc{##1}\glspostdescription
\ifglshasfield{useri}{##1}{\space
% in the event of multiple cites (as in the vestibulum2
% sample entry), \glsentryuseri{##1} needs to be expanded
% before being passed to \cite.
\glsletentryfield{\thiscite}{##1}{useri}%
(See \expandafter\cite\expandafter{\thiscite})}{}%
\space ##2}%
}

\begin{document}

\chapter{Sample}

\forglsentries{\thislabel}{\gls{\thislabel}. }

\printglossary[style=cites,nopostdot=false,nogroupskip]

\bibliographystyle{plain}
\bibliography{xampl}

\end{document}

This document loads the hyperref package, which creates hyperlinks from the entries in the document (referenced using commands like \gls) to their definition in the glossary. These hyperlinks are displayed in red text. I've used \forglsentries just to iterate over all the defined entries for this example. In practice, you would typically just use \gls{label}. For example:
Here is a reference to the term \gls{fusce}.


The entries have all been defined in the file example-glossaries-cite.tex, which you should find installed in the same location as the glossaries package (or in a sub-directory called test-entries). The entry definitions look like this:

\newglossaryentry{fusce}{name={fusce},
description={suscipit cursus sem},user1={article-minimal}}

\newglossaryentry{vivamus}{name={vivamus},
description={risus mi, egestas ac},user1={article-full}}

\newglossaryentry{imperdiet}{name={imperdiet},
description={varius, faucibus quis, leo},user1={whole-journal}}

\newglossaryentry{aenean2}{name={aenean},
description={tincidunt},user1={inbook-minimal}}

\newglossaryentry{crasid}{name={cras id},
description={justo quis nibh scelerisque dignissim},
user1={inbook-full}}


If you don't use arara, you need to run the following commands:

pdflatex cites
makeglossaries cites
pdflatex cites
bibtex cites
pdflatex cites
pdflatex cites

These commands can be run from a terminal or command prompt or you might be able to run them by clicking on a button in your text editor.

I've used the nopostdot option to remove the terminating full stop that is placed by default after the description. The entries all have a "1" after the description. This is the page number on which the entry was referenced. In this sample document all the entries were referenced on page 1.