2

I’m getting dangling glossary entries. If an acronym or glossary entry is not referenced by the main document, only from other glossary entries (which are referenced from the main document and thus show up in the glossary chapter), they do not end up in the PDF, and hyperref shows they are dangling:

pdfTeX warning (dest): name{glo:foobar} has been referenced but does not exist, replaced by a fixed one

pdfTeX warning (dest): name{glo:foo} has been referenced but does not exist, replaced by a fixed one

MWE

\documentclass{article}
\usepackage{hyperref}
\hypersetup{
    colorlinks = true,
    linkcolor = blue,
    urlcolor = blue,
    citecolor = blue,
}
\usepackage[nonumberlist,style=altlist]{glossaries}
\makeglossaries

\newacronym{foo}{foo}{first metasyntactic variable}

\newacronym{meow}{meow}{the sound a cat makes}

\newglossaryentry{foobar}
{
    name=foobar,
    description={combination of two metasyntactic variables,
        but also often used as \emph{fubar}}
}

\newglossaryentry{bar}
{
    name=bar,
    description={second metasyntactic variable, see also
        \gls{foo}, \gls{foobar}, \gls{baz}}
}

\newglossaryentry{baz}
{
    name=baz,
    description={third metasyntactic variable, see also
        \gls{foo}, \gls{bar}}
}

\newglossaryentry{eins}{name=eins,description={eins, siehe \gls{zwei}}}
\newglossaryentry{zwei}{name=zwei,description={zwei, siehe \gls{drei}}}
\newglossaryentry{drei}{name=drei,description={drei, siehe \gls{vier}}}
\newglossaryentry{vier}{name=vier,description={vier, siehe \gls{fynf}}}
\newglossaryentry{fynf}{name=fynf,description={fynf, siehe \gls{sechs}}}
\newglossaryentry{sechx}{name=sechs,description={sechs, siehe \gls{sieben}}}
\newglossaryentry{sieben}{name=sieben,description={sieben, siehe \gls{acht}}}
\newglossaryentry{acht}{name=acht,description={acht, und alle haben mitgemacht}}

\begin{document}

bla bla \gls{bar} bla bla \gls{baz} bla bla \gls{eins} bla bla

\newpage
\printglossaries

\end{document}

The resulting glossary chapter has only bar and baz but not those entries they refer to, even though they ought link to them. (However, meow should not show up.) Similarily, entries eins through acht should also show up (i.e. something that limits nesting is not acceptable; in reality, this will likely not nest that much, but as generation of the PDF is automated, I require a way that permits me to script this and, if looping is needed, to be able to break the loop in a deterministic fashion).

After some comments, I have added a request to the latex-maven-plugin to allow repeating running makeglossaries as a quick workaround (with limited recursion depth, of course)… for now. (The question still stays open, I cannot rely on bib2gls or test it yet.)

  • Okay, I made a mistake, this macro was just to suppress the glossary link output, so this was not what you searched for, but it is mostly used to associate different glossary entries. – TeXnician Feb 9 '17 at 17:34
  • Hm, this works for me. After compilation and makeglossaries script I see all \gls usages expanded in the glossary – user31729 Feb 9 '17 at 17:49
  • @ChristianHupfer how do you compile it? I run pdflatex mwe.tex then makeglossaries mwe then twice pdflatex again. – mirabilos Feb 9 '17 at 17:51
  • 1
    @mirabilos: I don't know. I have to investigate that. Perhaps Nicola Talbot shows up and has a better solution for this – user31729 Feb 9 '17 at 17:56
  • 1
    @cfr I'm guessing you missed the question Is there a program for managing glossary tags? – Nicola Talbot Feb 9 '17 at 20:27
2

As has been mentioned in the comments, the problem here is that the entries in the description field aren't present in the document on the first LaTeX run. It's only once they are actually typeset in the glossary (after the glossary has been created by the indexing application) that they are actually indexed which means another call to the indexing application. There's not much that can be done about this with just glossaries and makeglossaries. You could try searching for the pattern pdfTeX warning (dest): name{glo:label} has been referenced but does not exist but this only appears with hyperref. The underlying problem (the indexing isn't complete on the first run) remains. You can also get a false match for this pattern if you've accidentally used \glshyperlink without indexing the entry.

