2

I have discovered the following bug with the nomencl package when using \pagenumbering{gobble}. The following MWE example works fine, but when the \pagenumbering{gobble} is un-commented I get my nomenclature items being rejected.

MWE document.tex

\documentclass[11pt, a4paper, twoside]{extarticle}
\usepackage{nomencl}
\usepackage{lipsum}
\makenomenclature
\begin{document}
    %\pagenumbering{gobble}
    \nomenclature{$c$}{Speed of light in a vacuum inertial frame}
    \nomenclature{$h$}{Planck constant}
    \lipsum[1]
    \printnomenclature
\end{document}

Running the commands:

pdflatex document.tex
makeindex -s nomencl.ist -o document.nls document.nlo
pdflatex document.tex

Why did I use \pagenumbering{gobble}?

Because of the popularity of this question and answer.

WORKAROUND

I found the following work around using \thispagestyle{empty} instead of \pagenumbering{gobble}, although this doesn't explain why the problem occurred in the first place.

\documentclass[11pt, a4paper, twoside]{extarticle}
\usepackage{nomencl}
\usepackage{lipsum}
\makenomenclature
\begin{document}
    \lipsum[1]
    \thispagestyle{empty}
    \clearpage
    \setcounter{section}{0}
    \pagenumbering{arabic}
    \nomenclature{$c$}{Speed of light in a vacuum inertial frame}
    \nomenclature{$h$}{Planck constant}
    \lipsum[1]
    \printnomenclature
\end{document}
  • 1
    It isn't a bug. You shouldn't use \pagenumbering{gobble} in the first place. Indexing writes page numbers to external files and reads them back in. What do you expect the package to do if you've killed off the numbering, as in your original example? It isn't a bug if users actively destroy core functionality on which packages depend. – cfr Jul 5 '17 at 2:35
  • In addition to @cfr's comment, makeindex reports an error explaining the problem (Illegal page number). – Nicola Talbot Jul 5 '17 at 7:33
  • @cfr In the question I have explained why I was originally using \pagenumbering{gobble}. It took a while to track it down to this conflict, partly because I didn't think it was obvious that the nomenclature package would need references to page numbers (unlike the imakeidx package). – oliversm Jul 5 '17 at 8:04
  • @oliversm The problem isn't with the nomencl package, it's with makeindex which requires a page number in a specific format. – Nicola Talbot Jul 5 '17 at 8:15
  • @NicolaTalbot Do you want to add some kind of answer? – Johannes_B Dec 3 '17 at 14:10
3

TLDR: It's not a bug but is the result of makeindex requiring a valid page number, as it's designed for creating indexes.


Packages such as nomencl (and glossaries etc) have to sort and collate the information that needs to appear in the list of nomenclature/symbols/terms. TeX really isn't designed for that kind of data processing. (The glossaries package has an option that does this but it suffers from severe limitations, such as a long build time and fragile sorting.) This means that an external tool is required. The package author has two options:

  1. Use an existing tool.
  2. Create a new tool.

The first option is the simplest and is adopted by nomencl. There are two main tools available with TeX distributions that are designed for this kind of action: makeindex and xindy. However, these tools are specifically designed for indexes, which require page numbers (locations). Of the two, xindy is more flexible, but it still requires either a valid location or a cross-reference for each entry, whereas makeindex always requires a location, and it only recognises a specific style of location. (Cross-references are dealt with by discarding the location.)

In the case of lists of nomenclature/terms/symbols that have an accompanying description, the page number is often not displayed (or is just listed in the index), but because an indexing tool is used, a valid page number is required for the tool to accept the data even though the location list formed by the indexing application may be ignored by LaTeX.

This is a fundamental drawback of using an indexing tool for something that is like an index but not exactly the same. The advantage of using an existing indexing tool (especially makeindex, which has been around for a long time) is that most TeX distributions should have the application installed and ready for use. In the case of makeindex, it's also been around long enough for the code to have been inspected and is now considered safe enough for it to be added to TeX's list of trusted applications, which means that it can be run in the restricted shell escape.

In the case of \pagenumbering{@gobble}, the location (obtained by expanding \thepage) becomes an empty string, which isn't a valid location, so it's rejected by makeindex.

The second option (create a new tool) is more complicated, especially for package authors who can write LaTeX code but aren't familiar with programming languages. New applications take time to make it into TeX distributions:

  • If they are written in a compiled language (such as C), they only run on the operating system that they were compiled on. (For example, if I write a program in C it will only run on Linux, not on Windows etc.) If you want to run it on another operating system you need to port the code and compile it for your platform.
  • If they are written in an interpreted language (such as Perl) or a language that is compiled into code that requires a runtime environment (such as Java), then they will run on any operating system that has the interpreter or runtime environment installed.

In either case, the distribution of the new application is limited to systems that can execute the compiled application or that can execute the interpreter/runtime environment needed to run the application. This typically excludes old operating systems.

The glossaries-extra package combines both approaches: as with the base glossaries package it can be used with makeindex or xindy, but unlike the base package it can also be used with bib2gls, which was designed specifically for the glossaries-extra package, and will therefore allow empty locations (in fact, it will allow any location, but it will only form ranges when it can determine numerical values).

MWE:

\documentclass[11pt, a4paper, twoside]{extarticle}
\usepackage{filecontents}
\begin{filecontents*}{\jobname.bib}
@symbol{speedoflight,
  name={\ensuremath{c}},
  description={Speed of light in a vacuum inertial frame}
}

@symbol{planck,
  name={\ensuremath{h}},
  description={Planck constant}
}
\end{filecontents*}

\usepackage{lipsum}
\usepackage[record]{glossaries-extra}% 'record' option required for bib2gls

\GlsXtrLoadResources[
  src={\jobname},% entries in \jobname.bib
  selection={all},% select all defined entries
  sort={none},% don't bother sorting
  save-locations=false% location lists not required
]

\begin{document}
\pagenumbering{gobble}
\lipsum[1]

\printunsrtglossary
\end{document}

Document build (where the file is called test.tex):

pdflatex test
bib2gls test
pdflatex test

Result:

image of document

  • Very extensive answer. +1 Thanks. – Johannes_B Dec 3 '17 at 16:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.