Latest news 2021-09-06: new blog post "Legacy Documents and TeX Live Docker Images".

# Bug Tracker

ID 146🔗 2020-01-30 12:12:04 Closed (Duplicate) glossaries v4.42 Inserting \null breaks legit use case 102

## Description

Hi Nicola,

this is a report on the border line between a bug report and a feature request but since it breaks my intended behavior and I think it needs to be fixed in the core I put it here.

My problem is that I want to use an "invisible" \printglossary to count the number of acronyms used in the text AtBeginDocument via a custom style (cf. glossaries: count the number of used abbreviations (i.e. those to be output by \printacronyms)). Unfortunately this inserts a \null if there are no abbreviations used that breaks the layout of my slides (I am using beamer, which is the reason why I need to count the number of abbreviations in the first place :).

From reading the documentation I do not completely understand why the \nulls are a feature and not a bug (cf. [TeX.SX Link]) but in any case it would be nice to make it optional (or at least provide a way to turn it off).

KR

## MWE

\documentclass{beamer}

\usepackage[nomain,acronym]{glossaries}

\newacronym{TEST}{TEST}{Test}

\makeglossaries

\newcounter{acronum}
\makeatletter
\newglossarystyle{countentries}{%
\setcounter{acronum}{0}
\renewenvironment{theglossary}{}{}%
\let\glsgrouptitle\@gobble
\let\glsnavhypertarget\@gobbletwo
\let\glsgroupskip\@empty
\let\glsentryitem\@gobble
\let\glsentrycounterlabel\@empty
\let\glstarget\@gobbletwo
\let\glossaryentrynumbers\@gobble
\let\subglossentry\@gobblethree
\let\glssubentryitem\@gobble
\let\glssubentrycounterlabel\@empty
\let\currentglossary\@empty
\renewcommand\glossarysection[2][]{}%
\let\glossarypreamble\@empty
\let\glossarypostamble\@empty
\let\glsresetentrylist\@empty
\renewcommand\glossentry[2]{\stepcounter{acronum}}%
}
\AtBeginDocument{\printacronyms[style=countentries]}
\makeatother

\begin{document}

\begin{frame}{1. slide}
\end{frame}

\end{document}


## Evaluation

The use of \null is mentioned in the user manual. (I will add a more detailed note in the next release.) The reason for it is hidden away in the documented code:

If the glossary file doesn't exist, do \null. (This ensures that the page is shipped out and all write commands are done.) This might produce an empty page, but at this point the document isn't complete, so it shouldn't matter.

This had to be added in response to an earlier bug report, so I'm not keen to revert it. Once the external glossary files have been created, \null is no longer used, so this shouldn't affect the document once a full build has been performed.

If you want to count the number entries that have been used in the document it would be simpler to just use \forallglsentries combined with \ifglsused at the end of the document and save the result in the aux file to be read in on the next run.

Name (optional):

Are you human? Please confirm the bug report ID (which can be found at the top of this page) or login if you have an account.

Comment:

You can use the following markup:

Block:

[pre]Displayed verbatim[/pre]
[quote]block quote[/quote]

In line:

[tt]code[/tt]
[file]file/package/class name[/file]
[em]emphasized text[/em]
[b]bold text[/b]
[url]web address[/url] [sup]superscript[/sup]
[sub]subscript[/sub]

Ordered list:
[ol]
[li]first item[/li]
[li]second item[/li]
[/ol]

Unordered list:
[ul]
[li]first item[/li]
[li]second item[/li]
[/ul]

You can use the Preview button to review your message formatting before submitting.