Bug Tracker

ID:146 🔗
Status:Closed (Duplicate)
Category:glossaries
Version:v4.42
Cross-ref:102
Submitted by:stefanct
Date:2020-01-30 12:12:04
Summary:Inserting \null breaks legit use case

Report

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\glossaryheader\@empty
    \let\glsgroupheading\@gobble
    \let\glsgrouptitle\@gobble
    \let\glsnavhypertarget\@gobbletwo
    \let\glsnavigation\@empty
    \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

Duplicate of \printglossary outputs extra empty pages when there is no glossary file yet.

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.

Add comment or return to search results.

Watch This Report

If you would like to be notified whenever updates are made to this report, please fill in your email address in the box below and click on "Notify Me of Changes" button. (Please ensure the address is valid.) Your details won't be passed on to third parties in line with this site's Privacy Policy.

If you supply your name, it will be used in the email greeting, which provides a more personal message, otherwise you'll just get a generic greeting. If you have previously supplied your name when signing up for notifications, you don't need to resupply it unless you want to change it.

If you have previously subscribed to notifications for this report, you can unsubscribe by clicking on the "Stop Notification" button.

The "Confirm Bug ID" field helps to protect against spambots. Please enter the bug ID (which you can find at the top of this page).

(Optional.)
E mail:
Confirm E mail:
Confirm Bug ID:

To unsubscribe from all notifications use the notifications page.

Comment

You can append a comment to the report using the form below. Comments are checked first before being added. Any spam or offensive content will be removed first according to this site's Terms of Website Use. Please bear in mind that I develop and maintain free software in my spare time. If you want commerical level support then you can hire a TeX consultant.

The "Confirm Bug ID" field helps to protect against spambots. Please enter the bug ID (which you can find at the top of this page).

(Optional. If provided, it will be shown with the comment.)
Confirm Bug ID:

You can use the following markup:

[pre]Displayed verbatim[/pre]
[tt]monospace text[/tt]
[em]emphasized text[/em]
[b]bold text[/b]
[url]web address[/url]

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

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

Click on the Preview button to preview the message.

Return to search results.