Debian Codegraph @

texmf-dist/doc/support/bib2gls/README.md

raw
1 # bib2gls
2
3 Command line application to convert `.bib` files to
4 `glossaries-extra.sty` resource files.
5
6 Author: Nicola Talbot (https://www.dickimaw-books.com/contact)
7
8 Application Home Page: https://www.dickimaw-books.com/software/bib2gls
9
10 Version details of the current installation can be obtained with
11 `--version` or `-v`:
12
13 ```bash
14 bib2gls --version
15 convertgls2bib --version
16 datatool2bib --version
17 ```
18
19 ## Licence
20
21 Copyright (C) 2017-2025 Nicola L. C. Talbot (dickimaw-books.com)
22
23 License GPLv3+: GNU GPL version 3 or later
24 http://gnu.org/licenses/gpl.html
25 This is free software: you are free to change and redistribute it.
26 There is NO WARRANTY, to the extent permitted by law.
27
28 ## Requirements
29
30 - Java Runtime Environment (at least Java 8).
31
32 - TeX distribution that includes `glossaries-extra.sty`
33 and dependent packages (such as `glossaries.sty`).
34
35 ## Summary
36
37 This application may be used to extract glossary information
38 stored in a `.bib` file and convert it into glossary entry
39 definition commands. This application should be used
40 with `glossaries-extra`'s `record` package option. It performs
41 two functions:
42
43 - selects entries according to records found in the `.aux` file
44 (similar to `bibtex`)
45
46 - hierarchically sorts entries and collates location lists
47 (similar to `makeindex` or `xindy`)
48
49 This means that the glossary entries can now be managed
50 in a system such as JabRef, and only the entries that are
51 actually required will be defined, reducing the resources
52 required by TeX.
53
54 ##Supplementary applications
55
56 ### `convertgls2bib`
57
58 The supplementary application `convertgls2bib` can be used
59 to convert existing `.tex` files containing definitions
60 (`\newglossaryentry` etc) to the `.bib` format
61 required by `bib2gls`.
62
63 For example, if `entries.tex` contains:
64 ```latex
65 \newglossaryentry{bird}{name={bird},description={feathered animal}}
66
67 \newabbreviation{html}{HTML}{Hypertext Markup Language}
68
69 \newterm[plural=geese]{goose}
70
71 \newdualentry{svm}{SVM}{support vector machine}
72 {Statistical pattern recognition technique}
73 ```
74 Then do:
75 ```bash
76 convertgls2tex entries.tex entries.bib
77 ```
78 to create `entries.bib`.
79
80 ## Example
81
82 File `entries.bib`:
83
84 ```bibtex
85 @entry{bird,
86 name={bird},
87 description = {feathered animal}
88 }
89
90 @abbreviation{html,
91 short="HTML",
92 long={hypertext markup language}
93 }
94
95 @dualentryabbreviation{svm,
96 long = {support vector machine},
97 short = {SVM},
98 description = {statistical pattern recognition technique}
99 }
100
101 @symbol{v,
102 name={$\vec{v}$},
103 text={\vec{v}},
104 description={a vector}
105 }
106
107 @index{goose,plural="geese"}
108 ```
109
110 File `myDoc.tex`:
111
112 ```latex
113 \documentclass{article}
114
115 \usepackage[record,abbreviations]{glossaries-extra}
116
117 \GlsXtrLoadResources[
118 src={entries},% data in entries.bib
119 sort={en-GB}% sort according to 'en-GB' locale
120 ]
121
122 \begin{document}
123 \Gls{bird} and \gls{goose}.
124
125 First: \gls{svm}. Next: \gls{svm}.
126
127 \printunsrtglossaries
128 \end{document}
129 ```
130
131 Document build:
132 ```bash
133 pdflatex myDoc
134 bib2gls myDoc
135 pdflatex myDoc
136 ```
137 (Replace `pdflatex` with `latex`, `xelatex` or `lualatex` as
138 appropriate.)
139
140 ### `datatool2bib`.
141
142 The supplementary application `datatool2bib` can be used to convert
143 `datatool` databases to `.bib` files suitable for use with `bib2gls`.
144
145 ## Related Resources
146
147 - [bib2gls FAQ](https://www.dickimaw-books.com/faq.php?category=bib2gls).
148 - [bib2gls gallery](https://www.dickimaw-books.com/gallery/#bib2gls).
149
150 TUGboat articles:
151
152 - Glossaries with bib2gls, issue [40:1, 2019](http://tug.org/TUGboat/Contents/contents40-1.html).
153 [(PDF)](http://tug.org/TUGboat/tb40-1/tb124talbot-bib2gls.pdf)
154 - bib2gls: selection, cross-references and locations, issue [41:3, 2020](http://tug.org/TUGboat/Contents/contents41-3.html).
155 [(PDF)](http://tug.org/TUGboat/tb41-3/tb129talbot-bib2gls-more.pdf)
156 - bib2gls: sorting, issue [42:2, 2021](http://tug.org/TUGboat/Contents/contents42-2.html). [(PDF)](https://tug.org/TUGboat/tb42-2/tb131talbot-sorting.pdf)
157 - bib2gls: standalone entries and repeated lists (a little book of
158 poisons), issue [43:1, 2022](https://tug.org/TUGboat/Contents/contents43-1.html).
159 [(PDF)](https://tug.org/TUGboat/tb43-1/tb133talbot-bib2gls-reorder.pdf)
160
161 ## Installation
162
163 The files should be installed as follows where *TEXMF* indicates
164 your local or home TEXMF path (for example, `~/texmf/`):
165
166 - *TEXMF*`/scripts/bib2gls/bib2gls.jar` (Java application.)
167 - *TEXMF*`/scripts/bib2gls/convertgls2bib.jar` (Java application.)
168 - *TEXMF*`/scripts/bib2gls/datatool2bib.jar` (Java application.)
169 - *TEXMF*`/scripts/bib2gls/bibglscommon.jar` (Java library
170 providing code shared by `bib2gls` and the conversion tools.)
171 - *TEXMF*`/scripts/bib2gls/texparserlib.jar` (Java library.)
172 - *TEXMF*`/scripts/bib2gls/resources/bib2gls-en.xml` (main English
173 resource file.)
174 - *TEXMF*`/scripts/bib2gls/resources/bib2gls-extra-en.xml`
175 (supplementary English resource file.)
176 - *TEXMF*`/scripts/bib2gls/resources/bib2gls-extra-nl.xml`
177 (supplementary Dutch resource file.)
178 - *TEXMF*`/scripts/bib2gls/bib2gls.sh` (Unix-like systems only.)
179 - *TEXMF*`/scripts/bib2gls/convertgls2bib.sh` (Unix-like systems
180 only.)
181 - *TEXMF*`/scripts/bib2gls/datatool2bib.sh` (Unix-like systems
182 only.)
183 - *TEXMF*`/doc/support/bib2gls/bib2gls.pdf` (User manual.)
184 - *TEXMF*`/doc/support/bib2gls/bib2gls-begin.pdf` (Introductory Guide.)
185 - *TEXMF*`/doc/support/bib2gls/examples/` (example files)
186
187 Note that `texparserlib.jar` isn't an application. It's
188 a library used by `bib2gls.jar` and the `*2bib` conversion tools
189 and so needs to be on the same class path as them.
190
191 The bash `.sh` scripts are provided for Unix-like users.
192 They're not required for Windows. The `.1` files are `man`
193 files and should be placed where `man` can find them. (They
194 are created from the `.pod` files.)
195
196 To test installation:
197 ```bash
198 bib2gls --version
199 convertgls2bib --version
200 ```
201 These should display the version details.
202
203 ## Source Code
204
205 Instructions for compiling the manual and jar files are listed
206 below. The source is also available on GitHub, but that may be for
207 a newer experimental version.
208
209 - https://github.com/nlct/bib2gls
210 - https://github.com/nlct/texparser
211
212
213 ### User Manual (bib2gls.pdf)
214
215 The examples directory needs to be ../examples relative to directory
216 containing bib2gls.tex as the .bib, .tex and .pdf files are included
217 in the manual.
218
219 ```bash
220 xelatex bib2gls
221 bibtex bib2gls
222 bib2gls -g bib2gls
223 xelatex bib2gls
224 bib2gls -g bib2gls
225 xelatex bib2gls
226 xelatex bib2gls
227 ```
228
229 Similarly for the bib2gls-begin.pdf document.
230
231 ### JAR Files
232
233 Create the following directories:
234
235 `lib`
236 `lib/resources`
237 `java`
238 `classes/com/dickimawbooks/bib2gls`
239 `classes/com/dickimawbooks/gls2bib`
240 `classes/com/dickimawbooks/texparserlib`
241
242 Unpack the zip files:
243
244 ```bash
245 unzip -d java bib2gls-src.zip
246 unzip -d java gls2bib-src.zip
247 unzip -d java texparserlib-src.zip
248 ```
249
250 Copy the `.xml` language file to `lib/resources/`
251
252 Compile `texparserlib.jar`:
253
254 ```bash
255 cd java/lib
256 javac -d ../../classes
257 -Xlint:unchecked -Xlint:deprecation *.java */*.java */*/*.java
258 cd ../../classes
259 jar cf ../lib/texparserlib.jar
260 com/dickimawbooks/texparserlib/*.class \
261 com/dickimawbooks/texparserlib/*/*.class \
262 com/dickimawbooks/texparserlib/*/*/*.class
263 ```
264
265 Compile `bib2gls.jar`:
266
267 ```bash
268 cd java/bib2gls
269 javac -d ../../classes -cp ../../lib/texparserlib.jar *.java
270 cd ../classes
271 jar cmf ../java/bib2gls/Manifest.txt ../lib/bib2gls.jar
272 com/dickimawbooks/bib2gls/*.class
273 ```
274
275 Compile `convertgls2bib.jar`:
276
277 ```bash
278 cd java/gls2bib
279 javac -d ../../classes -cp ../../lib/texparserlib.jar *.java
280 cd ../classes
281 jar cmf ../java/gls2bib/Manifest.txt ../lib/convertgls2bib.jar
282 com/dickimawbooks/gls2bib/*.class
283 ```