Debian Codegraph @

doc/bibtool.tex

raw
1 %%*** bibtool.tex *************************************************************
2 %%
3 %% This file is part of BibTool.
4 %% It is distributed under the Creative Commons Attribution-Share
5 %% Alike 3.0 License.
6 %%
7 %% (c) 1995-2020 Gerd Neugebauer
8 %%
9 %% Net: [email protected]
10 %%
11 %%-----------------------------------------------------------------------------
12 %% Usage: latex bibtool
13 %% bibtex bibtool
14 %% latex bibtool
15 %% makeindex -s bibtool.ist bibtool
16 %% latex bibtool
17 %%*****************************************************************************
18
19 \documentclass[11pt,a4paper]{scrbook}
20
21 \usepackage{bibtool-doc}
22
23 \input{config.tex}
24
25 \hypersetup{pdftitle={BibTool Manual}}
26 \hypersetup{pdfauthor={Gerd Neugebauer}}
27 \hypersetup{pdfsubject={Version \Version}}
28
29 \makeindex
30
31 \DeclareFontShape{OT1}{cmss}{m}{it}{<-> ssub * cmss/m/sl}{}
32
33 \definecolor{keyword}{rgb}{0,.5,0}
34 \definecolor{bibtex-bg}{rgb}{0.9607843137,0.9019607843,0.8235294118}
35 \usepackage{listings}
36 \lstdefinelanguage{BibTeX}{sensitive=false,
37 basicstyle=\footnotesize\ttfamily,
38 keywordstyle=\bfseries\color{keyword},
39 keywords={@string,@article,@book,@misc,@proceedings,@manual,@modify,
40 @alias,@include,@InBook,@XData},
41 backgroundcolor=\color{bibtex-bg},
42 frame=single,
43 framerule=0pt}
44 \lstdefinelanguage{BibTool}{sensitive=false,
45 basicstyle=\scriptsize\ttfamily,
46 keywordstyle=\color{keyword}\bfseries,
47 alsoletter=.,%
48 keywords={add.field,apply.alias,apply.modify,apply.include,and,
49 bibtex.env.name,bibtex.search.path,check.double,
50 check.double.delete,check.rule,check.case.sensitive,
51 clear.crossref.map,clear.ignored.words,count.all,count.used,
52 crossref.limit,crossref.map,default.key,delete.field,
53 dir.file.separator,dump.symbols,env.separator,extract.file,
54 extract.regex,expand.macros,expand.crossref,expand.xdata,
55 fmt.inter.name,fmt.name.pre,fmt.name.name,fmt.name.title,
56 fmt.title.title,fmt.et.al,fmt.word.separator,field.type,false,
57 input,ignored.word,ilike,key.generation,key.base,key.format,
58 key.make.alias,key.number.separator,key.expand.macros,like,
59 macro.file,mod,new.entry.type,new.field.type,new.format.type,not,
60 nil,output.file,or,pass.comments,preserve.key.case,preserve.keys,
61 print,print.align.string,print.align.comment,print.align.preamble,
62 print.align.key,print.align,print.all.strings,print.entry.types,
63 print.equal.right,print.braces,print.comma.at.end,
64 print.deleted.prefix,print.deleted.entries,print.indent,
65 print.line.length,print.newline,print.parentheses,
66 print.terminal.comma,print.use.tab,print.wide.equal,quiet,
67 regexp.syntax,rename.field,resource,resource.search.path,
68 rewrite.rule,rewrite.case.sensitive,rewrite.limit,select,
69 select.by.string,select.by.non.string,select.by.string.ignored,
70 select.case.sensitive,select.fields,select.non,select.crossrefs,
71 sort,sort.cased,sort.macros,sort.reverse,sort.order,sort.format,
72 suppress.initial.newline,symbol.type,tex.define,true,verbose,
73 version},
74 backgroundcolor=\color{rsc-bg},
75 frame=single,
76 framerule=0pt}
77
78 \makeatletter%>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
79
80 \newcommand\opt[1]{\texttt{-{}#1}\index{#1@\texttt{-{}#1}}}
81
82 \definecolor{sh-bg}{rgb}{.9,.9,.9}
83 \definecolor{sh-border}{rgb}{.4,.4,.4}
84
85 \newcommand\sh{\smallskip\par\hspace*{2em}\@ifnextchar[{\sh@}{\sh@@}}
86 \def\sh@[#1]#2{%
87 \fcolorbox{sh-border}{sh-bg}{\hspace*{1em}\begin{minipage}{.85\textwidth}
88 \texttt{bibtool -{}#1 }\textit{#2}\index{#1@\texttt{-{}#1}}
89 \end{minipage}}\smallskip\par\noindent\ignorespaces}
90 \newcommand\sh@@[1]{%
91 \fcolorbox{sh-border}{sh-bg}{\hspace*{1em}\begin{minipage}{.85\textwidth}
92 \texttt{bibtool }\textit{#1}
93 \end{minipage}}\smallskip\par\noindent\ignorespaces}
94
95 \newcommand\bibLaTeX{Bib\-\LaTeX\index{biblatex@Bib\-\LaTeX}}
96
97 \makeatother%<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
98
99 \newcommand\rsc[1]{\textsf{#1}\index{#1@\textsf{#1}}}
100 \newcommand\rscEqBraces[2]{\rsc{#1} = \(\{\)#2\(\}\)}
101 \newcommand\rscBraces[2]{\rsc{#1} \(\{\)#2\(\}\)}
102 \newcommand\rscIt[1]{\textsf{\textit{#1}}}
103 \newcommand\env[1]{\texttt{#1}\index{#1@\texttt{#1}}}
104
105 \definecolor{rsc-bg}{rgb}{.9,1,.9}
106 \definecolor{rsc-border}{rgb}{.4,.6,.4}
107 \newbox\rscbox
108 \newenvironment{Resources}%
109 {\setbox\rscbox=\hbox\bgroup\hspace*{.06\textwidth}\begin{minipage}{.88\textwidth}\sffamily\obeylines\obeyspaces
110 }{\end{minipage}\egroup\vspace{1.5ex}%
111 \fcolorbox{rsc-border}{rsc-bg}{\usebox\rscbox}%
112 \medskip\par
113 }
114
115 \newcommand\code[1]{\texttt{#1}}
116 \newcommand\file[1]{\textsf{#1}}
117
118 \newcommand\off{\textsf{off}}
119 \newcommand\on{\textsf{on}}
120
121 \newcommand\bs{\texttt{\symbol{"5C}}\ignorespaces}
122 \newcommand\BS{\(\backslash\)}
123 \newcommand\Hat{\^{}}
124
125 \newfont\cminch{cminch}
126 \ifx\chaptername\relax\else
127 \renewcommand\chaptername{\cminch}
128 \renewcommand\appendixname{\cminch}
129 \fi
130
131 \newcommand\rfill[1]{\leaders\hrule height #1\hfill}
132
133 \newenvironment{Summary}{\subsection*{Summary}
134 \begin{center}\small
135 \begin{tabular}{p{.08\textwidth}p{.35\textwidth}p{.48\textwidth}}
136 \toprule
137 \textit{\scriptsize Option}&
138 \textit{\scriptsize Resource command}&
139 \textit{\scriptsize Description}\\
140 \midrule
141 }{\bottomrule\end{tabular}\end{center}}
142
143 \newcommand\Desc[3]{\textit{#1}&\textit{#2}&#3\\\hline}
144
145 \newenvironment{Example}{\smallskip\par\textit{Example}\par}{\smallskip\par}
146
147 \newenvironment{Disclaimer}{\begin{center}\sffamily\tiny --- }{ ---\end{center}}
148
149 \newcommand\LINK[2]{\texttt{#2}}
150 \newcommand\Link[2]{\href{#1}{\texttt{#2}}}
151 \newcommand\email[1]{\href{mailto:#1}{\texttt{#1}}}
152
153 \newcommand\FTP[2]{\texttt{#1}}
154
155 \newcommand\ASCII{\textsc{ascii}}
156
157 \let\BIBTEX\BibTeX
158 \renewcommand\BibTeX{\BIBTEX\index{bibtex@\BIBTEX}}
159
160 \begin{document} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
161
162 \title{\BibTool{} Manual}
163 \author{\(\cal G\)\hspace{-.1em}erd \(\cal N\)\hspace{-.2em}eugebauer}
164 \maketitle
165
166 \begin{Abstract}
167 \BibTeX\ provides an easy to use means to integrate citations and
168 bibliographies into \LaTeX\ documents. But the user is left alone with the
169 management of the \BibTeX\ files. The program \BibTool\ is intended to fill
170 this gap. \BibTool\ allows the manipulation of \BibTeX\ files which goes
171 beyond the possibilities -- and intentions -- of \BibTeX. The possibilities
172 of \BibTool\ include sorting and merging of \BibTeX\ data bases, generation
173 of uniform reference keys, and selecting of references used in a
174 publication.
175 \end{Abstract}
176
177 %------------------------------------------------------------------------------
178 \newpage
179 \begingroup\setlength\parskip{1ex}\setlength\parindent{0pt}
180 This file is part of \BibTool{} Version \Version
181 \medskip\par
182
183 Copyright \copyright{} \Year{} Gerd Neugebauer
184 \medskip\par
185
186 \BibTool{} is free software; you can redistribute it and/or modify it under
187 the terms of the \LINK{GPL.html}{GNU General Public License} as published by
188 the Free Software Foundation; either version 1, or (at your option) any later
189 version.
190
191 \BibTool{} is distributed in the hope that it will be useful, but WITHOUT ANY
192 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
193 A PARTICULAR PURPOSE. See the \LINK{GPL.html}{GNU General Public License} for
194 more details.
195
196 You should have received a copy of the \LINK{GPL.html}{GNU General Public
197 License} along with this documentation; see the file
198 \LINK{GPL.html}{COPYING}. If not, write to the Free Software Foundation, 675
199 Mass Ave, Cambridge, MA 02139, USA.
200 \vfill\par
201 Gerd Neugebauer\\
202 Im Lerchelsb\"ohl 5\\
203 64521 Gro\ss-Gerau (Germany)\par\noindent
204 Net: \Link{http://www.gerd-neugebauer.de/}{http://www.gerd-neugebauer.de/}
205 \par\noindent
206 E-Mail: \email{[email protected]}
207 \endgroup
208 %------------------------------------------------------------------------------
209 \tableofcontents
210
211 %------------------------------------------------------------------------------
212 \chapter{Introduction}
213
214 The user's manual is divided into two parts. In this first part the big
215 picture on \BibTool{} is shown. The next chapter after this one is then
216 devoted to the nitty gritty details.
217
218
219 \section{Related Programs}
220
221 \BibTeX{} \cite{lamport:latex,patashnik:bibtexing,patashnik:designing} is a
222 system for integrating bibliographic information into \LaTeX{}
223 \cite{lamport:latex} documents. \BibTeX{} is designed to serve exactly this
224 purpose. It has shown that various tasks in relation with managing
225 bibliographic databases are not covered by \BibTeX. Usual activities on
226 bibliographic databases include
227 \begin{itemize}
228 \item inserting new entries
229 \item editing
230 \item using citations in documents
231 \item sorting and merging of bibliographic data bases
232 \item extraction of bibliographic data bases
233 \end{itemize}
234 %
235 Since only the integration in documents is covered by \BibTeX{} several
236 utilities emerged to fill the gaps. We will sketch some of them shortly.
237 %
238 \begin{description}
239 \item
240 [\href{https://www.ctan.org/pkg/bibtex}{\BibTeX}] is
241 a program by Oren Patashnik to select publications used in a \LaTeX{}
242 document and format them for inclusion into this document. This program
243 should be part of each \TeX{} installation.
244
245 \item
246 [\href{https://www.ctan.org/pkg/biber}{biber}] is a program to replace
247 \BibTeX\ when used in combination with
248 \href{https://www.ctan.org/pkg/biblatex/}{\bibLaTeX}
249
250 \item
251 [\href{https://www.ctan.org/pkg/bibclean}{bibclean}]
252 is a program by Nelson H.F.~Beebe to pretty-print \BibTeX{} files. It also
253 can act as syntax checker. The C sources can be compiled on several systems.
254
255 \item
256 [\href{https://www.ctan.org/pkg/biblook}{bibindex/biblook}]
257 is a pair of programs by Nelson H.F.~Beebe to generate an index for a
258 \BibTeX{} file and use it to perform a fast look-up of certain entries. The
259 programs so far run only under UNIX.
260
261 \item
262 [\href{https://www.ctan.org/pkg/bibsort}{bibsort}]
263 is a UNIX shell script by Nelson H.F.~Beebe to sort a \BibTeX{} file.
264
265 \item
266 [\href{https://www.ctan.org/pkg/bibextract}{bibextract}]
267 is a UNIX shell script by Nelson H.F.~Beebe to extract entries from a
268 \BibTeX{} file which are used in a \LaTeX{} document.
269
270 \item
271 [\href{https://www.ctan.org/pkg/lookbibtex}{lookbibtex/bibdestringify}]
272 are Perl scripts by John Heidemann to extract entries from a \BibTeX{}
273 file which are used in a \LaTeX{} document and to remove strings from a
274 \BibTeX{} file.
275
276 \item
277 [\href{https://www.ctan.org/pkg/bibtools}{bibtools}]
278 is a collection of UNIX shell scripts by David Kotz to add and extract
279 entries to bibliographic databases. Several small programs are provided to
280 perform special tasks.
281
282 \item
283 [\href{https://www.ctan.org/pkg/bibview}{bibview}]
284 is a Perl script by Dana Jacobsen to extract entries from a \BibTeX{} file
285 which are used in a \LaTeX{} document.
286
287 \item
288 [\href{https://www.ctan.org/pkg/jabref}{JabRef}]
289 is a graphical front-end to manage \BibTeX\ databases, designed and built to
290 be platform independent.
291
292 \item
293 [\href{https://www.ctan.org/pkg/bibcard}{BibCard}]
294 is a program by William C.~Ogden running under X11/xview which provides a
295 means to edit bibliographic databases.
296
297 \item
298 [\href{https://www.ctan.org/pkg/xbibtex}{xbibtex/bibprocess/bibsearch}]
299 are programs by Nicholas J. Kelly and Christian H. Bischof running under X11
300 which provides a means to edit bibliographic databases, add fields to a
301 \BibTeX{} file and extract certain entries from a \BibTeX{} file.
302
303 \item
304 [\href{https://www.ctan.org/pkg/bibview}{bibview}]
305 is an X11 program by Holger Martin, Peter Urban, and Armin Liebl to search
306 in and manipulate \BibTeX{} files. It is similar to BibCard and hyperbibtex.
307
308 \item
309 [\href{https://www.ctan.org/pkg/tkbibtex}{tkbibtex}]
310 is a \BibTeX{} file browser with support for editing, searching sorting and
311 merging. Written by Peter Corke in Tcl/Tk it runs under Unix and Windows.
312
313 \item [\href{https://www.ctan.org/pkg/bibdb}{bibdb}] Editor
314 for \BibTeX{} files that runs under Dos and Windows.
315
316 \item
317 [\href{https://www.ctan.org/pkg/qbibman}{qbibman}]
318 is a graphical user interface by Ralf G\"{o}rtz utilizing \BibTool{} as
319 underlying library. It is written in C++ and uses Qt.
320
321 \item [\href{http://barracuda.linuxbox.com/}{Barracuda}] an X11 Editor for
322 \BibTeX{} files, written in C++ and Qt.
323
324 \item [\BibTeX-Mode] is an extension of the editor GNU-Emacs to provide means
325 to edit \BibTeX{} files. Several useful operations are provided.
326 There is also a \BibTeX-Mode for the Emacs-like JED-Editor.
327
328 \item
329 [\href{https://www.ctan.org/pkg/btool/}{btOOL}]
330 is a Perl library to access \BibTeX{} files. It is implemented in Perl and C
331 and has been written by Greg Ward.
332
333 \end{description}
334
335 This is a selection of some programs I have heard of. I have tested some of
336 them and I have skipped through the documentation of others. Thus the
337 description may be too short or incomplete. Some additional information can be
338 found in \cite[Chapter~13]{goosens.mittelbach.ea:companion}.
339
340 Most of those utilities are tailored towards a particular operating system and
341 thus they are not available on other platforms. Most of these program are made
342 to perform a single task. Often they can not be configured to suit a personal
343 taste of a user.
344
345 Still there are some points not covered by the utilities mentioned above.
346 \BibTool{} tries to provide the missing features and integrate others into a
347 single tool.
348
349
350 %------------------------------------------------------------------------------
351 \section{Using \BibTool{}---Some Instructive Examples}
352
353 \BibTool\ has been developed on UN*X and UN*X-like machines. This has
354 influenced many of the design decisions. Version 1 was controlled using
355 numerous command line options. This way of controlling has been supplemented
356 in version 2 by the concept of a resource file. This resource file allows the
357 modification of the various internal parameters determining the behavior of
358 \BibTool.
359
360 When \BibTool\ has been compiled correctly there should be an executable file
361 named \texttt{bibtool}\footnote{Maybe with an additional extension.}. We will
362 assume that you are running \BibTool\ from a command line interpreter. There
363 you can simply issue the command
364
365 \sh{}
366
367 Now \BibTool{} will start reading from the standard input lines obeying the
368 rules of a \BibTeX{} file.\footnote{We assume that no resource file can be
369 found. Resource files will be described later.} The entries read are
370 pretty-printed on the standard output. It is obvious that this behavior is not
371 very useful in itself. The origin of this kind of interface lies in the
372 concepts of UN*X where many commands can act as filters.
373
374 Usually we do not intend to use \BibTool{} in this way. Thus we need a way to
375 specify an input file. This is simply done by adding the file name as argument
376 after the command name like in
377
378 \sh{file.bib}
379
380 The result of this command can at once be seen on the screen. The contents of
381 the file \texttt{file.bib} is pretty printed.
382
383
384 Now that we have seen the simplest case of the application of \BibTool{} we
385 will see the case of a useful application of \BibTool. This application is the
386 sorting and merging of \BibTeX{} databases.
387
388
389 %------------------------------------------------------------------------------
390 \subsection{Sorting and Merging}\label{sample.sort}
391
392 \BibTeX{} files can be sorted by specifying the command line option \opt{s}.
393 The given files are sorted according to the reference key. Several files can
394 be given at once in which case \BibTool{} will sort and merge those files.
395
396 \sh[s]{file1.bib file2.bib}
397
398 With the command line option \opt{S} the files are sorted in reverse \ASCII{}
399 order.
400
401 \sh[S]{file1.bib file2.bib}
402
403 If you want to sort the \BibTeX{} files according to the authors then the
404 following invocation should do the trick:\index{N@\%N}
405
406 \sh[s]{--sort.format="\%N(author)" file1.bib file2.bib}
407
408 This means that the sorting order is determined by the (normalized) author
409 field. Note that single quotes encapsulating the \rsc{sort.format} are
410 necessary to prevent the command line interpreter to gobble the special
411 characters.
412
413
414 If you want to sort the \BibTeX{} files according to the date then you have to
415 know how the year field is filled. Suppose you know that the year contains the
416 year preceeded by the month like in \texttt{Mar 2018}. Then the following
417 invocation sorts according to the year:\index{d@\%d}
418
419 \sh[s]{--sort.format="\%d(year)" file1.bib file2.bib}
420
421
422 %------------------------------------------------------------------------------
423 \subsection{Key Generation}
424
425 Once you have a reference and you insert it into a \BibTeX{} file you have to
426 assign a reference key to it. The problem is to find a key which is unique and
427 meaningful, i.e.\ easy to remember. The easiest way to remember a key is to
428 use an algorithm to create it and remember the algorithm---which is the same
429 for all keys.
430
431 One algorithm which comes to mind is to use the author and (an initial part)
432 of the title. Alternatively we can use the author and the year. But the
433 problem is with industrious authors writing more than one publication per
434 year. The necessary disambiguation of such references is not very intuitive.
435 However, \BibTool{} has the capability to describe desired keys. Thus, the
436 alternatives described above can be realized.
437
438
439 For this section we want to use the following \BibTeX{} entry as our
440 example:\footnote{Shamelessly stolen from the \BibTeX{} \file{xamples.bib}
441 file.} Suppose it is contained in a file named \file{sample.bib}.
442
443 \label{sample1}%
444 \begin{lstlisting}[language=BibTeX]
445 @ARTICLE{article-full,
446 author = {L[eslie] A. Aamport},
447 title = {The Gnats and Gnus Document Preparation System},
448 journal = {\mbox{G-Animal's} Journal},
449 year = 1986,
450 volume = 41,
451 number = 7,
452 pages = "73+",
453 month = jul,
454 note = "This is a full ARTICLE entry",
455 }
456 \end{lstlisting}
457
458 First, we want to see how we can make keys consisting of author and title.
459 This is one of my favorite algorithms thus it is rather easy to use it. You
460 simply have to run the following command:
461
462 \sh[k]{\texttt{sample.bib \opt{o} sample1.bib}}
463
464 After the command has completed it's work the following entry can be found in
465 the output file \file{sample1.bib}:
466
467 \begin{lstlisting}[language=BibTeX]
468 @Article{ aamport:gnats,
469 author = {L[eslie] A. Aamport},
470 title = {The Gnats and Gnus Document Preparation System},
471 journal = {\mbox{G-Animal's} Journal},
472 year = 1986,
473 volume = 41,
474 number = 7,
475 pages = "73+",
476 month = jul,
477 note = "This is a full ARTICLE entry"
478 }
479 \end{lstlisting}
480
481 You see that the reference key has been changed. It now consists of the last
482 name and the first relevant word of the title, separated by a colon. Sometimes
483 it might be desirable to incorporate the initial names as well. This can be
484 achieved by the command
485
486 \sh[K]{\texttt{sample.bib \opt{o} sample1.bib}}
487
488 The resulting reference key is \texttt{aamport.la:gnats}. The initials are
489 appended after the first name. Thus the usual lexicographic order on the keys
490 will (hopefully) bring together the publications of the same first author.
491
492 Another alternative is to use the author and the year. This can be achieved
493 with the following command:\footnote{Note that some command line interpreters
494 (like the UN*X shells) require the format string to be quoted (enclosed in
495 single quotes).}\index{n@\%n}
496
497 \sh[f]{\texttt{\%n(author):\%2d(year) sample.bib \opt{o} sample1.bib}}
498
499 The resulting key is \texttt{Aamport:86}. Note that the last example works as
500 desired for our sample file. But for a real application of this technique a
501 deep understanding of the key generation mechanism as described in
502 section~\ref{sec:key.gen} is necessary.
503
504
505 %------------------------------------------------------------------------------
506 \subsection{Normalization}\label{sample.norm}
507
508 \BibTool{} can be used to normalize the appearance of \BibTeX{} databases. As
509 an example we can consider the different forms of delimiters for fields.
510 \BibTeX{} allows the use of of braces or double quotes. Now it can be
511 desirable to use one style only. For this purpose the rewriting facility of
512 \BibTool{} can be applied.
513
514 \sh{-{}- \texttt{ 'rewrite.rule=\symbol{"7B}"\symbol{"5E}\symbol{"5C}"%
515 \symbol{"5C}([\symbol{"5E}\#]*\symbol{"5C})\symbol{"5C}"\$"
516 "\symbol{"7B}\symbol{"5C}1\symbol{"7D}"\symbol{"7D}'} \opt{o} out.bib}
517
518 Since this seems to be rather cryptic we will have a closer look at this
519 example. First we have to mention that the outer quotes are there because the
520 UN*X shell (csh, sh, bash,...) treats some characters special and we want to
521 avoid this to happen to the rewrite rule given. A similar quoting mechanism
522 might be required for all command line interpreters.
523
524 The rewrite rule is applied to any field. The first string---called
525 pattern---which is enclosed in double quotes is matched against the contents
526 of the field. If a match is found then the matching sub-string is replaced by
527 the replacement text in the second string.
528
529 The pattern is a regular expression\index{regular expression} like the ones
530 used in Emacs\index{Emacs}. The first character is the hat (\verb|^|). This
531 character anchors the match at the beginning of the line. The last character
532 is the dollar sign which anchors the end at the end of the field value. Thus
533 only complete matches are considered.
534
535 Since we want to find those fields whose values are enclosed in double quotes
536 they are given after the hat and before the dollar. To avoid a
537 misinterpretation as the end of the pattern they have to be quoted with the
538 backslash (\verb|\|).
539
540 Next we have the parentheses \verb|\(|\ldots\verb|\)|. They are instructions
541 to memorize the matching sub-string in a register. Since it is the first
542 instruction of this kind the register number~1 is used.
543
544 Now we come to the point where we have to specify the contents of the string.
545 For this purpose we use a character class---written as \verb|[|\ldots\verb|]|.
546 Since the first character in this class specification is a hat this class
547 consists of all characters but those given after the hat. Thus all characters
548 but the hash sign (\verb|#|\index{\#}) are allowed.
549
550 The star (\verb|*|\index{*}) after the character class indicates that an
551 arbitrary number of characters of this class are allowed.
552
553 We have used the complicated construction with a character class to avoid
554 wrong results which would have resulted when this rewrite rule is applied to a
555 concatenated field value like the following one:
556
557 \begin{lstlisting}[language=BibTeX]
558 author = "A. U. Thor" # " and " # "S. O. Meone"
559 \end{lstlisting}
560
561 Such fields are left unchanged by the rewrite rule given above. We could have
562 used the point (\verb|.|) instead of the character class since the point
563 matches any character. But this would have let to the syntactic wrong result:
564 \begin{lstlisting}[language=BibTeX]
565 author = {A. U. Thor" # " and " # "S. O. Meone}
566 \end{lstlisting}
567
568 But we have to complete the explanation of the rewrite rule. The remaining
569 part is the replacement text. Here we just have to note that the sub-string
570 \verb|\1| is not copied verbose but replaced with the contents of the first
571 register. This register contains the contents of the field without the
572 delimiting double quotes.
573
574 Thus we have a solution to our initial problem which is conservative in the
575 sense that it sometimes fails but never produces a wrong result.
576
577
578 %------------------------------------------------------------------------------
579 \subsection{Extracting Entries for a Document}\label{sample:extract}
580
581 \BibTool{} can be used to extract the references used in a document. For this
582 purpose \BibTool{} analyzes the \verb|.aux| file and takes the information
583 given there. This includes the names of the \BibTeX{} files. Thus no \BibTeX{}
584 files have to be given in the command line. Instead the \verb|.aux| file has
585 to specified---preceded by the option \opt{x}.
586
587 \sh[x]{document.aux \opt{o} document.bib}
588
589 The second option \opt{o} followed by a file name specifies the destination of
590 the output. This means, instead of writing the result to the standard output
591 stream the result is written into this file.
592
593 %------------------------------------------------------------------------------
594 \subsection{Extracting Entries Matching a Regular Expression}
595
596 \BibTool{} can be used to extract the references which fulfill certain
597 criteria. Those criteria can be specified utilizing regular
598 expressions.\footnote{Those features are only usable if the regular expression
599 library has been enabled during the configuration of \BibTool{}---which is
600 the default.} As a special case we can extract all entries containing a
601 certain sub-string of the key:
602
603 \sh[X]{tex all.bib \texttt{-o} some.bib}
604
605 This instruction selects all entries containing the sub-string \texttt{tex} in
606 the key. The second option \opt{o} followed by a file name specifies the
607 destination of the output. Thus instead of writing the result to the standard
608 output stream the result is written into this file.
609
610 Next we want to look up all entries containing a sub-string in some of its
611 fields. For this purpose we search for the string in all fields
612 first:\footnote{Note that some command line interpreters (e.g the UN*X shells)
613 might need additional quoting of the select instruction since it contains
614 special characters.}
615
616 \sh[-]{select\{"tex"\} all.bib \texttt{-o} some.bib}
617
618 Note that the comparison is not done case sensitive; however this can be
619 customized (see page~\pageref{sec:extract}).
620
621 Finally we want to select only those entries containing the sub-string in
622 anyone of certain fields. For this purpose we simply specify the names of
623 those fields in the \textit{select} instruction:
624
625 \sh[-]{select\{title booktitle \$key "tex"\} all.bib \texttt{-o} some.bib}
626
627 This example extracts all entries containing the sub-string \texttt{tex} in
628 the title field, the booktitle field, or the reference key.
629
630 After we have come so far we can say that the first example in this section is
631 in fact a short version of the following command:
632
633 \sh[-]{select\{\$key "tex"\} all.bib \texttt{-o} some.bib}
634
635 As a simple case of extraction we might want to extract all books from a
636 bibliography. This can be done with the following command:
637
638 \sh[-]{select\{@book\} all.bib \texttt{-o} some.bib}
639
640 A similar method can also be applied for other entry types.
641
642 \begin{description}
643 \item[Note] Usually cross-referenced entries are not selected automatically.
644 This can result in incomplete---and thus incorrect---\BibTeX\ files. To
645 avoid this behavior use the following command:
646
647 \sh[-]{select\{\@{}book\} \texttt{-c} all.bib \texttt{-o} some.bib}
648
649 \end{description}
650
651 %------------------------------------------------------------------------------
652 \subsection{Translating ISO 8859-1 Characters}
653
654 Sometimes you need to translate some special characters into \BibTeX\
655 sequences. Suppose you have edited a \BibTeX\ file and by mistake used those
656 nice characters that are incompatible with standard \ASCII{} as used in
657 \BibTeX. You can use \BibTool\ to do the trick:
658
659 \sh[r]{iso2tex \opt{i} iso.bib \opt{o} ascii.bib}
660
661
662 %------------------------------------------------------------------------------
663 \subsection{Correctly Sorting Cross-referenced Entries}
664
665 \BibTeX\ has a restriction that a cross-referenced entry has to come after the
666 referencing entry. This can be achieved by putting all entries containing a
667 field ``crossref'' before those containing none. As second sorting criterion
668 we want to use the reference key.
669
670 This can be achieved with a resource file containing the
671 following instructions\index{l@\%l}
672
673 \begin{Resources}
674 \rsc{sort.format} = \{\{\%1.\#s(crossref)a\#z\}\$key\}
675 \rsc{sort.reverse} = off
676 \rsc{sort} = on
677 \end{Resources}
678
679 The magic is contained in the first instruction. Thus we will examine it in
680 detail:
681 \begin{description}
682 \item [\texttt{\%1.\#s(crossref)}]\index{l@\%l}\ \\
683 This formatting instruction does not produce any output but simply acts as
684 condition to determine whether or not to include the following string. The
685 condition counts the allowed characters (\texttt{\#s}) of the field
686 \texttt{crossref} and compares this number with the given interval
687 \([1,\infty]\) (\texttt{1.}).
688
689 Thus it detects those entries containing a non empty crossref field.
690 \item [\texttt{\%1.\#s(crossref)a}]\index{l@\%l}\ \\
691 If the condition holds then the string \texttt{a} is used as part of the
692 sort key.
693 \item [\texttt{\{\%1.\#s(crossref)a\#z\}}]\index{l@\%l}\ \\
694 If the first condition fails then the next alternative after the hash mark
695 (\texttt{\#}) is considered. This is the string \texttt{z} which will always
696 succeed and thus be included into the sort key.
697
698 Thus this construction will produce \texttt{a} if a crossref field is
699 present and not empty or \texttt{z} otherwise.
700 \item [\texttt{\{\%1.\#s(crossref)a\#z\}\$key}]\index{l@\%l}\ \\
701 Finally the reference key (\texttt{\$key}) is appended to the characterizing
702 initial letter.
703 \end{description}
704
705 The sorting according to ascending ASCII order will bring all the entries with
706 crossref fields to the beginning.
707
708
709 %------------------------------------------------------------------------------
710 \subsection{Petering Out Fields}
711
712 Sometimes you might be collecting \BibTeX\ files form various sources. Then
713 there might be additional and for you useless fields. For instance a creator
714 of the \BibTeX\ files may have included a library number in the field |libno|
715 and you want to get rid of it. In such a case you can use the resource
716 \rsc{delete.field} as in the following example.
717
718 The following instruction is placed in a resource file which is passed to
719 \BibTool\ with the command line option \opt{r}.
720
721 \begin{Resources}
722 \rsc{delete.field} = \{ libno \}
723 \end{Resources}
724
725 If you have several fileds to delete then you can use the resource
726 \rsc{delete.field} several times. All fields will be deleted.
727
728 Another example can be achieved with the following command line:
729
730 \sh[r]{keep\_bibtex wild.bib \opt{o} reduced.bib}
731
732 This invocation utilizes the library \file{keep\_bibtex.rsc} which declares
733 that only those fields should not be deleted which are defined for the
734 standard styles of \BibTeX.
735
736 And in a similar way the standard fields of \bibLaTeX\ can be kept with the
737 following command line:
738
739 \sh[r]{keep\_biblatex wild.bib \opt{o} reduced.bib}
740
741
742 %------------------------------------------------------------------------------
743 \subsection{\BibTool\ for \bibLaTeX}
744
745 \BibTool\ contains the definitions to cope with \BibTeX\ files prepared for
746 \bibLaTeX. These definitions are contained in the library \file{biblatex.rsc}.
747 It can be easily included on the command line:
748
749 \sh[r]{biblatex \opt{i} in.bib \opt{o} out.bib}
750
751 Details can be found in section~\ref{lib:biblatex}.
752
753 %------------------------------------------------------------------------------
754 \section{Interfacing \BibTool{} with Other Programming Languages}
755
756 \BibTool{} can be used as a means for other programming languages to access
757 \BibTeX{} data bases. In this course \BibTool{} reads the \BibTeX{} file and
758 prints it in a normalized form which makes it easy for the host programming
759 language to parse it and get the information about the entries and fields.
760
761 In addition \BibTool{} can already pre-select several entries or do other
762 useful transformations before the host programming language even sees the
763 contents. Thus it is fairly easy to write a CGI script (e.g.\ in Perl) which
764 utilizes \BibTool{} to extract certain entries from a \BibTeX{} data base and
765 presents the result on a HTML page.
766
767 Currently the distribution of \BibTool{} contains frames of programs in Perl
768 and Tcl which can be used as a basis for further developments.
769
770 I am working towards making \BibTool{} a linkable library of C code. As one
771 step into this direction the exported functions and header information has
772 been documented. This documentation is contained in the distribution.
773
774 A tight integration of BibTool into another programming language is possible.
775 As an experiment into this direction I have chosen Tcl as the target language.
776 The result is BibTcl which is contained in the distribution of \BibTool.
777
778
779 %------------------------------------------------------------------------------
780 \section{Getting \BibTool, Hot News, and Bug Reports}
781
782 Usually \BibTool{} can be found on the CTAN or one of its mirrors. Thus you
783 can get \BibTool{} via HTTP or FTP or extract it from a DVD containing a dump
784 of the CTAN. It can be found in the following location:
785 \begin{list}{}{}
786 \item \Link{http://mirrors.ctan.org/biblio/bibtex/utils/bibtool}%
787 {http://mirrors.ctan.org/biblio/bibtex/utils/bibtool}
788 \end{list}
789
790 A signature for the source bundle is provided as well. My public key can be
791 found on \Link{http://pgp.mit.edu/}{http://pgp.mit.edu/}. You should search
792 for \texttt{[email protected]}.
793
794 \BibTool\ is hosted in a public repository at
795 \Link{https://github.com}{github}\footnote{It used to be on
796 Sarovar 'till December 2013.}. The repository contains the released sources
797 as well as the development versions. The repository can be found at
798 \begin{quote}
799 \Link{https://github.com/ge-ne/bibtool}{https://github.com/ge-ne/bibtool}
800 \end{quote}
801
802 I have set up a WWW page for \BibTool. It contains a short description of the
803 features and links to the documentation and the current downloadable version
804 in source form. The URL is:
805
806 \begin{quote}
807 \Link{http://www.gerd-neugebauer.de/software/TeX/BibTool/}{http://www.gerd-neugebauer.de/software/TeX/BibTool/}
808 \end{quote}
809
810 In addition, this page contains a description of the current version of
811 \BibTool{} and a list of changes in the last few releases.
812
813 If you encounter problems installing or using \BibTool{} you can send me a bug
814 report to my email address \texttt{[email protected]}. Please include
815 the following information into a bug report:
816 \begin{itemize}
817 \item The version of \BibTool{} you are using.
818 \item Your hardware specification and operating system version.
819 \item The C compiler you are using and its version. (Only for compilation and
820 installation problems)
821 \item The resource file you are using. Try to reduce it to the absolute
822 minimum necessary for demonstrating the problem.
823 \item A \emph{small} \BibTeX{} file showing the problem.
824 \item The command line options of an invocation of \BibTool{} making
825 the problem appear.
826 \item A short justification why you think that the behavior is an error.
827 \end{itemize}
828
829 I have had the experience that compiling this information has helped me find
830 my own problems in using software. Thus I could fix several problems before
831 sending a bug report.
832
833 On the other side I have unfortunately also had the experience that I have got
834 complains about problems in my software. After several questions it turned out
835 that the program had not been used properly.
836
837 Oh, sure. There have been bugs and I suppose there are still some bugs in
838 \BibTool. I am grateful for each hint which helps me eliminating these bugs.
839
840
841
842 \section{Contributing to \BibTool}
843
844 As you might have read \BibTool{} is free software in the sense of the Free
845 Software Foundation. This means that you can use it as a whole or parts of it
846 as long as you do not deny anyone to have the sources and use it freely. See
847 the file \LINK{COPYING}{COPYING} for details.
848
849 If you feel morally obliged to provide compensation for the use of this
850 program I have the following suggestions.
851
852 \begin{itemize}
853 \item Proofread this documentation and report any errors you find as well as
854 additional material to put in.
855 \item Provide additional contributed pieces to \BibTool. For instance useful
856 resource files which could be included into the library.
857 \item Write a useful program and release it to the public without making
858 profit, preferably under an Open Source license like the \LINK{GPL.html}{GNU
859 General Public License} or the GNU artistic license.
860 \end{itemize}
861
862
863 %------------------------------------------------------------------------------
864 \appendix
865 \chapter{Reference Manual}
866 %------------------------------------------------------------------------------
867
868 This part of the documentation tries to describe all commands and options.
869 Since the behavior of \BibTool{} can be adjusted at compile time not all
870 features may be present in your executable. Thus watch out and complain to the
871 \emph{installer} if something is missing.
872
873 %------------------------------------------------------------------------------
874 \section{Beware of the Command Line}
875
876 Be aware that command line interpreters have different ideas about what to do
877 with a command line before passing the arguments to a program. Thus it might
878 be necessary to carefully quote the arguments. Especially if the command
879 contains spaces it is very likely that quoting is needed.
880
881 For instance in UN*X shells it is in general a good strategy to enclose
882 command line arguments in single quotes (\verb|'|) if they contain white-space
883 or special characters like \texttt{\symbol{"5C}}, \texttt{\$}, \texttt{\&},
884 \verb|!|, or \verb|#|.
885
886 Instead of excessively using command line arguments it is preferable and less
887 error-prone to put the major configuration into a resource file and just
888 include this resource file on the command line. Details on this are described
889 in the next section.
890
891 %------------------------------------------------------------------------------
892 \section{Command Line Usage and Resource Files}
893
894 \BibTool{} can be controlled either by arguments given in the command line or
895 by commands given in a file (or both). Those command files are called resource
896 files. If \BibTool{} is installed correctly you should have the executable
897 command \texttt{bibtool} (maybe with an additional extension). Depending on
898 your computer and operating system you can start \BibTool{} in different ways.
899 This can be done either by issuing a command in a command line interpreter
900 (shell), by clicking an icon, or by selecting a menu item. In the following
901 description we will concentrate on the use in a UN*X like shell. There you can
902 type simply
903
904 \sh{}
905
906 Now \BibTool{} is waiting for your input. As you type \BibTool{} reads what
907 you type. This input is interpreted as data conforming \BibTeX{} file rules.
908 The result is printed when \BibTool{} is finished. You can terminate the
909 reading phase with your End-Of-File character (e.g.\ Control-D on UN*X, or
910 Control-Z on MS-D*S)
911
912 This application in itself is rather uninteresting. Thus we come to the
913 possibility to give arguments to \BibTool. The simplest argument is \opt{h} as
914 in
915
916 \sh[h]{}
917
918 This command should print the version number and a short description of the
919 command line arguments to the screen.
920
921 The next application is the specification of resources. Resource files can be
922 given in the command line after the flag \opt{r}.
923
924 \sh[r]{resource\_file}
925
926 In this way an arbitrary number of resource files can be given. Those resource
927 files are read in turn and the commands contained are evaluated. If no
928 resource file is given in the command line \BibTool{} tries to find one in
929 standard places. First of all the environment variable \env{BIBTOOLRSC} is
930 searched. If it is defined then the value is taken as a list of resource file
931 names separated by colon (UNIX), semicolon (DOS), or comma (Amiga). All of
932 them are tried in turn and loaded if they exist. If the environment variable
933 is not set or no file could be loaded successfully then the default resource
934 file (usually the file \texttt{.bibtoolrsc}) is tried to be read in the home
935 directory (determined by the environment variable \env{HOME}) or the current
936 directory.
937
938 The resource files are searched similar to the searching mechanism for
939 \BibTeX{} files (see section \ref{sec:search}). The extension \texttt{.rsc} is
940 tried and a search path can be used. This search path is initialized from the
941 environment variable \env{BIBTOOL}. Initially only the current directory is on
942 the search path. The search path can also be set in a resource file (for
943 following resource file reading). This can be achieved by setting the resource
944 \rsc{resource.search.path}.
945
946 \begin{Resources}
947 \rsc{resource.search.path} = \emph{path}
948 \end{Resources}
949
950 When an explicit resource file is given in the command line the defaults are
951 not used. To incorporate the default resource searching mechanism the command
952 line option \opt{R} can be used:
953
954 \sh[R]{}
955
956 Now let us consider some examples. Suppose that the current directory contains
957 a default resource file (named \file{.bibtoolrsc}) and an additional resource
958 file \file{my\_rsc}.
959
960 The following invocation of \BibTool{} uses only the resource file
961 \textit{my\_rsc}:
962
963 \sh{\opt{r} my\_rsc \opt{i} sample}
964
965 If you want to initialize the resources from the default resource file before
966 you can use the \opt{R} \emph{before} the inclusion of the resource file:
967
968 \sh{\opt{R} \opt{r} my\_rsc \opt{i} sample}
969
970 If you add the \opt{R} argument after the resource specification then the
971 default resource is evaluated after your resource file. Thus settings are
972 potentially overwritten:
973
974 \sh{\opt{r} my\_rsc \opt{R} \opt{i} sample}
975
976 Additionally note that resource files are evaluated at once whereas input
977 files are read in one chunk at the end. Thus you can not specify one set of
978 parameters to be used for one file and another set of parameters for the next
979 file. This is impossible within one invocation of \BibTool\footnote{This might
980 be changed in the next major revision (3.0).}.
981
982 As a consequence of this behavior the last example is equivalent to the
983 following invocations:
984
985 \sh{\opt{r} my\_rsc \opt{i} sample \opt{R}}\vspace*{-4ex}
986 \sh{\opt{i} sample \opt{r} my\_rsc \opt{R}}
987 \medskip
988
989 Now we have to describe the commands allowed in a resource file. The general
990 form of a resource command is of the form
991
992 \begin{Resources}
993 \rscIt{name} = $\{$\textit{value}$\}$
994 \end{Resources}
995
996 \rscIt{name} is the resource name which conforms the rules of \BibTeX{}
997 reference keys. Thus \rscIt{name} can be composed of all characters but
998 white-space characters and\index{\#}\index{\%}\index{=}\index{,}\index{\"@\"{}}%
999 \index{'}\index{(}\index{)}\index{\{@$\{$}\index{\}@$\}$}
1000 \begin{verbatim}
1001 " # % ' ( ) , = { }
1002 \end{verbatim}
1003
1004 Resource names are currently composed of letters and the period. The next
1005 component is an optional equality sign (\texttt{=}). The equality sign is
1006 recommended as it helps detecting syntax problems. White-space characters
1007 surrounding the equality sign or separating resource name and resource value
1008 are ignored. The resource value can be of the following kind:
1009 \begin{itemize}
1010 \item A number composed of digits only.
1011 \item A string conforming the rules of resource names, i.e.\ made up of all
1012 but the forbidden characters described above.
1013 \item A string containing arbitrary characters delimited by double quotes (")
1014 not containing double quotes. Parentheses and curly brackets have to come in
1015 matching pairs.
1016 \item A string containing arbitrary characters delimited by curly brackets
1017 (\{\}). Parentheses and curly brackets have to come in matching pairs.
1018 \end{itemize}
1019
1020 You can think of resource names as variables or functions in a programming
1021 language. Resource commands simply set the variables to the given value, add
1022 the value to the old value, or initiate a action. There are different types of
1023 resources
1024 \begin{itemize}
1025 \item Boolean resources can take only the values \rsc{on} and \rsc{off}. The
1026 values \rsc{on}, \rsc{t}, \rsc{true}, 1, and \rsc{yes} are interpreted as
1027 the same. For those values the case of the letters is ignored. Thus
1028 \rsc{true} and \rsc{TrUe} are the same. Every other value else is
1029 interpreted as \rsc{off}.
1030 \item Numeric resources can take numeric values only.
1031 \item String resources can take arbitrary strings.
1032 \end{itemize}
1033
1034 Usually white-space characters are ignored. There is one exception. The
1035 characters \texttt{\%} and \texttt{\#} act as comment start characters if
1036 given between resource commands. All characters to the end of the line are
1037 ignored afterwards.
1038
1039
1040 Now we come the description of the first resource available. To read in
1041 additional resource files the resource file may contain the resource
1042
1043 \begin{Resources}
1044 \rscBraces{resource}{additional/resource/file}
1045 \end{Resources}
1046
1047 Thus the resource given above has the same functionality as the command line
1048 option \opt{r} described above. Path names should be specified in the normal
1049 manner for your operating system.
1050
1051 One resource command useful for debugging is the \rsc{print} resource. The
1052 resource value is immediately written to the error stream. The output is
1053 terminated by a newline character. Certain translations are performed during
1054 the reading of a resource which can be observed when printing. Each sequence
1055 of white-space characters is translated into a single space.
1056
1057 To end this subsection we give an example of the \rsc{print} resource. In this
1058 sample we also see the possibility to omit the equality sign and use quotes as
1059 delimiters.
1060
1061 \begin{Resources}
1062 \rsc{print} "This is a stupid message."
1063 \end{Resources}
1064
1065 Finally we can note that the commands given in a resource file can also be
1066 specified on the command line. This can be achieved with the command line
1067 option \opt{-} The next command line argument is taken as a resource command.
1068
1069 \sh[-]{resource\_command}
1070
1071 This can be used to issue resource commands which do not have a command line
1072 counterpart. One example we have already seen. The \rsc{print} instruction can
1073 be used from the command line with the following
1074
1075 \sh[-]{print\{hello\_world\}}
1076
1077 %------------------------------------------------------------------------------
1078 \section{Exit Code}
1079
1080 \BibTool{} as invoked on the command line returns an exit code. This exit code
1081 can be used to control the flow of control for any script which uses
1082 \BibTool{} internally.
1083
1084 In general \BibTool{} returns an exit code of \verb|0| if no error occurs.
1085 Errors lead to an exit code different from \verb|0|.
1086
1087 \medskip
1088
1089 \begin{Summary}
1090 \Desc{\opt{h}}{}{Show a list of command line options.}
1091 \Desc{\opt{R}}{}{Immediately evaluate the
1092 instructions from the default file.}
1093 \Desc{}{\rsc{print} \{message\}}{Write out the text \textit{message}.}
1094 \Desc{\opt{r} file}{\rsc{resource} = file}{Immediately evaluate the
1095 instructions from the resource file \textit{file}.}
1096 \Desc{}{\rsc{resource.search.path}}{List of directories to search
1097 for resource files.}
1098 \Desc{\opt{-} rsc}{rsc}{Evaluate the resource instruction \textit{rsc}.}
1099 \end{Summary}
1100
1101 %------------------------------------------------------------------------------
1102 \section{Input File Specification and Search Path}\label{sec:search}
1103
1104 An arbitrary number of input files can be specified. Input files can be
1105 specified in two ways. The command line option \opt{i} is immediately followed
1106 by a file name. Since no restriction on the file name is applied this can also
1107 be used to specify files starting with a dash.
1108
1109 \sh[i]{input\_file}
1110
1111 The resource name \rsc{input} can be used to specify additional input files.
1112
1113 \begin{Resources}
1114 \rscBraces{input}{input\_file}
1115 \end{Resources}
1116
1117 Input files are processed in the order they are given. If no input file is
1118 specified the standard input is used to read from.
1119
1120 Depending on the special configuration of \BibTool{} there are two ways of
1121 searching for \BibTeX{} files. The native mode of \BibTool{} uses a list of
1122 directories and a list of extensions to find a file. Alternatively the
1123 kpathsea library can be used which provides additional features like the
1124 recursive searching in sub-directories. First we look at the native \BibTool{}
1125 searching mechanism.
1126
1127 The files are searched in the following way. If the file is can't be opened as
1128 given the extension \texttt{.bib} is appended and another read is tried. In
1129 addition directories can be given which are searched for input files. The
1130 search path can be given in two different ways. First, the resource name
1131 \rsc{bibtex.search.path} can be set to contain a search path specification.
1132
1133 \begin{Resources}
1134 \rscEqBraces{bibtex.search.path}{directory1:directory2:directory3}
1135 \end{Resources}
1136
1137 The elements of the search path are separated by colons. Thus colons are not
1138 allowed as parts of directories. Another source of the search path is the
1139 environment variable \env{BIBINPUTS}. This environment variable is usually
1140 used by \BibTeX{} to specify the search path. The syntax of the specification
1141 is the same as for the resource \rsc{bibtex.search.path}. To check the
1142 appropriate way to set your environment variable consult the documentation of
1143 your shell, since this is highly dependent on it.
1144
1145 To allow adaption to operating systems other than UN*X the following resources
1146 can be used. The name of the environment \rsc{bibtex.env.name} overwrites the
1147 name of the environment variable which defaults to \env{BIBINPUTS}.
1148
1149 \begin{Resources}
1150 \rscEqBraces{bibtex.env.name}{ENVIRONMENT\_VARIABLE}
1151 \end{Resources}
1152
1153 The first character of the resource \rsc{env.separator} is used as separator
1154 of directories in the resource \rsc{bibtex.search.path} and the environment
1155 variable given as \rsc{bibtex.env.name}.
1156
1157 \begin{Resources}
1158 \rscEqBraces{env.separator}{:}
1159 \end{Resources}
1160
1161 The default character separating directories in a file name is the slash
1162 (\verb|/|). The first character of the resource \rsc{dir.file.separator} can
1163 be used to change this value.
1164
1165 \begin{Resources}
1166 \rscEqBraces{dir.file.separator}{\BS}
1167 \end{Resources}
1168
1169 \textbf{Note} that the defaults for \rsc{env.separator} and
1170 \rsc{dir.file.separator} are set at compile time to a value suitable for the
1171 operating system. Usually you don't have to change them at all. For instance
1172 for MSD*S machines the \rsc{env.separator} is usually set to \verb|;| and the
1173 \rsc{dir.file.separator} is usually set to \verb|\|.
1174
1175 If the kpathsea library is used for searching \BibTeX{} files then some of the
1176 resources described above have no effect. They are replaced by their kpathsea
1177 counterparts. Most probably you are using the kpathsea library already in
1178 other \TeX{} related programs. Thus I just have to direct you to the
1179 documentation distributed with the kpathsea library for details.
1180
1181 \begin{Summary}
1182 \Desc{}{\rsc{bibtex.env.name}=\{var\}}{Use the environment variable
1183 \textit{env} to add more directories to the search path for \BibTeX{}
1184 (input) files.}
1185 \Desc{}{\rsc{bibtex.search.path}=\{path\}}{Use the list of directories
1186 \textit{path} to find \BibTeX{} (input) files.}
1187 \Desc{}{\rsc{dir.file.separator}=\{c\}}{Use the character \textit{c} to
1188 separate the directory from the file.}
1189 \Desc{}{\rsc{env.separator}=\{c\}}{Use the character \textit{c} to separate
1190 directories in a path.}
1191 \Desc{\opt{i} file}{\rsc{input}\{file\}}{Add the \BibTeX{}
1192 file \textit{file} to the list of input files.}
1193 \end{Summary}
1194
1195
1196 %------------------------------------------------------------------------------
1197 \section{Output File Specification and Status Reporting}
1198
1199 By default, the processed \BibTeX{} entries are written to the standard
1200 output. This output can be redirected to a file using the command line option
1201 \opt{o} as in
1202
1203 \sh[o]{output\_file}
1204
1205 The resource name \rsc{output.file} can also be used for this purpose.
1206
1207 \begin{Resources}
1208 \rscEqBraces{output.file}{output\_file}
1209 \end{Resources}
1210
1211 The output file may be one of the special values. If the output file is a
1212 single minus sign then the output is redirected to the standard output stream
1213 as shown in the following example:
1214
1215 \begin{Resources}
1216 \rscEqBraces{output.file}{-}
1217 \end{Resources}
1218
1219 If the output file is the empty string -- i.e. no characters at all -- then
1220 the output is suppressed entirely. This can be useful for instance if the
1221 input file should be validated only. An empty output file can be seen in the
1222 following example:
1223
1224 \begin{Resources}
1225 \rscEqBraces{output.file}{}
1226 \end{Resources}
1227
1228 No provisions are made to check if the output file is the same as a input
1229 file.
1230
1231 A second output stream is used to display error messages and status reports.
1232 The standard error stream is used for this purpose.
1233
1234 The messages can roughly be divided in three categories: error messages,
1235 warnings, and status reports. Error messages indicate severe problems. They
1236 can not be suppressed. Warnings indicate possible problems which could
1237 (possibly) have been corrected. They are displayed by default but can be
1238 suppressed. Status reports are messages during the processing which indicate
1239 actions currently performed. They are suppressed by default but can be
1240 enabled.
1241
1242 Warning messages can be suppressed using the command line option \opt{q}.
1243 This option toggles the Boolean quiet value.
1244
1245 \sh[q]{}
1246
1247 The same effect can be obtained by assigning the value \textsf{on} or
1248 \textsf{off} to the resource \rsc{quiet}:
1249
1250 \begin{Resources}
1251 \rsc{quiet} = on
1252 \end{Resources}
1253
1254 Status reports are useful to see the operations performed. They can be enabled
1255 using the command line option \opt{v}. This option toggles the Boolean verbose
1256 value.
1257
1258 \sh[v]{}
1259
1260 The same can also be achieved with the Boolean resource \rsc{verbose}:
1261
1262 \begin{Resources}
1263 \rsc{verbose} = on
1264 \end{Resources}
1265
1266 Another output stream can be used to select the string definitions. This is
1267 described in section~\ref{sec:macros} on macros.
1268
1269 %\iffalse
1270 %For completeness we can also mention that the internal symbol table can be
1271 %printed using the command line option \opt{\$} or the boolean resource
1272 %\rsc{dump.symbols}. This is mainly meant for debugging purposes. \emph{Please
1273 % send me a bug report and the diffs to fix it :-)}
1274 %\fi
1275
1276 \begin{Summary}
1277 \Desc{\opt{o} file}{\rsc{output.file} \{file\}}{Direct output to the
1278 file \textit{file}. If file is \texttt{-} then the standard output is
1279 used. If the file is the empty string then the output is suppressed.}
1280 \Desc{\opt{q}}{\rsc{quiet}=on}{Suppress warnings. Errors can not be
1281 suppressed.}
1282 \Desc{\opt{v}}{\rsc{verbose}=on}{Enable informative messages on the
1283 activities of \BibTool.}
1284 \end{Summary}
1285
1286
1287 %------------------------------------------------------------------------------
1288 \section{Parsing and Pretty Printing}\label{sec:parse.pretty}
1289
1290 The first and simplest task we have to provide on \BibTeX{} files is the
1291 parsing and pretty printing. This is not superfluous since \BibTeX{} is rather
1292 pedantic about the accepted syntax. Thus I decided to try to be generous and
1293 correct as many errors as I can.
1294
1295 This can be changed with the resource \rsc{parse.exit.on.error}. If this
1296 resouce is turned on then \BibTool\ exits iimediately when an error during the
1297 parsing is encountered. The default is \textsf{off}.
1298 \begin{Resources}
1299 \rsc{parse.exit.on.error} = on
1300 \end{Resources}
1301
1302 Each input file is parsed and stored in an internal representation. \BibTeX{}
1303 simply ignores any characters between entries. \BibTool{} stores the comments
1304 and attaches them to the entry immediately following them. Normally anything
1305 between entries is simply discarded and a warning printed. The Boolean
1306 resource \rsc{pass.comments} can be used to change this behavior.
1307
1308 \begin{Resources}
1309 \rsc{pass.comments} = on
1310 \end{Resources}
1311
1312 If this resource is on then the characters between entries are directly passed
1313 to the output file. This transfer starts with the first non-space character
1314 after the end of an entry.
1315
1316 The standard \BibTeX{} styles support a limited number of entry types. Those
1317 are predefined in \BibTool. Additional entry types can be defined using the
1318 resource \rsc{new.entry.type} as in
1319
1320 \begin{Resources}
1321 \rscBraces{new.entry.type}{Anthology}
1322 \end{Resources}
1323
1324 This option can also be used to redefine the appearance of entry types which
1325 are already defined. Suppose we have defined \emph{Anthology} as above.
1326 Afterwards we can redefine this entry type to be printed in upper case with
1327 the following option:
1328
1329 \begin{Resources}
1330 \rscBraces{new.entry.type}{ANTHOLOGY}
1331 \end{Resources}
1332
1333 Each undefined entry type leads to an error message.
1334
1335 When a database is printed the different kinds of entries are printed
1336 together. For instance all normal entries are printed en block. The order of
1337 the entry types is determined by the resource \rsc{print.entry.types}. The
1338 value of this resource is a string where each character represents an entry
1339 type to be printed. If a letter is missing then this part of the database is
1340 omitted. The following letters are recognized---uppercase letters are folded
1341 to their lowercase counterparts if they are not mentioned explicitly:
1342 \begin{description}
1343 \item [a] The aliases of the database.
1344 \item [c] The comments of the database which are not attached to an entry.
1345 \item [i] The includes of the database.
1346 \item [m] The modifies of the database.
1347 \item [n] The normal entries of the database.
1348 \item [p] The preambles of the database.
1349 \item [\$] The strings (macros) of the database.
1350 \item [S] The strings (macros) of the database which are used in the other
1351 entries.
1352 \item [s] The strings (macros) of the database where the resource
1353 \rsc{print.all.strings} determines whether all strings are printed or the
1354 used ones only.
1355 \end{description}
1356
1357 The following invocation prints the preambles and the normal entries only.
1358 This can be desirable if the macros are printed into a separate file.
1359
1360 \begin{Resources}
1361 \rscBraces{print.entry.types}{pn}
1362 \end{Resources}
1363
1364 The internal representation is printed in a format which can be adjusted by
1365 certain options. Those options are available through resource files or
1366 by specifying resources on the command line.
1367
1368 \begin{description}
1369 \item [\rsc{print.line.length}]
1370 This numeric resource specifies the desired width of the lines. lines
1371 which turn out to be longer are tried to split at spaces and continued
1372 in the next line. The value defaults to 77.
1373 \item [\rsc{print.indent}]
1374 This numeric resource specifies indentation of normal items, i.e.\
1375 items in entries which are not strings or comments. The value defaults
1376 to 2.
1377 \item [\rsc{print.align}]
1378 This numeric resource specifies the column at which the '=' in
1379 non-comment and non-string entries are aligned. This value defaults
1380 to 18.
1381 \item [\rsc{print.align.key}]
1382 This numeric resource specifies the column at which the keys in
1383 non-comment and non-string entries are aligned. This value defaults
1384 to 18.
1385 \item [\rsc{print.align.string}]
1386 This numeric resource specifies the column at which the '=' in string
1387 entries are aligned. This value defaults to 18.
1388 \item [\rsc{print.align.preamble}]
1389 This numeric resource specifies the column at which preamble
1390 entries are aligned. This value defaults to 11.
1391 \item [\rsc{print.align.comment}]
1392 This numeric resource specifies the column at which comment
1393 entries are aligned.\footnote{This is mainly obsolete now
1394 since comments do not have to follow any syntactic
1395 restriction.} This value defaults to 10.
1396 \item [\rsc{print.comma.at.end}]
1397 This Boolean resource determines whether the comma between fields
1398 should be printed at the end of the line. If it is \textsf{off} then
1399 the comma is printed just before the field name. In this case the
1400 alignment given by \rsc{print.align} determines the column of the
1401 comma.
1402 \item [\rsc{print.equal.right}]
1403 This Boolean resource specifies whether the = sign in normal entries
1404 is aligned right. If turned off then the = sign is flushed left to the
1405 field name. This value defaults to \textsf{on}.
1406 \item [\rsc{print.newline}]
1407 This numeric resource specifies the number of newlines between
1408 entries. This value defaults to 1.
1409 \item [\rsc{print.terminal.comma}]
1410 This Boolean resource specifies whether a comma should be printed
1411 after the last record of a normal entry. This contradicts the rules of
1412 \BibTeX\ but might be useful for other programs. This value defaults
1413 to \textsf{off}.
1414 \item [\rsc{print.use.tab}]
1415 This Boolean resource specifies if the \texttt{TAB} character should be
1416 used for indenting. This use is said to cause portability problems.
1417 Thus it can be disabled. If disabled then the appropriate number of
1418 spaces are inserted instead. This value defaults to \textsf{on}.
1419 \item [\rsc{print.wide.equal}]
1420 This Boolean resource determines whether the equality sign should be
1421 forced to be surrounded by spaces. Usually this resource is \off{}
1422 which means that no spaces are required around the equality sign and
1423 they can be omitted if the alignment forces it.
1424 \item [\rsc{suppress.initial.newline}]
1425 This Boolean resource suppresses the initial newline before normal
1426 records since this might be distracting under certain circumstances.
1427 \end{description}
1428
1429 The resource values described above are illustrated by the following examples.
1430 First we look at a string entry.
1431 \bigskip
1432
1433 \ifHTML
1434 {\small
1435 \begin{verbatim}
1436 | |
1437 | print.align.string print.line.length |
1438 \end{verbatim}
1439 }
1440 \else
1441 \noindent
1442 \vbox{
1443 \begin{minipage}{\textwidth}
1444 \begingroup%
1445 \settowidth{\unitlength}{\texttt{\small m}}%
1446 \begin{picture}(0,2)(0,-3)
1447 \put(18,0){\line(0,1){5.5}}
1448 \put(77,0){\line(0,1){5.5}}
1449 \put(77,0){\makebox(0,0)[r]{\rsc{print.line.length}}}
1450 \put(18,0){\makebox(0,0)[l]{\rsc{print.align.string}}}
1451 \end{picture}
1452 \endgroup
1453 \vspace{1ex}\end{minipage}}
1454 \fi
1455
1456 Next we look at an unpublished entry. It has a rather long list of authors and
1457 a long title. It shows how the lines are broken.
1458 \vspace{4.5ex}
1459
1460 \ifHTML
1461 {\small
1462 \begin{verbatim}
1463 | print.align.key
1464 |
1465 @Unpublished{ unpublished-key,
1466 author = "First A. U. Thor and Seco N. D. Author and Third A. Uthor
1467 and others",
1468 title = "This is a rather long title of an unpublished entry which
1469 exceeds one line",
1470 note = "Some useless comment"
1471 }
1472 | | |
1473 | print.indent | print.align print.line.length |
1474 \end{verbatim}
1475 }
1476 \else
1477 \noindent
1478 \hbox{%
1479 \begin{minipage}{\textwidth}
1480 {\small
1481 \begin{verbatim}
1482 @Unpublished{ unpublished-key,
1483 author = "First A. U. Thor and Seco N. D. Author and Third A. Uthor
1484 and others",
1485 title = "This is a rather long title of an unpublished entry which
1486 exceeds one line",
1487 note = "Some useless comment"
1488 }
1489 \end{verbatim}%
1490 }%
1491 \settowidth{\unitlength}{\texttt{\small m}}%
1492 \begin{picture}(0,2)(0,-3)
1493 \put( 2,0){\line(0,1){14.5}}
1494 \put(18,15.5){\line(0,1){3.5}}
1495 \put(18,0){\line(0,1){14.5}}
1496 \put(77,0){\line(0,1){14.5}}
1497 \put(18,19){\makebox(0,0)[l]{\rsc{print.align.key}}}
1498 \put(77,0){\makebox(0,0)[r]{\rsc{print.line.length}}}
1499 \put(18,0){\makebox(0,0)[l]{\rsc{print.align}}}
1500 \put( 2,0){\makebox(0,0)[l]{\rsc{print.indent}}}
1501 \end{picture}
1502 \end{minipage}}
1503 \vspace{1ex}
1504 \fi
1505
1506 The field names of an entry are usually printed in lower case. This can be
1507 changed with the resource \rsc{new.field.type}. The argument of this resource
1508 is an equation where left of the '=' sign is the name of a field and on the
1509 right side is it's print name. They should only contain allowed characters.
1510
1511 \begin{Resources}
1512 \rsc{new.field.type} {\(\{\) author = AUTHOR \(\}\)}
1513 \end{Resources}
1514
1515 This feature can be used to rewrite the field types. Thus it is completely
1516 legal to have a different replacement text than the original field:
1517
1518 \begin{Resources}
1519 \rsc{new.field.type} {\(\{\) OPTauthor = Author \(\}\)}
1520 \end{Resources}
1521
1522 String names are used case insensitive by \BibTeX. \BibTool{} normalizes
1523 string names before printing. By default string names are translated to lower
1524 case. Currently two other types are supported: translation to upper case and
1525 translation to capitalized case, i.e. the first letter upper case and the
1526 others in lower case.
1527
1528 The translation is controlled by the resource
1529 \rsc{symbol.type}\label{symbol.type}. The value is one of the strings
1530 \verb|lower|, \verb|upper|, and \verb|cased|. The resource can be set as in
1531
1532 \begin{Resources}
1533 \rsc{symbol.type} = upper
1534 \end{Resources}
1535
1536 The macro names are passed through the same normalization apparatus as field
1537 types. Thus you can force a rewriting of macro names with the same method as
1538 described above. You should be careful when choosing macro names which are
1539 also used as field types.
1540
1541 The reference key is usually translated to lower case letters unless a new key
1542 is generated (see section~\ref{sec:key.gen}). In this case the chosen format
1543 determines the case of the key. Sometimes it can be desirable to preserve the
1544 case of the key as given (even so \BibTeX{} does not mind). This can be
1545 achieved with the Boolean resource \rsc{preserve.key.case}. Usually it is
1546 turned off (because of backward compatibility and the memory used for this
1547 feature). You can turn it on as in
1548
1549 \begin{Resources}
1550 \rsc{preserve.key.case} = on
1551 \end{Resources}
1552
1553 If it is turned on then the keys as they are read are recorded and used when
1554 printing the entries. The internal comparisons are performed case insensitive.
1555 This is not influenced by the resource \rsc{preserve.key.case}. Especially
1556 this holds for sorting which does not recognize differences in case.
1557
1558 \begin{Summary}
1559 \Desc{}{\rsc{new.entry.type}\{type\}}{Define a new entry type \textit{type}.}
1560 \Desc{}{\rsc{new.field.type}\{type\}}{Define a new field type \textit{type}.}
1561 \Desc{}{\rsc{parse.exit.on.error}=on}{Force immediate exit at the first
1562 parse error encountered.}
1563 \Desc{}{\rsc{pass.comments}=on}{Do not discard comments but attach
1564 them to the entry following them.}
1565 \Desc{}{\rsc{preserve.key.case}=on}{Do not translate keys to lower
1566 case when reading.}
1567 \Desc{}{\rsc{print.align.comment}=n}{Align comment entries at column
1568 \textit{n}.}
1569 \Desc{}{\rsc{print.align.key}=n}{Align the key of normal entries at
1570 column \textit{n}.}
1571 \Desc{}{\rsc{print.align.string}=n}{Align the \texttt{=} of string
1572 entries at column \textit{n}.}
1573 \Desc{}{\rsc{print.align}=n}{Align the \texttt{=} of normal entries at
1574 column \textit{n}.}
1575 \Desc{}{\rsc{print.comma.at.end}=on}{Put the separating comma at then end of
1576 the line instead of the beginning.}
1577 \Desc{}{\rsc{print.indent}=n}{Indent normal entries to column \textit{n}.}
1578 \Desc{}{\rsc{print.line.length}=n}{Break lines at column \textit{n}.}
1579 \Desc{}{\rsc{print.print.newline}=n}{Number of empty lines between entries.}
1580 \Desc{}{\rsc{print.use.tab}=on}{Use the \texttt{TAB} character to
1581 compress multiple spaces.}
1582 \Desc{}{\rsc{print.wide.equal}=off}{Force spaces around the equal sign.}
1583 \Desc{}{\rsc{suppress.initial.newline}=on}{Suppress the initial newline
1584 before normal records.}
1585 \Desc{}{\rsc{symbol.type}=type}{Translate symbols according to
1586 \textit{type}: upper, lower, or cased.}
1587 \end{Summary}
1588
1589
1590 %------------------------------------------------------------------------------
1591 \section{Sorting}\label{sorting}
1592
1593 The entries can be sorted according to a certain sort key. The sort key is by
1594 default the reference key. Sorting can enabled with the command line switches
1595 \opt{s} and \opt{S} as in
1596
1597 \sh[s]{}\vspace{-4ex}
1598 \sh[S]{}
1599
1600 The first variant sorts in ascending \ASCII{} order (including differentiation
1601 of upper and lower case). The second form sorts in descending \ASCII{} order.
1602 The same effect can be achieved with the Boolean resource values \rsc{sort}
1603 and \rsc{sort.reverse} respectively.
1604
1605 \begin{Resources}
1606 \rscEqBraces{sort}{on}
1607 \rscEqBraces{sort.reverse}{on}
1608 \end{Resources}
1609
1610 The resource \rsc{sort} determines whether or not the entries should be
1611 sorted. The resource \rsc{sort.reverse} determines whether the order is
1612 ascending (off) or descending (on) \ASCII{} order of the sort key. The sort
1613 key is initialized from the reference key if not given otherwise.
1614
1615 Alternatively the sort key can be constructed according to a specification.
1616 This specification can be given in the same way as a specification for key
1617 generation. This is described in section \ref{sec:key.gen} in detail.
1618
1619 The associated resource name is \rsc{sort.format}. Several formats are
1620 combined as alternatives.
1621
1622 \begin{Resources}
1623 \rscEqBraces{sort.format}{\%N(author)}\index{N@\%N}
1624 \rscEqBraces{sort.format}{\%N(editor)}
1625 \end{Resources}
1626
1627 Those two lines are equivalent with the single resource
1628
1629 \begin{Resources}
1630 \rscEqBraces{sort.format}{\textit{\%N(author) \# \%N(editor)}}\index{N@\%N}
1631 \end{Resources}
1632
1633 This means that the sort key is set to the (normalized) author names if an
1634 author is given. Otherwise it tries to use the normalized editor name. If
1635 everything fails the sort key is empty.
1636
1637 Let us reconsider the unprocessed example on page \pageref{sample1}. Without
1638 any \rsc{sort.format} instructions this entry would sorted in under
1639 ``article-full''. With the \rsc{sort.format} given above it would be sorted in
1640 under ``Aamport.LA''.
1641
1642 \textbf{Note} that in \ASCII{} order the case is important. The
1643 uppercase letters all come before the lowercase letters. \medskip
1644
1645 Usually the keys are folded to lower case during the normalization. Thus the
1646 lower case variants are also used for comparison. The resource
1647 \rsc{preserve.key.case} can be used to print cased keys as they are
1648 encountered in the input file. This feature can be combined with the Boolean
1649 resource \rsc{sort.cased} to achieve sorting according to the unfolded
1650 reference key:
1651
1652 \begin{Resources}
1653 \rscEqBraces{preserve.key.case}{on}
1654 \rscEqBraces{sort.cased}{on}
1655 \end{Resources}
1656
1657 Beside the normal entries the macros (string entries) are sorted. This happens
1658 in per default. The resource \rsc{sort.macros} can be used to turn off this
1659 feature as in
1660
1661 \begin{Resources}
1662 \rscEqBraces{sort.macros}{off}
1663 \end{Resources}
1664
1665 An example of sorting can be seen in section~\ref{sample.sort} on page
1666 \pageref{sample.sort}.
1667
1668 \begin{Summary}
1669 \Desc{\opt{S}}{}{Enable sorting of entries in reverse sorting order.}
1670 \Desc{\opt{s}}{\rsc{sort}}{Enable sorting of entries.}
1671 \Desc{}{\rsc{sort.cased}=on}{Use the cased form of the reference key for sorting.}
1672 \Desc{}{\rsc{sort.format}\{spec\}}{Add disjunctive branch \textit{spec} to
1673 the sort key specifier.}
1674 \Desc{}{\rsc{sort.macros}=off}{Turn off the sorting of string entries.}
1675 \Desc{}{\rsc{sort.reverse}=on}{Reverse the sorting order.}
1676 \end{Summary}
1677
1678 %------------------------------------------------------------------------------
1679 \section{Regular Expression Matching}\label{sec:regex}
1680
1681 \BibTool{} makes use of the GNU regular expression library. Thus a short
1682 excursion into regular expressions is contained in this manual. Several
1683 examples of the application of regular expressions can be found also in other
1684 sections of this manual.
1685
1686 A concise description of regular expressions is contained in the document
1687 \file{regex-0.12/regex.texi} contained in the \BibTool{} distribution. In any
1688 cases of doubt this documentation is preferable. The remainder of this section
1689 contains a short description of regular expressions.
1690
1691 Note that the default regular expressions of the Emacs style are used.
1692
1693 \begin{description}
1694 \item[Ordinary characters] match only to themselves or their upper or lower
1695 case counterpart. Any character not mentioned as special is an ordinary
1696 character. Among others letters and digits are ordinary characters.
1697
1698 For instance the regular expression \emph{abc} matches the string
1699 \emph{abc}.
1700
1701 \item[The period] (\verb|.|) matches any single character.
1702
1703 For instance the regular expression \emph{a.c} matches the string \emph{abc}
1704 but it does not match the string \emph{abbc}.
1705
1706 \item[The star] (\verb|*|) is used to denote any number of repetitions of the
1707 preceding regular expression. If no regular expression precedes the star then
1708 it is an ordinary character.
1709
1710 For instance the regular expression \emph{ab*c} matches any string which
1711 starts with a followed by an arbitrary number of b and ended by a c. Thus it
1712 matches \emph{ac} and \emph{abbbc}. But it does not match the string
1713 \emph{abcc}.
1714
1715 \item[The plus] (\verb|+|) is used to denote any number of repetitions of the
1716 preceding regular expression, but at least one. Thus it is the same as the
1717 star operator except that the empty string does not match. If no regular
1718 expression precedes the plus then it is an ordinary character.
1719
1720 For instance the regular expression \emph{ab+c} matches any string which
1721 starts with a followed by one or more b and ended by a c. Thus it matches
1722 \emph{abbbc}. But it does not match the string \emph{ac}.
1723
1724 \item[The question mark] (\verb|?|) is used to denote an optional regular
1725 expression. The preceding regular expression matches zero or one times. If
1726 no regular expression precedes the question mark then it is an ordinary
1727 character.
1728
1729 For instance the regular expression \emph{ab?c} matches any string which
1730 starts with a followed by at most one b and ended by a c. Thus it matches
1731 \emph{abc}. But it does not match the string \emph{abbc}.
1732
1733 \item[The bar] (\verb/\|/) separates two regular expressions. The combined
1734 regular expression matches a string if one of the alternative separated by
1735 the bar does.
1736
1737 Note that the bar has to be preceded by a backslash.
1738
1739 For instance the regular expression \emph{abc\(\backslash\mid\)def} matches
1740 the string \emph{abc} and the string \emph{def}.
1741
1742 \item[Parentheses] (\verb|\(\)|) can be used to group regular expressions. A
1743 group is enclosed in parentheses. It matches a string if the enclosed
1744 regular expression does.
1745
1746 Note that the parentheses have to be preceded by a backslash.
1747
1748 For instance the regular expression
1749 \emph{\(a\backslash(b\backslash\mid\backslash d)c\)} matches the strings
1750 \emph{abc} and \emph{adc}.
1751
1752 \item[The dollar] (\verb|$|) %$
1753 matches the empty string at the end of the string. It can be used to anchor
1754 a regular expression at the end. If the dollar is not the end of the
1755 regular expression then it is an ordinary character.
1756
1757 For instance the regular expression \emph{abc\$} matches the string
1758 \emph{aaaabc} but does not match the string \emph{abcdef}.
1759
1760 \item[The hat] (\texttt{\Hat}) matches the empty string at the beginning of
1761 the string. It can be used to anchor a regular expression at the beginning.
1762 If the hat is not the beginning of the regular expression then it is an
1763 ordinary character. There is one additional context in which the hat has a
1764 special meaning. This context is the list operator described below.
1765
1766 For instance the regular expression \emph{\Hat abc} matches the strings
1767 \emph{abcccc} but does not match the string \emph{aaaabc}.
1768
1769 \item[The brackets] (\verb|[]|) are used to denote a list of characters. If
1770 the first character of the list is the hat (\texttt{\Hat}) then the list
1771 matches any character not contained in the list. Otherwise it matches any
1772 characters contained in the list.
1773
1774 For instance the regular expression \emph{[abc]} matches the single letter
1775 strings \emph{a}, \emph{b}, and \emph{c}. It does not match \emph{d}.
1776
1777 The regular expression \emph{[\Hat abc]} matches any single letter string
1778 not consisting of an a, b, or c.
1779
1780 \item[The backslash] (\texttt{\BS}) is used for several purposes. Primarily it
1781 can be used to quote any special character. Thus if a special character is
1782 preceded by the backslash then it is treated as if it were an ordinary
1783 character.
1784
1785 If the backslash is followed by a digit \(d\)\/ then this construct is the
1786 same as the \(d^{th}\) matching group.
1787
1788 For instance the regular expression \emph{(an)\BS1as} matches the string
1789 \emph{ananas} since the first group matches \emph{an}.
1790
1791 If the backslash is followed by the character \texttt{n} then this is
1792 equivalent to entering a newline.
1793
1794 If the backslash is followed by the character \texttt{t} then this is
1795 equivalent to entering a single \texttt{TAB} character.
1796
1797 \end{description}
1798
1799
1800 %------------------------------------------------------------------------------
1801 \section{Selecting Items}
1802
1803 \subsection{Extracting by \texttt{aux} Files}
1804
1805 \BibTool{} includes a module to extract \BibTeX{} entries required for a
1806 document. This is accomplished by analyzing the \texttt{aux} file of the
1807 document. The \texttt{aux} file is usually produced by \LaTeX. It contains the
1808 information which \BibTeX{} files and which references are used in the
1809 document. Only those entries mentioned in the \texttt{aux} file are selected
1810 for printing. Since the \BibTeX{} files are already named in the \texttt{aux}
1811 file it is not necessary to specify an input file.
1812
1813 To use an \texttt{aux} file the command line option \opt{x} can be given. This
1814 option is followed by the name of the \texttt{aux} file.
1815
1816 \sh[x]{file.aux}
1817
1818 Multiple files can be given this way. As always the same functionality can be
1819 requested with a resource. The resource \rsc{extract.file} can be used for
1820 this purpose.
1821
1822 \begin{Resources}
1823 \rscBraces{extract.file}{\textit{file.aux}}
1824 \end{Resources}
1825
1826 A small difference exists between the two variants. the command line option
1827 automatically sets the resource \rsc{print.all.strings} to \verb|off|. This
1828 has to be done in the resource file manually.
1829
1830 Note that the extraction automatically respects the cross-references in the
1831 selected entries. Thus you will get a complete \BibTeX\ file---unless some
1832 references can not be resolved and an error is produced.
1833
1834 One special feature of \BibTeX{} is supported. If the command
1835 \verb|\nocite{*}| is given in the \LaTeX{} file then all entries of the
1836 bibliography files are included in the bibliography. The same behavior is
1837 imitated by the extracting mechanism of \BibTool.
1838
1839 An example of extracting can be seen in section~\ref{sample:extract} on page
1840 \pageref{sample:extract}.
1841
1842 \subsection{Extracting with Sub-string Matching}
1843
1844 The simplest way of specifying an entry---except by giving its key---is to
1845 give a string which has to be present in one of the fields or pseudo fields.
1846 The resource \rsc{select.by.string} can be used to store a selection rule
1847 which is applied at the appropriate time later on. If several rules are
1848 supplied then any entry matching one of the rules is selected. Thus different
1849 rules act as alternatives. This includes rules with regular expressions as
1850 described in section~\ref{sec:extract}.
1851
1852 The simplest form of the resource \rsc{select.by.string} is to specify a
1853 single string to search for. This string has to be enclosed in double quotes.
1854 Since the argument of the resource has to be enclosed in braces we get the
1855 following funny syntax:
1856
1857 \begin{Resources}
1858 \rscBraces{select.by.string}{"some string"}
1859 \end{Resources}
1860
1861 This operation selects all entries containing \texttt{some string} in one of
1862 the normal fields. The search can be restricted to specific fields or extended
1863 to pseudo fields by specifying those fields before the search string. An
1864 arbitrary number of white-space separated fields can be given there. Thus the
1865 general syntax for this resource is as follows:
1866
1867 \begin{Resources}
1868 \rscBraces{select.by.string}{\textit{field\(_1\) \(\ldots\) field\(_n\) "string"}}
1869 \end{Resources}
1870
1871 To make this selection operation more flexible it is possible to determine
1872 whether or not the comparison against the value of a field is performed case
1873 sensitive. This can be done with the Boolean resource
1874 \rsc{select.case.sensitive}. Since the selection is performed after all
1875 resources have been read the value of this resource is only considered then.
1876 Thus it is not possible to mix case sensitive and non case sensitive
1877 selections as with regular expressions (see section~\ref{sec:extract}).
1878
1879 During the matching of the search string against the value of a field
1880 \BibTool{} ignores certain characters. Thus it is possible to hide irrelevant
1881 details like braces or spaces. The characters to ignore are stored in the
1882 resource \rsc{select.by.string.ignored}. As a default the following resource
1883 command is performed implicitly:
1884
1885 \begin{Resources}
1886 \rscBraces{select.by.string.ignored}{"\{\} []"}
1887 \end{Resources}
1888
1889 As for the resource \rsc{select.case.sensitive} the evaluation of the resource
1890 \rsc{select.by.string.ignored} is performed just before the comparisons are
1891 carried out. Thus it is not possible to use several rules with different
1892 ignored sets of characters.
1893
1894 In addition to the functionality described above the resource
1895 \rsc{select.by.non.string} can be used to select all entries for which the
1896 match against the given field fails. The general form is the same as for
1897 \rsc{select.by.string}:
1898
1899 \begin{Resources}
1900 \rscBraces{select.by.non.string}{\textit{field\(_1\) \(\ldots\) field\(_n\) "string"}}
1901 \end{Resources}
1902
1903 \begin{description}
1904 \item[Note] Cross-references are not considered unless \rsc{select.crossrefs}
1905 is set.
1906 \end{description}
1907
1908 \subsection{Extracting with Regular Expressions}\label{sec:extract}
1909
1910 Another selecting mechanism uses regular expressions to select items. This
1911 feature can be used in addition to the selection according to \texttt{aux}
1912 files. The regular expression syntax is identical to the one used in GNU
1913 Emacs. For a description see section \ref{sec:regex}.
1914
1915 The resource \rsc{select} allows to specify which fields should be used to
1916 select entries. The general form is as follows:
1917
1918 \begin{Resources}
1919 \rscBraces{select}{\textit{field\(_1\) \(\ldots\) field\(_n\) "regular\_expression"}}
1920 \end{Resources}
1921
1922 If no field is specified then the regular expression is searched in each
1923 field. If no regular expression is specified then any value is accepted; i.e.
1924 the regular expression \texttt{"."} is used.
1925
1926 Any number of selection rules can be given. An entry is selected if one of
1927 those rules selects it. The select rule selects an entry if this entry has a
1928 field named \emph{field} which has a sub-string matching
1929 \emph{regular\_expression}. The field can be missing in which case the regular
1930 expression is tried to match against any field in turn.
1931
1932 The pseudo fields \verb|$key|, \verb|$type|, and \verb|@|\emph{type} can be
1933 used to access the key and the type of the entry. See page
1934 \pageref{pseudo:key} for details. The routines used there are the same as
1935 those used here.
1936
1937 Analogously to the negation of the string matching the regular expression
1938 matching can be negated. The resource to perform this functionality is
1939 \rsc{select.non}. The general form is
1940
1941 \begin{Resources}
1942 \rscBraces{select.non}{\textit{field\(_1\) \(\ldots\) field\(_n\) "regular\_expression"}}
1943 \end{Resources}
1944
1945
1946 The Boolean resource \rsc{select.case.sensitive} can be used to determine
1947 whether the selection is performed case sensitive or not:
1948
1949 \begin{Resources}
1950 \rscEqBraces{select.case.sensitive}{off}
1951 \end{Resources}
1952
1953 Note that the selection does not take place immediately. Instead all selection
1954 rules are collected and the selection is performed at an appropriate time
1955 later on. The different selection rules are treated as alternatives. Thus any
1956 entry which matches at least one of the rules is selected. Nevertheless the
1957 value of the resource \rsc{select.case.sensitive} is used which is in effect
1958 when the selection rule is issued. Thus it is possible to mix case sensitive
1959 rules with non-case sensitive rule.
1960
1961 A regular expression can be specified in the command line using the option
1962 \opt{X} as in
1963
1964 \sh[X]{regular\_expression}
1965
1966 The fields compared against this regular expression are given in the string
1967 valued resource \rsc{select.fields}. Initially this resource has the value
1968 \verb|$key|. In general the value is a list of fields and pseudo fields to be
1969 considered. The elements of the list are separated by spaces. If the list is
1970 empty then all fields and the key are considered for comparison.
1971 %$
1972
1973 Thus the following setting means that the regular only the fields \verb|author|
1974 and \verb|editor| are considered when doing a selection.
1975
1976 \begin{Resources}
1977 \rscEqBraces{select.fields}{"author editor"}
1978 \end{Resources}
1979
1980 Without changing the resource \rsc{select.fields} the command line given
1981 previously is equi\-va\-lent to the (longer) command
1982
1983 \sh[-]{select\{\$key "regular\_expression"\}}
1984
1985 Note that the resources \rsc{select.case.sensitive} and \rsc{select.fields}
1986 are used for all regular expressions following their definition until they are
1987 redefined. This means that it is possible to specify that some comparisons are
1988 done case sensitive and others are not done case sensitive.
1989
1990
1991 Finally the resource \rsc{extract.regex} can be used as in
1992
1993 \begin{Resources}
1994 \rscEqBraces{extract.regex}{\textit{regular\_expression}}
1995 \end{Resources}
1996
1997 This is equivalent to specifying a single regular expression to be matched
1998 against the key. This feature is kept for backward compatibility only. It is
1999 not encouraged and will vanish in a future release.
2000
2001 \begin{description}
2002 \item[Note] Cross-references are not considered unless \rsc{select.crossrefs}
2003 is set.
2004 \end{description}
2005
2006 \subsection{Extracting and Cross-references}\label{sec:xref}
2007
2008 When extracting entries due to contained sub-strings or regular expression
2009 matching cross-references are not considered automatically. This behavior can
2010 result in incomplete and thus incorrect \BibTeX\ files.
2011
2012 The automatic selection of cross-referenced entries can be controlled by the
2013 resource \rsc{select.crossrefs}. This resource is \texttt{off} by default.
2014 This means that cross-references are ignored.
2015
2016 The following instruction can be used to turn on the automatic inclusion of
2017 cross-referenced entries:
2018
2019 \begin{Resources}
2020 \rsc{select.crossrefs} = on
2021 \end{Resources}
2022
2023 \subsection{Inheritance and Cross-references}\label{sec:inherit}
2024
2025 \BibTeX\ provides one way to include fields from one entry into another. This
2026 is accomplished with the help of the \texttt{crossref} field.
2027
2028 \begin{lstlisting}[language=BibTeX]
2029 @Book{book-entry,
2030 bookauthor = "A. U. Thor",
2031 booktitle = "This is the book title"
2032 }
2033 @InBook{in-book-entry,
2034 author = {L[eslie] A. Aamport},
2035 title = {The Gnats and Gnus Document Preparation System},
2036 crossref = {book-entry}
2037 }
2038 \end{lstlisting}
2039
2040 Sometimes it is desirable to include the fields referenced via
2041 \texttt{crossref} and thus avoiding to have referenced entries in the
2042 bibliography. This can be accomplished with the boolean resource
2043 \rsc{expand.crossref}. This resource is \texttt{off} by default. This means
2044 that cross-references left as they are.
2045
2046 The following instruction can be used to turn on the automatic expansion of
2047 cross-referenced entries:
2048
2049 \begin{Resources}
2050 \rsc{expand.crossref} = on
2051 \end{Resources}
2052
2053 Note that the crossref mechanism implemented in \BibTool\ acts like
2054 inheritance. This means that fields \emph{not present} in the entry containing
2055 a \texttt{crossref} field are taken from the referenced entry. If for instance
2056 the entry and the referenced entry both contain a title filed then the one in
2057 the entry in not overwritten by one in the referenced entry.
2058
2059 A referenced entry can in turn contain another \texttt{crossref} field. The
2060 referenced entry is recursively explored. This can lead to infinite
2061 cross-reference chains when expanding. The depth of cross-reference chains can
2062 be restricted with the resource \rsc{crossref.limit}. This numeric value
2063 limits the depth of the cross-references. If the actual depth is greater than
2064 this value then the cross-referencing is terminated artificially. The default
2065 value is 32.
2066
2067 \begin{Resources}
2068 \rsc{crossref.limit} = 42
2069 \end{Resources}
2070
2071 \bibLaTeX\ \cite{lehmann:biblatex} has introduced a mechanism to modify the
2072 names of the fields which are included via \texttt{crossref}. This can for
2073 instance be useful because the standard styles expect a title field of a @Book
2074 but the same information goes into the booktitle field in an @InBook.
2075
2076 To support this behaviour \BibTool\ contains a mapping which declares which
2077 name for a field should be substituted when the cross-referencing is expanded.
2078 It defines which field name to used when the field is expanded from a source
2079 entry of a type with a certain name into an entry of another type.
2080
2081 This is accomplished with the resource \rsc{crossref.map}. It takes an
2082 argument with four symbols: source entry type, source field name, target
2083 entry type, and target field name. This invocation adds a replacement rule to
2084 the set of rules already present:
2085
2086 \begin{Resources}
2087 \rsc{crossref.map} \{source.type source.field target.type target.field\}
2088 \end{Resources}
2089
2090 The source type and target type need to be defined entry types. Otherwise a
2091 warning is issued and the new rule is ignored.
2092
2093 To ease the definition of mapping rules the source type and target type can be
2094 sets of types respectively. Those are enclosed in braces and separated with
2095 white-space.
2096
2097 \begin{Resources}
2098 \rsc{crossref.map} \{\{source.type$_1$ source.type$_2$\} source.field
2099 \{target.type$_1$ target.type$_2$ target.type$_3$\} target.field\}
2100 \end{Resources}
2101
2102 In such a case each combination with an element of one of the four
2103 constituents is added as mapping rule.
2104
2105 If a mapping rule exists for one combination of source type, source filed, and
2106 target type when defining a new rule then the old rule is overwritten. The
2107 replacement uses the newly defined target field instead.
2108
2109 Initially the set of mapping rules is empty. If some mapping rules have been
2110 defined they can be cleared with the resource \rsc{clear.crossref.map}. The
2111 invocation discards all previously defined mapping rules.
2112
2113 \begin{Resources}
2114 \rsc{clear.crossref.map} \{\}
2115 \end{Resources}
2116
2117 \bibLaTeX\ \cite{lehmann:biblatex} knows of an additional inheritance
2118 mechanism. For this purpose a special entry type \texttt{@XData} can be used.
2119 This entry carries the fields to be inherited by other entries.
2120 The inheriting entry contains a field named \texttt{xdata} which contains a
2121 comma separated list of \texttt{@XData} entries from which it inherits.
2122
2123 \begin{lstlisting}[language=BibTeX]
2124 @XData{x1,
2125 bookauthor = "A. U. Thor",
2126 booktitle = "This is the book title"
2127 }
2128 @XData{aw,
2129 publisher = "Addison-Wesley Publishing",
2130 address = "Reading, Mass."
2131 }
2132 @InBook{in-book-entry,
2133 author = {L[eslie] A. Aamport},
2134 title = {The Gnats and Gnus Document Preparation System},
2135 xdata = {x1,aw}
2136 }
2137 \end{lstlisting}
2138
2139 \BibTool\ supports this inheritance by taking it into consideration when
2140 selecting. Similar to the expansion of \texttt{crossref} fields \BibTool\ can
2141 be asked to expand \texttt{xdata} fields. This can be achieved with the
2142 boolean resource \rsc{expand.xdata}. This resource is \off\ by default. It can
2143 be turned on as in the following example:
2144
2145 \begin{Resources}
2146 \rsc{expand.xdata} = on
2147 \end{Resources}
2148
2149
2150 \begin{Summary}
2151 \Desc{}{\rsc{expand.crossref}=on}{Include the fields for entries references
2152 via a \texttt{crossref} field.}
2153 \Desc{}{\rsc{expand.xdata}=on}{Include the fields for entries references
2154 via an \texttt{xdata} field.}
2155 \Desc{\opt{x}}{\rsc{extract.file}\{file\}}{Extract the entries from an
2156 \texttt{aux} file.}
2157 \Desc{}{\rsc{extract.regex}\{expr\}}{Discouraged backward
2158 compatibility command.}
2159 \Desc{\opt{X} regex}{\rsc{select}\{spec\}}{Select certain entries according
2160 to a regular expression.}
2161 \Desc{}{\rsc{select.by.non.string}\{spec\}}{Select certain entries according
2162 to a failing sub-string matching.}
2163 \Desc{}{\rsc{select.by.string}\{spec\}}{Select certain entries according to
2164 a sub-string matching.}
2165 \Desc{}{\rsc{select.by.string.ignored}\{chars\}}{Define the class of
2166 characters to be ignored by the sub-string matching.}
2167 \Desc{}{\rsc{select.case.sensitive}=off}{Turn off the case
2168 insensitive comparison.}
2169 \Desc{\opt{c}}{\rsc{select.crossrefs}=on}{Turn on the additional selection of
2170 cross-referenced entries.}
2171 \Desc{}{\rsc{select.fields}\{fields\}}{Determine fields for \opt{X}.}
2172 \Desc{}{\rsc{select.non}\{spec\}}{Select certain entries according
2173 to a failing regular expression matching.}
2174 \end{Summary}
2175
2176
2177 %------------------------------------------------------------------------------
2178 \section{Key Generation}\label{sec:key.gen}
2179
2180 The key generation facility provides a mean to uniformly replace the reference
2181 keys by generated values. Some algorithms are hardwired, namely the generation
2182 of short keys or long keys either unconditionally or only when they are
2183 needed. Additionally a free formatting facility is provided. This can be used
2184 to specify your own algorithm to generate keys. The generation of new keys can
2185 be enabled using the command line option \opt{f} in the following way:
2186
2187 \sh[f]{format}
2188
2189 This command adds format disjunctivly to the formatting instructions already
2190 given. The same effect can be achieved with the resource \rsc{key.format}.
2191
2192 \begin{Resources}
2193 \rscEqBraces{key.format}{\textit{format}}
2194 \end{Resources}
2195
2196 Some values of \textit{format} have a special meaning. Fixed formatting rules
2197 are used when one of them is in effect. The special values are described
2198 below. To illustrate their results we consider the following \BibTeX{}
2199 database entries:
2200 \begin{lstlisting}[language=BibTeX]
2201 @Unpublished{unpublished-key,
2202 author = "First A. U. Thor and Seco N. D. Author and Third A. Uthor
2203 and others",
2204 title = "This is a rather long title of an unpublished entry which
2205 exceeds one line",
2206 ...
2207 }
2208 @Article{,
2209 author = {L[eslie] A. Aamport},
2210 title = {The Gnats and Gnus Document Preparation System},
2211 ...
2212 }
2213 @BOOK{whole-collection,
2214 editor = "David J. Lipcoll and D. H. Lawrie and A. H. Sameh",
2215 title = "High Speed Computer and Algorithm Organization",
2216 ...
2217 }
2218 @MISC{misc-minimal,
2219 key = "Missilany",
2220 note = "This is a minimal MISC entry"
2221 }
2222 \end{lstlisting}
2223
2224 \begin{description}
2225 \item [\rsc{short}]
2226 If a field named \verb|key| is present then its value is used. Otherwise if
2227 an author or editor field are present, then this field is used. The short
2228 version uses last names only. Afterwards a title or booktitle field is
2229 appended, after the \rsc{fmt.name.title} separator has been inserted.
2230 Finally if all else fails then the default key \rsc{default.key} is used.
2231 The result is disambiguated (cf.\ \rsc{key.base}).
2232
2233 To see the effect we apply \BibTool{} to the example entries given earlier
2234 with the command line argument \verb|-- key.format=short|. This results in
2235 the following keys (remaining lines skipped):
2236 \begin{lstlisting}[language=BibTeX]
2237 @Unpublished{ thor.author.ea:this,
2238 @Article{ aamport:gnats,
2239 @Book{ lipcoll.lawrie.ea:high,
2240 @Misc{ missilany,
2241 \end{lstlisting}
2242
2243 \item [\rsc{long}]
2244 The long version acts like the short version but incorporates initials when
2245 formatting names.
2246
2247 If \BibTool{} is applied to the example entries given earlier with the
2248 command line argument \verb|-- key.format=long| we get the following keys:
2249 \begin{lstlisting}[language=BibTeX]
2250 @Unpublished{ thor.fau.author.snd.ea:this,
2251 @Article{ aamport.la:gnats,
2252 @Book{ lipcoll.dj.lawrie.dh.ea:high,
2253 @Misc{ missilany,
2254 \end{lstlisting}
2255
2256 \item [\rsc{new.short}]
2257 This version formats like \rsc{short} but only if the given key field is
2258 empty. This is obsoleted by the resource \rsc{preserve.keys} and will be
2259 withdrawn in a future release.
2260
2261 If \BibTool{} is applied to the example entries given earlier with the
2262 command line argument \verb|-- key.format=short.need| we get the following
2263 keys:
2264 \begin{lstlisting}[language=BibTeX]
2265 @Unpublished{ unpublished-key,
2266 @Article{ aamport:gnats,
2267 @Book{ whole-collection,
2268 @Misc{ misc-minimal,
2269 \end{lstlisting}
2270 \item [\rsc{new.long}]
2271 This version formats like \rsc{long} but only if the given key field is
2272 empty. This is obsoleted by the resource \rsc{preserve.keys} and will be
2273 withdrawn in a future release.
2274
2275 If \BibTool{} is applied to the example entries given earlier with the
2276 command line argument \verb|-- key.format=short.need| we get the following
2277 keys:
2278 \begin{lstlisting}[language=BibTeX]
2279 @Unpublished{ unpublished-key,
2280 @Article{ aamport.la:gnats,
2281 @Book{ whole-collection,
2282 @Misc{ misc-minimal,
2283 \end{lstlisting}
2284
2285 \item [\rsc{empty}]
2286 The empty version clears the key entirely. The result does not conform to
2287 the \BibTeX{} syntax rules. This feature can be useful if a resource file
2288 must be used which generates only new keys. In this case a first pass can
2289 clear the keys and the given resource file can be applied in a second pass
2290 to generate all keys.
2291
2292 If \BibTool{} is applied to the example entries given earlier with the
2293 command line argument \verb|-- key.format=empty| we get the following
2294 keys:
2295 \begin{lstlisting}[language=BibTeX]
2296 @Unpublished{ ,
2297 @Article{ ,
2298 @Book{ ,
2299 @Misc{ ,
2300 \end{lstlisting}
2301 \end{description}
2302
2303 In contrast to the command line option, the resource instruction only modifies
2304 the formatting specification. The key generation has to be activated
2305 explicitly. This can be done using the command line option \opt{F} as in
2306
2307 \sh[F]{}
2308
2309 Alternatively the Boolean resource \rsc{key.generation} can be used in a
2310 resource file:
2311
2312 \begin{Resources}
2313 \rsc{key.generation} = on
2314 \end{Resources}
2315
2316 Usually all keys are regenerated. This can have the unpleasant side-effect to
2317 invalidate citations in old documents. For this situation the resource
2318 \rsc{preserve.keys} is meant. This resource is usually \verb|off|. If it is
2319 turned \verb|on| then only those entries receive new keys if they do not have
2320 a key already. This means that the input contains only a sequence of
2321 white-space characters (which is not accepted by \BibTeX) as in the following
2322 example:
2323
2324 \begin{lstlisting}[language=BibTeX]
2325 @Article{,
2326 author = {L[eslie] A. Aamport},
2327 title = {The Gnats and Gnus Document Preparation System},
2328 journal = {\mbox{G-Animal's} Journal},
2329 year = 1986,
2330 volume = 41,
2331 number = 7,
2332 pages = "73+",
2333 month = jul,
2334 note = "This is a full ARTICLE entry",
2335 }
2336 \end{lstlisting}
2337
2338 Even if \rsc{preserve.keys} is \verb|on|, \BibTool{} still changes all keys to
2339 lower case by default. This can be suppressed by switching
2340 \rsc{preserve.key.case} to \verb|on| (see section~\ref{sec:parse.pretty}).
2341
2342 When the \rsc{key.format} is not \rsc{empty} then the keys are disambiguated
2343 by appending letters or numbers. Thus there can not occur a conflict which
2344 would arise when two entries have the same key. The disambiguation uses the
2345 resource \rsc{key.number.separator}. If a key is found (during the generation)
2346 which is already been used then the valid characters from the value of this
2347 resource is appended. Additionally a number is added. The appearance of the
2348 number can be controlled with the resource \rsc{key.base}. This resource can
2349 take the values \rsc{upper}, \rsc{lower}, and \rsc{digit}. The effect can be
2350 seen in the following table:
2351
2352 \begin{center}%
2353 \begin{tabular}{cccc}
2354 \textrm{generated key}&\rsc{digit}&\rsc{lower}&\rsc{upper}\\\hline
2355 \texttt{key} & \texttt{key} & \texttt{key} & \texttt{key} \\
2356 \texttt{key} & \texttt{key*1} & \texttt{key*a} & \texttt{key*A} \\
2357 \texttt{key} & \texttt{key*2} & \texttt{key*b} & \texttt{key*B} \\
2358 \texttt{key} & \texttt{key*3} & \texttt{key*c} & \texttt{key*C} \\
2359 \texttt{key} & \texttt{key*4} & \texttt{key*d} & \texttt{key*D}
2360 \end{tabular}
2361 \end{center}
2362
2363
2364 As we have seen there are options to adapt the behavior of formatting. Before
2365 we explain the free formatting specification in section \ref{sec:key.format} we
2366 will present the formatting options. Those options can be activated from a
2367 resource file or with the corresponding feature to specify resource
2368 instructions on the command line.
2369
2370 \begin{description}
2371 \item [\rsc{preserve.keys}]
2372 This Boolean resource determines whether existing keys should
2373 be left unchanged when new keys are generated.
2374 The default value is \verb|off|.
2375 \item [\rsc{preserve.key.case}]
2376 This Boolean resource determines whether keys should be recorded and
2377 used exactly as read as opposed to normalizing them by translating all
2378 uppercase letters to lower case. The default value is \verb|off|.
2379 \item [\rsc{default.key}]
2380 The value of this resource is used if nothing else fits.
2381 The default value is \verb|**key*|.
2382 \item [\rsc{key.base}]
2383 The value of this resource is used to determine the kind of formatting
2384 the disambiguating number. Possible values are \rsc{upper},
2385 \rsc{lower}, and \rsc{digit}. Uppercase letters, lower case letters,
2386 or digits are used respectively.
2387 \item [\rsc{key.number.separator}]
2388 The value of this resource is used to separate the disambiguating
2389 number from the rest of the key.
2390 The default value is \verb|*|.
2391 \item [\rsc{key.expand.macros}]
2392 The value of this Boolean resource is used to indicate whether
2393 macros should be expanded while generating a key.
2394 The default value is \verb|off|.
2395 \item [\rsc{fmt.name.title}]
2396 The value of this resource is used by the styles \rsc{short} and
2397 \rsc{long} to separate names and titles.
2398 The default value is \verb|:|.
2399 \item [\rsc{fmt.title.title}]
2400 The value of this resource is used to separate words inside titles.
2401 The default value is \verb|:|.
2402 \item [\rsc{fmt.name.name}]
2403 The value of this resource is used to separate different names (where
2404 the \BibTeX{} file has \verb|and|) when formatting names.
2405 The default value is \verb|.|.
2406 \item [\rsc{fmt.inter.name}]
2407 The value of this resource is used to separate parts of multi-word
2408 names when formatting names.
2409 The default value is \verb|-|.
2410 \item [\rsc{fmt.name.pre}]
2411 The value of this resource is used to separate names and first names
2412 when formatting names.
2413 The default value is \verb|.|.
2414 \item [\rsc{fmt.et.al}]
2415 The value of this resource is used to format \verb|and others| parts
2416 of a name list.
2417 The default value is \verb|.ea|.
2418 \item [\rsc{fmt.word.separator}]
2419 The value of this resource is used as additional characters not to be
2420 considered as word constituents. Word separators are white-space and
2421 punctuation characters. Those can not be redefined.
2422 The default value is empty.
2423 \end{description}
2424
2425 The key style \rsc{short} can be formulated in terms of the format
2426 specification given in section \ref{sec:key.format} as follows:
2427
2428 \begin{lstlisting}[language=BibTool]
2429 {
2430 { %-2n(author)
2431 # %-2n(editor)
2432 }
2433 { %s($fmt.name.title) %-1T(title)
2434 # %s($fmt.name.title) %-1T(booktitle)
2435 #
2436 }
2437 }
2438 #
2439 { { %s($fmt.name.title) %-1T(title)
2440 # %s($fmt.name.title) %-1T(booktitle)
2441 }
2442 }
2443 # %s($default.key)
2444 \end{lstlisting}
2445
2446 The syntax and meaning of such format specifications is explained in section
2447 \ref{sec:key.format}.
2448
2449 \subsection{Aliases for Renamed Entries}
2450
2451 \BibTool{} provides a means to automatically generate \verb|@Alias|
2452 definitions for those entries whoich have received a new key during the key
2453 generation. This works for a sufficiently current \BibTeX{} only.
2454
2455 The aliases can be requested with the boolean resource \rsc{key.make.alias}.
2456 This can be set in a resource file file thie:
2457
2458 \begin{Resources}
2459 \rsc{key.make.alias} = on
2460 \end{Resources}
2461
2462 The default is \texttt{off}. This means that no additional entries are
2463 created.
2464
2465
2466 \begin{Summary}
2467 \Desc{}{\rsc{preserve.keys}=off}{Do not generate new keys if one is already
2468 present.}
2469 \Desc{}{\rsc{preserve.key.case}=on}{Do not translate keys to lower
2470 case when reading.}
2471 \Desc{}{\rsc{default.key}=\{key\}}{Key used if nothing else applies.}
2472 \Desc{}{\rsc{fmt.et.al}=\{ea\}}{String used to abbreviate further names.}
2473 \Desc{}{\rsc{fmt.inter.name}=\{s\}}{String used between parts of names.}
2474 \Desc{}{\rsc{fmt.name.name}=\{s\}}{String used between names.}
2475 \Desc{}{\rsc{fmt.name.pre}=\{s\}}{String separating first and last names.}
2476 \Desc{}{\rsc{fmt.name.title}=\{s\}}{String used to separate names
2477 from titles.}
2478 \Desc{}{\rsc{fmt.title.title}=\{s\}}{String used to separate words
2479 in titles.}
2480 \Desc{}{\rsc{key.base}=\{base\}}{Kind of numbers or letters for
2481 disambiguating keys.}
2482 \Desc{}{\rsc{key.expand.macros}=off}{Turn off macro expansion for key
2483 generation.}
2484 \Desc{\opt{f}}{\rsc{key.format}\{fmt\}}{Set the specification for
2485 key generation to \textit{fmt}.}
2486 \Desc{\opt{F}}{\rsc{key.generation}=on}{Turn on key generation.}
2487 \Desc{}{\rsc{key.make.alias}=on}{Turn on creation of \texttt{@Alias} entries
2488 for entries which have received a new key.}
2489 \Desc{}{\rsc{key.number.separator}=\{s\}}{String to be used before the
2490 disambiguating number.}
2491 \end{Summary}
2492
2493
2494 %------------------------------------------------------------------------------
2495 \section{Format Specification}\label{sec:key.format}
2496
2497 \subsection{Constant Parts}
2498
2499 The simplest component of a format is a constant string. Such strings are
2500 made up of any character except white-space and the following ten characters
2501
2502 \begin{verbatim}
2503 " # % ' ( ) , = { }
2504 \end{verbatim}
2505
2506 This choice of special characters is the same as the special characters of
2507 \BibTeX. Since no means is provided to include a special character into a
2508 format string we guarantee that the resulting key string is conform to the
2509 \BibTeX{} rules.
2510
2511 For example the following strings are legal constant
2512 parts of a format:
2513 \begin{verbatim}
2514 Key
2515 the_name.of-the-@uthor-is:
2516 \end{verbatim}
2517
2518
2519 Now we come to explain the meaning of the special characters. The first case
2520 consists of the white-space characters. They are simply ignored. Thus the
2521 following format strings are equal:\footnote{Well, this is not the whole
2522 truth. Internally it makes a difference whether there is a space or not. In
2523 the presence of spaces more memory is used. But you shouldn't worry too much
2524 about this.}
2525 \begin{verbatim}
2526 Author Or Editor
2527 AuthorOrEditor
2528 A u t h o r O r E d i t o r
2529 \end{verbatim}
2530
2531
2532 \subsection{Formatting Fields}\label{ssec:fields}
2533
2534 The next component of formats are made up formatting instructions which are
2535 starting with a \texttt{\%} character. The general idea has been inspired by
2536 formatting facilities of C. Since there are several different types of
2537 information in a \BibTeX{} entry we provide several primitives for formatting.
2538 The simplest form is for instance\index{N@\%N}
2539 \begin{verbatim}
2540 %N(author)
2541 \end{verbatim}
2542
2543 The \texttt{\%} character is followed by a single character---here
2544 \verb|N|---which indicates the way of formatting and the name of the field to
2545 be formatted enclosed in parenthesis. The example above requests to format the
2546 field \verb|author| according to formatting rules for names (\verb|N|).
2547
2548 The general form is
2549
2550 \begin{itemize}
2551 \item [] \texttt{\%}\textit{sign pre.post qualifier letter}\texttt{(}\textit{field}\texttt{)}
2552 \end{itemize}
2553
2554 In this specification \textit{sign} is \texttt{+} or \texttt{-}. \texttt{+}
2555 means that all characters will be translated to upper case. \texttt{-} means
2556 that all characters will be translated to lower case. If no sign is given, the
2557 case of the field is preserved.
2558
2559 \textit{pre} and \textit{post} are positive integers whose meaning depends on
2560 the format letter \textit{letter}. \textit{qualifier letter} is a one letter
2561 specification indicating the desired formatting type optionally preceded by
2562 the qualifier \verb|#|. Possible values are as described in the following
2563 list:
2564
2565 \begin{itemize}
2566 \item [\texttt{p}] \index{p@\%p|(}Format names according to the format
2567 specifier number \textit{post}. In a list of names at most \textit{pre}
2568 names are used. If there are more names they are treated as given as
2569 \texttt{and others}.
2570
2571 \textit{pre} defaults to 2 and \textit{post} defaults to 0.
2572
2573 See section~\ref{sec:names} for a description of how to specify name
2574 formats.
2575
2576 \begin{Example}
2577 \begin{lstlisting}[language=BibTeX]
2578 author = {A. U. Thor and S. O. Meone and others}
2579 \end{lstlisting}\vspace{-2ex}
2580 With the above item we get the following results:
2581
2582 \begin{tabular}{ll}
2583 \texttt{\%p(author)} & \texttt{Thor.Meone.ea} \\
2584 \texttt{\%1p(author)} & \texttt{Thor.ea} \\
2585 \texttt{\%-2p(author)} & \texttt{thor.meone.ea} \\
2586 \texttt{\%+1p(author)} & \texttt{THOR.EA}
2587 \end{tabular}
2588 \end{Example}\index{p@\%p|)}
2589
2590 \item [\texttt{n}] \index{n@\%n|(}Format last names only.\\
2591 In a list of names at most \textit{pre} last names are used. If there are
2592 more names they are treated as given as \texttt{and others}. If
2593 \textit{post} is greater than 0 then at most \textit{post} characters per
2594 name are used. Otherwise the whole name is considered.
2595
2596 \textit{pre} defaults to 2 and \textit{post} defaults to 0.
2597
2598 This is the same as using the \texttt{p} format specifier with the post
2599 value of 0. The \textit{post} value of the \texttt{n} specifier is used as
2600 the \textit{len} value of the first item of the name format specifier.
2601 (See also section~\ref{sec:names})
2602
2603 \begin{Example}
2604 \begin{lstlisting}[language=BibTeX]
2605 author = {A. U. Thor and S. O. Meone and others}
2606 \end{lstlisting}\vspace{-2ex}
2607 With the above item we get the following results:
2608
2609 \begin{tabular}{ll}
2610 \texttt{\%n(author)} & \texttt{Thor.Meone.ea} \\
2611 \texttt{\%1n(author)} & \texttt{Thor.ea} \\
2612 \texttt{\%-2n(author)} & \texttt{thor.meone.ea} \\
2613 \texttt{\%+1n(author)} & \texttt{THOR.EA} \\
2614 \texttt{\%.3n(author)} & \texttt{Tho.Meo.ea}
2615 \end{tabular}
2616 \end{Example}\index{n@\%n|)}
2617
2618 \item [\texttt{N}] \index{N@\%N|(}Format names with last names and
2619 initials.\\
2620 In a list of names at most \textit{pre} last names are used. If there are
2621 more names they are treated as given as \texttt{and others}. If
2622 \textit{post} is greater than 0 then at most \textit{post} characters per
2623 name are used. Otherwise the whole name is considered.
2624
2625 \textit{pre} defaults to 2 and \textit{post} defaults to 0.
2626
2627 This is the same as using the \texttt{p} format specifier with the post
2628 value of 1. The \textit{post} value of the \texttt{n} specifier is used as
2629 the \textit{len} value of the first item of the name format specifier.
2630 (See also section~\ref{sec:names})
2631
2632 \begin{Example}
2633 \begin{lstlisting}[language=BibTeX]
2634 author = {A. U. Thor and S. O. Meone and others}
2635 \end{lstlisting}\vspace{-2ex}
2636 With the above item we get the following results:
2637
2638 \begin{tabular}{ll}
2639 \texttt{\%N(author)} & \texttt{Thor.AU.Meone.SO.ea} \\
2640 \texttt{\%1N(author)} & \texttt{Thor.AU.ea} \\
2641 \texttt{\%-2N(author)} & \texttt{thor.au.meone.so.ea} \\
2642 \texttt{\%+1N(author)} & \texttt{THOR.AU.EA} \\
2643 \texttt{\%.3N(author)} & \texttt{Tho.AU.Meo.SO.ea}
2644 \end{tabular}
2645 \end{Example}\index{N@\%N|)}
2646
2647 \item [\texttt{d}] \index{d@\%d|(}Format a number, e.g.\ a year.\\
2648
2649 The \textit{post}$^{th}$ number in the field is searched. At most
2650 \textit{pre} digits---counted from the right---are used. For instance
2651 the field \texttt{"june 1958"} formatted with \texttt{\%2d} results in
2652 \texttt{58}.
2653
2654 \textit{pre} defaults to a large number except in when the negative sign
2655 is present. Then it defaults to 1.
2656
2657 \textit{post} defaults to 1. Thus if you want to select the second number
2658 you can simply use \texttt{\%.2d} as format specifier.
2659
2660 If no number is contained in the field then this specifier fails. Thus the
2661 specifier \texttt{\%0d} can be used to check for a number.
2662
2663 Positive and negative signs make no sense in specifying translations since
2664 numbers have no uppercase or lowercase counterparts. Thus they have a
2665 different meaning in this context.
2666
2667 If the positive sign is given then the specifier does not fail at all.
2668 Instead of failing a single \verb|0| is used.
2669
2670 If the negative sign is given then the result is padded with \verb|0| if
2671 required. In this case the specifier does not fail at all. Even if no
2672 number is found then an appropriate number of \verb|0|s is used.
2673
2674 \begin{Example}
2675 \begin{lstlisting}[language=BibTeX]
2676 pages = {89--123}
2677 \end{lstlisting}\vspace{-2ex}
2678 With the above item we get the following results:
2679
2680 \begin{tabular}{ll}
2681 \texttt{\%d(pages)} & \texttt{89} \\
2682 \texttt{\%1d(pages)} & \texttt{9} \\
2683 \texttt{\%4d(pages)} & \texttt{89} \\
2684 \texttt{\%-4d(pages)} & \texttt{0089} \\
2685 \texttt{\%-5.2d(pages)} & \texttt{00123} \\
2686 \texttt{\%.3d(pages)} & \textit{fails} \\
2687 \texttt{\%+.3d(pages)} & \texttt{0} \\
2688 \texttt{\%0d(pages)} & \textit{succeeds with empty result}
2689 \end{tabular}
2690 \end{Example}\index{d@\%d|)}
2691
2692 \item [\texttt{D}] \index{D@\%D|(}Format a number.\\
2693 This format specifier acts like the \texttt{d} specifier except that the
2694 number is not truncated. Thus a large number comes out complete and not
2695 only the last few digits.
2696
2697 \begin{Example}
2698 \begin{lstlisting}[language=BibTeX]
2699 pages = {89--123}
2700 \end{lstlisting}\vspace{-2ex}
2701 With the above item we get the following results:
2702
2703 \begin{tabular}{ll}
2704 \texttt{\%D(pages)} & \texttt{89} \\
2705 \texttt{\%1D(pages)} & \texttt{89} \\
2706 \texttt{\%4D(pages)} & \texttt{89} \\
2707 \texttt{\%-4D(pages)} & \texttt{0089} \\
2708 \texttt{\%-5.2D(pages)} & \texttt{00123} \\
2709 \texttt{\%.3D(pages)} & \textit{fails} \\
2710 \texttt{\%+.3D(pages)} & \texttt{0} \\
2711 \texttt{\%0D(pages)} & \texttt{89}
2712 \end{tabular}
2713 \end{Example}\index{D@\%D|)}
2714
2715 \item [\texttt{s}] \index{s@\%s|(}Take a field as is (after translation of
2716 special characters).\\
2717 At most \textit{pre} characters are used.
2718
2719 \textit{pre} defaults to a large number.
2720
2721 \begin{Example}
2722 \begin{lstlisting}[language=BibTeX]
2723 author = {A. U. Thor and S. O. Meone and others}
2724 \end{lstlisting}\vspace{-2ex}
2725 With the above item we get the following results:
2726
2727 \begin{tabular}{ll}
2728 \texttt{\%s(author)} & \texttt{A.-U.-Thor-and-S.-O.-Meone-and-others} \\
2729 \texttt{\%8s(author)} & \texttt{A.-U.-Th} \\
2730 \texttt{\%-8s(author)} & \texttt{a.-u.-th} \\
2731 \texttt{\%+8s(author)} & \texttt{A.-U.-TH} \\
2732 \texttt{\%0s(author)} & \textit{succeeds with empty result}
2733 \end{tabular}
2734 \end{Example}\index{s@\%s|)}
2735
2736 \item [\texttt{T}] \index{T@\%T|(}Format sentences. Certain words are
2737 ignored.\\
2738 At most \textit{pre} words are used. The other words are ignored. If
2739 \textit{pre} is 0 then no artificial limit is forced. If \textit{post} is
2740 positive then at most \textit{post} letters of each word are considered.
2741 Otherwise the complete words are used.
2742
2743 New words to be ignored can be added with the resource \rsc{ignored.word}.
2744
2745 \textit{pre} defaults to 1 and \textit{post} defaults to 0.
2746
2747 \begin{Example}
2748 \begin{lstlisting}[language=BibTeX]
2749 title = {The Whole Title}
2750 \end{lstlisting}\vspace{-2ex}
2751 With the above item we get the following results:
2752
2753 \begin{tabular}{ll}
2754 \texttt{\%T(title)} & \texttt{Whole} \\
2755 \texttt{\%2T(title)} & \texttt{Whole-Title} \\
2756 \texttt{\%2.1T(title)} & \texttt{W-T} \\
2757 \texttt{\%-T(title)} & \texttt{whole} \\
2758 \texttt{\%+T(title)} & \texttt{WHOLE}
2759 \end{tabular}
2760 \end{Example}
2761
2762 The string to be formatted according to this specification is separated
2763 into words. To accomplish this white-space characters and punctuation
2764 characters are considered to be not part of a word but as separator. To
2765 add additional word separators use the resource \rsc{fmt.word.separator}.
2766 In the following example the characters \verb|+|, \verb|-|, \verb|<|,
2767 \verb|=|, \verb|>|, \verb|*|, and \verb|/| are declared as additional word
2768 separators.
2769
2770 \begin{Resources}
2771 \rsc{fmt.word.separator} = \texttt{"+-<=>*/"}
2772 \end{Resources}
2773
2774 Note that the effect of \rsc{fmt.word.separator} is accumulating more
2775 characters. It is not possible to define a character not to be a word
2776 separator once it has this property.\index{T@\%T|)}
2777
2778 \item [\texttt{t}] \index{t@\%t|(}Format sentences. In contrast to the
2779 format letter \texttt{T} no words are ignored.\\
2780 At most \textit{pre} words are used. The other words are ignored. If
2781 \textit{pre} is 0 then no artificial limit is forced. If \textit{post} is
2782 positive then at most \textit{post} letters of each word are considered.
2783 Otherwise the complete words are used.
2784
2785 \textit{pre} defaults to 1 and \textit{post} defaults to 0.
2786
2787 \begin{Example}
2788 \begin{lstlisting}[language=BibTeX]
2789 title = {The Whole Title}
2790 \end{lstlisting}\vspace{-2ex}
2791 With the above item we get the following results:
2792
2793 \begin{tabular}{ll}
2794 \texttt{\%t(title)} & \texttt{The} \\
2795 \texttt{\%2t(title)} & \texttt{The-Whole} \\
2796 \texttt{\%2.1t(title)} & \texttt{T-W} \\
2797 \texttt{\%-t(title)} & \texttt{the} \\
2798 \texttt{\%+t(title)} & \texttt{THE}
2799 \end{tabular}
2800 \end{Example}\index{t@\%t|)}
2801
2802 \item [\texttt{W}] \index{W@\%W|(}Format word lists.\\
2803 This specifier acts like \texttt{T} except that nothing is inserted
2804 between words.
2805
2806 \begin{Example}
2807 \begin{lstlisting}[language=BibTeX]
2808 title = {The Whole Title}
2809 \end{lstlisting}\vspace{-2ex}
2810 With the above item we get the following results:
2811
2812 \begin{tabular}{ll}
2813 \texttt{\%W(title)} & \texttt{Whole} \\
2814 \texttt{\%2W(title)} & \texttt{WholeTitle} \\
2815 \texttt{\%2.1W(title)} & \texttt{WT} \\
2816 \texttt{\%-W(title)} & \texttt{whole} \\
2817 \texttt{\%+W(title)} & \texttt{WHOLE}
2818 \end{tabular}
2819 \end{Example}\index{W@\%W|)}
2820
2821 \item [\texttt{w}] \index{w@\%w|(}Format word lists.\\
2822 This specifier acts like \texttt{t} except that nothing is inserted
2823 between words.
2824
2825 \begin{Example}
2826 \begin{lstlisting}[language=BibTeX]
2827 title = {The Whole Title}
2828 \end{lstlisting}\vspace{-2ex}
2829 With the above item we get the following results:
2830
2831 \begin{tabular}{ll}
2832 \texttt{\%w(title)} & \texttt{The} \\
2833 \texttt{\%2w(title)} & \texttt{TheWhole} \\
2834 \texttt{\%2.1w(title)} & \texttt{TW} \\
2835 \texttt{\%-w(title)} & \texttt{the} \\
2836 \texttt{\%+w(title)} & \texttt{THE}
2837 \end{tabular}
2838 \end{Example}\index{w@\%w|)}
2839
2840 \item [\texttt{\#p}] \index{p@\%\#p|(}Count the number of names.
2841
2842 If no \textit{sign} is given or the \textit{sign} is \verb|+| then the
2843 following rules apply. If the count is less than \textit{pre} or the count
2844 is greater than \textit{post} then this specifier fails. Otherwise it
2845 succeeds without adding something to the key.
2846
2847 The construction \verb|and others|, which indicates an unspecified number
2848 of additional authors, counts as one single author.
2849
2850 If the \textit{sign} is \verb|-| then the specifier succeeds if and only
2851 if the specifier without this sign fails. Thus the \verb|-| acts like a
2852 negation of the condition.
2853
2854 If post has the value 0 than this is treated like \(\infty\).
2855
2856 If \(a\) is the number of names separated by \texttt{and} then\\
2857 \texttt{\%\textit{l}.\textit{h}\#p} succeeds if and only if
2858 \(l\leq a\leq h\).\\
2859 \texttt{\%-\textit{l}.\textit{h}\#p} succeeds if and only if \(l>a\) or
2860 \(a>h\).
2861
2862 \textit{pre} and \textit{post} both defaults to 0.
2863
2864 \begin{Example}
2865 \begin{lstlisting}[language=BibTeX]
2866 author = {A. U. Thor and S. O. Meone and others}
2867 \end{lstlisting}\vspace{-2ex}
2868 With the above item we get the following results:
2869
2870 \begin{tabular}{ll}
2871 \texttt{\%2\#p(author)} & \textit{succeeds with empty result} \\
2872 \texttt{\%4\#p(author)} & \textit{fails} \\
2873 \texttt{\%-4\#p(author)} & \textit{succeeds with empty result} \\
2874 \texttt{\%3.4\#p(author)} & \textit{succeeds with empty result} \\
2875 \texttt{\%-3.4\#p(author)} & \textit{fails}
2876 \end{tabular}
2877 \end{Example}\index{p@\%\#p|)}
2878
2879 \item [\texttt{\#n}] Is the same as \texttt{\#p}\index{n@\%\#n}.
2880
2881 \item [\texttt{\#N}] Is the same as \texttt{\#p}\index{N@\%\#N}.
2882
2883 \item [\texttt{\#s}] \index{s@\%\#s|(}Count the number of allowed characters.
2884
2885 If no \textit{sign} is given or the \textit{sign} is \verb|+| then the
2886 following rules apply. If the count is less than \textit{pre} or the count
2887 is greater than \textit{post} then this specifier fails. Otherwise it
2888 succeeds without adding something to the key.
2889
2890 If the \textit{sign} is \verb|-| then the specifier succeeds if and only
2891 if the specifier without this sign fails. Thus the \verb|-| acts like a
2892 negation of the condition.
2893
2894 If post has the value 0 than this is treated like \(\infty\).
2895
2896 \textit{pre} and \textit{post} both default to 0.
2897
2898 If \(a\) is the number of allowed characters then\\
2899 \texttt{\%\textit{l}.\textit{h}\#s} succeeds if and only if
2900 \(l\leq a\leq h\).\\
2901 \texttt{\%-\textit{l}.\textit{h}\#s} succeeds if and only if \(l>a\) or
2902 \(a>h\).
2903
2904 \begin{Example}
2905 \begin{lstlisting}[language=BibTeX]
2906 title = {The Whole Title}
2907 \end{lstlisting}\vspace{-2ex}
2908 With the above item we get the following results:
2909
2910 \begin{tabular}{ll}
2911 \texttt{\%\#s(title)} & \textit{succeeds with empty result}\\
2912 \texttt{\%13.13\#s(title)} & \textit{succeeds with empty result}\\
2913 \texttt{\%10.16\#s(title)} & \textit{succeeds with empty result}\\
2914 \texttt{\%-10.16\#s(title)} & \textit{fails}
2915 \end{tabular}
2916 \end{Example}\index{s@\%\#s|)}
2917
2918 \item [\texttt{\#w}] \index{w@\%\#w|(}Count the number of words. All words
2919 are considered as valid. The division into words is performed after
2920 de\TeX{}ing the field.
2921
2922 If no \textit{sign} is given or the \textit{sign} is \verb|+| then the
2923 following rules apply. If the count is less than \textit{pre} or the count
2924 is greater than \textit{post} then this specifier fails. Otherwise it
2925 succeeds without adding something to the key.
2926
2927 If the \textit{sign} is \verb|-| then the specifier succeeds if and only
2928 if the specifier without this sign succeeds. Thus the \verb|-| acts like a
2929 negation of the condition.
2930
2931 If post has the value 0 than this is treated like \(\infty\).
2932
2933 \textit{pre} and \textit{post} both default to 0.
2934
2935 If \(a\) is the number of words separated by white-space then\\
2936 \texttt{\%\textit{l}.\textit{h}\#p} succeeds if and only if
2937 \(l\leq a\leq h\).\\
2938 \texttt{\%-\textit{l}.\textit{h}\#p} succeeds if and only if
2939 \(l>a\) or \(a>h\).
2940
2941 \begin{Example}
2942 \begin{lstlisting}[language=BibTeX]
2943 title = {The Whole Title}
2944 \end{lstlisting}\vspace{-2ex}
2945 With the above item we get the following results:
2946
2947 \begin{tabular}{ll}
2948 \texttt{\%\#w(title)} & \textit{succeeds with empty result}\\
2949 \texttt{\%3.3\#w(title)} & \textit{succeeds with empty result}\\
2950 \texttt{\%1.6\#w(title)} & \textit{succeeds with empty result}\\
2951 \texttt{\%-1.6\#w(title)} & \textit{fails}
2952 \end{tabular}
2953 \end{Example}\index{w@\%\#w|)}
2954
2955 \item [\texttt{\#t}] \index{t@\%\#t}Is the same as \texttt{\#w}.
2956
2957 \item [\texttt{\#W}] \index{W@\%\#W|(}Count the number of words. Certain
2958 words are ignored. The ignored words are determined by the resource
2959 \rsc{ignored.word}. The division into words is performed after
2960 de\TeX{}ing the field.
2961
2962 If no \textit{sign} is given or the \textit{sign} is \verb|+| then the
2963 following rules apply. If the count is less than \textit{pre} or the
2964 count is greater than \textit{post} then this specifier fails. Otherwise
2965 it succeeds without adding something to the key.
2966
2967 If the \textit{sign} is \verb|-| then the specifier succeeds if and only
2968 if the specifier without this sign fails. Thus the \verb|-| acts like a
2969 negation of the condition.
2970
2971 If post has the value 0 than this is treated like \(\infty\).
2972
2973 \textit{pre} and \textit{post} both default to 0.
2974
2975 If \(a\) is the number of words separated by white-space which are
2976 not marked to be ignored then\\
2977 \texttt{\%\textit{l}.\textit{h}\#p} succeeds if and only if
2978 \(l\leq a\leq h\).\\
2979 \texttt{\%-\textit{l}.\textit{h}\#p} succeeds if and only if \(l>a\) or
2980 \(a>h\).
2981
2982 \begin{Example}
2983 \begin{lstlisting}[language=BibTeX]
2984 title = {The Whole Title}
2985 \end{lstlisting}\vspace{-2ex}
2986 With the above item we get the following results:
2987
2988 \begin{tabular}{ll}
2989 \texttt{\%\#W(title)} & \textit{succeeds with empty result}\\
2990 \texttt{\%2.2\#W(title)} & \textit{succeeds with empty result}\\
2991 \texttt{\%1.6\#W(title)} & \textit{succeeds with empty result}\\
2992 \texttt{\%-1.6\#W(title)} & \textit{fails}
2993 \end{tabular}
2994 \end{Example}\index{w@\%\#w|)}
2995
2996 \item [\texttt{\#T}] \index{T@\%\#T}Is the same as \texttt{\#W}.
2997
2998 \end{itemize}
2999
3000 If some words are enclosed in brace, they are considered as one composed word.
3001 For example, with the format \verb|%t(title)|\index{t@\%t}, and
3002 this field:
3003 \begin{lstlisting}[language=BibTeX]
3004 title = "{The Whole Title}"
3005 \end{lstlisting}
3006 In this case we obtain \verb|The-Whole-Title|.
3007
3008 The field specification \textit{(field)} selects the field of the entry to be
3009 formatted. As usual in \BibTeX{} the case of the letters is ignored. If the
3010 field does not exist then the formatting fails and continues at the next
3011 alternative (see below).
3012
3013 But the field is not only sought in the current entry. According to the
3014 behavior of \BibTeX{} the special field \texttt{crossref} is taken into
3015 account. If a field is missing them the entry named in the \texttt{crossref}
3016 field is also considered. Since this dereferencing contains the potential
3017 danger of an infinite loop the number of dereferencing steps is restricted by
3018 the numeric resource \rsc{crossref.limit}. The number of uses of the
3019 \texttt{crossref} field is limited by the value of this resource. The default
3020 of this resource is 32.
3021
3022 Usually a value of 1 would be sufficient for \BibTeX{} files conforming to the
3023 standard styles. Nevertheless other applications can be imagined where a
3024 higher value is desirable.
3025
3026 To turn off the crossref feature complete you can set the value of
3027 \rsc{crossref.limit} to 0. In this case only the fields found in the entry
3028 itself are considered.
3029
3030
3031 \subsection{Pseudo Fields}\label{sec:pseudo-fields}
3032
3033 In addition to the ordinary fields of an entry there are several
3034 pseudo fields. They are listed below.
3035
3036 \begin{description}
3037 \item [\texttt{\$key}]\label{pseudo:key}%
3038 This pseudo field contains the old reference key---before generating a new
3039 one. If none has been given then the access fails.
3040
3041 \item [\texttt{\$sortkey}]%
3042 This pseudofield contains the string according to which the sorting is
3043 performed. It defaults to the reference key.
3044
3045 \item [\texttt{\$default.key}]%
3046 This pseudo field contains the value of the resource \rsc{default.key}
3047 similarly the resources \rsc{fmt.name.title}, \rsc{fmt.title.title},
3048 \rsc{fmt.name.name}, \rsc{fmt.inter.name}, \rsc{fmt.name.pre}, and
3049 \rsc{fmt.et.al} can be accessed.
3050
3051 \item [\texttt{\$source}]%
3052 This pseudo field contains the name of the file the entry has been read
3053 from. If this file can not be determined, e.g. because the entry has been
3054 read from stdin, then this pseudo field is empty.
3055
3056 \item [\texttt{\$type}]%
3057 This pseudo field contains the type of the entry, i.e.\ the string following
3058 the initial \texttt{@} of an \BibTeX{} entry, e.g.\ \texttt{article}. It is
3059 always present.
3060
3061 \item [\texttt{@}\textit{type}]%
3062 This pseudo field is matched against the type of the entry. If they are
3063 identical (ignoring cases) then the type is returned. Otherwise the access
3064 fails.
3065
3066 In an article item the specification \texttt{\%s(@Article)}\index{s@\%s}
3067 succeeds and returns \texttt{Article} whereas
3068 \texttt{\%s(@Book)}\index{s@\%s} fails.
3069
3070 \item [\texttt{\$day}]%
3071 This pseudo field contains the current day as a two digit number or the
3072 empty string if this value is not available. The date and time values are
3073 determined at the beginning of the \BibTool{} run and does not reflect the
3074 execution time used by \BibTool.
3075
3076 On some systems the timing function might be missing or returning strange
3077 values. In this case the timing fields simply return the empty string.
3078
3079 \item [\texttt{\$month}]%
3080 This pseudo field contains the current month as a two digit number or the
3081 empty string if this value is not available.
3082
3083 \item [\texttt{\$mon}]%
3084 This pseudo field contains the current month name as a string or the
3085 empty string if this value is not available.
3086
3087 \item [\texttt{\$year}]%
3088 This pseudo field contains the current year as a four digit number or the
3089 empty string if this value is not available.
3090
3091 \item [\texttt{\$hour}]%
3092 This pseudo field contains the current hour as a two digit number or the
3093 empty string if this value is not available.
3094
3095 \item [\texttt{\$minute}]%
3096 This pseudo field contains the current minute as a two digit number or the
3097 empty string if this value is not available.
3098
3099 \item [\texttt{\$second}]%
3100 This pseudo field contains the current second as a two digit number or the
3101 empty string if this value is not available.
3102
3103 \item [\texttt{\$user}] %
3104 This pseudo field contains the contents of the environment variable
3105 \texttt{\$USER} or the empty string if this value is not available. On UN*X
3106 systems this variable usually contains the name of the user. This can be
3107 used to write logging information into a field.
3108
3109 \item [\texttt{\$hostname}]%
3110 This pseudo field contains the contents of the environment variable
3111 \texttt{\$HOSTNAME} or the empty string if this value is not available.
3112 \end{description}
3113
3114
3115 \subsection{Conjunctions}
3116
3117 Conjunctions are formatting instructions evaluated in sequence. The
3118 conjunctions are simply written by successive formatting instructions. A
3119 conjunction succeeds if every part succeeds. The empty conjunction always
3120 succeeds.
3121
3122 Suppose an \BibTeX{} entry contains fields for \texttt{editor} and
3123 \texttt{year}. Then the following conjunction succeeds:
3124
3125 \begin{itemize}
3126 \item [] \texttt{\%-3n(editor) : \%2d(year)} \index{n@\%n}\index{d@\%d}
3127 \end{itemize}
3128
3129 If the value of the \texttt{editor} field is \verb|"|\verb|E.D. Itor"| and the
3130 \texttt{year} field contains \texttt{"1992"} then the result is
3131 \texttt{itor:92}.
3132
3133 \subsection{If-Then-Else}\label{ssec:if-then-else}
3134
3135 Depending on the presence of a (pseudo-) field formatting instructions can be
3136 issued. This corresponds to an if-then-else statement in a
3137 \textsc{Pascal}-like language. The syntax is as follows:
3138
3139 \begin{itemize}
3140 \item [] \verb|(|\textit{field}\/\verb|)|
3141 \verb|{|\textit{then-part}\/\verb|}|
3142 \verb|{|\textit{else-part}\/\verb|}|
3143 \end{itemize}
3144
3145 If the access to the (pseudo-)field as described in \ref{ssec:fields} succeeds
3146 then the \textit{then-part} is evaluated. Otherwise the \textit{else-part} is
3147 evaluated. Both parts may be empty. Nevertheless the braces are required.
3148
3149 Let us look at an example. The following construction can be used to format a
3150 field \texttt{author} if it is present or print a constant string.
3151
3152 \begin{itemize}
3153 \item [] \verb|(author){|\texttt{\%}\verb|N(author)}{--no-author--}|
3154 \index{N@\%N}
3155 \end{itemize}
3156
3157
3158 \subsection{Alternatives}
3159
3160 Alternatives (disjunctives) are separated by the hash mark (\verb|#|). The
3161 general form is
3162
3163 \begin{itemize}
3164 \item [] \textit{alternative\(_1\)} \verb|#|
3165 \textit{alternative\(_2\)} \verb|#|
3166 \textit{\dots} \verb|#|
3167 \textit{alternative\(_n\)}
3168 \end{itemize}
3169
3170 The alternatives are evaluated from left to right. The first one that succeeds
3171 terminates the processing of all alternatives with success. If no alternative
3172 is successful then the whole construct fails.
3173
3174 An alternative can be empty. The empty alternative succeeds without any other
3175 effect.
3176
3177 The example given in subsection \ref{ssec:if-then-else} can be also written as
3178
3179 \begin{itemize}
3180 \item [] \texttt{\%}\verb|N(author) # --no-author--|\index{N@\%N}
3181 \end{itemize}
3182
3183 If the author field is accessible the first alternative succeeds and
3184 terminates the construct. Otherwise the constant string is used. This constant
3185 string always succeeds.
3186
3187
3188 \subsection{Grouping}
3189
3190 Any number of constructs can be enclosed in braces (\verb|{}|) for grouping.
3191 Thus the precedence of operators can be bypassed.
3192
3193 Coming back to our example from the previous subsection. To complicate the
3194 example we want to append an optional title, or a constant string. This is
3195 accomplished as follows.
3196
3197
3198 \begin{itemize}
3199 \item [] \verb|{|\texttt{\%}\verb|N(author) # --no-author-- } |\index{N@\%N}
3200 \verb|{|\texttt{\%}\verb|T(title) # --no-title-- } |\index{T@\%T}
3201 \end{itemize}
3202
3203 The grouping allows to restrict the range of the alternative operator \verb|#|
3204 in this example.
3205
3206 Another example shows how the alternative together with grouping can be
3207 used to share a format specification for certain types of entries:
3208
3209 \begin{itemize}
3210 \item [] \verb|{|\texttt{\%}\verb|0s(@book) # |\texttt{\%}\verb|0s(@proceedings)} --book-or-proc--|\index{s@\%s}
3211 \end{itemize}
3212
3213 The \texttt{\%}\verb|0s|\index{s@\%s} specifier is used to check for the
3214 existence of a certain field without actually adding anything to the output.
3215 Other constructs may serve for the same purpose. This construct is applied to
3216 the pseudo fields \texttt{@book} and \texttt{@proceedings}. The access to the
3217 pseudo field fails if requested in another type of entry. Those two checks are
3218 combined to form a disjunction. Thus the following code---the constant in this
3219 example---is reached only if we are in a book or in a proceedings entry. It is
3220 not reached in an article.
3221
3222
3223 \subsection{Ignored Words}
3224
3225 Certain format specifiers act on lists of words. In this situation it can be
3226 desirable to ignore certain words. For instance when a sort key is constructed
3227 with the title of books it is common practice to omit certain words like
3228 articles. This is accomplished by a list of ignored words. This list is
3229 initialized at compile time to contain articles of different languages (If the
3230 installer has not modified it).
3231
3232 The resource \rsc{ignored.word} can be used to put additional words onto the
3233 list of ignored words. For this purpose the new word is given as argument to
3234 the resource. Note that there should be no space between the braces and the
3235 word. For example:
3236
3237 \begin{Resources}
3238 \rscBraces{ignored.word}{word}
3239 \end{Resources}
3240
3241 To gain complete control over the list of ignored words you can completely
3242 overwrite the compiled in defaults. This can be accomplished by clearing the
3243 list of ignored words. Afterwards no word is recognized as ignored word until
3244 new words are added to this list. This operation can be performed with the
3245 resource \rsc{clear.ignored.words}. In principal this operation does not
3246 require any argument. Since this contradicts the syntactic restrictions for
3247 resources you have to give an empty argument to this resource:
3248
3249 \begin{Resources}
3250 \rscBraces{clear.ignored.words}{}
3251 \end{Resources}
3252
3253
3254 \subsection{Expanding \TeX/\LaTeX{} Macros}
3255
3256 When fields are formatted certain \LaTeX{} macros may be replaced by pure
3257 text. Each macro not defined is simply ignored. Initially no \LaTeX{} macro is
3258 defined. The resource \rsc{tex.define} can be used to define \LaTeX{} macros.
3259 The syntax is very close to \LaTeX. The simplest form is the following
3260 definition.
3261
3262 \begin{Resources}
3263 \rscBraces{tex.define}{\textit{macro=replacement text}}
3264 \end{Resources}
3265
3266 This resource defines a simple macro which is replaced by the replacement
3267 text. This replacement text may in turn contain macros.
3268
3269 In addition to this simple macro also macros involving arguments can be
3270 defined. As in \LaTeX's \verb|\newcommand| the number of arguments is appended
3271 after the macro name.
3272
3273 \begin{Resources}
3274 \rscBraces{tex.define}{\textit{macro}\texttt{[}\textit{arg}\texttt{]=}\textit{replacement text}}
3275 \end{Resources}
3276
3277 The number of arguments may not exceed 9. The actual parameters are addressed
3278 by writing \texttt{\#}\textit{n}, where \textit{n} is the number of the argument.
3279
3280 For instance, this feature can be used to ignore certain arguments of macros.
3281
3282 Note that spaces between the macro head and the equality sign (\verb|=|) are
3283 ignored. Any unwanted spaces after the equality sign may have strange effects.
3284
3285 Usually the macro name starts with a backslash (\verb|\|). If the macro name
3286 starts with another character then this character is made active
3287 (cf.~\cite{knuth:texbook}). This feature is especially useful for translating
3288 characters with an extended ASCII code (\(\geq128\)) to the appropriate \TeX{}
3289 macros.
3290
3291 For instance the following definition forces the expansion of the macro
3292 \verb|\TeX| to the string \verb|TeX|.
3293
3294 \begin{Resources}
3295 \rscBraces{tex.define}{\BS{}TeX=TeX}
3296 \end{Resources}
3297
3298 Without this definition the title \verb|The \TeX{}book| would result in
3299 \verb|book|. With this definition the same title results in \verb|TeXbook|.
3300
3301 Suppose you have an input file containing 8-bit characters (e.g. ISO 8859-1
3302 encoding). The following definition can be used to map this character into a
3303 pure ASCII string\footnote{To add an e is the German convention for umlaut
3304 characters.}
3305
3306 \begin{Resources}
3307 \rscBraces{tex.define}{{\"u}=ue}
3308 \end{Resources}
3309
3310 With the following definition the \verb|\protect| macro and the corresponding
3311 braces would be ignored when formatting field, otherwise the braces would
3312 remain.
3313
3314 \begin{Resources}
3315 \rscBraces{tex.define}{\BS{}protect[1]=\#1}
3316 \end{Resources}
3317
3318 Some useful definitions can be found in the libraries distributed with
3319 \BibTool{} (see also appendix \ref{chap:resource.files}).
3320
3321
3322 \subsection{Name Formatting}\label{sec:names}
3323
3324 Names are a complicated thing. \BibTool{} tries to analyze names and
3325 ``understand'' them correctly. According to the \BibTeX{} definition a
3326 name consists of four types of components:
3327 \begin{itemize}
3328 \item The first names are any names before the last names which start
3329 with an upper case letter.\\
3330 For instance for the name ``Ludwig van Beethoven'' the first name is
3331 ``Ludwig''.
3332 \item The last name is the last word (or group of words) which does
3333 not belong to the junior part.\\
3334 For instance for the name ``Ludwig van Beethoven'' the last name is
3335 ``Beethoven''.
3336 \item The von part are the names before the last name which start with
3337 lower case letters.\\
3338 For instance for the name ``Ludwig van Beethoven'' the von part consists of
3339 the word ``van''.
3340 \item The junior part of a name is an appendix following the last
3341 name. \BibTool{} knows only a small number of words that can appear
3342 in the junior part: junior, jr., senior, sen., Esq., PhD., and roman
3343 numerals up to XXX.
3344 \end{itemize}
3345
3346 Everything except the last name is optional. Each part can also consist of
3347 several words. More on names can be found in \cite{lamport:latex} and
3348 \cite{patashnik:designing}.
3349
3350 \BibTool{} provides a means to specify how the various parts of a name
3351 should be used to construct a string. This string can be used as part
3352 of a key with the \texttt{\%p}\index{p@\%p} format specifier (see above).
3353
3354 \BibTool{} uses a small number of name format specifiers.\footnote{The exact
3355 number can be changed in the configuration file before compilation. The
3356 default is 128.} Initially most of them are undefined. The name format
3357 specifier 0 is initially set to the value
3358 \verb|%*l[|\emph{fmt.inter.name}\/\verb|]|. The name format specifier 1 is
3359 initially set to the value
3360 \verb|%*l[|\emph{fmt.inter.name}\/\verb|]%*1f[|\emph{fmt.inter.name}\/\verb|]|.
3361
3362 The name format specifiers 0 and 1 are used by the formatting instructions
3363 \verb|%N|\index{N@\%N} and \verb|%n|\index{n@\%n}. Thus you should be careful
3364 when redefining them. To help you keep an eye on these two name format
3365 specifiers \BibTool{} issues a warning when they are modified.
3366
3367 The resource \rsc{new.format.type} can be used to assign values to those name
3368 format specifiers:\index{f@\%f}\index{v@\%v}\index{l@\%l}
3369
3370 \begin{Resources}
3371 \rscBraces{new.format.type}{17="\%f\%v\%l"}
3372 \end{Resources}
3373
3374 This instruction sets the name format specifier number 17 to the given value.
3375 This value is a string of characters to be used directly. There is only one
3376 construct which is not used literally. This construct is started by a \% sign
3377 optionally followed by a \verb|+| or a \verb|-| and a number. Next comes one
3378 of the letters \texttt{f}\index{f@\%f}, \texttt{v}\index{v@\%v},
3379 \texttt{l}\index{f@\%f}, or \texttt{j}\index{j@\%j}. Finally there are three
3380 optional arguments enclosed in brackets.
3381
3382 Thus the general form looks as follows:
3383
3384 \begin{itemize}
3385 \item [] \texttt{\%}\textit{sign} \textit{len}\texttt{.}\textit{number}
3386 \textit{letter} \texttt{[}%
3387 \textit{pre}\texttt{][}%
3388 \textit{mid}\texttt{][}%
3389 \textit{post}\texttt{]}
3390 \end{itemize}
3391
3392 The letter \texttt{f}\index{f@\%f} denotes all first names. The letter
3393 \texttt{l}\index{l@\%l} denotes all last names. The letter
3394 \texttt{v}\index{v@\%v} denotes all words in the von part. The letter
3395 \texttt{j}\index{j@\%j} denotes all words in the junior part.
3396
3397 If \textit{sign} is \verb|+| then the words are translated to upper case. If
3398 \textit{sign} is \verb|-| then the words are translated to lower case. If no
3399 sign is given then no conversion is performed. If the sign is \verb|*| then
3400 the translation is inherited from the calling format.
3401
3402 The number \textit{len} can be used to specify the number of characters to be
3403 used. Each word is truncated to at most \textit{len} characters if
3404 \textit{len} is greater than 0. Otherwise no truncation is performed. Thus a
3405 value of \(0\) acts like \(\infty\). Note that the length of the name format
3406 specifiers 0 and 1 are automatically inherited from the calling format.
3407
3408 The fractional number \textit{number} after the period denotes the number of
3409 name parts to be taken into account. This can be used to just show the one
3410 first name if more are given.
3411
3412 If \texttt{[}\textit{mid}\texttt{]} is given then this string is used between
3413 several words of the given part. If none is given then the empty string is
3414 used.
3415
3416 If \texttt{[}\textit{pre}\texttt{]} is given then this string is used before
3417 the given part, but only if the part is not empty. If none is given then the
3418 empty string is used.
3419
3420 If \texttt{[}\textit{post}\texttt{]} is given then this string is used after
3421 the given part, but only if the part is not empty. If none is given then the
3422 empty string is used.
3423
3424
3425 Now we can come to an example. Suppose the name field contains the value
3426 \texttt{Cervantes Saavedra, Miguel de}\footnote{This is the author of ``Don
3427 Quixote''}. This name has two last names, one first name and one word in the
3428 von part.
3429
3430 We want to apply the following name format specifier
3431
3432 \begin{itemize}
3433 \item [] \verb|%1f[.][][.]|\verb|%1v[.][][.]|\verb|%3l[-]|\verb|%1j| \index{f@\%f}\index{v@\%v}\index{l@\%l}
3434 \end{itemize}
3435
3436 This means we want to use abbreviation of first name, von and junior part to
3437 one letter and of three letters of the last name. Thus we will get the result
3438 \verb|M.d.Cer-Saa|.
3439
3440 Note that the name specifier does not take care to include only allowed
3441 letters into a key. Thus watch out and avoid special characters as white-space
3442 and comma.
3443
3444
3445 %------------------------------------------------------------------------------
3446 \subsection{Example}
3447
3448 To end this section we should have a look at a complete example of key
3449 generation specification. For this purpose we define a rule according to which
3450 the keys should be generated:
3451 \begin{enumerate}
3452 \item If a field named \texttt{bibkey} is present then the value of this field
3453 should be used.
3454 \item If the type of the entry is a book then the authors/editors are used
3455 followed by the year separated by a colon.
3456 \item If the type of the entry is an article in a journal (\texttt{article}) then
3457 the author, the journal, the number, and the year should be used. Author and
3458 journal should be separated by a colon, The journal should be abbreviated
3459 with the initials and separated from number and year by a period.
3460 \item If the type of the entry is a volume of conference proceedings
3461 (\texttt{proceedings}) then the editor, the first 5 initials of the title
3462 and the year should be used. The editor should be followed by a colon and
3463 the year preceded by a period.
3464 \item If the type of the entry is a contribution in conference proceedings
3465 then the author, the initials of the book title and the year should be used.
3466 \item Otherwise the first three letters of the type, the author and the
3467 year should be used. If no author is given then the initials of the
3468 title should be used instead---but at most 6 characters.
3469 \end{enumerate}
3470 The names should include up to two names abbreviated to four letters and
3471 should be translated to lower case. If an information is missing then the
3472 respective part together with the following separator should be omitted.
3473
3474 The disambiguation should be done by appending upper case letters without a
3475 preceding string. If everything else fails three question marks should be
3476 inserted as key.
3477
3478 To implement this scheme we write the following specification into a resource
3479 file:
3480 \begin{lstlisting}[language=BibTool]
3481 key.expand.macros = on
3482 key.base = upper
3483 key.number.separator = {}
3484 key.format =
3485 {
3486 %s(bibkey)
3487 #
3488 %0w(@book)
3489 { %-2.4n(author): # %-2.4n(editor): # }
3490 { %4d(year) # }
3491 #
3492 %0w(@article)
3493 { %-2.4n(author): # }
3494 { %-.1W(journal). # }
3495 { %4d(year) # }
3496 #
3497 %0w(@proceedings)
3498 { %-2.4n(editor): # }
3499 { %-.1W(title). # %-.1W(booktitle). # }
3500 { %4d(year) # }
3501 #
3502 %0w(@inproceedings)
3503 { %-2.4n(author): # }
3504 { %-.1W(booktitle). # }
3505 { %4d(year) # }
3506 #
3507 %3s($type)-
3508 { %-2.4n(author):
3509 # %-6.1W(title).
3510 }
3511 {%4d(year) # }
3512 #
3513 %3s($type)-
3514 %4d(year)
3515 # ???
3516 }
3517 \end{lstlisting}
3518
3519 Since each part has been explained before we just need some overall remarks. I
3520 prefer to use the backtracking-based disjunctions instead of nested
3521 if-then-else constructs because they save some braces. They can be read as a
3522 switch statement, or even better as a \texttt{cond} statement in Lisp. This
3523 means they describe cases. The first successful case terminates the evaluation
3524 of the whole cascade.
3525
3526 The constructions like \verb|%0w(@book)| are use to distinguish the different
3527 types. This construction does not produce any output. It just succeeds or
3528 fails depending on the type of the current entry. The \verb|%0w| could also
3529 be replaced by other specifiers which serve the same purpose.
3530
3531 The constructions like \verb|{%4d(year) # }| always succeed. The hash sign
3532 (\verb|#|) catches the failure and inserts the second alternative---which
3533 happens to be empty---if the requested field does not exist.
3534
3535
3536 \begin{Summary}
3537 \Desc{}{\rsc{clear.ignored.words}\{\}}{Forget all words from the list of
3538 ignored words.}
3539 \Desc{}{\rsc{new.format.type}\{n=spec\}}{Define a new way to format names.}
3540 \Desc{}{\rsc{ignored.word}\{s\}}{Add a word to the list of ignored words.}
3541 \Desc{}{\rsc{tex.define}\{macro=text\}}{Expand the \TeX{} macro
3542 \textit{macro} to \textit{text}.}
3543 \Desc{}{\rsc{tex.define}\{macro[n]=text\}}{Expand the \TeX{} macro
3544 with arguments.}
3545 \end{Summary}
3546
3547 %------------------------------------------------------------------------------
3548 \section{Field Manipulation}
3549
3550 This sections contains some operations to manipulate fields in some kind.
3551
3552 %------------------------------------------------------------------------------
3553 \subsection{Adding Fields}
3554
3555 Certain fields can be added. This feature can be used for instance
3556 to update time stamps. For this purpose it is important to know that deletion
3557 is done before addition. It is also important to know that the newly added
3558 entries are not rewritten (see next section) even though rewrite rules are
3559 applicable. The resource \rsc{add.field} is provided to perform this
3560 operation.
3561
3562 \begin{Resources}
3563 \rscBraces{add.field}{\textit{field=value}}
3564 \end{Resources}
3565
3566 This instruction replaces the contents of the field \textit{field} by
3567 \textit{value} in each entry. If this field does not exist already then it is
3568 added first. The additions are applied in the sequence they are given.
3569
3570 \textit{value} can contain formatting instructions already introduced in the
3571 section~\ref{ssec:fields} about ``Formatting Fields'' on
3572 page~\pageref{ssec:fields}.
3573
3574 Suppose a time stamp is stored in the field \texttt{time}. With these
3575 resources the update of a time-stamp can be achieved using the resource
3576 instructions
3577
3578 \begin{Resources}
3579 \rscBraces{add.field}{time="June 13, 2000"}
3580 \end{Resources}
3581
3582 If you want to update all time fields to contain the current date the
3583 following instruction can be used. It makes use of the pseudo fields (see
3584 page~\pageref{pseudo:key}).\index{s@\%s}
3585
3586 \begin{Resources}
3587 \rscBraces{add.field}{time="\%s(\$mon) \%s(\$day), \%s(\$year)"}
3588 \end{Resources}
3589
3590 If you want to strip the month to three leading letters and the year to two
3591 trailing digits this can be achieved with the following
3592 instruction:\index{s@\%s}\index{d@\%d}
3593
3594 \begin{Resources}
3595 \rscBraces{add.field}{time="\%3s(\$mon) \%s(\$day), \%2d(\$year)"}
3596 \end{Resources}
3597
3598 %------------------------------------------------------------------------------
3599 \subsection{Deleting Fields}
3600
3601 Certain fields can be deleted. The resource \rsc{delete.field} is provided to
3602 perform this operation.
3603
3604 The following instruction deletes all fields named \textit{field}:
3605
3606 \begin{Resources}
3607 \rscBraces{delete.field}{\textit{field}}
3608 \end{Resources}
3609
3610 Several instructions of this type can be used to delete several fields.
3611
3612
3613 %------------------------------------------------------------------------------
3614 \subsection{Keeping Fields}
3615
3616 The reverse to the specification of fields to be deleted is the specification
3617 of fields to be kept. Then all fields which are not declared to be kept are
3618 deleted. The resource \rsc{keep.field} allows such a specification.
3619
3620 In the simplest form you can specify the name of a field to be kept. This is
3621 shown in the following example.
3622
3623 \begin{Resources}
3624 \rscBraces{keep.field}{\textit{field}}
3625 \end{Resources}
3626
3627 Several instructions with the resource \rsc{keep.field} can be given. Then all
3628 fields which are not specified to be kept are deleted.
3629
3630 Note that in the extreme case all fields are deleted and an empty entry
3631 containing just the key remains.
3632
3633 Next you can add a condition
3634
3635 \begin{Resources}
3636 \rscBraces{keep.field}{\textit{field} if \textit{field$_c$} = "\textit{pattern}"}
3637 \end{Resources}
3638
3639 The condition follows the key word \texttt{if}. It consists of the comparison
3640 of a field -- or pseudo-field -- with a pattern. The pattern is a regular
3641 expression with which the field is matched. The matching is perfomed
3642 case-insensitiv.
3643
3644 As simplification you can specify several fields to be kept in one rule. For
3645 this purpose you enclose the field names in braces and separate them with
3646 white-space. This is illustrated in the following resources:
3647
3648 \begin{Resources}
3649 \rscBraces{keep.field}{\{\textit{field$_1$} \ldots \textit{field$_n$}\}}
3650 \rscBraces{keep.field}{\{\textit{field$_1$} \ldots \textit{field$_n$}\} if \textit{field$_c$} = "\textit{pattern}"}
3651 \end{Resources}
3652
3653 The forms of the arguments given above require to list the fields to be given
3654 explicitly. In addition to these forms you can specify the star (\verb|*|) as
3655 field name. If the special field name \verb|*| is encountered then this is
3656 interpreted as arbitrary field name.
3657
3658 \begin{Resources}
3659 \rscBraces{keep.field}{*}
3660 \rscBraces{keep.field}{* if \textit{field$_c$} = "\textit{pattern}"}
3661 \end{Resources}
3662
3663 The first form is rather useless since it means that all fields should be
3664 kept. This nullifies any other rule to keep a field.
3665
3666 The second form can be used to express that all fields should be kept if the
3667 record satisfies the given condition.
3668
3669 The libraries \file{keep\_bibtex.rsc} and \file{keep\_biblatex.rsc} contain
3670 \rsc{keep.field} resources contain declarations to keep the fields in the
3671 record types defined in the standard styles of \BibTeX\ and \bibLaTeX\
3672 respectively.
3673
3674 %------------------------------------------------------------------------------
3675 \subsection{Renaming Fields}
3676
3677 Fields can be renamed during the field rewriting phase. This takes immediate
3678 effect such that rewriting rules can fire after the renaming has been
3679 performed.
3680
3681 The resource \rsc{rename.field} can be used to perform this operation. This
3682 resource can be used in the following forms:
3683
3684 \begin{Resources}
3685 \rscBraces{rename.field}{\textit{old=new}}
3686 \rscBraces{rename.field}{\textit{old=new} if \textit{field=pattern}}
3687 \end{Resources}
3688
3689 The parameters \textit{old} and \textit{new} are the old and the new name of
3690 the field. The values are (unquoted) symbols. They are treated case
3691 in-sensitive. The final appearance in the output is determined in the printing
3692 phase.
3693
3694 In the second form a selector is added. \textit{field} is the name of a field
3695 or pseudo field (see section~\ref{sec:pseudo-fields}). The value of this field
3696 is gathered from the current record and matched against the pattern given as
3697 \textit{pattern}. \textit{pattern} is a string value enclosed in double quotes.
3698 The matching succeeds if the \textit{pattern} matches a substring of the value
3699 of the \textit{field}. If the record does not have such a field then the
3700 renaming is not applied.
3701
3702 The case-sensitivity of the matching is controlled by the resource
3703 \rsc{rewrite.case.sensitive}.
3704
3705 The equal signs in the parameter of the resource are optional. They can
3706 omitted or written as \#.
3707
3708 Note that it is up to you to ensure that double appearing field names are
3709 avoided. They would lead to illegal records in the \BibTeX\ output.
3710
3711 Note that the selecting pattern is rather restricted at the moment. This might
3712 change in the future.
3713
3714 The following examples illustrate the function of the resource
3715 \rsc{rename.field}.
3716
3717 The following rule fixes a typo in the field name.
3718
3719 \begin{Resources}
3720 \rscBraces{rename.field}{autor = author}
3721 \end{Resources}
3722
3723 The following rule renames the field \texttt{title} to \texttt{booktitle} for
3724 books. All other record types are unaffected.
3725
3726 \begin{Resources}
3727 \rscBraces{rename.field}{title = booktitle if \$type = "book"}
3728 \end{Resources}
3729
3730
3731 %------------------------------------------------------------------------------
3732 \subsection{Field Rewriting}\label{sec:field.rewriting}
3733
3734 Field modifications can be used to optimize or normalize the appearance of a
3735 \BibTeX{} data base. The powerful facility of regular expression matching is
3736 used for this purpose as we have already seen in section~\ref{sample.norm}.
3737
3738 The resource \rsc{rewrite.rule} can be used to specify rewrite rules. The
3739 general form is as follows:
3740
3741 \begin{Resources}
3742 \rscBraces{rewrite.rule}{field\(_1\) \(\ldots\) field\(_n\) \# pattern \# replacement\_text}
3743 \end{Resources}
3744
3745 \emph{field\(_1\) \(\ldots\) field\(_n\)} is a list of field names. The
3746 rewrite rule is only applied to those fields which have one of those names. If
3747 no field name is given then the rewrite rule is applied to all fields.
3748
3749 \begin{Resources}
3750 \rscBraces{rewrite.rule}{\textit{pattern \# replacement\_text}}
3751 \end{Resources}
3752
3753 Next there is the separator '\#'. This separator is optional. It can also be
3754 the equality sign '='.
3755
3756 \emph{pattern} is a regular expression enclosed in double quotes ("). This
3757 pattern is matched against sub-strings of the field value---including the
3758 delimiters. If a match is found then the matching string is replaced by the
3759 replacement text or the field deleted if no replacement text is given.
3760
3761 \emph{replacement\_text} is the string to be inserted for the matching
3762 sistering of the field value. The backslash '\BS' is used as escape character.
3763 '\BS\(n\)' is replaced by the \(n^{th}\)\/ matching group of \emph{pattern}.
3764 \(n\)\/ is a single digit (1--9). Otherwise the character following the
3765 backslash is inserted.\footnote{Future releases may use backslash followed by
3766 letters for special purposes. It is not safe to rely on escaping letters.}
3767 Thus it is possible to have double quotes inside the replacement text.
3768
3769 Other specials are
3770 \begin{itemize}
3771 \item [\BS\$] which is replaced by the key of the current entry.
3772 \item [\BS @] which is replaced by the type of the current entry.
3773 \end{itemize}
3774
3775 If no replacement text is given then the whole field is deleted. In fact the
3776 instruction \rsc{delete.field} is only an alias for a corresponding rewrite
3777 rule with an empty replacement text. This behavior is illustrated in the
3778 following abstract examples:
3779
3780 \begin{Resources}
3781 \rscBraces{rewrite.rule}{\textit{field \# pattern}}
3782 \rscBraces{rewrite.rule}{\textit{pattern}}
3783 \end{Resources}
3784
3785 More concrete, the rewrite rule
3786
3787 \begin{Resources}
3788 \rscBraces{rewrite.rule}{ time \# "\Hat\(\{\}\)\$" }
3789 \end{Resources}
3790
3791 deletes the time field if the value of the field is empty and enclosed in
3792 curly braces. This is checked with the anchored regular expression
3793 \texttt{\^{}\(\{\}\)\$}. The hat \verb|^| matches the beginning of the value
3794 and the dollar \texttt{\$} matches its end. Since nothing is in
3795 between---except the field delimiters---the rule is applied only to time
3796 fields with empty contents.
3797
3798 This can be generalized to the following rewrite rule which deletes all empty
3799 fields using the same mechanism and just omitting the specification of a field
3800 name:
3801
3802 \begin{Resources}
3803 \rscBraces{rewrite.rule}{ "\Hat\(\{\}\)\$" }
3804 \end{Resources}
3805
3806 Note that for a similar kind of rule for double quotes as field delimiters you
3807 need to quote these characters with backslashes:
3808
3809 \begin{Resources}
3810 \rscBraces{rewrite.rule}{ "\Hat\BS"\BS"\$" }
3811 \end{Resources}
3812
3813
3814 The replacement text may contain field formatting instructions as described in
3815 section~\ref{ssec:fields} on page~\pageref{ssec:fields}. These field
3816 formatting instructions are replaced by their respective values. Thus we could
3817 exploit again the time stamp example from above. The following rewrite rule
3818 will update an existing time stamp without adding one if none is present:
3819
3820 \begin{Resources}
3821 \rscBraces{rewrite.rule}{ time ".*" = "\%3s(\$mon) \%s(\$day), \%2d(\$year)" }\index{s@\%s}\index{d@\%d}
3822 \end{Resources}
3823
3824 The pattern \verb|.*| matches any sequence of arbitrary characters. Thus the
3825 old contents of the field is a match. In this example the value is not reused
3826 in the replacement text. Thus the old contents is completely replaced by the
3827 new one.
3828
3829 Usually the matching is done case insensitive. This means that any upper case
3830 letter matches its lower counterpart and vice versa. This behavior is
3831 controlled by the Boolean resource \rsc{rewrite.case.sensitive} which is
3832 \rsc{on} by default. Changing this variable influences only rewrite rules
3833 specified later.
3834
3835 \begin{Resources}
3836 \rsc{rewrite.case.sensitive} = off
3837 \end{Resources}
3838
3839 A problem occurs e.g. when a string is replaced by a string containing the
3840 original one. To avoid infinite recursion in such cases the numeric resource
3841 \rsc{rewrite.limit} controls the number of applications of each rewrite rule.
3842 If the number given in \rsc{rewrite.limit} is not negative and this limit is
3843 exceeded then a warning is printed and further applications of this rule are
3844 stopped. A negative value of the resource \rsc{rewrite.limit} indicates that
3845 no limitation should be used.
3846
3847
3848 Next we will investigate some concrete examples. Note that in these examples
3849 the character '\texttt{\symbol{32}}' denotes a single space. It is used to
3850 highlight places where spaces have to be used which would be hard to recognize
3851 otherwise.
3852
3853 \begin{itemize}
3854 \item Empty entries are composed of delimiters -- either double quotes or
3855 curly braces which enclose an arbitrary number of spaces. If we want to
3856 delete empty entries we can use the following two rules.
3857
3858 \begin{Resources}
3859 \rscBraces{rewrite.rule}{\texttt{ "\symbol{"5E}\symbol{"5C}"\symbol{32}*\symbol{"5C}"\$" }}
3860 \rscBraces{rewrite.rule}{\texttt{ "\symbol{"5E}\symbol{"7B}\symbol{32}*\symbol{"7D}\$" }}
3861 \end{Resources}
3862
3863 The caret '\texttt{\symbol{"5E}}' denotes the beginning of the whole string
3864 and the dollar is its end. The star is an operator which says that an
3865 arbitrary number of the preceding regular expression -- i.e.\ the space --
3866 can occur at this point.
3867
3868 \item Ranges of pages should usually be composed of numbers separated by an
3869 n-dash (\opt{-}). The next example shows how the pages field can be
3870 normalized. Spaces are deleted and a single minus sign is replaced by a
3871 double minus.
3872
3873 \begin{Resources}
3874 \rscBraces{rewrite.rule}{\texttt{ pages \# "\symbol{"5C}(\symbol{"5B}0-9\symbol{"5D}+\symbol{"5C})\symbol{32}*-\symbol{32}*\symbol{"5C}(\symbol{"5B}0-9\symbol{"5D}+\symbol{"5C})" = "\symbol{"5C}1--\symbol{"5C}2" }}
3875 \end{Resources}
3876
3877 \item Field rewriting may be used to remove \LaTeX{} commands. This example
3878 shows how to remove from titles a \texttt{\char"5C protect} macro together with
3879 the braces, in case the delimiter is a double quote.
3880
3881 \begin{Resources}
3882 \rscBraces{rewrite.rule}{\texttt{title \# "\char"5E\char"5C"\char32*\char"5C\char"5C \char32*protect\char32*\char"7B \char"5C(.*\char"5C)\char"7D\char"5C"\$" = "\symbol{"5C}"\symbol{"5C}1\char"5C"" }}
3883 \end{Resources}
3884 \end{itemize}
3885
3886 %------------------------------------------------------------------------------
3887 \subsection{Field Ordering}
3888
3889 Fields can be reordered within an entry. This feature is controlled by the
3890 presence of a specification for the order to use. The order is specified with
3891 the resource \rsc{sort.order}. The general form is as follows:
3892
3893 \begin{Resources}
3894 \rscBraces{sort.order}{ \textit{entry = field\(_1\) \# field\(_2\) \# ...} }
3895 \end{Resources}
3896
3897 \emph{entry} is the name of an entry like \texttt{book}. The \emph{field}s are
3898 an arbitrary number of field names like \texttt{author}. This specification
3899 says that \emph{field1} should precede \emph{field2} etc. Fields which are not
3900 in this list are arranged after the specified ones. The are left in the same
3901 order as they appear in the entry.
3902
3903 Another possibility is to specify the entry \texttt{*}. Such a sorting order
3904 is applicable to any kind of entry. If no specific sort order is found then
3905 this general order is used if one has been specified.
3906
3907 Any sorting order is added to a list of sorting orders if it has not been
3908 defined before. If a sorting order is specified again, the old one is simply
3909 overwritten.
3910
3911 Consider the following part of a resource file:
3912
3913 \begin{Resources}
3914 \rscBraces{sort.order}{* = author \# title}
3915 \rscBraces{sort.order}{misc = author \# title \# howpublished \# year \# month \# note}
3916 \end{Resources}
3917
3918 This means that the author field goes before the title field in any entry
3919 type. For the misc entries additional specifications are made.
3920
3921 The library \file{sort\_fld.rsc} contains a sample sorting order for the
3922 standard entry types.
3923
3924
3925 \begin{Summary}
3926 \Desc{}{\rsc{add.field}\{field=value\}}{Add a new field to each entry.}
3927 \Desc{}{\rsc{delete.field}\{field\}}{Delete the named field from all
3928 entries.}
3929 \Desc{}{\rsc{rename.field}\{old=new\}}{Rename a field.}
3930 \Desc{}{\rsc{rename.field}\{old=new if field=pattern\}}{Rename a field if
3931 the record satisfies a certain condition.}
3932 \Desc{}{\rsc{rewrite.case.sensitive}=off}{Turn off the case
3933 comparison during field rewriting.}
3934 \Desc{}{\rsc{rewrite.rule}\{fields\#pattern\#text\}}{Replace in all
3935 given fields the pattern by the replacement text.}
3936 \Desc{}{\rsc{sort.order}=\{entry=f\#\ldots\#f\}}{Specify a
3937 preference order for fields in a given entry.}
3938 \end{Summary}
3939
3940
3941 %------------------------------------------------------------------------------
3942 \section{Semantic Checks}
3943
3944 Semantic checks can be enabled in addition to the syntactic checks performed
3945 during parsing.
3946
3947 \subsection{Finding Double Entries}
3948
3949 When merging several bibliographic data bases a common problem is the
3950 occurrence of doubled entries in the resulting data base. When searching for
3951 double entries several problems arise. Which entries should be considered
3952 equal and what should happen to double entries.
3953
3954 The first question is answered as follows. Two entries are considered equal if
3955 their sort key is identical. The condition of identical sort keys allows the
3956 user to specify which criteria should be used when comparing entries. This can
3957 be achieved with the resource \rsc{sort.format} (see section \ref{sorting}).
3958
3959 It remains the question what to do with the doubles. Usually it is not
3960 desirable to keep double entries in one data base, so only one entry found is
3961 kept. The others are printed as comments, i.e.\ the initial ``@'' is replaced
3962 by ``\#\#\#''. Thus all information is still present but inactive in the
3963 \BibTeX{} file. However, further processing with \BibTool{} will remove these
3964 entries if \rsc{pass.comments} is \rsc{off}, which is the default.
3965
3966 Sometimes it is not desirable to include deleted entries in the output -- not
3967 even as comments. In this case the default behavior can be changed with the
3968 help of the Boolean resource \rsc{print.deleted.entries}. If this resource is
3969 \rsc{off} then deleted entries are suppressed completely.
3970
3971 The prefix for deleted entries is stored in the resource
3972 \rsc{print.deleted.prefix} which defaults to ``\#\#\#''. Thus it can be
3973 redefined. However note that you should avoid using a string ending in an at
3974 sign \texttt{@} since this would undo the effect of deleting an entry.
3975
3976 The Boolean resource \rsc{check.double.delete} can be used to delete double
3977 entries completely. For this purpose it has to be turned off as in:
3978
3979 \begin{Resources}
3980 \rsc{check.double.delete} = on
3981 \end{Resources}
3982
3983 The resource \rsc{check.double} can be used to turn on the checking of
3984 doubles. This feature is turned off initially.
3985
3986 \begin{Resources}
3987 \rsc{check.double} = on
3988 \end{Resources}
3989
3990 Checking of doubles can also be turned on with the command line option
3991 \opt{d}:
3992
3993 \sh[d]{}
3994
3995 \subsection{Non-unique Fields}
3996
3997 Double entries are identified by the sort format. Another check which can be
3998 specified is that certain fields are unique. Examples are the reference key
3999 or a DOI number.
4000
4001 The resource \rsc{unique.field} can be used to specify unique constraints for
4002 fields. Each invocation of this resource adds another field and enables the
4003 respective checks.
4004
4005 \begin{Resources}
4006 \rscBraces{unique.field}{\textit{field}}
4007 \end{Resources}
4008
4009 The argument is the name of a field or pseudo-field. The pseudo-fields |$key|
4010 and |$sortkey| are supported in this context. The pseudo-field |$key| contains
4011 the reference key. The pseudo-field |$sortkey| contains the formatted sort
4012 key. The sort key is constructed according to the contents of the resource
4013 \rsc{sort.format} -- even if no sorting is requested. If no sort format is
4014 specified then the value of |$sortkey| contains the |$key|.
4015
4016 Note that this resource produces messages only. Differing from
4017 \rsc{check.double} the identified records are not marked or deleted.
4018
4019
4020 \subsection{Regular Expression Checks}
4021
4022 The regular expressions (see section \ref{sec:regex}) which are used to
4023 rewrite fields (see section \ref{sec:field.rewriting}) can also be used to
4024 perform semantic checks on fields. For this purpose the resources
4025 \rsc{check.rule}, \rsc{check.warning.rule}, and \rsc{check.error.rule} are
4026 provided. The syntax of these resources is the same as for \rsc{rewrite.rule}.
4027
4028 \begin{Resources}
4029 \rscBraces{check.rule}{ \textit{field \# pattern \# message} }
4030 \rscBraces{check.warning.rule}{ \textit{field \# pattern \# message} }
4031 \rscBraces{check.error.rule}{ \textit{field \# pattern \# message} }
4032 \end{Resources}
4033
4034 Again \emph{field} and \emph{message} is optional. The separator \# can also
4035 be written as equality sign (=) or omitted.
4036
4037 Each field is processed as follows. Each check.rule is tried in turn until one
4038 rule is found where \emph{field} (if given) is identical to the field name and
4039 \emph{pattern} matches a sub-string of the field value. If such a rule is
4040 found then the \emph{message} is written to the error stream. If no message is
4041 given then nothing is printed and processing of the current field is ended.
4042
4043 \emph{message} is treated like the replacement text in \rsc{rewrite.rule},
4044 Thus the special character combinations described in section
4045 \ref{sec:field.rewriting} are expanded.
4046
4047 The variants \rsc{check.warning.rule} and \rsc{check.error.rule} contain an
4048 additional indication as warning or error respectively.
4049
4050 Usually the matching is not done case sensitive. This means that any upper
4051 case letter matches its lower counterpart and vice versa. This behavior is
4052 controlled by the Boolean resource \rsc{check.case.sensitive} which is ON by
4053 default. Changing this variable influences only rewrite rules as described in
4054 section~\ref{sec:field.rewriting}.
4055
4056 \begin{Resources}
4057 \rsc{check.case.sensitive} = off
4058 \end{Resources}
4059
4060 Consider the following example. We want to check that the year field contains
4061 only years from 1800 to 2029. Additionally we want to allow two digit
4062 abbreviations.
4063
4064 \begin{Resources}
4065 \rscBraces{check.rule}{\texttt{ year "\Hat[\BS"\symbol{"7B}]1[89][0-9][0-9][\BS"\symbol{"7D}]\$" }}
4066 \rscBraces{check.rule}{\texttt{ year "\Hat[\BS"\symbol{"7B}]20[0-2][0-9][\BS"\symbol{"7D}]\$" }}
4067 \rscBraces{check.rule}{\texttt{ year "\Hat[\BS"\symbol{"7B}][0-9][0-9][\BS"\symbol{"7D}]\$" }}
4068 \rscBraces{check.rule}{\texttt{ year "" "\BS@ \BS\$: Year has to be a suitable number" }}
4069 \end{Resources}
4070
4071 The first rule matches any number starting with 1 followed by 8 or 9 and
4072 finally two digits. The whole number may be enclosed in double quotes or curly
4073 braces.\footnote{In fact the regular expression allows also strings starting
4074 with a quote and ending in a curly brace. But this syntactical nonsense is
4075 ruled out by the parser already.} The hat at the beginning and the dollar at
4076 the end force that the pattern matches against the whole field value only.
4077
4078 The second rule applies for the years starting with 200, 201, or 202. The
4079 following character is an arbitrary digit.
4080
4081 The next rule covers years consisting of two digits. The first three rules
4082 produce no error message but end the search for further matches. Thus is
4083 something suitable is found then one of the first rules finds it.
4084
4085 Otherwise we have to produce an error message. This is done with the third
4086 rule. The empty pattern matches against any value of the year field. This rule
4087 is only applied if the preceding rules do not match. In this case we print an
4088 error message. \texttt{\BS@} is replaced by the current type and
4089 \texttt{\BS\$} by the current key.
4090
4091
4092 \begin{Summary}
4093 \Desc{}{\rsc{check.case.sensitive}=off}{Perform semantic checks case
4094 sensitive.}
4095 \Desc{\opt{d}}{\rsc{check.double}=on}{Find and mark or delete entries with
4096 identical sort keys.}
4097 \Desc{}{\rsc{check.double.delete}=on}{Delete double entries instead
4098 of deactivating them.}
4099 \Desc{}{\rsc{check.rule}\{field\#pattern\#msg\}}{If the value of
4100 field matches pattern then print the given message.}
4101 \end{Summary}
4102
4103
4104 %------------------------------------------------------------------------------
4105 \section{Strings -- also called Macros}\label{sec:macros}
4106
4107 Strings in \BibTeX{} files play an important role when managing large
4108 bibliographic data bases. Thus the deserve special treatment. If the resource
4109 \rsc{macro.file} is defined then the macros are written to this file. The
4110 argument is a file name as in
4111
4112 \begin{Resources}
4113 \rscBraces{macro.file}{\textit{macro/file/name}}
4114 \end{Resources}
4115
4116 Note that the reverse operation to string export namely the import of strings
4117 does not deserve special treatment. You can simply give the macro file as one
4118 of the input files---preferably before any input file that makes use of one of
4119 the macros contained therein.
4120
4121 The Boolean resource \rsc{print.all.strings} indicates if all macros defined
4122 in the \BibTeX{} file should be printed or only those macros actually used.
4123
4124 \begin{Resources}
4125 \rsc{print.all.strings} = on
4126 \end{Resources}
4127
4128 The appearance of string names is controlled by the resource \rsc{symbol.type}
4129 (see \pageref{symbol.type}).
4130
4131 Strings can be expanded when printing entries. This feature of \BibTool{} is
4132 controlled by the resource \rsc{expand.macros} as in
4133
4134 \begin{Resources}
4135 \rsc{expand.macros} = on
4136 \end{Resources}
4137
4138 The effect is that all known strings in normal entries are replaced by their
4139 values. If the values are not defined at the time of expansion then the macro
4140 name remains untouched. As a side effect strings concatenations are
4141 simplified. Imagine the following \BibTeX{} file.
4142
4143 \begin{lstlisting}[language=BibTeX]
4144 @string{ WGA = " World Gnus Almanac" }
4145
4146 @Book{ almanac-66,
4147 title = 1967 # WGA,
4148 month = "1~" # jan
4149 }
4150 \end{lstlisting}
4151
4152 If \BibTool{} is applied with \rsc{expand.macros} turned on this results in
4153 the following output -- if the default settings are used for every other
4154 resource.
4155 \begin{lstlisting}[language=BibTeX]
4156 @STRING{wga = " World Gnus Almanac" }
4157
4158 @Book{ almanac-66,
4159 title = {1967 World Gnus Almanac},
4160 month = {1~} # jan
4161 }
4162 \end{lstlisting}
4163 The macro \texttt{WGA} has been expanded and merged with \verb|1967|. Note
4164 that the string \verb|jan| has not been expanded since the value should be
4165 defined in a \BibTeX{} style file (\file{.bst}).
4166
4167 When macros are expanded the delimiters of entries are normalized, i.e.\ only
4168 one style is used. In this example braces have been used. The alternative
4169 would be to use double quotes. This behavior is controlled by the resource
4170 \rsc{print.braces}. If this resource is on then braces are used otherwise
4171 double quotes are taken. It can be changed like in
4172
4173 \begin{Resources}
4174 \rsc{print.braces} = off
4175 \end{Resources}
4176
4177 The delimiters of the whole entry are recommended to be braces. For
4178 compatibility with Scribe it is also allowed that parentheses are used for
4179 those delimiters. This behavior can be achieved with the Boolean resource
4180 \rsc{print.parentheses}. Initially this resource is off. It can be set like in
4181 the following instruction:
4182
4183 \begin{Resources}
4184 \rsc{print.parentheses} = on
4185 \end{Resources}
4186
4187
4188 \begin{Summary}
4189 \Desc{\opt{m} \textit{file}}{\rsc{macro.file}=\{file\}}{Write the macro
4190 definitions to the file \textit{file}.}
4191 \Desc{}{\rsc{print.all.strings}=off}{Print only those macro definitions
4192 which are used instead of all.}
4193 \Desc{}{\rsc{expand.macros}=on}{Turn on macro (string) expansion in fields.}
4194 \Desc{}{\rsc{print.braces}=off}{Switch to the use of quotes for expanded
4195 macros instead of braces.}
4196 \Desc{}{\rsc{print.parentheses}=on}{Enclose the whole entry in parentheses
4197 instead of braces.}
4198 \end{Summary}
4199
4200
4201 %------------------------------------------------------------------------------
4202 \section{Statistics}
4203
4204 Some information can be obtained at the end of a \BibTool{} run. The number of
4205 \BibTeX{} items read and written is printed. To enable this feature the
4206 resources \rsc{count.all} and \rsc{count.used} are provided.
4207
4208 \begin{Resources}
4209 \rsc{count.all} = on
4210 \end{Resources}
4211
4212 \rsc{count.all} indicates that all known types of \BibTeX{} items should be
4213 listed.
4214
4215 \begin{Resources}
4216 \rsc{count.used} = on
4217 \end{Resources}
4218
4219 \rsc{count.used} forces only those types of \BibTeX{} items to be listed which
4220 have been found in the input files.
4221
4222
4223 \begin{Summary}
4224 \Desc{\opt{\#}}{\rsc{count.all}=on}{Print statistics about all known entry
4225 types.}
4226 \Desc{\opt{@}}{\rsc{count.used}=on}{Print statistics about the used entry
4227 types only.}
4228 \end{Summary}
4229
4230 %------------------------------------------------------------------------------
4231 \section{\BibTeX1.0 Support}
4232
4233 \BibTool\ supports already some of the feature proposed for \BibTeX1.0.
4234
4235 %------------------------------------------------------------------------------
4236 \subsection{Including Bibliographies}
4237
4238 The bibliography file may contain an instruction of the following form:
4239
4240 \begin{lstlisting}[language=BibTeX]
4241 @include{abc.bib}
4242 \end{lstlisting}
4243
4244 Such an entry is stored in the database and printed when requested.
4245 Nevertheless the resource \rsc{apply.include} can be used to control this
4246 behavior.
4247
4248 %------------------------------------------------------------------------------
4249 \subsection{Aliases}
4250
4251 The bibliography file may contain an instruction of the following form:
4252
4253 \begin{lstlisting}[language=BibTeX]
4254 @alias{abc=def}
4255 \end{lstlisting}
4256
4257 This means that the key \texttt{abc} is treated as an alias for the key
4258 \texttt{def}. Usually this alias is stored as alias in the database. For old
4259 \BibTeX\ files it may be desirable to eliminate aliases and introduce copies
4260 of records instead. Nevertheless the resource \rsc{apply.alias} can be used to
4261 control this behavior.
4262
4263 %------------------------------------------------------------------------------
4264 \subsection{Modifications}
4265
4266 The bibliography file may contain an instruction of the following form:
4267
4268 \begin{lstlisting}[language=BibTeX]
4269 @modify{key,
4270 abc = {def}
4271 }
4272 \end{lstlisting}
4273
4274 This modification is stored in the database without being applied.
4275 Nevertheless the resource \rsc{apply.modify} can be used to control this
4276 behavior.
4277
4278
4279 \begin{Summary}
4280 \Desc{}{\rsc{apply.alias}=on}{Expand the aliased entries in the database.}
4281 \Desc{}{\rsc{apply.include}=on}{Include the entries contained in the
4282 bibliography file given in \texttt{@include}.}
4283 \Desc{}{\rsc{apply.modify}=on}{apply the modifies in the database.}
4284 \end{Summary}
4285
4286
4287 %------------------------------------------------------------------------------
4288 %------------------------------------------------------------------------------
4289 \chapter{Limitations}
4290
4291 \section{Limits of \BibTool}
4292
4293 \BibTool{} has been written with dynamic memory management wherever possible.
4294 Thus \BibTool{} should be limited by the memory available only. Especially the
4295 limitation on the field length which is present in \BibTeX\,0.99 is not
4296 present in \BibTool.
4297
4298 \BibTeX{} needs a special order when cross-referenced entries are used. This
4299 limitation has also been released in \BibTool.
4300
4301
4302 \section{Bugs and Problems}
4303
4304 Problems currently known are the following ones. They are not considered to be
4305 bugs.
4306 \begin{itemize}
4307 \item The referencing feature of \BibTeX{} is not supported. \verb|\cite|
4308 macros can be contained in fields (e.g. notes). Such things can be confused.
4309 \item The memory management uses dynamic memory. This memory is reused but not
4310 returned to the operating system. Thus \BibTool{} may run out of memory even
4311 if a more elaborated memory management may find free memory. This is a
4312 design decision and I don't think that I will change it.
4313 \item The \TeX{} reading apparatus is only imitated to a certain limit. But
4314 this should be enough for most applications to produce satisfactory results.
4315 \item In several modules ASCII encoding is assumed. I do not know to which
4316 extend this influences the functionality since I don't have access to
4317 non-ASCII machines.
4318 \item Macro expansion uses a dynamic array which can turn out to be too
4319 short. This will be corrected as soon as I have an example where this bug
4320 shows up.
4321 \end{itemize}
4322
4323 The distribution of \BibTool{} also contains a file named \file{ToDo}. If you
4324 are interested in more detailed descriptions of possible problems,
4325 limitations, and ideas for improvements in further releases then you can have
4326 a look at the contents of this file.
4327
4328 %------------------------------------------------------------------------------
4329 %------------------------------------------------------------------------------
4330 \chapter{Sample Resource Files}\label{chap:resource.files}
4331
4332 Sample resource files are included in the distribution of \BibTool{} in the
4333 directory \file{lib}. Only some of them are reproduced in this section.
4334
4335 \section{The Default Settings}
4336
4337 The following list shows the defaults for all resource instructions.
4338
4339 \begin{lstlisting}[language=BibTool]
4340 apply.alias = off
4341 apply.include = off
4342 apply.modify = off
4343 bibtex.env.name = "BIBINPUTS"
4344 check.case.sensitive = on
4345 check.double = off
4346 check.double.delete = off
4347 count.all = off
4348 count.used = off
4349 crossref.limit = 32
4350 default.key = "**key*"
4351 dir.file.separator = "/"
4352 env.separator = ":"
4353 expand.macros = on
4354 fmt.et.al = ".ea"
4355 fmt.inter.name = "-"
4356 fmt.name.name = "."
4357 fmt.name.pre = "."
4358 fmt.name.title = ":"
4359 fmt.title.title = "-"
4360 ignored.word = "{a}"
4361 ignored.word = "{a}n"
4362 ignored.word = "the"
4363 ignored.word = "le"
4364 ignored.word = "les"
4365 ignored.word = "la"
4366 ignored.word = "{}un"
4367 ignored.word = "{}une"
4368 ignored.word = "{}el"
4369 ignored.word = "{}il"
4370 ignored.word = "der"
4371 ignored.word = "die"
4372 ignored.word = "das"
4373 ignored.word = "{}ein"
4374 ignored.word = "{}eine"
4375 key.base = lower
4376 key.expand.macros = on
4377 key.format = short
4378 key.generation = off
4379 key.make.alias = off
4380 key.number.separator = "*"
4381 new.entry.type = "{}Article"
4382 new.entry.type = "Book"
4383 new.entry.type = "Booklet"
4384 new.entry.type = "Conference"
4385 new.entry.type = "{}InBook"
4386 new.entry.type = "{}InCollection"
4387 new.entry.type = "{}InProceedings"
4388 new.entry.type = "Manual"
4389 new.entry.type = "MastersThesis"
4390 new.entry.type = "Misc"
4391 new.entry.type = "PhDThesis"
4392 new.entry.type = "Proceedings"
4393 new.entry.type = "TechReport"
4394 new.entry.type = "{}Unpublished"
4395 preserve.keys = off
4396 preserve.key.case = off
4397 print.align = 18
4398 print.align.string = 18
4399 print.align.preamble = 11
4400 print.align.comment = 10
4401 print.align.key = 18
4402 print.braces = on
4403 print.comma.at.end = on
4404 print.all.strings = on
4405 print.deleted.prefix = "\#\#\#"
4406 print.deleted.entries = on
4407 print.entry.types = "pisnmac"
4408 print.equal.right = on
4409 print.indent = 2
4410 print.line.length = 77
4411 print.newline = 1
4412 print.parentheses = off
4413 print.terminal.comma = off
4414 print.use.tab = on
4415 print.wide.equal = off
4416 rewrite.case.sensitive = on
4417 rewrite.limit = 512
4418 quiet = off
4419 select.case.sensitive = off
4420 select.crossrefs = off
4421 select.fields = "\$key"
4422 sort = off
4423 sort.cased = off
4424 sort.format = "\%s(\$key)"\index{s@\%s}
4425 sort.macros = on
4426 sort.reverse = off
4427 suppress.initial.newline = off
4428 symbol.type = lower
4429 verbose = off
4430 \end{lstlisting}
4431
4432 \section{\bibLaTeX\ Support}\label{lib:biblatex}
4433
4434 The resource file \verb|biblatex| contains various definitions for \bibLaTeX.
4435
4436 Entry types for \bibLaTeX{}
4437
4438 \begin{lstlisting}[language=BibTool]
4439 new.entry.type{Article}
4440 new.entry.type{Book}
4441 new.entry.type{MVBook}
4442 new.entry.type{InBook}
4443 new.entry.type{BookInBook}
4444 new.entry.type{SuppBook}
4445 new.entry.type{Booklet}
4446 new.entry.type{Collection}
4447 new.entry.type{MVCollection}
4448 new.entry.type{InCollection}
4449 new.entry.type{SuppCollection}
4450 new.entry.type{Manual}
4451 new.entry.type{Misc}
4452 new.entry.type{Online}
4453 new.entry.type{Patent}
4454 new.entry.type{Periodical}
4455 new.entry.type{SuppPeriodical}
4456 new.entry.type{Proceedings}
4457 new.entry.type{MVProceedings}
4458 new.entry.type{Reference}
4459 new.entry.type{MVReference}
4460 new.entry.type{Inreference}
4461 new.entry.type{Report}
4462 new.entry.type{Set}
4463 new.entry.type{Thesis}
4464 new.entry.type{Unpublished}
4465 new.entry.type{Cdata}
4466 new.entry.type{CustomA}
4467 new.entry.type{CustomB}
4468 new.entry.type{CustomC}
4469 new.entry.type{CustomD}
4470 new.entry.type{CustomE}
4471 new.entry.type{CustomF}
4472 new.entry.type{Conference}
4473 new.entry.type{Electronic}
4474 new.entry.type{MasterThesis}
4475 new.entry.type{PhdThesis}
4476 new.entry.type{TechReport}
4477 new.entry.type{WWW}
4478 new.entry.type{Artwork}
4479 new.entry.type{Audio}
4480 new.entry.type{BibNote}
4481 new.entry.type{Commentary}
4482 new.entry.type{Image}
4483 new.entry.type{Jurisdiction}
4484 new.entry.type{Legislation}
4485 new.entry.type{Legal}
4486 new.entry.type{Letter}
4487 new.entry.type{Movie}
4488 new.entry.type{Music}
4489 new.entry.type{Performance}
4490 new.entry.type{Review}
4491 new.entry.type{Software}
4492 new.entry.type{Standard}
4493 new.entry.type{Video}
4494 new.entry.type{XData}
4495 \end{lstlisting}
4496
4497 Field capitalization for \bibLaTeX{}
4498
4499 \begin{lstlisting}[language=BibTool]
4500 % special fields
4501 new.field.type { entryset = EntrySet }
4502 new.field.type { entrysubtype = EntrySubtype }
4503 new.field.type { execute = Execute }
4504 new.field.type { hyphenation = Hyphenation }
4505 new.field.type { keywords = Keywords }
4506 new.field.type { label = Label }
4507 new.field.type { options = Options }
4508 new.field.type { presort = Presort }
4509 new.field.type { shorthand = Shorthand }
4510 new.field.type { sortkey = SortKey }
4511 new.field.type { sortname = SortName }
4512 new.field.type { sorttitle = SortTitle }
4513 new.field.type { sortyear = SortYear }
4514 new.field.type { crossref = CrossRef }
4515 new.field.type { xdata = XData }
4516 new.field.type { xref = XRef }
4517 % data fields
4518 new.field.type { abstract = Abstract }
4519 new.field.type { addendum = Addendum }
4520 new.field.type { address = Address }
4521 new.field.type { afterword = Afterword }
4522 new.field.type { annotation = Annotation }
4523 new.field.type { annote = Annote }
4524 new.field.type { annotator = Annotator }
4525 new.field.type { author = Author }
4526 new.field.type { authortype = AuthorType }
4527 new.field.type { bookauthor = BookAuthor }
4528 new.field.type { booksubtitle = BookSubtitle }
4529 new.field.type { booktitle = BookTitle }
4530 new.field.type { booktitleaddon = BookTitleAddOn }
4531 new.field.type { chapter = Chapter }
4532 new.field.type { commentator = Commentator }
4533 new.field.type { date = Date }
4534 new.field.type { doi = DOI }
4535 new.field.type { edition = Edition }
4536 new.field.type { editor = Editor }
4537 new.field.type { editora = EditorA }
4538 new.field.type { editorb = EditorB }
4539 new.field.type { editorc = EditorC }
4540 new.field.type { editortype = EditorType }
4541 new.field.type { editoratype = EditorAType }
4542 new.field.type { editorbtype = EditorBType }
4543 new.field.type { editorctype = EditorCType }
4544 new.field.type { eid = EID }
4545 new.field.type { eprint = EPrint }
4546 new.field.type { eprintclass = EPrintClass }
4547 new.field.type { eprinttype = EPrintType }
4548 new.field.type { eventdate = EventDate }
4549 new.field.type { eventtitle = EventTitle }
4550 new.field.type { file = File }
4551 new.field.type { foreword = Foreword }
4552 new.field.type { gender = Gender }
4553 new.field.type { howpublished = HowPublished }
4554 new.field.type { indexsorttitle = IndexSortTitle }
4555 new.field.type { indextitle = IndexTitle }
4556 new.field.type { institution = Institution }
4557 new.field.type { introduction = Introduction }
4558 new.field.type { isan = ISAN }
4559 new.field.type { isbn = ISBN }
4560 new.field.type { ismn = ISMN }
4561 new.field.type { isrn = ISRN }
4562 new.field.type { issn = ISSN }
4563 new.field.type { issue = Issue }
4564 new.field.type { issuetitle = IssueTitle }
4565 new.field.type { issuesubtitle = IssueSubtitle }
4566 new.field.type { iswc = ISWC }
4567 new.field.type { journal = Journal }
4568 new.field.type { journaltitle = JournalTitle }
4569 new.field.type { journalsubtitle = JournalSubtitle }
4570 new.field.type { language = Language }
4571 new.field.type { library = Library }
4572 new.field.type { location = Location }
4573 new.field.type { bookpagination = BookPagination }
4574 new.field.type { mainsubtitle = MainSubtitle }
4575 new.field.type { maintitle = MainTitle }
4576 new.field.type { maintitleaddon = MainTitleAddOn }
4577 new.field.type { month = Month }
4578 new.field.type { nameaddon = NameAddOn }
4579 new.field.type { note = Note }
4580 new.field.type { number = Number }
4581 new.field.type { organization = Organization }
4582 new.field.type { origlanguage = OrigLanguage }
4583 new.field.type { origlocation = OrigLocation }
4584 new.field.type { origpublisher = OrigPublisher }
4585 new.field.type { origtitle = OrigTitle }
4586 new.field.type { origdate = OrigDate }
4587 new.field.type { pages = Pages }
4588 new.field.type { pagetotal = PageTotal }
4589 new.field.type { pagination = Pagination }
4590 new.field.type { part = Part }
4591 new.field.type { pdf = PDF }
4592 new.field.type { pubstate = PubState }
4593 new.field.type { reprinttitle = ReprintTitle }
4594 new.field.type { holder = Holder }
4595 new.field.type { publisher = Publisher }
4596 new.field.type { school = School }
4597 new.field.type { series = Series }
4598 new.field.type { shortauthor = ShortAuthor }
4599 new.field.type { shorteditor = ShortEditor }
4600 new.field.type { shorthandintro = ShorthandIntro }
4601 new.field.type { shortjournal = ShortJournal }
4602 new.field.type { shortseries = ShortSeries }
4603 new.field.type { shorttitle = ShortTitle }
4604 new.field.type { subtitle = Subtitle }
4605 new.field.type { title = Title }
4606 new.field.type { titleaddon = TitleAddOn }
4607 new.field.type { translator = Translator }
4608 new.field.type { type = Type }
4609 new.field.type { url = URL }
4610 new.field.type { urldate = URLDate }
4611 new.field.type { venue = Venue }
4612 new.field.type { version = Version }
4613 new.field.type { volume = Volume }
4614 new.field.type { volumes = Volumes }
4615 new.field.type { year = Year }
4616 % aliases
4617 new.field.type { archiveprefix = ArchivePrefix }
4618 new.field.type { primaryclass = PrimaryClass }
4619 % custom fields
4620 new.field.type { namea = NameA }
4621 new.field.type { nameb = NameB }
4622 new.field.type { namec = NameC }
4623 new.field.type { nameatype = NameAType }
4624 new.field.type { namebtype = NameBType }
4625 new.field.type { namectype = NameCType }
4626 new.field.type { lista = ListA }
4627 new.field.type { listb = ListB }
4628 new.field.type { listc = ListC }
4629 new.field.type { listd = ListD }
4630 new.field.type { liste = ListE }
4631 new.field.type { listf = ListF }
4632 new.field.type { usera = UserA }
4633 new.field.type { userb = UserB }
4634 new.field.type { userc = UserC }
4635 new.field.type { userd = UserD }
4636 new.field.type { usere = UserE }
4637 new.field.type { userf = UserF }
4638 new.field.type { verba = VerbA }
4639 new.field.type { verbb = VerbB }
4640 new.field.type { verbc = VerbC }
4641 \end{lstlisting}
4642
4643 Cross-reference mappings for \bibLaTeX{}
4644
4645 \begin{lstlisting}[language=BibTool]
4646 crossref.map {{inbook bookinbook suppbook} bookauthor =
4647 {mvbook book} author
4648 }
4649 crossref.map {{book inbook bookinbook suppbook} maintitle =
4650 mvbook title
4651 }
4652 crossref.map {{book inbook bookinbook suppbook} mainsubtitle =
4653 mvbook subtitle
4654 }
4655 crossref.map {{book inbook bookinbook suppbook} maintitleaddon =
4656 mvbook titleaddon
4657 }
4658 crossref.map {{collection reference incollection inreference suppollection}
4659 maintitle =
4660 {mvcollection mvreference} title
4661 }
4662 crossref.map {{collection reference incollection inreference suppollection}
4663 mainsubtitle =
4664 {mvcollection mvreference} subtitle
4665 }
4666 crossref.map {{collection reference incollection inreference suppollection}
4667 maintitleaddon =
4668 {mvcollection mvreference} titleaddon
4669 }
4670 crossref.map {{proceedings inproceedings}
4671 maintitle =
4672 mvproceedings title
4673 }
4674 crossref.map {{proceedings inproceedings}
4675 mainsubtitle =
4676 mvproceedings subtitle
4677 }
4678 crossref.map {{proceedings inproceedings}
4679 maintitleaddon =
4680 mvproceedings titleaddon
4681 }
4682 crossref.map {{inbook bookinbook suppbook}
4683 booktitle =
4684 book title
4685 }
4686 crossref.map {{inbook bookinbook suppbook}
4687 booksubtitle =
4688 book subtitle
4689 }
4690 crossref.map {{inbook bookinbook suppbook}
4691 booktitleaddon =
4692 book titleaddon
4693 }
4694 crossref.map {{incollection inreference suppollection}
4695 booktitle =
4696 {collection reference} title
4697 }
4698 crossref.map {{incollection inreference suppollection}
4699 booksubtitle =
4700 {collection reference} subtitle
4701 }
4702 crossref.map {{incollection inreference suppollection}
4703 booktitleaddon =
4704 {collection reference} titleaddon
4705 }
4706 crossref.map {inproceedings booktitle =
4707 proceedings title
4708 }
4709 crossref.map {inproceedings booksubtitle =
4710 proceedings subtitle
4711 }
4712 crossref.map {inproceedings booktitleaddon =
4713 proceedings titleaddon
4714 }
4715
4716 crossref.map {{article subperiodical} journaltitle =
4717 periodical} title
4718 }
4719 crossref.map {{article subperiodical} journalsubtitle =
4720 periodical subtitle
4721 }
4722 \end{lstlisting}
4723
4724 \section{Useful Translations}
4725
4726 The resource file \verb|tex_def| translates international characters into
4727 plain text representations. Especially the German umlaut sequences are
4728 translated. For instance the letter {\"A} which is written as \verb|{\"A}| in
4729 a \BibTeX{} file is translated to \verb|Ae|.\footnote{Note that the short
4730 notation of \texttt{german.sty} or \texttt{babel} is not understood by
4731 \BibTeX{} nor by \BibTool. }
4732
4733 Additionally some logos are defined.
4734 \begin{lstlisting}[language=BibTool]
4735 tex.define {\"[1]=#1e}
4736 tex.define {\ss=ss}
4737 tex.define {\AE=AE}
4738 tex.define {\OE=OE}
4739 tex.define {\aa=aa}
4740 tex.define {\AA=AA}
4741 tex.define {\o=o}
4742 tex.define {\O=O}
4743 tex.define {\l=l}
4744 tex.define {\L=L}
4745 tex.define {\i=i}
4746 tex.define {\j=j}
4747 tex.define {\TeX=TeX}
4748 tex.define {\LaTeX=LaTeX}
4749 tex.define {\LaTeXe=LaTeX2e}
4750 tex.define {\BibTeX=BibTeX}
4751 tex.define {\AMSTeX=AMSTeX}
4752 \end{lstlisting}
4753
4754
4755 \section{Other Resource Files}
4756
4757 The distribution contains additional resource files. Some of them are sketched
4758 here. Others may be contained in the distribution as well. Look into the
4759 appropriate directory.
4760
4761 \begin{description}
4762 \item [\file{iso2tex}]\ \\
4763 define rewrite rules to translate ISO 8859-1 characters into \BibTeX\
4764 compatible sequences.
4765 \item [\file{iso\_def}]\ \\
4766 define macro equivalents for ISO 8859-1 characters into \TeX{} compatible
4767 sequences.
4768 \item [\file{sort\_fld}]\ \\
4769 defines a sort order for the common \BibTeX\ entry types.
4770 \item [\file{check\_y}]\ \\
4771 contains a sample for semantic checks. The year field is checked to be a
4772 suitable number.
4773 \item [\file{month}]\ \\
4774 tries to introduce \BibTeX\ strings for month names. Provisions are made to
4775 preserve other information contained in the month field.
4776 \item [\file{opt}]\ \\
4777 copes with \texttt{OPT} prefixes as introduced e.g. by bibtex-mode.
4778 \item [\file{braces}]\ \\
4779 tries to replace double quotes as field delimiters by braces.
4780 \item [\file{keep\_bibtex}]\ \\
4781 defines the entry types and attributes according to the standard \BibTeX\
4782 styles to be kept. Any undeclared attribute will be deleted.
4783 \item [\file{keep\_biblatex}]\ \\
4784 defines the entry types and attributes according to the standard \bibLaTeX\
4785 styles to be kept. Any undeclared attribute will be deleted.
4786 \end{description}
4787
4788
4789 %------------------------------------------------------------------------------
4790 \bibliographystyle{alpha}
4791 \bibliography{bibtool}
4792
4793 \ifHTML\else
4794 \ifx\ptt\undefined\global\let\ptt\ttfamily\fi
4795 \ifx\psf\undefined\global\let\psf\sffamily\fi
4796 \ifx\pdollar\undefined\global\let\pdollar\$\fi
4797 \fi
4798 \printindex
4799
4800 \end{document} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4801 %
4802 % Local Variables:
4803 % mode: latex
4804 % TeX-master: nil
4805 % fill-column: 78
4806 % End: