“Authors Give Back” SmashWords Sale (March 20 - April 20, 2020): ebook editions of crime novel The Private Enemy and short story I've Heard the Mermaid Sing both FREE for the duration of the sale.

# Gallery: Units (glossaries-extra.sty)

If you have a small screen, you may prefer to switch on the small image setting.

This example is copied from my article Glossaries, Nomenclature, Lists of Symbols and Acronyms. It uses the glossaries-extra package to take advantage of the post-link hook.

The entry representing a unit has the unit name (ohm) in the name field and the symbolic representation (\si{\ohm}) in the symbol field. (The command \si is provided by the siunitx package, which needs to be loaded.)

\newglossaryentry{ohm}{name=ohm,symbol={\si{\ohm}},
category=unit,% category label
description=unit of electrical resistance}


The category unit is used to identify the entry as representing a unit. (The category field defaults to general if not set in \newglossaryentry.) This allows customisation of the link text (the text produced by commands like \gls) so that the unit (provided in the symbol field) can be automatically appended in parentheses on first use.

\newcommand*{\glsxtrpostlinkunit}{%


The symbol on its own can be referenced with \glssymbol (which internally sets \glscustomtext).

The default glossary style is list which doesn’t display the symbol field, so I’ve used the index style instead.

An alternative version that only uses the base glossaries package can be found in Units (glossaries.sty).

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

% arara: pdflatex
% arara: makeglossaries
% arara: pdflatex
\documentclass{article}

\usepackage{siunitx}
\usepackage{glossaries-extra}

\makeglossaries

\newglossaryentry{resistor}{name={resistor},
description={component that implements electrical resistance}}

\newglossaryentry{ohm}{name=ohm,symbol={\si{\ohm}},
category=unit,% category label
description=unit of electrical resistance}

\begin{document}
A \gls{resistor} is an electrical component.
The \gls{ohm} is a unit of resistance.

Symbol: \glssymbol{ohm} and let's mention \gls{ohm} again.

\printglossary[style=index]
\end{document}



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

pdflatex sample-units
makeglossaries sample-units
pdflatex sample-units