TransWikia.com

Missing number error with acro after updating and installing packages

TeX - LaTeX Asked by Henry DeYoung on September 20, 2020

I recently updated l3kernel and other packages and installed biblatex-chem and libertinust1math. I am now getting an error with the acro package.

Specifically, I am trying to use emph{Iac{NFA}} and am getting "ERROR: Missing number, treated as zero" for l__acro_article_Indefinite_bool in the following minimal example. (See below for the complete error message.) Before updating and installing the above packages, everything had been working correctly with the document from which I derived this example.

I’m not sure what’s going on, although it seems related to biblatex for some reason. Does anyone know what is causing this?

documentclass{article}

usepackage[backend=biber]{biblatex}
addbibresource{biblatex-examples.bib}

usepackage{acro}
DeclareAcronym{NFA}{%
  short = NFA,
  short-indefinite = an,
  long = nondeterministic finite automaton,
  long-plural-form = nondeterministic finite automata%
}

listfiles

begin{document}
emph{Iac{NFA}} is a mathematical machine.
cite{knuth:ct:a}
end{document}

Here is a section of the .log file surrounding the error. The complete .log file can be found at .log of error

openout3 = `thesis.bcf'.

Package biblatex Info: Trying to load bibliographic data...
Package biblatex Info: ... file 'thesis.bbl' found.

(./thesis.bbl)
Package biblatex Info: Reference section=0 on input line 16.
Package biblatex Info: Reference segment=0 on input line 16.
l__acro_aux_file_iow=write4
openout4 = `thesis.acr'.

AtBeginShipoutBox=box46

(/usr/local/texlive/2020basic/texmf-dist/tex/latex/translations/translations-ba
sic-dictionary-english.trsl
File: translations-basic-dictionary-english.trsl (english translation file `tra
nslations-basic-dictionary')
)
Package translations Info: loading dictionary `translations-basic-dictionary' f
or `english'. on input line 16.

./thesis.tex:17: Missing number, treated as zero.
<to be read again> 
                   l__acro_article_Indefinite_bool 
l.17 emph{Iac{NFA}}
                      is a mathematical machine.
A number should have been here; I inserted `0'.
(If you can't figure out why I needed to see a number,
look up `weird error' in the index to The TeXbook.)

Package atveryend Info: Empty hook `BeforeClearDocument' on input line 19.
[1{/usr/local/texlive/2020basic/texmf-var/fonts/map/pdftex/updmap/pdftex.map}]
Package atveryend Info: Executing hook `AfterLastShipout' on input line 19.

(./thesis.aux (./thesis.acr))
Package atveryend Info: Empty hook `AtVeryEndDocument' on input line 19.

One Answer

Ouch! This is a sneaky one.

First, the issue is unrelated (kind of) to biblatex. The issue only appears there because biblatex adds NoCaseChange to expl3's text_expand:n. If you do that manually with

ExplSyntaxOn
tl_put_right:Nn l_text_expand_exclude_tl { NoCaseChange }
tl_put_right:Nn l_text_case_exclude_arg_tl { NoCaseChange }
cs_set_eq:NN NoCaseChange use:n
ExplSyntaxOff

you can remove biblatex from the equation.

The problem is that NoCaseChange is equal to use:n, and use:n is an extremely ubiquitous macro, so that will make anything look like NoCaseChange, which is not good. In the specific case of acro, it uses tl_map_tokens:nn to iterate on a list that contains {indefinite}, and eventually reaches a code that looks like:

use:n{__acro_article:nnn {NFA}{long-acc}}{indefinite}

which should pass the {indefinite} token list to __acro_article:nnn {NFA}{long-acc}, which works great... unless use:n means to skip the argument while case-changing, which is exactly what happens here: the __acro_article:nnn thing is skipped, and indefinite is title-case changed to Indefinite, and everything goes off the tracks.

I think the correct way to fix this would be to make NoCaseChange different from use:n and @firstofone so that it isn't that easily mistaken:

ExplSyntaxOn
cs_gset:Npn NoCaseChange #1 { use:n {#1} }
ExplSyntaxOff

Add that to your document after loading biblatex and it should work fine:

documentclass{article}

usepackage[backend=biber]{biblatex}
addbibresource{biblatex-examples.bib}

usepackage{acro}
DeclareAcronym{NFA}{%
  short = NFA,
  short-indefinite = an,
  long = nondeterministic finite automaton,
  long-plural-form = nondeterministic finite automata%
}

listfiles

%% Workaround to NoCaseChange and tl_map_tokens:nn issue:
ExplSyntaxOn
cs_gset:Npn NoCaseChange #1 { use:n {#1} }
ExplSyntaxOff

begin{document}
emph{Iac{NFA}} is a mathematical machine.
cite{knuth:ct:a}
end{document}

Correct answer by Phelype Oleinik on September 20, 2020

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP