About 🛈
Shop 🛒Shop 🛒
LaTeX 🖹
Software 💾
Books 📚
Gallery 🖺
News 📢
Contact 📧
Blog 🖋
Smashwords Summer/Winter Sale 1st July – 31st July 2019: 75% off ebook crime fiction novel The Private Enemy, and 100% off (free!) ebook crime short story I've Heard the Mermaid Sing.

bib2gls

bib2gls is a Java command line application to convert .bib files to glossaries-extra.sty resource files and simultaneously perform the indexing step. This application is available on CTAN and is now in both TeX Live and MikTeX. For help on including bib2gls into your document build, see Incorporating makeglossaries or makeglossaries-lite or bib2gls into the document build.

Details

Latest Version: See the CTAN page for the latest stable release.
Requirements: Java Runtime Environment (at least JRE 8) and at least v1.12 of the glossaries-extra package (but the newest version is recommended).
Licence: GPLv3+
Documentation: User Manual (PDF)
Related Resources: bib2gls gallery and bib2gls FAQ.

Example Usage

The glossary entries are stored in a bib file. For example, the file entries.bib might contain:

@entry{bird,
  name={bird},
  description = {feathered animal}
}

@abbreviation{html,
  short="html",
  long={hypertext markup language}
}

@symbol{v,
  name={$\vec{v}$},
  text={\vec{v}},
  description={a vector}
}

@index{goose,plural="geese"}
Here's an example document that uses this data:
\documentclass{article}

\usepackage[record]{glossaries-extra}

\GlsXtrLoadResources[
  src={entries},% data in entries.bib
  sort={en-GB},% sort according to 'en-GB' locale
]

\begin{document}
\Gls{bird} and \gls{goose}.

\printunsrtglossaries
\end{document}

If this document is called myDoc.tex, the build process is:

pdflatex myDoc
bib2gls myDoc
pdflatex myDoc

Note that there's no makeglossaries (or makeindex/xindy) invocation, since bib2gls not only fetches the references used in the document, it also sorts the entries and collates the location lists. The information is written to a temporary file with the extension .glstex which is input by \GlsXtrLoadResources. Since the entries are defined in that file according to their sorted order, the glossary can simply be displayed using \printunsrtglossary (or the iterative \printunsrtglossaries).

You may have multiple resources with different sort methods. For example:

\GlsXtrLoadResources[
  src={terms},% data in terms.bib
  sort={en-GB},% sort according to 'en-GB' locale
  type={main}% put the entries in the 'main' glossary
]
\GlsXtrLoadResources[
  src={symbols},% data in symbols.bib
  sort={use},% sort according to use
  type={symbols}% put the entries in the 'symbols' glossary
]

There are a variety of sorting methods: locale (e.g. en for English or de-CH-1996 for Swiss-German using the new orthography), use (order of use within the document), definition (order of definition in the bib file), letter (case or case-insensitive), numerical (integer, hexadecimal, octal, binary, float, double). You can also select the field to sort by.

Note that, although bib2gls functions as an indexing application, if you really need to use makeindex or xindy (for example, you need a custom xindy rule that can't be replicated by bib2gls), then you can switch off bib2gls's indexing functions (sort={none}, save-locations={false}) and simply use it to fetch the data from the .bib file. In order to do this, you'll need the record=alsoindex package option instead of just record (along with the xindy package option for xindy syntax) and use \makeglossaries and \printglossaries as usual. (Put \makeglossaries before \GlsXtrLoadResources[src={bib-files}, sort={none}, save-locations={false}].) The build process will then need to be

pdflatex myDoc
bib2gls myDoc
pdflatex myDoc
makeglossaries myDoc
pdflatex myDoc

This is because the indexing in the makeglossaries step can't be performed until the entries have been defined, and the entries can't be defined until they've been fetched by bib2gls, but bib2gls can't fetch them until the entry use has been recorded in the .aux file. In this case, the only benefits to using bib2gls is the ability to manage the entries in a system such as JabRef and the ability to pick up dependent entries that haven't been referenced in the document.

Download

This application is now on CTAN. The source code is available on GitHub.

Manual Installation

Now that bib2gls is in both TeX Live and MikTeX, installation is best done through your TeX package manager. However, if you need to manually install bib2gls for some reason, then the files should be installed as follows where TEXMF indicates your local or home TEXMF path (for example, ~/texmf/):

With Unix-like systems add a symbolic link called bib2gls somewhere on your path that links to the bib2gls.sh bash script. For example:
cd ~/bin
ln -s ~/texmf/scripts/bib2gls/bib2gls.sh bib2gls
To test the installation run the following from your command prompt or terminal:
bib2gls --version
If you get the following message:
Fatal error: Can't find language resource file.
then check that the resources sub-directory has been correctly copied over.

Windows users can create a batch script analogous to bib2gls.sh called bib2gls.bat that contains the following:

@ECHO OFF
FOR /F %%I IN ('kpsewhich --progname=bib2gls --format=texmfscripts bib2gls.jar') DO SET JARPATH=%%I
java -Djava.locale.providers=CLDR,JRE -jar "%JARPATH%" %*

If bib2gls is later added to the TeX distributions for Windows, the distribution will probably provide an executable file that you can use instead.

Source code is available on GitHub.

Top

© 2017 Dickimaw Books. "Dickimaw", "Dickimaw Books" and the Dickimaw parrot logo are trademarks. The Dickimaw parrot was painted by Magdalene Pritchett.

Terms of Use Privacy Policy Cookies Site Map FAQs