15

This question led to a new application:
bib2gls

I use the "glossaries" package a lot, and it is super helpful in complex writing for sorting lots of things out. However, as my "glossary.tex" file gets larger and larger, it becomes more difficult to manage. I was hoping to find a program for that task, similar to JabRef, but I can't.

Does anyone know of one? A program that could be adapted for the same purpose would also be appreciated.

  • 1
    You could use DB Browser for SQLite, and put the items into a simple database. You can then export the items you need using either the SQL-editor for ad hoc queries or making report forms. – Sveinung Dec 5 '16 at 22:13
  • 1
    @Sveinung That's a good solution if you're starting from scratch. generate a database and export it into a report that would generate the tex. Here, however, we need some sort of software that will be able to read an existing tex file and manage it – Elad Den Dec 6 '16 at 11:37
  • 4
    JabRef recently switched to the MIT license. @EladDen Tweaking JabRef would definitely be legal. I am new to the glossaries package, but the information stored in them looks structurally similar to BibTeX entries (a key and several field-value pairs). So I think you could store this information in JabRef. What you would need is an importer and an exporter that translates the tex code of a glossary entry into / from a BibTeX entry. If you feel like it, you could propose the feature at discourse.jabref.org and motivate it a little. – joergl Dec 9 '16 at 8:28
  • 1
    @ChristophS A late welcome to the site. Always nice to see you guys here. – percusse Dec 9 '16 at 19:12
  • 2
    I did think about writing one, but I have too many other projects to find the time. If it is possible to tweak JabRef, some things to take into account: there are fields that by default derive their value from other fields (e.g. text defaults to the same value as name, plural defaults to text with s appended); it's possible to add custom fields, so there isn't a fixed set of fields (e.g. glossaries-accsup.sty, glossaries-prefix.sty and glossaries-extra.sty add extra fields); the type field may need changing according to the document; abbreviations may need different handling. – Nicola Talbot Dec 10 '16 at 12:00
14
+250

As there currently does not exist such tool and it seems many users want to have such a tool, I decided to integrate this into JabRef as a feature. The idea is to have a similar, but more advanced functionality like for managing journal abbrevations in JabRef.

Therefore I have created an issue to track the development. https://github.com/JabRef/jabref/issues/2366

I will probably start around Christmas with the development.

7

(Answer rewritten following release of bib2gls v1.0.)

There's a new command line application called bib2gls that can be used to convert .bib files to a format that can be input using glossaries-extra's \GlsXtrLoadResources command. The record package option is required. The application requires at least Java 7, although newer versions are recommended (Java 7 has reached its end of life and is now deprecated). It also needs at least v1.12 of glossaries-extra, but works better with the latest version.

The application performs two functions in one:

  1. fetches the information from the .bib file(s) according to the information found in the .aux file (like bibtex);
  2. performs hierarchical sorting and collates locations (like makeindex or xindy).

This means you can use JabRef to manage the entries. Unlike makeindex, xindy and bibtex, the file created by bib2gls isn't the formatted list but the entry definitions provided in the order obtained from sorting. Only those entries that were selected from the .bib file are defined and since they have been defined in the appropriate order, the glossary can simply be displayed using \printunsrtglossary (or \printunsrtglossaries), which is provided by glossaries-extra.

The record package option automatically switches on undefaction=warn, which means that if you try to reference (with \gls etc) an undefined entry then you just get a warning instead of an error. On the first LaTeX run the entries aren't defined (as with \cite). This means that iterative commands like \glsaddall don't work. Instead you can use selection=all in the options of \GlsXtrLoadResources.

