The site has just moved to a new web hosting provider. There may be some temporary disruption.

# Gallery (glossaries-extra): Mini-Glossary Sample

Here are two ways of providing an environment called minigloss that automatically displays a list of terms that have been used within in at the end of the environment. The first uses the unset buffering mechanism and the second uses the auto-indexing hook. Both cases list the symbols in order of use in the mini-list.

## Unset Buffer

This example provides an environment that uses the unset buffering mechanism to pick up any instances of \gls within the environment, and displays a list of all those terms.

This buffering mechanism is actually designed to keep track of all instances of \glsunset for situations where changing the first use flag can cause a problem. Since \gls internally uses \glsunset this method can also be used to keep track of which terms were referenced. Note that this comes with some limitations:

• The first use flag is now not set until the buffering is stopped, which means that if a term wasn't referenced before the start of the buffering then all instances of \gls within the buffering area will be treated as the first use of that term.
• Commands that don't internally call \glsunset, such as \glssymbol won't be added to the buffer's internal list.
• The buffer's internal list will be in the order of each instance of \glsunset.

The starred form of \GlsXtrStartUnsetBuffering is used to prevent duplicates appearing in the list. Hyperlinks go to the main glossary at the end of the document.

(The 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[colorlinks]{hyperref}
\usepackage[nogroupskip]{glossaries-extra}

\makeglossaries

\loadglsentries{example-glossaries-symbolnames}

\newcommand{\miniglosshandler}[1]{\glsentryname{#1} & \glsentrydesc{#1}\\}

\newenvironment{minigloss}%
{%
\GlsXtrStartUnsetBuffering*\ignorespaces
}%
{%
\par\noindent\textbf{Symbols:}\par\centering
\begin{tabular}{ll}
\GlsXtrForUnsetBufferedList{\miniglosshandler}
\end{tabular}
\par
\bigskip
\GlsXtrStopUnsetBuffering
\ignorespacesafterend
}

\begin{document}
Reference \gls{sym.gamma} in this paragraph.

\begin{minigloss}
$$f(\gls{sym.alpha}) = \gls{sym.zeta}\gls{sym.alpha} + \gls{sym.beta}[^2]$$
\end{minigloss}

Reference \gls{sym.delta} here.

\printglossaries
\end{document}



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

pdflatex minigloss
makeglossaries minigloss
pdflatex minigloss

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.

Download: PDF, document source.

## Auto-Indexing Hook

The auto-indexing hook \glsxtrdowrglossaryhook can similarly be used to construct an internal list of entries that have been indexed. The list and hook are locally defined within the minigloss environment. This has the advantage of not interfering with the first use flag and can pick up commands like \glstext, as long as the command uses the indexing hook.
% arara: pdflatex
% arara: makeglossaries
% arara: pdflatex
\documentclass{article}

\usepackage[colorlinks]{hyperref}
\usepackage[nogroupskip]{glossaries-extra}

\makeglossaries

\loadglsentries{example-glossaries-symbolnames}

\newcommand{\miniglosswrhook}[1]{%
\xifinlist{#1}{\miniglosslist}{}{\listxadd{\miniglosslist}{#1}}%
}

\newcommand{\miniglosshandler}[1]{\glsentryname{#1} & \glsentrydesc{#1}\\}

\newenvironment{minigloss}%
{%
\def\miniglosslist{}%
\let\glsxtrdowrglossaryhook\miniglosswrhook
\ignorespaces
}%
{%
\par\noindent\textbf{Symbols:}\par\centering
\begin{tabular}{ll}
\forlistloop{\miniglosshandler}{\miniglosslist}%
\end{tabular}
\par
\bigskip
\ignorespacesafterend
}

\begin{document}
Reference \gls{sym.gamma} in this paragraph.

\begin{minigloss}
$$f(\gls{sym.alpha}) = \gls{sym.zeta}\gls{sym.alpha} + \gls{sym.beta}[^2]$$
\end{minigloss}

Reference \gls{sym.delta} here.

\printglossaries
\end{document}



Download: PDF, document source.

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