Latest news 2022-03-24: new blog post "Book Shop Closed Indefinitely Due to PayPal Removing Support for Encrypted Website Payments".

# Gallery: Mini-Glossary

Here are two ways of providing an environment called minigloss that automatically displays a list of terms that have been used within it 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. See Mini-Glossary (bib2gls) for an example that uses the same order for the mini-list as the main 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:

\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
}


The 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 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[nogroupskip]{glossaries-extra}

\makeglossaries

\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


## 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.

\newcommand{\miniglosswrhook}[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
}


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[nogroupskip]{glossaries-extra}

\makeglossaries

\newcommand{\miniglosswrhook}[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}