glossaries
supports cross-referenced entries. In particular, if I use one glossary entry in another and only include the second explicitly in my document, glossaries
can still figure out that it should include the first entry in the glossary.
However, this requires 2 runs of makeglossaries
:
- compile ->
makeglossaries
-> compile ->makeglossaries
-> compile
or else the first entry will be missing from the list.
So far, this is not especially problematic: just remember to run makeglossaries
twice, recompiling in between.
Things get complicated, however, if the first, cross-referenced entry itself cross-references a third entry. Now the third entry should be included, but an additional run of makeglossaries
is required. Moreover, should the third entry cross-reference a fourth, yet another run is needed. And so on for any fifth, sixth... entries.
For example:
\begin{filecontents}{mygloss.tex}
\newglossaryentry{animal}{%
name = animal,
description = {A living organism. Cf.~\gls{plant}}}
\newglossaryentry{apple}{%
name = apple,
description = {A type of \gls{fruit}}}
\newglossaryentry{fruit}{%
name = fruit,
description = {A method of seed-dispersal favoured by some \glspl{plant}}}
\newglossaryentry{plant}{%
name = plant,
description = {A living organism. Cf.~\gls{animal}}}
\end{filecontents}
\documentclass{article}
\usepackage{glossaries}
\makeglossaries
\loadglsentries{mygloss}
\begin{document}
An \gls{apple} a day keeps the doctor away.
\printglossaries
\end{document}
Unfortunately, glossaries
does not provide any warning when an entry is used by not included in the glossary. It does not tell me, for example, that the reference to fruit
is undefined after the first compilation cycle. It just silently includes fruit
in the definition of apple
without including the definition of fruit
in the glossary.
Keeping track of this for complex documents which use complex databases of entries becomes rather problematic.
How can I most easily and reliably determine when an additional compilation cycle is required?
One possibility I'm wondering about is to create a shell script which compares the result of the following commands:
grep glossentry <filename>.glo | wc -l
grep glossentry <filename>.gls | wc -l
and conclude that no further runs are required if, and only if, the results of the two grep
s are equal.
However, I am not certain if this is generally reliable, especially when multiple .glo
and .gls
files are involved. Nor am I clear whether there is no more readily-available method for determining that another run is needed.
\glsaddallunused
is no option? This reduces the number ofpdflatex | makeglossaries
cycles to 2 runs, in my point of view