Command line application to convert
.bib files to
glossaries-extra.sty resource file
(This application was developed as a follow-up from my answer on TeX on StackExchange.)
The bib2gls tool forms part of a LaTeX document build, performing two
functions in one: glossary information is fetched from one or
.bib files by examining the
.aux file (similar to BibTeX)
and the terms are then sorted hierarchically and the locations collated into
compact lists (similar to Makeindex/Xindy). A
is then created containing the data defined in terms of
\newabbreviation (provided by
glossaries-extra.sty) in the appropriate order. This file
is input by
\GlsXtrLoadResources (which also writes the required
settings to the
.aux file for
bib2gls). The glossary
can then simply by displayed with
.bib files can be managed in an application like JabRef.
You may prefer to start with the introductory guide
before moving on to the main user manual.
This application requires at least Java 8 and at least v1.12 of
(2017-02-03) and at least v4.04 of glossaries.sty. (Although newer versions are recommended,
and may be required for some features.)
The main home page is
The latest stable version of
bib2gls is available from CTAN.
The code in this GitHub repository may be for an unstable version.
Stable versions have a version number in the form major.minor.
Unstable versions have a version number in the form major.minor.YYYYMMDD.
If you already have a
.tex file containing lots of
\newacronym etc, you can convert it to a
file using the supplementary command line application
convertgls2bib. For example, if the original definitions
convertgls2bib entries.tex entries.bib
will create the file
entries.bib containing all the definitions
entries.tex. Other information in
entries.tex should be
ignored, but command definitions will be parsed. (Avoid any code
that's overly complicated. The TeX parser library isn't a
.bib format doesn't support spaces in labels, so if your
.tex file has spaces in labels use
to substitute the spaces with replacement. For example
convertgls2bib --space-sub '-' entries.tex entries.bib
will replace spaces with hyphens or
convertgls2bib --space-sub '' entries.tex entries.bib
will strip spaces. The values of the
alias fields will also be adjusted, but any references using
\gls etc will have to be replaced manually (or use your
text editor's search and replace function).
The files should be installed as follows where TEXMF indicates
your local or home TEXMF path (for example,
/scripts/bib2gls/bib2gls.sh(Unix-like systems only)
/scripts/bib2gls/convertgls2bib.sh(Unix-like systems only)
For Unix-like systems, add a symbolic link called
bib2gls somewhere on
your path that links to the
bib2gls.sh bash script.
cd ~/bin ln -s ~/texmf/scripts/bib2gls/bib2gls.sh bib2gls
To test the installation run the following from your command prompt or terminal:
If you get the following message:
Fatal error: Can't find language resource file.
then check that the
resources sub-directory has been correctly
Windows users may find that their TeX distribution has converted the
bib2gls.jar file to an executable
bib2gls.exe. If not, you can create a
batch script analogous to
contains the following:
@ECHO OFF FOR /F "tokens=*" %%I IN ('kpsewhich --progname=bib2gls --format=texmfscripts bib2gls.jar') DO SET JARPATH=%%I java -Djava.locale.providers=CLDR,JRE -jar "%JARPATH%" %*
Compile Source Code
texparserlib.jar which can be compiled from
cd java/bib2gls javac -d ../../classes -cp ../../lib/texparserlib.jar *.java cd ../classes jar cmf ../java/bib2gls/Manifest.txt ../lib/bib2gls.jar com/dickimawbooks/bib2gls/*.class
gls2bib. The actual
.jar file is called
convertgls2bib.jar to reduce the chances of accidentally
using the wrong application.
cd java/gls2bib javac -d ../../classes -cp ../../lib/texparserlib.jar *.java cd ../classes jar cmf ../java/gls2bib/Manifest.txt ../lib/convertgls2bib.jar com/dickimawbooks/gls2bib/*.class
License GPLv3+: GNU GPL version 3 or later http://gnu.org/licenses/gpl.html This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law.