If you already have existing .tex files containing all your entry definitions (that's loaded with \input or \loadglsentries) then you can use the supplementary application convertgls2bib to convert it to a .bib file for use with bib2gls. For example, suppose entries.tex contains:

\newglossaryentry{sample}{name={sample},description={an example}}

\newabbreviation{html}{HTML}{Hypertext Markup Language}

\newterm[plural=geese]{goose}

\newterm[see={[\seealsoname]goose}]{duck}

then

convertgls2bib entries.tex entries.bib

will create the file entries.bib that contains:

% Encoding: UTF-8
@entry{sample,
  name = {sample},
  description = {an example}
}

@abbreviation{html,
  short = {HTML},
  long = {Hypertext Markup Language}
}

@index{goose,
  plural = {geese}
}

@index{duck,
  seealso = {goose}
}

The .bib encoding can be changed using --bibenc <encoding> and the .tex encoding can be specified using --texenc <encoding>. For example:

convertgls2bib --texenc UTF-8 --bibenc UTF-8 entries.tex entries.bib

The .bib format doesn't permit spaces in labels so you can use --space-sub <replacement> to replace spaces with <replacement>. For example:

convertgls2bib --space-sub '-' entries.tex entries.bib

or

convertgls2bib --space-sub '' entries.tex entries.bib

Remember that you'll need to make the relevant changes in your \gls etc argument to reflect this substitution.

bib2gls has a primitive LaTeX interpreter to allow it to deduce the sort value if omitted. If you use @preamble to provide commands, bib2gls will try to add them to the interpreter's list of known commands. You can store the @preamble code in separate .bib files if the provided commands are used in entries defined in multiple .bib files. It may be that you don't want the interpreter to pick up some command definitions, so you could divide the @preamble up into two files, say glossdefs-interpret.bib and glossdefs-nointerpret.bib.

For example, suppose I need:

\providecommand{\strong}[1]{\textbf{\color{red}#1}}
\providecommand{\swap}[2]{#2 (#1)}

and suppose I start with just one .bib file called entries.bib:

@preamble{"\providecommand{\strong}[1]{\textbf{\color{red}#1}}
\providecommand{\swap}[2]{#2 (#1)}"}

@index{example,
  name={\strong{\swap{stuff}{example}}}
}

@index{sample}
@index{test}
@index{foo}
@index{bar}

Here's the test document test.tex:

\documentclass{article}

\usepackage{color}
\usepackage[record,style=indexgroup]{glossaries-extra}

\GlsXtrLoadResources[src={entries},selection=all]

% adjust indexgroup style:
\renewcommand{\glstreenamefmt}[1]{#1}
\renewcommand{\glstreegroupheaderfmt}[1]{\textbf{#1}}

\begin{document}
\printunsrtglossaries
\end{document}

The build process is:

pdflatex test
bib2gls --group test
pdflatex test

(The --group switch is needed because I'm using a glossary style that has letter groups.) The result looks like:

Glossary B bar F foo R example (stuff) S sample T test

Inspecting test.glstex (the file created by bib2gls) shows that the sort value for example is

sort={redexample (stuff)}

This is because bib2gls has picked up the definitions of both \strong and \swap from @preamble, so it expands

\strong{\test{stuff}{example}

to

\textbf{\color{red}example (stuff)}

and then ignores \textbf and \color leaving redexample (stuff), which is why the example entry ends up in the R letter group.

I can use interpret-preamble=false to prevent bib2gls from trying to interpret the contents of @preamble (it will just write the contents to the .glstex file):

\GlsXtrLoadResources[
  src={entries},% definitions are in entries.bib
  selection=all,% select all entries
  interpret-preamble=false% don't interpret @preamble

]

Now the document looks like:

Glossary B bar F foo S sample example (stuff) T test

Inspecting the .glstex file shows that the sort value for example has been set as:

sort={stuffexample}

This is because bib2gls now doesn't recognise \strong or \swap so it interprets \strong{\test{stuff}{example}} as simply stuffexample, which is why example now ends up in the S letter group. What's needed is for bib2gls to pick up the definition of \swap but not \strong, so I need to create the file glossdefs-nointerpret.bib that contains:

@preamble{"\providecommand{\strong}[1]{\textbf{\color{red}#1}}"}

and glossdefs-interpret.bib that contains:

@preamble{"\providecommand{\swap}[2]{#2 (#1)}"}

The document is now:

\documentclass{article}

\usepackage{color}
\usepackage[record,style=indexgroup]{glossaries-extra}

\GlsXtrLoadResources[src={glossdefs-nointerpret},interpret-preamble=false]
\GlsXtrLoadResources[src={glossdefs-interpret,entries},selection=all]

% adjust indexgroup style:
\renewcommand{\glstreenamefmt}[1]{#1}
\renewcommand{\glstreegroupheaderfmt}[1]{\textbf{#1}}

\begin{document}
\printunsrtglossaries
\end{document}

which now results in:

Glossary B bar E example (stuff) F foo S sample T test

You can have multiple \GlsXtrLoadResources. Any definitions found in @preamble will be remembered for the next resource set so the above can also be:

\documentclass{article}

\usepackage{color}
\usepackage[record,style=indexgroup]{glossaries-extra}

\GlsXtrLoadResources[src={glossdefs-nointerpret},interpret-preamble=false]
\GlsXtrLoadResources[src={glossdefs-interpret}]
\GlsXtrLoadResources[src={entries},selection=all]

% adjust indexgroup style:
\renewcommand{\glstreenamefmt}[1]{#1}
\renewcommand{\glstreegroupheaderfmt}[1]{\textbf{#1}}

\begin{document}
\printunsrtglossaries
\end{document}

You can have multiple .bib files listed in src, in which case they'll all be sorted together. Each \GlsXtrResources set is sorted independently of the other sets. Suppose testfile1.bib contains:

@index{duck}
@index{zebra}
@index{aardvark}

and testfile2.bib contains:

@index{caterpillar}
@index{bee}
@index{wombat}

and test.tex contains:

\documentclass{article}

\usepackage[record,style=indexgroup]{glossaries-extra}

\GlsXtrLoadResources[src={testfile1,testfile2},selection=all]

% adjust indexgroup style:
\renewcommand{\glstreenamefmt}[1]{#1}
\renewcommand{\glstreegroupheaderfmt}[1]{\textbf{#1}}

\begin{document}
\printunsrtglossaries
\end{document}

then the result is

Glossary A aardvark B bee C caterpillar D duck W wombat Z zebra

However, if I load the .bib files using two separate resource commands:

\documentclass{article}

\usepackage[record,style=indexgroup]{glossaries-extra}

\GlsXtrLoadResources[src={testfile1},selection=all]
\GlsXtrLoadResources[src={testfile2},selection=all]

% adjust indexgroup style:
\renewcommand{\glstreenamefmt}[1]{#1}
\renewcommand{\glstreegroupheaderfmt}[1]{\textbf{#1}}

\begin{document}
\printunsrtglossaries
\end{document}

then the result is a bit weird:

Glossary A aardvark D duck Z zebra B bee C caterpillar W wombat

but I can make use of this to alter the normal letter grouping:

\documentclass{article}

\usepackage[record,style=indexgroup]{glossaries-extra}

\GlsXtrLoadResources[src={testfile1},
 group={Group 1},
 selection=all]
\GlsXtrLoadResources[src={testfile2},
 sort={letter-nocase-reverse},
 group={Group 2},
 selection=all]

% adjust indexgroup style:
\renewcommand{\glstreenamefmt}[1]{#1}
\renewcommand{\glstreegroupheaderfmt}[1]{\textbf{#1}}

\begin{document}
\printunsrtglossaries
\end{document}

(For illustrative purposes, I've sorted the second set differently.) This produces:

Glossary Group 1 aardvark duck zebra Group 2 wombat caterpillar bee

If you have any abbreviations you need to set the abbreviation style before the resource command. For example, suppose entries-abbrv.bib contains:

@string{ssi={server-side includes}}
@string{html={hypertext markup language}}

@abbreviation{shtml,
  short="shtml",
  long= ssi # " enabled " # html,
  description={a combination of \gls{html} and \gls{ssi}},
  seealso={html,ssi}
}

@abbreviation{html,
  short ="html",
  long  = html,
  description={a markup language for creating web pages}
}

@abbreviation{ssi,
  short="ssi",
  long = ssi,
  description={a simple interpreted server-side scripting language}
}

and test.tex contains:

\documentclass{article}

\usepackage[T1]{fontenc}
\usepackage[record,style=indexgroup]{glossaries-extra}

\setabbreviationstyle{long-short-sc-desc}
\GlsXtrLoadResources[src={entries-abbrv}]

\begin{document}
First use: \gls{shtml}. Next use: \gls{shtml}.

\printunsrtglossaries
\end{document}

Note that although shtml has been used in the document, the dependent entries html and ssi are automatically selected. The build process is still:

pdflatex test
bib2gls --group test
pdflatex test

This is different to makeglossaries which requires an extra makeglossaries and pdflatex to index the dependents. However the corresponding locations aren't picked up until a subsequent bib2gls and pdflatex call. Then the result looks like:

image of document

I can suppress the indexing in the glossary by changing the format to glsignore, which bib2gls recognises as a special ignored location:

\documentclass{article}

\usepackage[T1]{fontenc}
\usepackage[record,style=indexgroup]{glossaries-extra}

\setabbreviationstyle{long-short-sc-desc}
\GlsXtrLoadResources[src={entries-abbrv}]

\begin{document}
First use: \gls{shtml}. Next use: \gls{shtml}.

\GlsXtrSetDefaultNumberFormat{glsignore}
\printunsrtglossaries
\end{document}

image of document

If I want to use the long-short-sc style instead I can tell bib2gls to ignore the description field provided in the .bib file:

\documentclass{article}

\usepackage[T1]{fontenc}
\usepackage[record,style=indexgroup]{glossaries-extra}

\setabbreviationstyle{long-short-sc}
\GlsXtrLoadResources[src={entries-abbrv},
   ignore-fields={description}]

\begin{document}
First use: \gls{shtml}. Next use: \gls{shtml}.

\printunsrtglossaries
\end{document}

This produces:

image of document

If I change my mind and decide I actually want normal upper case short forms instead of using \textsc I can tell bib2gls to change the case of the short field:

\documentclass{article}

\usepackage[T1]{fontenc}
\usepackage[record,style=indexgroup]{glossaries-extra}

\setabbreviationstyle{long-short}
\GlsXtrLoadResources[src={entries-abbrv},
   short-case-change={uc},
   ignore-fields={description}]

\begin{document}
First use: \gls{shtml}. Next use: \gls{shtml}.

\printunsrtglossaries
\end{document}

This produces:

image of document

Now let's suppose I've been using the \newdualentry example command described in the glossaries manual. The closest matching entry type is @dualentryabbreviation, so I'm going to change entries-abbrv.bib to use that instead of @abbreviation:

@string{ssi={server-side includes}}
@string{html={hypertext markup language}}

@dualentryabbreviation{shtml,
  short="shtml",
  long= ssi # " enabled " # html,
  description={a combination of \gls{html} and \gls{ssi}},
  seealso={html,ssi}
}

@dualentryabbreviation{html,
  short ="html",
  long  = html,
  description={a markup language for creating web pages}
}

@dualentryabbreviation{ssi,
  short="ssi",
  long = ssi,
  description={a simple interpreted server-side scripting language}
}

The document needs the abbreviations package option, otherwise all the terms and abbreviations will end up in the main glossary:

\documentclass{article}

\usepackage[T1]{fontenc}
\usepackage[record,abbreviations,style=indexgroup]{glossaries-extra}

\setabbreviationstyle{long-short-sc}
\GlsXtrLoadResources[src={entries-abbrv}]

\begin{document}
First use: \gls{shtml}. Next use: \gls{shtml}.

\printunsrtglossaries
\end{document}

This produces:

image of document

Here's an example of a hierarchical index. The file entries.bib contains:

@index{birds}
@index{duck,parent={birds}}
@index{goose,plural={geese},parent={birds}}
@index{swan,parent={birds}}
@index{chicken,parent={birds}}

@index{vegetable}
@index{cabbage,parent={vegetable}}

@index{minerals}
@index{quartz,parent={minerals}}
@index{corundum,parent={minerals}}
@index{amber,parent={minerals}}
@index{gypsum,parent={minerals}}

@index{aardvark}
@index{bard}
@index{buzz}

@index{item}
@index{subitem,parent={item}}
@index{subsubitem,parent={subitem}}

@index{parentid,name={parent name}}
@entry{child,parent={parentid},description={an example}}

The file test.tex contains:

\documentclass{article}

\usepackage[record,stylemods={mcols},style=mcolindexgroup]{glossaries-extra}

\GlsXtrLoadResources[src={entries.bib}]

% adjust mcolindexgroup style:
\renewcommand{\glstreenamefmt}[1]{#1}
\renewcommand{\glstreegroupheaderfmt}[1]{\textbf{#1}}

\begin{document}
\gls{duck}.

\gls{quartz}, \gls{corundum}, \gls{amber}.

\gls{aardvark}, \gls{bard}, \gls{buzz}.

\gls{vegetable}, \gls{cabbage}.

\gls{subsubitem}.

\gls{child}.

\printunsrtglossaries
\end{document}

The resulting document looks like:

image of document

The duck's siblings haven't been selected, so the duck entry looks a little lonely. We can neaten the list by flattening the duck, which involves adjusting the name, text and parent to shift it up one hierarchical level. The parent bird entry is then no longer required and can be removed.

\documentclass{article}

\usepackage[record,stylemods={mcols},style=mcolindexgroup]{glossaries-extra}

\GlsXtrLoadResources[src={entries.bib},
 flatten-lonely=postsort% flatten lonely children
]

% adjust mcolindexgroup style:
\renewcommand{\glstreenamefmt}[1]{#1}
\renewcommand{\glstreegroupheaderfmt}[1]{\textbf{#1}}

\begin{document}
\gls{duck}.

\gls{quartz}, \gls{corundum}, \gls{amber}.

\gls{aardvark}, \gls{bard}, \gls{buzz}.

\gls{vegetable}, \gls{cabbage}.

\gls{subsubitem}.

\gls{child}.

\printunsrtglossaries
\end{document}

This now produces:

image of document

The duck has now been flattened but not the cabbage. This is because the parent entry (vegetable) has been indexed in the document, so it can't be removed. The cabbage can be flattened by changing the flatten lonely rule but its parent still can't be removed:

\documentclass{article}

\usepackage[record,stylemods={mcols},style=mcolindexgroup]{glossaries-extra}

\GlsXtrLoadResources[src={entries.bib},
 flatten-lonely=postsort,% flatten lonely children
 flatten-lonely-rule=discard unrecorded
]

% adjust mcolindexgroup style:
\renewcommand{\glstreenamefmt}[1]{#1}
\renewcommand{\glstreegroupheaderfmt}[1]{\textbf{#1}}

\begin{document}
\gls{duck}.

\gls{quartz}, \gls{corundum}, \gls{amber}.

\gls{aardvark}, \gls{bard}, \gls{buzz}.

\gls{vegetable}, \gls{cabbage}.

\gls{subsubitem}.

\gls{child}.

\printunsrtglossaries
\end{document}

The result is:

image of document

The bib2gls user manual contains a full description of all entry types, but here's a summary:

  • @entry required fields: description and name or parent. If name is omitted it's obtained from the parent name. If sort is omitted it's obtained from name.
  • @symbol required fields: name or parent. If name is omitted description is also required and the name is obtained from the parent name. If sort is omitted it's obtained from the entry's label.
  • @number as @symbol
  • @index no required fields. If name is omitted it's taken from the entry's label. If sort is omitted it's obtained from the name.
  • @abbreviation required fields: long and short. If sort is omitted it's taken from the short field.
  • @acronym as @abbreviation
  • @dualentry required fields: name and description. If sort is omitted it's taken from name. This also creates a corresponding entry with the label dual.label that has the name and description flipped.
  • @dualentryabbreviation required fields: short, long, description. The primary entry is an abbreviation (sorted according to short) and the dual entry is a regular term (sorted according to long).
  • @dualsymbol required fields: name and symbol. This creates a corresponding entry with the label dual.label that has the name and symbol flipped.
  • @dualnumber as @dualsymbol
  • @dualabbreviation required fields: short, long, dualshort and duallong. This creates a corresponding abbreviation with the label dual.label that has the short and dualshort flipped and long and duallong flipped.
  • @dualacronym as @dualabbreviation

The base glossaries package provides the fields: name, description, parent, descriptionplural, text, first, plural, firstplural, symbol, symbolplural, sort, type, user1, user2, user3, user4, user5, user6, nonumberlist, see, short, shortplural, long and longplural and (if \makenoidxglossaries) loclist.

For the .bib file it's best to avoid sort, type and nonumberlist. There's greater flexibility with the \GlsXtrLoadResources options. Don't set loclist as it's a private field with its own custom format.

The extension package provides additional fields: category, alias, seealso and (if the record option is used) group.

In addition bib2gls recognises the fields: dualshort, dualshortplural, duallong, duallongplural, dualplural. It also provides fields for its own private use (so don't use these in the bib file, but you can access them in the document when provided): location, dual, childcount.

The glossaries-accsupp package (\usepackage[accsupp]{glossaries-extra}) provides: access, textaccess, firstaccess, pluralaccess, firstpluralaccess, symbolaccess, symbolpluralaccess, descriptionaccess, descriptionpluralaccess, longaccess, shortaccess, longpluralaccess, shortpluralaccess.

The glossaries-prefix package provides: prefix, prefixplural, prefixfirst and prefixfirstplural.

If you provide your own fields using commands like \glsaddkey, put the definition before the first instance of \GlsXtrLoadResources.

  • The bib file works fine with JabRef and it already loads all the fields and shows them for editing. Of course it shows the standard fields, too. It would be nice if you could add some metadata in the comment field, e.g. @Comment{xxx-meta: glossaries-v1} If you need any futher help, just ask me. – Christoph S Feb 4 '17 at 17:03
  • @ChristophS Thanks for checking. That's great. Is there a reference for the @Comment syntax? (bib2gls picks up all the fields defined in the document from the .aux file, so it knows which ones to select from that. It will ignore unknown fields.) – Nicola Talbot Feb 4 '17 at 17:17
  • There is no real documentation about the @Comment field. Some defintion here. In JabRef we use it to store information about the format (bibtex/biblatex) @Comment{jabref-meta: databaseType:biblatex;}. We also store information about the groups defintion/tree in several Comment fields. From a JabRef point of view it would help to have just some simple metadata, to indicate that this is a (valid) glossary-bib file. Then we could show/hide some irrelevant fields/add new. – Christoph S Feb 4 '17 at 17:26
  • 1
    @ChristophS Okay, so perhaps something like @Comment{jabref-meta: databaseType:bib2gls;} which would by show the default set of fields. (I'll add the list of known fields to my answer.) – Nicola Talbot Feb 4 '17 at 17:58
5

I'm posting this answer since all this information is hard to fit in a comment.

To sum up the comments: It seems such software does not exist. It should either be developed, or an existing bibtex managing software, such as Jabref, can be tweaked to handle *.tex files containing glossaries definitions. @Christoph S of the Jabref dev team has shown his willingness to hear more, so here's a brief explanation:

The glossaries file has a somewhat resemblence to a bib file, where instead of bibliographical entries, the glossaries *.tex file contains glossaries entries. The definitions of glossaries (that can replace the entry type in bibtex, i.e. @misc) are:

\newglossaryentry
\longnewglossaryentry
\newacronym
\newterm
\newabbrevation
\glsxtrnewsymbol
\glsxtrnewnumber

The fields that a glossary entry can have are

name
description
parent
descriptionplural
text
first
plural
firstplural
symbol
symbolplural
sort
type
user1,...,user6
nonumberlist
see

A glossary managing GUI would have to be able to read these fields, manage entries and produce new ones.

Here is a glossaries sample file compiled from several sample files provided by the glossaries package

% This is a sample file, it was produced from the glossaries package sample files.


% The following definition of glossaries are typical and are used by most users, 
% they are covered by the beginners guide, and are simple

\newglossaryentry{Perl}{name=\texttt{Perl},
    sort=Perl, % need a sort key because name contains a command
    description=A scripting language}

\newglossaryentry{glossary}{name=glossary,
    description={\nopostdesc},
    plural={glossaries}}

\newglossaryentry{glossarycol}{
    description={collection of glosses},
    sort={2},
    parent={glossary}}

\newglossaryentry{glossarylist}{
    description={list of technical words},
    sort={1},
    parent={glossary}}

\newglossaryentry{pagelist}{name=page list,
    % description value has to be enclosed in braces
    % because it contains commas
    description={a list of individual pages or page ranges
        (e.g.\ 1,2,4,7-9)}}

\newglossaryentry{mtrx}{name=matrix,
    description={rectangular array of quantities},
    % plural is not simply obtained by appending an s, so specify
    plural=matrices}

% entry with a paragraph break in the description

\newglossaryentry{par}{name=paragraph,
    description={distinct section of piece of
        writing.\glspar Beginning on new, usually indented, line}}

% entry with two types of plural. Set the plural form to the
% form most likely to be used. If you want to use a different
% plural, you will need to explicity specify it in \glslink
\newglossaryentry{cow}{name=cow,
    % this isn't necessary, as this form (appending an s) is
    % the default
    plural=cows,
    % description:
    description={(\emph{pl.}\ cows, \emph{archaic} kine) an adult
        female of any bovine animal}}

\newglossaryentry{bravo}{name={bravo},
    description={\nopostdesc}}

\newglossaryentry{bravo1}{description={cry of approval (pl.\ bravos)},
    sort={1},
    plural={bravos},
    parent=bravo}

\newglossaryentry{bravo2}{description={hired ruffian or killer (pl.\ bravoes)},
    sort={2},
    plural={bravoes},
    parent=bravo}

\newglossaryentry{seal}{%
    name=seal,%
    description={sea mammal with flippers that eats fish}
}

\newglossaryentry{sealion}{%
    name={sea lion},%
    description={large seal}%
}

\newglossaryentry{M}{name={$M$},
    sort=M,
    description={mass},
    symbol=kg}

\newglossaryentry{svm}{
    % how the entry name should appear in the glossary
    name={Support vector machine (SVM)},
    % how the description should appear in the glossary
    description={Statistical pattern recognition
        technique~\cite{svm}},
    % how the entry should appear in the document text
    text={svm},
    % how the entry should appear the first time it is
    % used in the document text
    first={support vector machine (svm)}}

\newglossaryentry{ksvm}{
    name={Kernel support vector machine (KSVM)},
    description={Statistical pattern recognition technique
        using the ``kernel trick'' (see also SVM)},
    text={ksvm},
    first={kernel support vector machine}}

\newglossaryentry{ident}{name=identity matrix,
    description=diagonal matrix with 1s along the leading diagonal,
    plural=identity matrices}


% These are special characters or protected characters. glossaries knows how to handle these.
\newglossaryentry{quote}{name={"},
    description={the double quote symbol}}

\newglossaryentry{at}{name={@},
    description={the ``at'' symbol}}

\newglossaryentry{excl}{name={!},
    description={the exclamation mark symbol}}

\newglossaryentry{bar}{name={\ensuremath{|}},
    description={the vertical bar symbol}}

\newglossaryentry{hash}{name={\#},
    description={the hash symbol}}

\newglossaryentry{emigre}{%
    name={{é}migré},
    description={person who has emigrated to another country,
        especially for political reasons}
}

\newglossaryentry{not:set}{type=notation, % glossary type
    name={$\mathcal{S}$},
    description={A set},
    sort={S}}

%If one wants to use \gls call in a formula, he'd used the \ensuremath command
\newglossaryentry{Gamma}{name=\ensuremath{\Gamma(z)},
    description=Gamma function,
    sort=Gamma}

\newglossaryentry{Phi}{name={\ensuremath{\Phi(\alpha,\gamma;z)}},
    description=confluent hypergeometric function,sort=Pagz}

\newglossaryentry{knu}{name=\ensuremath{k_\nu(x)},
    description=Bateman's function,sort=kv}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% typical acronym definitions

%the typical definition of an acronym is this, that is not quite similar to the name={field}... This could pose a challange for tweaking a program such as jabref...

\newacronym{svm1}% label
{svm1}% abbreviation
{support vector machine one}% long form

\newacronym{laser}{laser}{light amplification by stimulated
    emission of radiation}





%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% These are samples I found in the samples provided by the glossaries package.
%%% They are more complex and are covered in the long detailed users guide
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\longnewglossaryentry{par1}{name={par1}}%
{%
    A long description with a paragraph break.

    This is the next paragraph.


% non-standard definition of an acronym - never used anything like that either
% This contrived acronym has non-standard plural forms.
% These are specified in the optional argument.
% Remove the optional argument to revert to the default
% plurals.
\newacronym[\glsshortpluralkey=cas,\glslongpluralkey=contrived
acronyms]{aca}{aca}{a contrived acronym}

\newacronym[description={a device that emits a narrow beam of
    light}]{laser}{laser}{light amplification by stimulated
    emission of radiation}

\newacronym[shortaccess=S V M]{svm}{svm}{support vector machine}

\newacronym[type=main]{vc}{VC}{Vector Calculus}

\newglossaryentry{pear}{name=pear,
    description={an oddly shaped fruit}}

\newglossaryentry{apple}{name=apple,
    description={firm, round fruit},
    see=[see also]{pear}}

\newglossaryentry{banana}{name=banana,
    description={a yellow fruit with an even odder shape than
        a \gls{pear}}}

\newglossaryentry{fruit}{name=fruit,
    description={sweet, fleshy product of plant containing seed}}

\glssee{fruit}{pear,apple,banana}

\newabbr{eg}{e.g.}{exempli gratia}
\newabbr{ie}{i.e.}{id est}
\newabbr{bsc}{B.Sc.}{Bachelor of Science}

\newdualentry{svm}% label
{SVM}% abbreviation
{support vector machine}% long form
{Statistical pattern recognition technique}% description

\newglossaryentry{sample}{name={sample},
    description={an example},
    prefix={a~},
    prefixplural={the\space}%
}

\newglossaryentry{oeil}{name={oeil},
    plural={yeux},
    description={eye},
    prefix={l'},
    prefixplural={les\space}}


%these are samples with custome fields (or keys), that is ed and ing are defined in the preamble of tex file and then these are defined. I would not expect a managing program to have a preamble for custom definitions, however, being able to produce custom 
\newglossaryentry{run}{name={run},%
    ed={ran},%
    ing={running},
    description={}}

\newglossaryentry{waddle}{name={waddle},%
    ed={waddled},%
    ing={waddling},%
    description={}}

The greatest challange that I see is the definition of a new acronym: It does not adhere to the typical structure of entry definition in bibtex.

as to @Nicola Talbot's concern with custom fields, Jabref has an option of editing an entry bib source, there one could add a custom bib field, the same can be done in the glossaries.

  • There's also \newterm provided by \usepackage[index]{glossaries} as well as \newabbreviation, \glsxtrnewsymbol and \glsxtrnewnumber provided by glossaries-extra.sty. – Nicola Talbot Dec 11 '16 at 12:02
  • @NicolaTalbot thanks ! do they have the same keys or do these define new ones ? – Elad Den Dec 11 '16 at 12:28
  • 1
    \newacronym and \newabbreviation set long, longplural, short and shortplural (to the long and short forms) and the type field (to \acronymtype and \glsxtrabbrvtype, respectively). With glossaries-extra all of those commands also set the category field. Those commands have an optional argument that can be used to set (or override) any of the fields available with \newglossaryentry. So perhaps if the long and short fields are set, it could identify an entry as an abbreviation and the export could then write them as either \newacronym or \newabbreviation. – Nicola Talbot Dec 11 '16 at 14:35
  • Thank you both for the brief information. I have created an issue for me to track the progress and will start working on it. I already have some ideas how to handle it technically github.com/JabRef/jabref/issues/2366 – Christoph S Dec 11 '16 at 18:53
  • The Gloss package by Bezos and Diaz already uses BibTeX as a database to handle large glossaries as entries. – erreka Dec 12 '16 at 1:20
2

With the gloss package by Bezos and Diaz you may manage glossaries as bibliographies with BibTeX; you use the \gloss command instead of \cite, and I guess JabRef without modification. Documentation is pretty clear. So I believe that what the OP asks for already exists.

  • 2
    This looks like an awesome tool, however, the glossaries package has many advantages: acronyms, styles and the long form being shown when first called are just a few. The glossaries package is widely used, and therefore a tool for managing glossaries database is required, and that is what the original question is asking. – Elad Den Dec 12 '16 at 6:37
0

One major issue I had with bib2gls, is that Zotero (my reference management of choice) doesn't allow the fields and bib types it uses.

Therefore, I created a little Python package bib2glossary, to convert between bib and tex, with user defined mapping of field-to-parameter names.

>> pip install bib2glossary
>> glossary2bib path/to/file.tex --entry-type misc --param2field path/to/file.json
>> bib2glossary path/to/file.bib --entry-type misc --param2field path/to/file.json

It uses TexSoup and BibtexParser to parse bibtex and latex respectively

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.