There is a new command line application called bib2gls that can be used instead of makeglossaries / makeindex / xindy, and is now in both TeX Live and MikTeX. It only works with the glossaries-extra extension package (at least v1.12, although the latest version is best), and the glossary entries are stored in a .bib file instead of in a .tex file. So your example entries would be in a .bib file (called, say, test.bib):

@acronym{foo,
  short={foo},
  long={first metasyntactic variable}
}


@acronym{meow,
  short={meow},
  long={the sound a cat makes}
}

@entry{foobar,
   name={foobar},
   description={combination of two metasyntactic variables,
       but also often used as \emph{fubar}}
}

@entry{bar,
   name={bar},
   description={second metasyntactic variable, see also
       \gls{foo}, \gls{foobar}, \gls{baz}}
}

@entry{baz,
   name={baz},
   description={third metasyntactic variable, see also
        \gls{foo}, \gls{bar}}
}

@entry{eins,name={eins},description={eins, siehe \gls{zwei}}}
@entry{zwei,name={zwei},description={zwei, siehe \gls{drei}}}
@entry{drei,name={drei},description={drei, siehe \gls{vier}}}
@entry{vier,name={vier},description={vier, siehe \gls{fynf}}}
@entry{fynf,name={fynf},description={fynf, siehe \gls{sechs}}}
@entry{sechs,name={sechs},description={sechs, siehe \gls{sieben}}}
@entry{sieben,name={sieben},description={sieben, siehe \gls{acht}}}
@entry{acht,name={acht},description={acht, und alle haben mitgemacht}}

There's a slight difference to the document .tex file:

\documentclass{article}
\usepackage{hyperref}
\hypersetup{
    colorlinks = true,
    linkcolor = blue,
    urlcolor = blue,
    citecolor = blue,
}
\usepackage[record,% <--- changed
   nonumberlist,style=altlist]
   {glossaries-extra}% <--- changed

\GlsXtrLoadResources[% <--- changed
  src={test},% data in test.bib
]

\begin{document}

bla bla \gls{bar} bla bla \gls{baz} bla bla \gls{eins} bla bla

\newpage
\printunsrtglossaries% <--- changed

\end{document}

Note that there's no \makeglossaries command. Instead the record option writes all the indexing information in the .aux file. This file is read by bib2gls, so it can find out which entries have been referenced. It then parses the fields for commands like \gls to determine dependencies. If you run bib2gls with --verbose it will list the dependencies that it's found for each entry:

Added dependent: foo
Added dependent: foobar
Added dependent: baz
Added dependent: barfoo
Added dependent: bar
Added dependent: zwei
Added dependent: drei
Added dependent: vier
Added dependent: fynf
Added dependent: sechs
Added dependent: sieben
Added dependent: acht

The default behaviour is to add the dependent entries for each referenced entry. The location list for the dependent entries won't updated until the next run (as that's something bib2gls can't determine), but since you've used nonumberlist this isn't an issue for your document.

The verbose mode also lists the entries as they're written to the external file that's loaded by \GlsXtrLoadResources:

acht
bar
barfoo
baz
drei
eins
foo
foobar
fynf
sechs
sieben
vier
zwei

so it's managed to pick up the dependants for the referenced entries.

  • Sounds very promising. Infinite loops is the problem with my script. Not always, but sometimes ... – cfr Feb 10 '17 at 4:05
  • Sounds promising, but it’s not ready yet… Debian only has glossaries-extra 1.11 ☹ But could you add a Maven build system (pom.xml) to the repository and remove the binary files (*.jar, possibly the PDF) (or at least move them to another branch) so I can package bib2gls for Debian eventually (once Norbert updates texlive to include the newer glossaries-extra version)? – mirabilos Feb 10 '17 at 11:11
  • @mirabilos I'll see if I can work out how to do that. I've not written any Maven build stuff. The latest version of glossaries-extra is v1.13 which I only uploaded to CTAN on 2017-02-07. v1.12 was released a few days earlier but there was an urgent bug fix (re \glsdisp). Hopefully it won't take long to make it into the distributions. I'm going away tomorrow for a week, but I'll try to sort stuff out when I get back. I'll move the binaries to my website to make things simpler. – Nicola Talbot Feb 10 '17 at 12:18
  • OK thanks, we’ll look at it when you come back then, and I have something I can use in the meanwhile. – mirabilos Feb 10 '17 at 13:37

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.