Latest news 2024-07-03: Ebook sale (1st – 31st July 2024): short story cybercrime fiction Unsocial Media free; short story cybercrime fiction Smile for the Camera free; short story noir crime fiction I’ve Heard the Mermaid Sing free; crime fiction novel The Private Enemy US$1.99; illustrated children’s story The Foolish Hedgehog US$0.99.

Gallery: URLs in Glossary

image of glossary with a URL on the line following the description and page number
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 (called urls). 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 initial 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 for this example to iterate over all the defined entries. In practice, you would typically just use commands like \gls{label} in the text. 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

(See Incorporating makeglossaries or makeglossaries-lite or bib2gls into the document build.)

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. If you don’t want these numbers you can use the nonumberlist option.

Download: PDF (51.74K), source code (977B), sample glossary definitions (1.61K).