About 🛈
Shop 🛒Shop 🛒
LaTeX 🖹
Software 💾
Books 📚
Gallery 🖺
News 📢
Contact 📧
Blog 🖋

Gallery (glossaries): Citations in Glossary Sample

Image of 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




{% based on list style
     % in the event of multiple cites (as in the vestibulum2
     % sample entry), \glsentryuseri{##1} needs to be expanded
     % before being passed to \cite.
     (See \expandafter\cite\expandafter{\thiscite})}{}%
    \space ##2}%



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



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:

description={suscipit cursus sem},user1={article-minimal}}

description={risus mi, egestas ac},user1={article-full}}

description={varius, faucibus quis, leo},user1={whole-journal}}


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

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.

Download: PDF, document source, sample glossary definitions.

© 2015 Dickimaw Books. "Dickimaw", "Dickimaw Books" and the Dickimaw parrot logo are trademarks. The Dickimaw parrot was painted by Magdalene Pritchett.

Terms of Use Privacy Policy Cookies Site Map FAQs