Nicola Talbot

2017-02-05 12:53:19 UTC

Permalink

Hi,Raw Message

I'm developing a new command line application called bib2gls

(https://github.com/nlct/bib2gls) which works with the glossaries-extra

package (http://ctan.org/pkg/glossaries-extra), and I'm looking for

volunteers to try out the experimental version before uploading it to CTAN.

For those of you who are familiar with the glossaries package, you may

be aware that you can create a .tex file containing all your glossary

definitions which can then be input into the document using either

\input or \loadglsentries.

For example, the file "myentries.tex" might contain:

\newglossaryentry{matrix}{name={matrix},

plural={matrices},

description={rectangular array of values}

}

\newglossaryentry{pi}{name={\ensuremath{\pi}},

description={the ratio of the length of the circumference

of a circle to its diameter}

}

The document might then look something like:

\documentclass{article}

\usepackage{glossaries}

\makeglossaries

\loadglsentries{myentries}% or just \input{myentries}

\begin{document}

A \gls{matrix}. Lots of \glspl{matrix}.

\[C = 2 \gls{pi} r^2 \]

\printglossaries

\end{document}

The document build process (assuming the document is called "myDoc.tex")

is (using the makeglossaries Perl script):

latex myDoc

makeglossaries myDoc

latex myDoc

(replace 'latex' with pdflatex, xelatex, lualatex as appropriate).

Alternatively using the light-weight Lua makeglossaries-lite script:

latex myDoc

makeglossaries-lite myDoc

latex myDoc

(or makeindex can be called directly with all the required options set).

xindy may be used instead by adding the 'xindy' package option:

\usepackage[xindy]{glossaries}

However the 'sort' key must now be added to the 'pi' entry:

\newglossaryentry{pi}{name={\ensuremath{\pi}},

sort={pi},

description={the ratio of the length of the circumference

of a circle to its diameter}

}

(otherwise xindy will fail).

Alternatively you can get TeX to sort and collate the entries:

\documentclass{article}

\usepackage{glossaries}

\makenoidxglossaries % <--- changed

\loadglsentries{myentries}% or just \input{myentries}

\begin{document}

A \gls{matrix}. Lots of \glspl{matrix}.

\[C = 2 \gls{pi} r^2 \]

\printnoidxglossaries % <--- changed

\end{document}

This also requires the 'sort' key for the 'pi' entry.

The new bib2gls application allows an alternative approach, but it

requires commands provided with the extension package glossaries-extra

and the entries are stored in a .bib format instead.

The above "myentries.tex" file can be rewritten as "myentries.bib":

@entry{matrix,

name={matrix},

plural={matrices},

description={rectangular array of values}

}

@symbol{pi,

name={\ensuremath{\pi}},

description={the ratio of the length of the circumference

of a circle to its diameter}

}

This can now be maintained in a bibliographic management system such as

JabRef as long as that application can be configured to recognise the

glossary fields.

The document now looks like:

\documentclass{article}

\usepackage[record]{glossaries-extra}% <--- changed

\GlsXtrLoadResources[% <--- changed

src={myentries}% data in 'myentries.bib'

]

\begin{document}

A \gls{matrix}. Lots of \glspl{matrix}.

\[C = 2 \gls{pi} r^2 \]

\printunsrtglossaries%<--- changed

\end{document}

The build process is:

latex myDoc

bib2gls myDoc

latex myDoc

bib2gls works in a similar way to bibtex. By default it only selects

those entries that have been referenced in the document and the entries

they depend on. (Use the option selection=all to select all entries in

the bib file. Note that \glsaddall doesn't work in this context, since

the entries need to be defined in order for \glsaddall to iterate over

them.)

bib2gls also sorts and collates so the xindy/makeindex step can be

skipped. (You can use bib2gls with xindy/makeindex if required, for

example, if you need a custom xindy rule. In which case you need

'record=alsoindex' and use \makeglossaries and \printglossaries as

usual, and add sort=none to the \GlsXtrLoadResources options list.)

You can have multiple bib files. For example:

\GlsXtrLoadResources[src={myterms,mysymbols}]

or:

\GlsXtrLoadResources[

src={myterms}, % data in myterms.bib

type=main,% put these entries in the 'main' glossary

sort={de-CH-1996}% sort according to Swiss German new orthography

]

\newglossary*{symbols}{Symbols}

\GlsXtrLoadResources[

src={mysymbols},% data in mysymbols.bib

type=symbols, % put these entries in the 'symbols' glossary

sort={letter-nocase}% case-insensitive letter sort

]

You can select a different field to sort by. For example, if the file

'constants.bib' contains:

@entry{pi,

name={\ensuremath{\pi}},

description={the ratio of the length of the circumference

of a circle to its diameter},

user1={3.14159}

}

@entry{eulercons,

name={\ensuremath{\gamma}},

description={Euler's constant},

user1={0.57721}

}

@entry{root2,

name={\ensuremath{\surd2}},

description={Pythagoras' constant},

user1={1.41421}

}

Then these can be sorted numerically according to the 'user1' field:

\GlsXtrLoadResources[src=constants,% constants.bib

sort={double},% decimal sort

sort-field={user1}

]

Requirements: Java 7, glossaries-extra v1.12 and dependent packages

(including glossaries v4.19+).

Installation instructions for the experimental version are at:

https://github.com/nlct/bib2gls#testing-the-experimental-version

A draft copy of the manual (bib2gls.pdf) can be found in:

https://github.com/nlct/bib2gls/tree/master/unstable

or to download it:

https://github.com/nlct/bib2gls/raw/master/unstable/bib2gls.pdf

Regards

Nicola Talbot

--

Home: http://www.dickimaw-books.com/

Creating a LaTeX Minimal Example:

http://www.dickimaw-books.com/latex/minexample/

Home: http://www.dickimaw-books.com/

Creating a LaTeX Minimal Example:

http://www.dickimaw-books.com/latex/minexample/