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

Gallery (glossaries): URLs in Glossary Sample

Image of urls in glossary sample
This example has URLs associated with some entries. Care needs to be taken if the URL contains special characters. For the percent character % the simplest method is to just use \%. The tilde character ~ is more complicated. In this case, I suggest using either \string~ or \glstildechar. Note that \protect~ doesn't work (as shown in the PDF).

The URL for each entry is 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). The value of the useri field is fetched and stored in a control sequence using \glsletentryfield which is then expanded before being processed by \url (provided by hyperref).

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

% arara: pdflatex
% arara: makeglossaries
% arara: pdflatex




{% based on list style




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

The URL associated with the entry \gls{aenean-url}
is \entryurl{aenean-url}.


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{aenean-url}.
The sample document defines a command (\entryurl) that allows you to reference the URL within the document text.

The entries have all been defined in the file example-glossaries-url.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={adipiscing auctor est},

 description={quam arcu, malesuada sed, volutpat et, elementum sit
amet, libero},


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

pdflatex urls
makeglossaries urls
pdflatex urls
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