Latest news 2024-10-15: New blog post: Tales for Our Times Book Launch.

bib2gls application FAQ

indexonlyfirst attribute doesn’t work 🔗

Consider the following example:

\documentclass{report}
\usepackage[record]{glossaries-extra}
\GlsXtrLoadResources[src=example-glossaries-acronym,category=abbreviation]
\glssetcategoryattribute{abbreviation}{indexonlyfirst}{true}
\begin{document}
\chapter{Sample}
\gls{lid}
\chapter{Another Sample}
\gls{lid}
\printunsrtglossary
\end{document}
The usual document build sequence LaTeX+bib2gls+LaTeX results in two locations in the location list for the “lid” dummy entry. The indexonlyfirst attribute should only index (record) the first use.

The problem here is that the entry isn’t defined on the first LaTeX run. This means that \gls is unable to determine the category for the entry (since it doesn’t exist yet, from LaTeX’s point of view). So \gls is unable to pick up the attribute. This means that an extra bib2gls call is needed.

Here’s the sequence starting from a clean directory (no aux or glstex files) where the document is saved in the file myDoc.tex:

  1. pdflatex myDoc
    The aux file is created containing two records for “lid”.
  2. bib2gls myDoc
    The glstex file is created with the location list for “lid” containing two locations.
  3. pdflatex myDoc
    The aux file is created containing one record for “lid” but the location list contains two locations (obtained from the glstex file created in the previous step).
  4. bib2gls myDoc
    The glstex file is created with the location list for “lid” containing one location.
  5. pdflatex myDoc
    The aux file is created containing one record for “lid” and the location list contains one location (obtained from the glstex file created in the previous step).
Unless you delete all temporary files at the start (or end) of each build, this problem will only occur when you first build your document or reference a new entry or change the category of an existing entry.

2023-01-31 21:48:15


Permalink: https://www.dickimaw-books.com/faq.php?id=272
Alternative link: https://www.dickimaw-books.com/faq.php?itemlabel=b2gindexonlyfirstattr

Category: bib2gls application
Topic: Indexing (Recording)