summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2007-08-24 18:43:05 +0000
committerKarl Berry <karl@freefriends.org>2007-08-24 18:43:05 +0000
commitfe752bd7396fcc8c6fb65128bcd481a5e326e7cd (patch)
tree216701b87bcd27c641a8a57b4cbd7e2c9dd815ae
parentfabf181c6946e1e5ea931f003df726c9c1c553b8 (diff)
datatool 1.01 (20aug07)
git-svn-id: svn://tug.org/texlive/trunk@4804 c570f23f-e606-0410-a88d-b1316a301751
-rw-r--r--Master/texmf-dist/bibtex/bst/datatool/databib.bst1248
-rw-r--r--Master/texmf-dist/doc/latex/datatool/README10
-rw-r--r--Master/texmf-dist/doc/latex/datatool/doc/CHANGES31
-rw-r--r--Master/texmf-dist/doc/latex/datatool/doc/datatool.pdfbin888470 -> 1180800 bytes
-rw-r--r--Master/texmf-dist/doc/latex/datatool/source/datatool.ins25
-rw-r--r--Master/texmf-dist/source/latex/datatool/datatool.dtx (renamed from Master/texmf-dist/doc/latex/datatool/source/datatool.dtx)8978
-rw-r--r--Master/texmf-dist/source/latex/datatool/datatool.ins40
-rw-r--r--Master/texmf-dist/tex/latex/datatool/databar.sty803
-rw-r--r--Master/texmf-dist/tex/latex/datatool/databib.sty1529
-rw-r--r--Master/texmf-dist/tex/latex/datatool/datapie.sty351
-rw-r--r--Master/texmf-dist/tex/latex/datatool/dataplot.sty917
-rw-r--r--Master/texmf-dist/tex/latex/datatool/datatool.sty3318
12 files changed, 16327 insertions, 923 deletions
diff --git a/Master/texmf-dist/bibtex/bst/datatool/databib.bst b/Master/texmf-dist/bibtex/bst/datatool/databib.bst
new file mode 100644
index 00000000000..c114335a843
--- /dev/null
+++ b/Master/texmf-dist/bibtex/bst/datatool/databib.bst
@@ -0,0 +1,1248 @@
+%%
+%% This is file `databib.bst',
+%% generated with the docstrip utility.
+%%
+%% The original source files were:
+%%
+%% datatool.dtx (with options: `databib.bst')
+%%
+%% datatool.dtx
+%% Copyright 2007 Nicola Talbot
+%%
+%% This work may be distributed and/or modified under the
+%% conditions of the LaTeX Project Public License, either version 1.3
+%% of this license of (at your option) any later version.
+%% The latest version of this license is in
+%% http://www.latex-project.org/lppl.txt
+%% and version 1.3 or later is part of all distributions of LaTeX
+%% version 2005/12/01 or later.
+%%
+%% This work has the LPPL maintenance status `maintained'.
+%%
+%% The Current Maintainer of this work is Nicola Talbot.
+%%
+%% This work consists of the files datatool.dtx and datatool.ins and the derived files datatool.sty, datapie.sty, dataplot.sty, databar.sty, databib.sty, databib.bst.
+%%
+
+ENTRY
+ { address
+ author
+ booktitle
+ chapter
+ edition
+ editor
+ howpublished
+ institution
+ journal
+ key
+ month
+ note
+ number
+ organization
+ pages
+ publisher
+ school
+ series
+ title
+ type
+ volume
+ year
+ isbn
+ doi
+ pubmed
+ url
+ abstract
+ }
+ {}
+ { label }
+
+INTEGERS { output.state before.all mid.sentence after.sentence after.block }
+
+FUNCTION {init.state.consts}
+{ #0 'before.all :=
+ #1 'mid.sentence :=
+ #2 'after.sentence :=
+ #3 'after.block :=
+}
+
+STRINGS { s t }
+
+FUNCTION {output.nonnull}
+{ 's :=
+ output.state before.all =
+ {
+ "%" * write$
+ newline$
+ }
+ { newline$
+ %add.period$ " " * write$
+ }
+ if$
+ % if$
+ % mid.sentence 'output.state :=
+ % }
+ %if$
+ s
+}
+
+FUNCTION {output}
+{ duplicate$ empty$
+ 'pop$
+ 'output.nonnull
+ if$
+}
+
+FUNCTION {output.check}
+{ 't :=
+ duplicate$ empty$
+ { pop$ "empty " t * " in " * cite$ * warning$ }
+ {
+ output.nonnull
+ }
+ if$
+}
+
+FUNCTION {output.bibitem}
+{ "\DTLnewbibrow" write$
+ newline$
+ "\DTLnewbibitem {CiteKey}{" write$
+ cite$ write$
+ "}%" write$
+ newline$
+ ""
+ before.all 'output.state :=
+}
+
+FUNCTION {fin.entry}
+{ "%" *
+ write$
+ newline$
+}
+
+FUNCTION {new.block}
+{ output.state before.all =
+ 'skip$
+ { after.block 'output.state := }
+ if$
+}
+
+FUNCTION {new.sentence}
+{ output.state after.block =
+ 'skip$
+ { output.state before.all =
+'skip$
+{ after.sentence 'output.state := }
+ if$
+ }
+ if$
+}
+
+FUNCTION {not}
+{ { #0 }
+ { #1 }
+ if$
+}
+
+FUNCTION {and}
+{ 'skip$
+ { pop$ #0 }
+ if$
+}
+
+FUNCTION {or}
+{ { pop$ #1 }
+ 'skip$
+ if$
+}
+
+FUNCTION {new.block.checka}
+{ empty$
+ 'skip$
+ 'new.block
+ if$
+}
+
+FUNCTION {new.block.checkb}
+{ empty$
+ swap$ empty$
+ and
+ 'skip$
+ 'new.block
+ if$
+}
+
+FUNCTION {new.sentence.checka}
+{ empty$
+ 'skip$
+ 'new.sentence
+ if$
+}
+
+FUNCTION {new.sentence.checkb}
+{ empty$
+ swap$ empty$
+ and
+ 'skip$
+ 'new.sentence
+ if$
+}
+
+FUNCTION {field.or.null}
+{ duplicate$ empty$
+ { pop$ "" }
+ 'skip$
+ if$
+}
+
+FUNCTION {emphasize}
+{ duplicate$ empty$
+ { pop$ "" }
+ { "{\em " swap$ * "}" * }
+ if$
+}
+
+FUNCTION {group}
+{ duplicate$ empty$
+ { pop$ "" }
+ { "{" swap$ * "}" * }
+ if$
+}
+
+INTEGERS { nameptr namesleft numnames }
+
+FUNCTION {format.names}
+{
+ 's :=
+ #1 'nameptr :=
+ s num.names$ 'numnames :=
+ numnames 'namesleft :=
+ { namesleft #0 > }
+ {
+ %s nameptr "{vv,}{ll,}{jj,}{ff}" format.name$ 't :=
+ "{" *
+ s nameptr "{vv}" format.name$ 't :=
+ t * "}" *
+ "{" *
+ s nameptr "{ll}" format.name$ 't :=
+ t * "}{" *
+ s nameptr "{jj}" format.name$ 't :=
+ t * "}" *
+ "{" *
+ s nameptr "{ff}" format.name$ 't :=
+ t * "}" *
+ s nameptr "" format.name$ 't :=
+ namesleft #1 >
+ { "," * }
+ { }
+ if$
+ nameptr #1 >
+{
+ t *
+}
+'t
+ if$
+ nameptr #1 + 'nameptr :=
+ namesleft #1 - 'namesleft :=
+ }
+ while$
+ "}" *
+}
+
+FUNCTION {format.authors}
+{
+ author empty$
+ { "" }
+ { author
+ "\DTLnewbibitem {Author}{" write$
+ format.names }
+ if$
+}
+
+FUNCTION {format.editors}
+{ editor empty$
+ { "" }
+ { editor
+ "\DTLnewbibitem {Editor}{" write$
+ format.names
+ }
+ if$
+}
+
+FUNCTION {format.title}
+{ title empty$
+ { "" }
+ {
+ "\DTLnewbibitem {Title}"
+ title "t" change.case$ group *
+ }
+ if$
+}
+
+FUNCTION {format.howpublished}
+{ howpublished empty$
+ { "" }
+ {
+ howpublished
+ "\DTLnewbibitem {HowPublished}" swap$ group *
+ }
+ if$
+}
+
+FUNCTION {format.organization}
+{ organization empty$
+ { "" }
+ {
+ organization
+ "\DTLnewbibitem {Organization}" swap$ group *
+ }
+ if$
+}
+
+FUNCTION {format.institution}
+{ institution empty$
+ { "" }
+ {
+ institution
+ "\DTLnewbibitem {Institution}" swap$ group *
+ }
+ if$
+}
+
+FUNCTION {format.key}
+{ key empty$
+ { "" }
+ {
+ key
+ "\DTLnewbibitem {Key}" swap$ group *
+ }
+ if$
+}
+
+FUNCTION {format.note}
+{ note empty$
+ { "" }
+ {
+ note
+ "\DTLnewbibitem {Note}" swap$ group *
+ }
+ if$
+}
+
+FUNCTION {format.isbn}
+{ isbn empty$
+ { "" }
+ {
+ isbn
+ "\DTLnewbibitem {ISBN}" swap$ group *
+ }
+ if$
+}
+
+FUNCTION {format.doi}
+{ doi empty$
+ { "" }
+ {
+ doi
+ "\DTLnewbibitem {DOI}" swap$ group *
+ }
+ if$
+}
+
+FUNCTION {format.pubmed}
+{ pubmed empty$
+ { "" }
+ {
+ pubmed
+ "\DTLnewbibitem {PubMed}" swap$ group *
+ }
+ if$
+}
+
+FUNCTION {format.abstract}
+{ abstract empty$
+ { "" }
+ {
+ abstract
+ "\DTLnewbibitem {Abstract}" swap$ group *
+ }
+ if$
+}
+
+FUNCTION {format.url}
+{ url empty$
+ { "" }
+ {
+ url
+ "\DTLnewbibitem {Url}" swap$ group *
+ }
+ if$
+}
+
+FUNCTION {format.address}
+{ address empty$
+ { "" }
+ {
+ address
+ "\DTLnewbibitem {Address}" swap$ group *
+ }
+ if$
+}
+
+FUNCTION {format.school}
+{ school empty$
+ { "" }
+ {
+ school
+ "\DTLnewbibitem {School}" swap$ group *
+ }
+ if$
+}
+
+FUNCTION {format.publisher}
+{ publisher empty$
+ { "" }
+ {
+ publisher
+ "\DTLnewbibitem {Publisher}" swap$ group *
+ }
+ if$
+}
+
+FUNCTION {n.dashify}
+{ 't :=
+ ""
+ { t empty$ not }
+ { t #1 #1 substring$ "-" =
+{ t #1 #2 substring$ "--" = not
+ { "--" *
+ t #2 global.max$ substring$ 't :=
+ }
+ { { t #1 #1 substring$ "-" = }
+{ "-" *
+ t #2 global.max$ substring$ 't :=
+}
+ while$
+ }
+ if$
+}
+{ t #1 #1 substring$ *
+ t #2 global.max$ substring$ 't :=
+}
+ if$
+ }
+ while$
+}
+
+FUNCTION {format.date}
+{ year empty$
+ { month empty$
+{ "" }
+{ "there's a month but no year in " cite$ * warning$
+ "\DTLnewbibitem {Month}" *
+ month group
+}
+ if$
+ }
+ { month empty$
+{ }
+{ "\DTLnewbibitem {Month}{" * month * "}" * }
+ if$
+ "\DTLnewbibitem {Year}{" * year * "}"
+ }
+ if$
+}
+
+FUNCTION {format.btitle}
+{ title
+ "\DTLnewbibitem {Title}{" swap$ *
+ "}" *
+}
+
+FUNCTION {tie.or.space.connect}
+{ duplicate$ text.length$ #3 <
+ { "~" }
+ { " " }
+ if$
+ swap$ * *
+}
+
+FUNCTION {either.or.check}
+{ empty$
+ 'pop$
+ { "can't use both " swap$ * " fields in " * cite$ * warning$ }
+ if$
+}
+
+FUNCTION {format.bvolume}
+{ volume empty$
+ { "" }
+ {
+ "\DTLnewbibitem {Volume}{" volume * "}" *
+ series empty$
+'skip$
+{
+ "\DTLnewbibitem {Series}" * series group *
+ }
+ if$
+ "volume and number" number either.or.check
+ }
+ if$
+}
+
+FUNCTION {format.number.series}
+{ volume empty$
+ { number empty$
+{
+ %series field.or.null group
+ series empty$
+ { "" }
+ { "\DTLnewbibitem {Series}" * series group }
+ if$
+ }
+{
+ "\DTLnewbibitem {Number}" number group *
+ series empty$
+ { "there's a number but no series in " cite$ * warning$ }
+ { "\DTLnewbibitem {Series}{" * series * "}" * }
+ if$
+}
+ if$
+ }
+ { "" }
+ if$
+}
+
+FUNCTION {format.edition}
+{ edition empty$
+ { "" }
+ {
+ "\DTLnewbibitem {Edition}"
+ edition "l" change.case$ group *
+ }
+ if$
+}
+
+INTEGERS { multiresult }
+
+FUNCTION {multi.page.check}
+{ 't :=
+ #0 'multiresult :=
+ { multiresult not
+ t empty$ not
+ and
+ }
+ { t #1 #1 substring$
+ duplicate$ "-" =
+ swap$ duplicate$ "," =
+ swap$ "+" =
+ or or
+{ #1 'multiresult := }
+{ t #2 global.max$ substring$ 't := }
+ if$
+ }
+ while$
+ multiresult
+}
+
+FUNCTION {format.pages}
+{ pages empty$
+ { "" }
+ { pages multi.page.check
+{ "\DTLnewbibitem {Pages}" pages n.dashify
+ group * }
+{ "\DTLnewbibitem {Pages}" pages
+ group *}
+ if$
+ }
+ if$
+}
+
+FUNCTION {format.vol.num.pages}
+{
+ volume empty$
+ { "" }
+ {
+ "\DTLnewbibitem {Volume}{" volume * "}" *
+ }
+ if$
+ number empty$
+ 'skip$
+ { "\DTLnewbibitem {Number}{" number * "}\relax " * *
+ volume empty$
+{ "there's a number but no volume in " cite$ * warning$ }
+'skip$
+ if$
+ }
+ if$
+ pages empty$
+ 'skip$
+ { duplicate$ empty$
+{ pop$ format.pages }
+{ "\DTLnewbibitem {Pages}" * pages n.dashify group * }
+ if$
+ }
+ if$
+}
+
+FUNCTION {format.chapter.pages}
+{ chapter empty$
+ 'format.pages
+ { type empty$
+{ "\DTLnewbibitem {Type}{chapter}" }
+{ "\DTLnewbibitem {Type}" type "l" change.case$ group *}
+ if$
+ "\DTLnewbibitem {Chapter}{" * chapter * "}" *
+ pages empty$
+'skip$
+{ format.pages * }
+ if$
+ }
+ if$
+}
+
+FUNCTION {format.in.ed.booktitle}
+{ booktitle empty$
+ { "" }
+ {
+ "\DTLnewbibitem {BookTitle}" booktitle group *
+ editor empty$
+ {}
+ {
+ "\DTLnewbibitem {Editor}{" *
+ editor format.names *
+ }
+ if$
+ }
+ if$
+}
+
+FUNCTION {empty.misc.check}
+{ author empty$ title empty$ howpublished empty$
+ month empty$ year empty$ note empty$
+ and and and and and
+ { "all relevant fields are empty in " cite$ * warning$ }
+ 'skip$
+ if$
+}
+
+FUNCTION {format.thesis.type}
+{ type empty$
+ 'skip$
+ { pop$
+ type "t" change.case$
+ "\DTLnewbibitem {Type}" swap$ group *
+ }
+ if$
+}
+
+FUNCTION {format.tr.number}
+{
+ type empty$
+ { "\techreportname " }
+ 'type
+ if$
+ number empty$
+ { "t" change.case$ "\DTLnewbibitem {Type}" swap$ group *}
+ { "\DTLnewbibitem {Type}" swap$ group *
+ "\DTLnewbibitem {Number}" *
+ number group * }
+ if$
+}
+
+FUNCTION {format.article.crossref}
+{ key empty$
+ { journal empty$
+{ "need key or journal for " cite$ * " to crossref " * crossref *
+ warning$
+ ""
+}
+{
+ "\DTLnewbibitem {Journal}" journal group *
+ }
+ if$
+ }
+ {
+ ""
+ }
+ if$
+ "\DTLnewbibitem {CrossRef}{" * crossref * "}" *
+}
+
+FUNCTION {format.crossref.editor}
+{ format.editors
+}
+
+FUNCTION {format.book.crossref}
+{ volume empty$
+ { "empty volume in " cite$ * "'s crossref of " * crossref * warning$
+ }
+ {
+ "\DTLnewbibitem {Volume}"
+ volume group *
+ }
+ if$
+ editor empty$
+ editor field.or.null author field.or.null =
+ or
+ { key empty$
+{ series empty$
+ { "need editor, key, or series for " cite$ * " to crossref " *
+ crossref * warning$
+ "" *
+ }
+ {
+ "\DTLnewbibitem {Series}{" * series *
+ "}" *
+ }
+ if$
+}
+{ ""
+ }
+ if$
+ }
+ {
+ format.crossref.editor *
+ }
+ if$
+ "\DTLnewbibitem {CrossRef}{" * crossref * "}" *
+}
+
+FUNCTION {format.incoll.inproc.crossref}
+{ editor empty$
+ editor field.or.null author field.or.null =
+ or
+ { key empty$
+{ booktitle empty$
+ { "need editor, key, or booktitle for " cite$ * " to crossref " *
+ crossref * warning$
+ ""
+ }
+ { "\DTLnewbibitem {BookTitle}{" booktitle * "}" * }
+ if$
+}
+{ "" }
+ if$
+ }
+ {
+ "\DTLnewbibitem {Editor}{" *
+ editor format.names
+ }
+ if$
+ "\DTLnewbibitem {CrossRef}{" * crossref * "}" *
+}
+
+FUNCTION {article}
+{ output.bibitem
+ "\DTLnewbibitem {EntryType}{article}%" write$
+ newline$
+ format.authors "author"
+ output.check
+ format.title "title" output.check
+ new.block
+ crossref missing$
+ {
+ "\DTLnewbibitem {Journal}" *
+ journal group "journal" output.check
+ format.vol.num.pages output
+ format.date "year" output.check
+ }
+ { format.article.crossref output.nonnull
+ format.pages output
+ }
+ if$
+ new.block
+ format.key output
+ format.note output
+ format.isbn output
+ format.doi output
+ format.pubmed output
+ format.url output
+ format.abstract output
+ fin.entry
+}
+
+FUNCTION {book}
+{ output.bibitem
+ "\DTLnewbibitem {EntryType}{book}%" write$
+ newline$
+ author empty$
+ { format.editors "author and editor" output.check }
+ { format.authors output.nonnull
+ crossref missing$
+{ "author and editor" editor either.or.check
+ }
+'skip$
+ if$
+ }
+ if$
+ new.block
+ format.btitle "title" output.check
+ crossref missing$
+ { format.bvolume output
+ new.block
+ format.number.series output
+ %new.sentence
+ format.publisher "publisher" output.check
+ format.address output
+ }
+ { new.block
+ format.book.crossref output.nonnull
+ }
+ if$
+ format.edition output
+ format.date "year" output.check
+ new.block
+ format.key output
+ format.note output
+ format.isbn output
+ format.doi output
+ format.pubmed output
+ format.url output
+ format.abstract output
+ fin.entry
+}
+
+FUNCTION {booklet}
+{ output.bibitem
+ "\DTLnewbibitem {EntryType}{booklet}%" write$
+ newline$
+ format.authors output
+ new.block
+ format.title "title" output.check
+ howpublished address new.block.checkb
+ format.howpublished output
+ format.address output
+ format.date output
+ new.block
+ format.key output
+ format.note output
+ format.isbn output
+ format.doi output
+ format.pubmed output
+ format.url output
+ format.abstract output
+ fin.entry
+}
+
+FUNCTION {inbook}
+{ output.bibitem
+ "\DTLnewbibitem {EntryType}{inbook}%" write$
+ newline$
+ author empty$
+ { format.editors "author and editor" output.check }
+ { format.authors output.nonnull
+ crossref missing$
+{ "author and editor" editor either.or.check }
+'skip$
+ if$
+ }
+ if$
+ new.block
+ format.btitle "title" output.check
+ crossref missing$
+ { format.bvolume output
+ format.chapter.pages "chapter and pages" output.check
+ new.block
+ format.number.series output
+ new.sentence
+ format.publisher "publisher" output.check
+ format.address output
+ }
+ { format.chapter.pages "chapter and pages" output.check
+ new.block
+ format.book.crossref output.nonnull
+ }
+ if$
+ format.edition output
+ format.date "year" output.check
+ new.block
+ format.key output
+ format.note output
+ format.isbn output
+ format.doi output
+ format.pubmed output
+ format.url output
+ format.abstract output
+ fin.entry
+}
+
+FUNCTION {incollection}
+{ output.bibitem
+ "\DTLnewbibitem {EntryType}{incollection}%" write$
+ newline$
+ format.authors "author" output.check
+ format.title "title" output.check
+ crossref missing$
+ { format.in.ed.booktitle "booktitle" output.check
+ format.bvolume output
+ format.number.series output
+ format.chapter.pages output
+ new.sentence
+ format.publisher "publisher" output.check
+ format.address output
+ format.edition output
+ format.date "year" output.check
+ }
+ { format.incoll.inproc.crossref output.nonnull
+ format.chapter.pages output
+ }
+ if$
+ format.key output
+ format.note output
+ format.isbn output
+ format.doi output
+ format.pubmed output
+ format.url output
+ format.abstract output
+ fin.entry
+}
+
+FUNCTION {inproceedings}
+{ output.bibitem
+ "\DTLnewbibitem {EntryType}{inproceedings}%" write$
+ newline$
+ format.authors "author" output.check
+ format.title "title" output.check
+ crossref missing$
+ { format.in.ed.booktitle "booktitle" output.check
+ format.bvolume output
+ format.number.series output
+ format.pages output
+ address empty$
+{ %organization publisher new.sentence.checkb
+ format.organization write$
+ format.publisher output
+}
+{ format.address write$
+ new.sentence
+ format.organization output
+ format.publisher output
+}
+ if$
+ format.date "year" output.check
+ }
+ {
+ format.incoll.inproc.crossref output.nonnull
+ format.pages output
+ }
+ if$
+ format.key output
+ format.note output
+ format.isbn output
+ format.doi output
+ format.pubmed output
+ format.url output
+ format.abstract output
+ fin.entry
+}
+
+FUNCTION {conference} { inproceedings }
+
+FUNCTION {manual}
+{ output.bibitem
+ "\DTLnewbibitem {EntryType}{manual}%" write$
+ newline$
+ author empty$
+ { organization empty$
+'skip$
+{ format.organization output
+ format.address output
+}
+ if$
+ }
+ { format.authors output }
+ if$
+ new.block
+ format.btitle "title" output.check
+ author empty$
+ { organization empty$
+{ address new.block.checka
+ address output
+}
+'skip$
+ if$
+ }
+ { %organization address new.block.checkb
+ format.organization output
+ format.address output
+ }
+ if$
+ format.edition output
+ format.date output
+ new.block
+ format.key output
+ format.note output
+ format.isbn output
+ format.doi output
+ format.pubmed output
+ format.url output
+ format.abstract output
+ fin.entry
+}
+
+FUNCTION {mastersthesis}
+{ output.bibitem
+ "\DTLnewbibitem {EntryType}{mastersthesis}%" write$
+ newline$
+ format.authors "author" output.check
+ new.block
+ format.title "title" output.check
+ new.block
+ "\DTLnewbibitem {Type}{\mscthesisname }"
+ format.thesis.type output.nonnull
+ format.school "school" output.check
+ format.address output
+ format.date "year" output.check
+ new.block
+ format.key output
+ format.note output
+ format.isbn output
+ format.doi output
+ format.pubmed output
+ format.url output
+ format.abstract output
+ fin.entry
+}
+
+FUNCTION {misc}
+{ output.bibitem
+ "\DTLnewbibitem {EntryType}{misc}%" write$
+ newline$
+ format.authors output
+ title howpublished new.block.checkb
+ format.title output
+ %howpublished new.block.checka
+ format.howpublished output
+ format.date output
+ new.block
+ format.key output
+ format.note output
+ format.isbn output
+ format.doi output
+ format.pubmed output
+ format.url output
+ format.abstract output
+ fin.entry
+ empty.misc.check
+}
+
+FUNCTION {phdthesis}
+{ output.bibitem
+ "\DTLnewbibitem {EntryType}{phdthesis}%" write$
+ newline$
+ format.authors "author" output.check
+ new.block
+ format.btitle "title" output.check
+ new.block
+ "\DTLnewbibitem {Type}{\phdthesisname }"
+ format.thesis.type output.nonnull
+ format.school "school" output.check
+ format.address output
+ format.date "year" output.check
+ new.block
+ format.key output
+ format.note output
+ format.isbn output
+ format.doi output
+ format.pubmed output
+ format.url output
+ format.abstract output
+ fin.entry
+}
+
+FUNCTION {proceedings}
+{ output.bibitem
+ "\DTLnewbibitem {EntryType}{proceedings}%" write$
+ newline$
+ editor empty$
+ { format.organization output }
+ { format.editors output.nonnull }
+ if$
+ new.block
+ format.btitle "title" output.check
+ format.bvolume output
+ format.number.series output
+ address empty$
+ { editor empty$
+{ publisher new.sentence.checka }
+{ organization publisher new.sentence.checkb
+ format.organization output
+}
+ if$
+ format.publisher output
+ format.date "year" output.check
+ }
+ { format.address output
+ format.date "year" output.check
+ new.sentence
+ editor empty$
+'skip$
+{ format.organization output }
+ if$
+ format.publisher output
+ }
+ if$
+ new.block
+ format.key output
+ format.note output
+ format.isbn output
+ format.doi output
+ format.pubmed output
+ format.url output
+ format.abstract output
+ fin.entry
+}
+
+FUNCTION {techreport}
+{ output.bibitem
+ "\DTLnewbibitem {EntryType}{techreport}%" write$
+ newline$
+ format.authors "author" output.check
+ new.block
+ format.title "title" output.check
+ new.block
+ format.tr.number output.nonnull
+ format.institution "institution" output.check
+ format.address output
+ format.date "year" output.check
+ new.block
+ format.key output
+ format.note output
+ format.isbn output
+ format.doi output
+ format.pubmed output
+ format.url output
+ format.abstract output
+ fin.entry
+}
+
+FUNCTION {unpublished}
+{ output.bibitem
+ "\DTLnewbibitem {EntryType}{unpublished}%" write$
+ newline$
+ format.authors "author" output.check
+ new.block
+ format.title "title" output.check
+ new.block
+ format.key output
+ format.note output
+ format.isbn output
+ format.doi output
+ format.pubmed output
+ format.url output
+ format.abstract output
+ format.date output
+ fin.entry
+}
+
+FUNCTION {default.type} { misc }
+
+MACRO {jan} {"\DTLmonthname{01}"}
+
+MACRO {feb} {"\DTLmonthname{02}"}
+
+MACRO {mar} {"\DTLmonthname{03}"}
+
+MACRO {apr} {"\DTLmonthname{04}"}
+
+MACRO {may} {"\DTLmonthname{05}"}
+
+MACRO {jun} {"\DTLmonthname{06}"}
+
+MACRO {jul} {"\DTLmonthname{07}"}
+
+MACRO {aug} {"\DTLmonthname{08}"}
+
+MACRO {sep} {"\DTLmonthname{09}"}
+
+MACRO {oct} {"\DTLmonthname{10}"}
+
+MACRO {nov} {"\DTLmonthname{11}"}
+
+MACRO {dec} {"\DTLmonthname{12}"}
+
+MACRO {acmcs} {"\DTLacmcs "}
+
+MACRO {acta} {"\DTLacta "}
+
+MACRO {cacm} {"\DTLcacm "}
+
+MACRO {ibmjrd} {"\DTLibmjrd "}
+
+MACRO {ibmsj} {"\DTLibmsj "}
+
+MACRO {ieeese} {"\DTLieeese "}
+
+MACRO {ieeetc} {"\DTLieeetc "}
+
+MACRO {ieeetcad} {"\DTLieeetcad "}
+
+MACRO {ipl} {"\DTLipl "}
+
+MACRO {jacm} {"\DTLjacm "}
+
+MACRO {jcss} {"\DTLjcss "}
+
+MACRO {scp} {"\DTLscp "}
+
+MACRO {sicomp} {"\DTLsicomp "}
+
+MACRO {tocs} {"\DTLtocs "}
+
+MACRO {tods} {"\DTLtods "}
+
+MACRO {tog} {"\DTLtog "}
+
+MACRO {toms} {"\DTLtoms "}
+
+MACRO {toois} {"\DTLtoois "}
+
+MACRO {toplas} {"\DTLtoplas "}
+
+MACRO {tcs} {"\DTLtcs "}
+
+READ
+
+STRINGS { longest.label }
+
+INTEGERS { number.label longest.label.width }
+
+FUNCTION {initialize.longest.label}
+{ "" 'longest.label :=
+ #1 'number.label :=
+ #0 'longest.label.width :=
+}
+
+FUNCTION {longest.label.pass}
+{ number.label int.to.str$ 'label :=
+ number.label #1 + 'number.label :=
+ label width$ longest.label.width >
+ { label 'longest.label :=
+ label width$ 'longest.label.width :=
+ }
+ 'skip$
+ if$
+}
+
+EXECUTE {initialize.longest.label}
+
+ITERATE {longest.label.pass}
+
+FUNCTION {begin.bib}
+{ preamble$ empty$
+ 'skip$
+ { preamble$ write$ newline$ }
+ if$
+}
+
+EXECUTE {begin.bib}
+
+EXECUTE {init.state.consts}
+
+ITERATE {call.type$}
+
+FUNCTION {end.bib}
+{
+}
+
+EXECUTE {end.bib}
diff --git a/Master/texmf-dist/doc/latex/datatool/README b/Master/texmf-dist/doc/latex/datatool/README
index 34e1b34558a..581ed50375f 100644
--- a/Master/texmf-dist/doc/latex/datatool/README
+++ b/Master/texmf-dist/doc/latex/datatool/README
@@ -1,6 +1,6 @@
-LaTeX Bundle : datatool v1.0 (datatool.sty, datapie.sty, dataplot.sty, databar.sty)
+LaTeX Bundle : datatool v1.01 (datatool.sty, datapie.sty, dataplot.sty, databar.sty, databib.sty)
-Last Modified : 23 July 2007
+Last Modified : 17 Aug 2007
Author : Nicola Talbot
@@ -72,6 +72,11 @@ databar.sty:
Hooks provided to annotate chart.
+databib.sty:
+
+ Provides commands to convert a BibTeX database into a datatool
+ database.
+
*The datatool bundle replaces the csvtools bundle which is now obsolete.*
The datatool.sty package requires the following packages/files:
@@ -80,7 +85,6 @@ xkeyval
xfor
fp
substr
-compare.tex
The datapie.sty, dataplot.sty and databar.sty packages requires
the tikz/pgf package.
diff --git a/Master/texmf-dist/doc/latex/datatool/doc/CHANGES b/Master/texmf-dist/doc/latex/datatool/doc/CHANGES
index 11c7fa0086c..a898c349e78 100644
--- a/Master/texmf-dist/doc/latex/datatool/doc/CHANGES
+++ b/Master/texmf-dist/doc/latex/datatool/doc/CHANGES
@@ -1 +1,32 @@
+v1.01 (2007/08/17) :
+ * Added databib package.
+
+ * datatool.sty:
+
+ - Fixed bug in datatool caused when certain commands occur
+ in database entries or when the data type is tested.
+ - Fixed bug in \DTLsubstituteall (caused problems when certain
+ - commands occurred in string)
+ - Added \DTLsplitstring
+ - Added \DTLifSubString and \DTLisSubString
+ - Added \DTLifStartsWith and \DTLisPrefix
+ - Added case insensitive string tests
+ - \DTLinitials and \DTLstoreinitials now work with ~ and \space
+ - \DTLinitials and \DTLstoreinitials now use \DTLinitialhyphen
+ - Added \dtlcompare (no longer using compare.tex)
+ - Added \DTLgetvalueforkey
+ - Added \DTLgetrowforkey
+ - Added optional argument to \DTLsort
+ - Fixed bug causing expansion in \DTLsort
+ - Fixed bug in \DTLsdforall and \DTLvarianceforall
+ - Removed extraneous spaces in \DTLaddall, \DTLminall,
+ \DTLmaxall, \DTLmeanforall, \DTLsdforall and \DTLvarianceforall
+ - Fixed bug in \DTLiflastrow
+ - Fixed bug in \DTLremovecurrentrow
+
+ * Manual:
+ - added code that produces fig "Student Marks (with average scores".
+ - fixed typos in examples "Editing Database Rows" & "Mail Merging"
+ - added section on null values
+
v1.0 (2007/07/23) : Initial Release
diff --git a/Master/texmf-dist/doc/latex/datatool/doc/datatool.pdf b/Master/texmf-dist/doc/latex/datatool/doc/datatool.pdf
index 7a2784f1ee0..eb622488c8e 100644
--- a/Master/texmf-dist/doc/latex/datatool/doc/datatool.pdf
+++ b/Master/texmf-dist/doc/latex/datatool/doc/datatool.pdf
Binary files differ
diff --git a/Master/texmf-dist/doc/latex/datatool/source/datatool.ins b/Master/texmf-dist/doc/latex/datatool/source/datatool.ins
deleted file mode 100644
index 8966a25bcbe..00000000000
--- a/Master/texmf-dist/doc/latex/datatool/source/datatool.ins
+++ /dev/null
@@ -1,25 +0,0 @@
-% datatool.ins generated using makedtx version 0.93b 2007/7/23 22:53
-\input docstrip
-
-\preamble
-Copyright (C) 2007 Nicola Talbot, all rights reserved.
-If you modify this file, you must change its name first.
-You are NOT ALLOWED to distribute this file alone. You are NOT
-ALLOWED to take money for the distribution or use of either this
-file or a changed version, except for a nominal charge for copying
-etc.
-\endpreamble
-
-\askforoverwritefalse
-
-\generate{\file{datapie.sty}{\usepreamble\defaultpreamble
-\usepostamble\defaultpostamble\from{datatool.dtx}{datapie.sty,package}}
-\file{dataplot.sty}{\usepreamble\defaultpreamble
-\usepostamble\defaultpostamble\from{datatool.dtx}{dataplot.sty,package}}
-\file{datatool.sty}{\usepreamble\defaultpreamble
-\usepostamble\defaultpostamble\from{datatool.dtx}{datatool.sty,package}}
-\file{databar.sty}{\usepreamble\defaultpreamble
-\usepostamble\defaultpostamble\from{datatool.dtx}{databar.sty,package}}
-}
-
-\endbatchfile
diff --git a/Master/texmf-dist/doc/latex/datatool/source/datatool.dtx b/Master/texmf-dist/source/latex/datatool/datatool.dtx
index a7363848b5a..f2afe8ec4b3 100644
--- a/Master/texmf-dist/doc/latex/datatool/source/datatool.dtx
+++ b/Master/texmf-dist/source/latex/datatool/datatool.dtx
@@ -1,16 +1,21 @@
%\iffalse
-% datatool.dtx generated using makedtx version 0.93b (c) Nicola Talbot
+% datatool.dtx generated using makedtx version 0.94b (c) Nicola Talbot
% Command line args:
+% -macrocode "databib.bst"
% -src "datatool.sty=>datatool.sty"
% -src "datapie.sty=>datapie.sty"
% -src "dataplot.sty=>dataplot.sty"
% -src "databar.sty=>databar.sty"
-% -doc "manual.tex"
+% -src "databib.sty=>databib.sty"
+% -src "databib.bst=>databib.bst"
% -author "Nicola Talbot"
-% -codetitle "datatool.sty"
% -dir "source"
+% -setambles ".*\.bst=>\nopreamble\usepreamble\defaultpreamble\nopostamble"
+% -comment "databib.bst"
+% -doc "manual.tex"
+% -codetitle "datatool.sty"
% datatool
-% Created on 2007/7/23 22:53
+% Created on 2007/8/19 14:27
%\fi
%\iffalse
%<*package>
@@ -39,9 +44,8 @@
%<*driver>
\documentclass[a4paper]{ltxdoc}
\usepackage{ifthen}
-\usepackage{alltt}
\usepackage[verbose=false]{datatool}
-\usepackage{datapie,databar}
+\usepackage{datapie,databar,databib}
\usepackage{textcomp}
\usepackage{graphicx}
\usepackage{colortbl}
@@ -73,11 +77,11 @@
\makeatother
\RecordChanges
\PageIndex
-\CheckSum{8992}
-\CodelineNumbered
+\CheckSum{13202}
\newcommand*{\sty}[1]{\textsf{#1}}
\newcommand*{\env}[1]{\textsf{#1}}
+\newcommand*{\ext}[1]{\texttt{#1}}
\definecolor{defbackground}{rgb}{0.8,1,1}
\makeatletter
@@ -95,17 +99,34 @@
\newcommand*{\ics}[1]{\cs{#1}\SpecialMainIndex{#1}}
\newsavebox\defsbox
+\newlength\defwidth
\newenvironment{definition}{%
+\setlength{\fboxsep}{4pt}\setlength{\fboxrule}{1.25pt}%
\begin{lrbox}{\defsbox}%
-\begin{minipage}{\linewidth}
+\setlength\defwidth\linewidth
+\addtolength\defwidth{-2\fboxrule}%
+\addtolength\defwidth{-2\fboxsep}%
+\begin{minipage}{\defwidth}\flushleft
}{%
\end{minipage}
\end{lrbox}%
\vskip10pt
\noindent
-{\setlength{\fboxsep}{4pt}\setlength{\fboxrule}{1.25pt}%
\fcolorbox{black}{defbackground}{\usebox\defsbox}%
-}\vskip10pt
+\vskip10pt
+}
+
+\newlength\tmplength
+\newcommand{\importantpar}{\relax
+\settowidth{\hangindent}{\bfseries\Huge$\bigtriangleup$\space}\relax
+\settoheight{\tmplength}{\bfseries\Huge$\bigtriangleup$}\relax
+\addtolength{\tmplength}{-0.5\baselineskip}\relax
+\hskip-\hangindent
+\smash{\raisebox{-\tmplength}{\bfseries
+\raisebox{3pt}{\large!}$\!$\makebox[0pt]{\Huge$\bigtriangleup$}\relax
+}}\relax
+\hskip0.5\hangindent
+\hangafter=-2\relax
}
\newcommand*{\pkgopt}[2][datatool]{\textsf{#2}\index
@@ -126,6 +147,16 @@
\@starttoc{loe}}
\makeatother
+ %bibliography database
+\DTLnewdb{docbib}
+\DTLnewrow{docbib}
+\DTLnewdbentry{docbib}{CiteKey}{Goossens}
+\DTLnewdbentry{docbib}{EntryType}{book}
+\DTLnewdbentry{docbib}{Author}{{}{Goossens}{}{Michel},{}{Mittelbach}{}{Frank},{}{Samarin}{}{Alexander}}
+\DTLnewdbentry{docbib}{Title}{The \LaTeX\ Companion}
+\DTLnewdbentry{docbib}{Publisher}{Addison-Wesley}
+\DTLnewdbentry{docbib}{Year}{1994}
+
\begin{document}
\DocInput{datatool.dtx}
@@ -135,7 +166,7 @@
%\MakeShortVerb{"}
%\DeleteShortVerb{\|}
%
-% \title{datatool v 1.0: Databases and data manipulation}
+% \title{datatool v 1.01: Databases and data manipulation}
% \author{Nicola L.C. Talbot\\[10pt]
%School of Computing Sciences\\
%University of East Anglia\\
@@ -143,17 +174,19 @@
%NR4 7TJ. United Kingdom.\\
%\url{http://theoval.cmp.uea.ac.uk/~nlct/}}
%
-% \date{23rd July 2007}
+% \date{17th August 2007}
% \maketitle
%\tableofcontents
%\listofexamples
+%\listoffigures
+%\listoftables
%
% \section{Introduction}
%
% \changes{1.0}{2007 July 22}{Initial version}
%The \sty{datatool} bundle consists of the following
-%packages: \sty{datatool}, \sty{datapie}, \sty{dataplot} and
-%\sty{databar}.
+%packages: \sty{datatool}, \sty{datapie}, \sty{dataplot},
+%\sty{databar} and \sty{databib}.
%
%The \sty{datatool} package can be used to:
%\begin{itemize}
@@ -162,7 +195,7 @@
%ascending or descending.)
%\item Perform repetitive operations on each row of a database
%(e.g.\ mail merging.) Conditions may be imposed to exclude rows.
-%\item Determine where an argument is an integer, a real number,
+%\item Determine whether an argument is an integer, a real number,
%currency or a string. (Scientific notation is currently not
%supported.) Locale dependent number settings are supported (such
%as a comma as a decimal character and a full stop as a number
@@ -173,6 +206,8 @@
%\item Names can be converted to initials.
%\item Strings can be tested to determine if they are all
%upper or lower case.
+%\item String comparisons (both case sensitive and case insensitive)
+%can be performed.
%\end{itemize}
%
%The \sty{datapie} package can be used to convert a database into
@@ -204,8 +239,8 @@
%a two dimensional plot using markers and/or lines. Three dimensional
%plots are currently not supported.
%
-%\textbf{This package replaces the \sty{csvtools} package which is now
-%obsolete.}
+%The \sty{databib} package can be used to convert a \BibTeX\ database
+%into a \sty{datatool} database.
%
%\section{Data Types}
%\label{sec:datatypes}
@@ -488,6 +523,92 @@
%produces:
%\DTLifcasedatatype{1,000}{string}{integer}{real}{currency}.
%
+%\DescribeMacro{\DTLifnumeq}
+%\begin{definition}
+%\cs{DTLifnumeq}\marg{num1}\marg{num2}\marg{true part}\marg{false part}
+%\end{definition}
+%If \meta{num1} is equal to \meta{num2}, then do \meta{true part},
+%otherwise do \meta{false part}. Note that both \meta{num1} and
+%\meta{num2} must be numerical (either integers, real numbers or
+%currency.) The currency symbol is ignored when determining
+%equality. For example
+%\begin{verbatim}
+%\DTLifnumeq{\pounds10.50}{10.5}{true}{false}
+%\end{verbatim}
+%produces:
+%\DTLifnumeq{\pounds10.50}{10.5}{true}{false}, since they are
+%considered to be numerically equivalent. Likewise:
+%\begin{verbatim}
+%\DTLifnumeq{\pounds10.50}{\$10.50}{true}{false}
+%\end{verbatim}
+%produces:
+%\DTLifnumeq{\pounds10.50}{\$10.50}{true}{false}.
+%
+%\DescribeMacro{\DTLifstringeq}
+%\begin{definition}
+%\cs{DTLifstringeq}\marg{string1}\marg{string2}\marg{true part}\marg{false part}
+%\end{definition}
+%\DescribeMacro{\DTLifstringeq*}
+%\begin{definition}
+%\cs{DTLifstringeq*}\marg{string1}\marg{string2}\marg{true part}\marg{false part}
+%\end{definition}
+%If \meta{string1} and \meta{string2} are the same, then do
+%\meta{true part}, otherwise do \meta{false part}. The starred
+%version ignores the case, the unstarred version is case
+%sensitive. Both
+%\meta{string1} and \meta{string2} are considered to be strings,
+%so for example:
+%\begin{verbatim}
+%\DTLifstringeq{10.50}{10.5}{true}{false}
+%\end{verbatim}
+%produces:
+%\DTLifstringeq{10.50}{10.5}{true}{false}.
+%
+%Note that
+%\begin{verbatim}
+%\DTLifstringeq{Text}{text}{true}{false}
+%\end{verbatim}
+%produces:
+%\DTLifstringeq{Text}{text}{true}{false}, whereas
+%\begin{verbatim}
+%\DTLifstringeq*{Text}{text}{true}{false}
+%\end{verbatim}
+%produces:
+%\DTLifstringeq*{Text}{text}{true}{false}, however it should also be
+%noted that many commands will be ignored, so:
+%\begin{verbatim}
+%\DTLifstringeq{\uppercase{t}ext}{text}{true}{false}
+%\end{verbatim}
+%produces:
+%\DTLifstringeq{\uppercase{t}ext}{text}{true}{false}.
+%
+%Spaces are considered to be equivalent to \cs{space} and "~". For
+%example:
+%\begin{verbatim}
+%\DTLifstringeq{an apple}{an~apple}{true}{false}
+%\end{verbatim}
+%produces:
+%\DTLifstringeq{an apple}{an~apple}{true}{false}. Consecutive spaces
+%are treated as the same, for example:
+%\begin{verbatim}
+%\DTLifstringeq{an apple}{an apple}{true}{false}
+%\end{verbatim}
+%produces:
+%\DTLifstringeq{an apple}{an apple}{true}{false}.
+%
+%\DescribeMacro{\DTLifeq}
+%\begin{definition}
+%\cs{DTLifeq}\marg{arg1}\marg{arg2}\marg{true part}\marg{false part}
+%\end{definition}
+%\DescribeMacro{\DTLifeq*}
+%\begin{definition}
+%\cs{DTLifeq*}\marg{arg1}\marg{arg2}\marg{true part}\marg{false part}
+%\end{definition}
+%If both \meta{arg1} and \meta{arg2} are numerical, then this is
+%equivalent to \cs{DTLifnumeq}, otherwise it is equivalent to
+%\cs{DTLifstringeq} (when using \cs{DTLifeq}) or \cs{DTLifstringeq*}
+%(when using \cs{DTLifeq*}).
+%
%\DescribeMacro{\DTLifnumlt}
%\begin{definition}
%\cs{DTLifnumlt}\marg{num1}\marg{num2}\marg{true part}\marg{false part}
@@ -499,10 +620,18 @@
%
%\DescribeMacro{\DTLifstringlt}
%\begin{definition}
-%\cs{DTLifstringlt}\marg{string1}\marg{string2}\marg{true part}\marg{false part}
+%\cs{DTLifstringlt}\marg{string1}\marg{string2}\marg{true
+%part}\marg{false part}
+%\end{definition}
+%\DescribeMacro{\DTLifstringlt*}
+%\begin{definition}
+%\cs{DTLifstringlt*}\marg{string1}\marg{string2}\marg{true
+%part}\marg{false part}
%\end{definition}
%If \meta{string1} is alphabetically less than \meta{string2}, then do
-%\meta{true part}, otherwise do \meta{false part}.
+%\meta{true part}, otherwise do \meta{false part}. The starred
+%version ignores the case, the unstarred version is case
+%sensitive.
%For example:
%\begin{verbatim}
%\DTLifstringlt{aardvark}{zebra}{less}{not less}
@@ -519,13 +648,31 @@
%\DTLifstringlt{2}{10}{less}{not less}, since the string "2"
%comes after the string "10" when arranged alphabetically.
%
+%The case sensitive (unstarred) version considers uppercase characters
+%to be less than lowercase characters, so
+%\begin{verbatim}
+%\DTLifstringlt{B}{a}{less}{not less}
+%\end{verbatim}
+%produces:
+%\DTLifstringlt{B}{a}{less}{not less}, whereas
+%\begin{verbatim}
+%\DTLifstringlt*{B}{a}{less}{not less}
+%\end{verbatim}
+%produces:
+%\DTLifstringlt*{B}{a}{less}{not less}.
+%
%\DescribeMacro{\DTLiflt}
%\begin{definition}
%\cs{DTLiflt}\marg{arg1}\marg{arg2}\marg{true part}\marg{false part}
%\end{definition}
+%\DescribeMacro{\DTLiflt*}
+%\begin{definition}
+%\cs{DTLiflt*}\marg{arg1}\marg{arg2}\marg{true part}\marg{false part}
+%\end{definition}
%If \meta{arg1} and \meta{arg2} are both numerical, then this
%is equivalent to \cs{DTLifnumlt}, otherwise it is equivalent
-%to \cs{DTLstringlt}.
+%to \cs{DTLstringlt} (when using \cs{DTLiflt}) or
+%\cs{DTLstringlt*} (when using \cs{DTLiflt*}).
%
%\DescribeMacro{\DTLifnumgt}
%\begin{definition}
@@ -538,10 +685,18 @@
%
%\DescribeMacro{\DTLifstringgt}
%\begin{definition}
-%\cs{DTLifstringgt}\marg{string1}\marg{string2}\marg{true part}\marg{false part}
+%\cs{DTLifstringgt}\marg{string1}\marg{string2}\marg{true
+%part}\marg{false part}
+%\end{definition}
+%\DescribeMacro{\DTLifstringgt*}
+%\begin{definition}
+%\cs{DTLifstringgt*}\marg{string1}\marg{string2}\marg{true
+%part}\marg{false part}
%\end{definition}
%If \meta{string1} is alphabetically greater than \meta{string2}, then
-%do \meta{true part}, otherwise do \meta{false part}. For example:
+%do \meta{true part}, otherwise do \meta{false part}. The
+%starred version ignores the case, the unstarred version is
+%case sensitive. For example:
%\begin{verbatim}
%\DTLifstringgt{aardvark}{zebra}{greater}{not greater}
%\end{verbatim}
@@ -557,63 +712,32 @@
%\DTLifstringgt{2}{10}{greater}{not greater}, since the string "2"
%comes after the string "10" when arranged alphabetically.
%
-%\DescribeMacro{\DTLifgt}
-%\begin{definition}
-%\cs{DTLifgt}\marg{arg1}\marg{arg2}\marg{true part}\marg{false part}
-%\end{definition}
-%If \meta{arg1} and \meta{arg2} are both numerical, then this
-%is equivalent to \cs{DTLifnumgt}, otherwise it is equivalent
-%to \cs{DTLstringgt}.
-%
-%\DescribeMacro{\DTLifnumeq}
-%\begin{definition}
-%\cs{DTLifnumeq}\marg{num1}\marg{num2}\marg{true part}\marg{false part}
-%\end{definition}
-%If \meta{num1} is equal to \meta{num2}, then do \meta{true part},
-%otherwise do \meta{false part}. Note that both \meta{num1} and
-%\meta{num2} must be numerical (either integers, real numbers or
-%currency.) The currency symbol is ignored when determining
-%equality. For example
+%As with \cs{DTLifstringlt}, uppercase characters are considered
+%to be less than lower case characters when performing a
+%case sensitive comparison so:
%\begin{verbatim}
-%\DTLifnumeq{\pounds10.50}{10.5}{true}{false}
+%\DTLifstringgt{B}{a}{greater}{not greater}
%\end{verbatim}
%produces:
-%\DTLifnumeq{\pounds10.50}{10.5}{true}{false}, since they are
-%considered to be numerically equivalent. Likewise:
+%\DTLifstringgt{B}{a}{greater}{not greater}, whereas
%\begin{verbatim}
-%\DTLifnumeq{\pounds10.50}{\$10.50}{true}{false}
+%\DTLifstringgt*{B}{a}{greater}{not greater}
%\end{verbatim}
%produces:
-%\DTLifnumeq{\pounds10.50}{\$10.50}{true}{false}.
+%\DTLifstringgt*{B}{a}{greater}{not greater}.
%
-%\DescribeMacro{\DTLifstringeq}
+%\DescribeMacro{\DTLifgt}
%\begin{definition}
-%\cs{DTLifstringeq}\marg{string1}\marg{string2}\marg{true part}\marg{false part}
+%\cs{DTLifgt}\marg{arg1}\marg{arg2}\marg{true part}\marg{false part}
%\end{definition}
-%If \meta{string1} and \meta{string2} are identical, then do
-%\meta{true part}, otherwise do \meta{false part}. Again, both
-%\meta{string1} and \meta{string2} are considered to be strings,
-%so for example:
-%\begin{verbatim}
-%\DTLifstringeq{10.50}{10.5}{true}{false}
-%\end{verbatim}
-%produces:
-%\DTLifstringeq{10.50}{10.5}{true}{false}.
-%
-%Note that the comparison is case sensitive, so for example:
-%\begin{verbatim}
-%\DTLifstringeq{Text}{text}{true}{false}
-%\end{verbatim}
-%produces:
-%\DTLifstringeq{Text}{text}{true}{false}.
-%
-%\DescribeMacro{\DTLifeq}
+%\DescribeMacro{\DTLifgt*}
%\begin{definition}
-%\cs{DTLifeq}\marg{arg1}\marg{arg2}\marg{true part}\marg{false part}
+%\cs{DTLifgt*}\marg{arg1}\marg{arg2}\marg{true part}\marg{false part}
%\end{definition}
-%If both \meta{arg1} and \meta{arg2} are numerical, then this is
-%equivalent to \cs{DTLifnumeq}, otherwise it is equivalent to
-%\cs{DTLifstringeq}.
+%If \meta{arg1} and \meta{arg2} are both numerical, then this
+%is equivalent to \cs{DTLifnumgt}, otherwise it is equivalent
+%to \cs{DTLstringgt} (when using \cs{DTLifgt}) or
+%\cs{DTLstringgt*} (when using \cs{DTLifgt*}).
%
%\DescribeMacro{\DTLifnumclosedbetween}
%\begin{definition}
@@ -640,17 +764,28 @@
%\begin{definition}
%\cs{DTLifstringclosedbetween}\marg{string}\marg{min}\marg{max}\marg{true part}\marg{false part}
%\end{definition}
+%\DescribeMacro{\DTLifstringclosedbetween*}
+%\begin{definition}
+%\cs{DTLifstringclosedbetween*}\marg{string}\marg{min}\marg{max}\marg{true part}\marg{false part}
+%\end{definition}
%This determines if \meta{string} is between \meta{min} and
%\meta{max} in the alphabetical sense, or is equal to either
-%\meta{min} or \meta{max}.
+%\meta{min} or \meta{max}. The starred version ignores the case,
+%the unstarred version is case sensitive.
%
%\DescribeMacro{\DTLifclosedbetween}
%\begin{definition}
%\cs{DTLifclosedbetween}\marg{arg}\marg{min}\marg{max}\marg{true part}\marg{false part}
%\end{definition}
+%\DescribeMacro{\DTLifclosedbetween*}
+%\begin{definition}
+%\cs{DTLifclosedbetween*}\marg{arg}\marg{min}\marg{max}\marg{true part}\marg{false part}
+%\end{definition}
%If \meta{arg}, \meta{min} and \meta{max} are numerical, then this is
%equivalent to \cs{DTLifnumclosedbetween}, otherwise it is equivalent to
-%\cs{DTLifstringclosedbetween}.
+%\cs{DTLifstringclosedbetween} (when using \cs{DTLifclosedbetween})
+%or
+%\cs{DTLifstringclosedbetween*} (when using \cs{DTLifclosedbetween*}).
%
%\DescribeMacro{\DTLifnumopenbetween}
%\begin{definition}
@@ -662,32 +797,42 @@
%currency.) Again, the currency symbol is ignored when determining
%equality. For example:
%\begin{verbatim}
-%\DTLifnumclosedbetween{5.4}{5}{7}{inside}{outside}
+%\DTLifnumopenbetween{5.4}{5}{7}{inside}{outside}
%\end{verbatim}
%produces:
-%\DTLifnumclosedbetween{5.4}{5}{7}{inside}{outside}.
+%\DTLifnumopenbetween{5.4}{5}{7}{inside}{outside}.
%Note that end points are not included. For example:
%\begin{verbatim}
-%\DTLifnumclosedbetween{5}{5}{7}{inside}{outside}
+%\DTLifnumopenbetween{5}{5}{7}{inside}{outside}
%\end{verbatim}
%produces:
-%\DTLifnumclosedbetween{5}{5}{7}{inside}{outside}.
+%\DTLifnumopenbetween{5}{5}{7}{inside}{outside}.
%
-%\DescribeMacro{\DTLifstringclosedbetween}
+%\DescribeMacro{\DTLifstringopenbetween}
%\begin{definition}
-%\cs{DTLifstringclosedbetween}\marg{string}\marg{min}\marg{max}\marg{true part}\marg{false part}
+%\cs{DTLifstringopenbetween}\marg{string}\marg{min}\marg{max}\marg{true part}\marg{false part}
+%\end{definition}
+%\DescribeMacro{\DTLifstringopenbetween*}
+%\begin{definition}
+%\cs{DTLifstringopenbetween*}\marg{string}\marg{min}\marg{max}\marg{true part}\marg{false part}
%\end{definition}
%This determines if \meta{string} is between \meta{min} and
-%\meta{max} in the alphabetical sense, or is equal to either
-%\meta{min} or \meta{max}.
+%\meta{max} in the alphabetical sense.
+%The starred version ignores the case,
+%the unstarred version is case sensitive.
%
-%\DescribeMacro{\DTLifclosedbetween}
+%\DescribeMacro{\DTLifopenbetween}
%\begin{definition}
-%\cs{DTLifclosedbetween}\marg{arg}\marg{min}\marg{max}\marg{true part}\marg{false part}
+%\cs{DTLifopenbetween}\marg{arg}\marg{min}\marg{max}\marg{true part}\marg{false part}
+%\end{definition}
+%\DescribeMacro{\DTLifopenbetween*}
+%\begin{definition}
+%\cs{DTLifopenbetween*}\marg{arg}\marg{min}\marg{max}\marg{true part}\marg{false part}
%\end{definition}
%If \meta{arg}, \meta{min} and \meta{max} are numerical, then this is
-%equivalent to \cs{DTLifnumclosedbetween}, otherwise it is equivalent to
-%\cs{DTLifstringclosedbetween}.
+%equivalent to \cs{DTLifnumopenbetween}, otherwise it is equivalent to
+%\cs{DTLifstringopenbetween} (when using \cs{DTLifopenbetween})
+%\cs{DTLifstringopenbetween*} (when using \cs{DTLifopenbetween*}).
%
%\DescribeMacro{\DTLifFPclosedbetween}
%\begin{definition}
@@ -773,6 +918,75 @@
%produces:
%\DTLifAllLowerCase{man{\oe}uvre}{all lower}{not all lower}.
%
+%\DescribeMacro{\DTLifSubString}
+%\begin{definition}
+%\cs{DTLifSubString}\marg{string}\marg{substring}\marg{true
+%part}\marg{false part}
+%\end{definition}
+%This tests if \meta{substring} is a sub-string of \meta{string}.
+%This command performs a case sensitive match. For example:
+%\begin{verbatim}
+%\DTLifSubString{An apple}{app}{is substring}{isn't substring}
+%\end{verbatim}
+%produces:
+%\DTLifSubString{An apple}{app}{is substring}{isn't substring}.
+%Note that spaces are considered to be equivalent to \cs{space}
+%or "~", so
+%\begin{verbatim}
+%\DTLifSubString{An apple}{n~a}{is substring}{isn't substring}
+%\end{verbatim}
+%produces:
+%\DTLifSubString{An apple}{n~a}{is substring}{isn't substring},
+%but other commands are skipped, so
+%\begin{verbatim}
+%\DTLifSubString{An \uppercase{a}pple}{app}{is substring}{isn't
+%substring}
+%\end{verbatim}
+%produces:
+%\DTLifSubString{An \uppercase{a}pple}{app}{is substring}{isn't
+%substring}, since the \cs{uppercase} command is ignored. Note also
+%that grouping is ignored, so:
+%\begin{verbatim}
+%\DTLifSubString{An {ap}ple}{app}{is substring}{isn't substring}
+%\end{verbatim}
+%produces:
+%\DTLifSubString{An {ap}ple}{app}{is substring}{isn't substring}.
+%
+%\cs{DTLifSubString} is case sensitive, so:
+%\begin{verbatim}
+%\DTLifSubString{An Apple}{app}{is substring}{isn't substring}
+%\end{verbatim}
+%produces:
+%\DTLifSubString{An Apple}{app}{is substring}{isn't substring}.
+%
+%\DescribeMacro{\DTLifStartsWith}
+%\begin{definition}
+%\cs{DTLifStartsWith}\marg{string}\marg{substring}\marg{true
+%part}\marg{false part}
+%\end{definition}
+%This is like \cs{DTLifSubString}, except that \meta{substring} must
+%occur at the start of \meta{string}. This command performs a case
+%sensitive match. For example,
+%\begin{verbatim}
+%\DTLifStartsWith{An apple}{app}{prefix}{not a prefix}
+%\end{verbatim}
+%produces:
+%\DTLifStartsWith{An apple}{app}{prefix}{not a prefix}. All the
+%above remarks for \cs{DTLifSubString} also applies to
+%\cs{DTLifStartsWith}. For example:
+%\begin{verbatim}
+%\DTLifStartsWith{\uppercase{a}n apple}{an~}{prefix}{not a prefix}
+%\end{verbatim}
+%produces:
+%\DTLifStartsWith{\uppercase{a}n apple}{an~}{prefix}{not a prefix},
+%since \cs{uppercase} is ignored, and "~" is considered to be the
+%same as a space, whereas
+%\begin{verbatim}
+%\DTLifStartsWith{An apple}{an~}{prefix}{not a prefix}
+%\end{verbatim}
+%produces:
+%\DTLifStartsWith{An apple}{an~}{prefix}{not a prefix}.
+%
%\subsection{\texorpdfstring{\sty{ifthen}}{ifthen} conditionals}
%\label{sec:ifthen}
%
@@ -902,8 +1116,19 @@
%\end{definition}
%This checks if \meta{arg1} is less than \meta{arg2}. As with
%\cs{DTLiflt}, if \meta{arg1} and \meta{arg2} are numerical,
-%a numerical comparison is used, otherwise an alphabetical
-%comparison is used.
+%a numerical comparison is used, otherwise a case sensitive
+%alphabetical comparison is used. (Note that there is no starred
+%version of this command, but you can instead use \cs{DTLisilt}
+%to ignore the case.)
+%
+%\DescribeMacro{\DTLisilt}
+%\begin{definition}
+%\cs{DTLisilt}\marg{arg1}\marg{arg2}
+%\end{definition}
+%This checks if \meta{arg1} is less than \meta{arg2}. As with
+%\cs{DTLiflt*}, if \meta{arg1} and \meta{arg2} are numerical,
+%a numerical comparison is used, otherwise a case insensitive
+%alphabetical comparison is used.
%
%\DescribeMacro{\DTLisgt}
%\begin{definition}
@@ -911,8 +1136,19 @@
%\end{definition}
%This checks if \meta{arg1} is greater than \meta{arg2}. As with
%\cs{DTLifgt}, if \meta{arg1} and \meta{arg2} are numerical,
-%a numerical comparison is used, otherwise an alphabetical
-%comparison is used.
+%a numerical comparison is used, otherwise a case sensitive
+%alphabetical comparison is used. (Note that there is no starred
+%version of this command, instead use \cs{DTLisigt} to
+%ignore the case.)
+%
+%\DescribeMacro{\DTLisigt}
+%\begin{definition}
+%\cs{DTLisigt}\marg{arg1}\marg{arg2}
+%\end{definition}
+%This checks if \meta{arg1} is greater than \meta{arg2}. As with
+%\cs{DTLifgt*}, if \meta{arg1} and \meta{arg2} are numerical,
+%a numerical comparison is used, otherwise a case insensitive
+%alphabetical comparison is used.
%
%\DescribeMacro{\DTLiseq}
%\begin{definition}
@@ -920,8 +1156,18 @@
%\end{definition}
%This checks if \meta{arg1} is equal to \meta{arg2}. As with
%\cs{DTLifeq}, if \meta{arg1} and \meta{arg2} are numerical,
-%a numerical comparison is used, otherwise an alphabetical
-%comparison is used.
+%a numerical comparison is used, otherwise a case sensitive
+%alphabetical comparison is used. (Note that there is no starred
+%version of this command, instead use \cs{DTLisieq}.)
+%
+%\DescribeMacro{\DTLisieq}
+%\begin{definition}
+%\cs{DTLisieq}\marg{arg1}\marg{arg2}
+%\end{definition}
+%This checks if \meta{arg1} is equal to \meta{arg2}. As with
+%\cs{DTLifeq*}, if \meta{arg1} and \meta{arg2} are numerical,
+%a numerical comparison is used, otherwise a case insensitive
+%alphabetical comparison is used.
%
%\DescribeMacro{\DTLisclosedbetween}
%\begin{definition}
@@ -930,8 +1176,19 @@
%This checks if \meta{arg} lies between \meta{min} and
%\meta{max} (end points included.) As with
%\cs{DTLifclosedbetween}, if the arguments are numerical,
-%a numerical comparison is used, otherwise an alphabetical
-%comparison is used.
+%a numerical comparison is used, otherwise a case sensitive
+%alphabetical comparison is used. (Note that there is no starred
+%version of this command, instead use \cs{DTLisiclosedbetween}.)
+%
+%\DescribeMacro{\DTLisiclosedbetween}
+%\begin{definition}
+%\cs{DTLisiclosedbetween}\marg{arg}\marg{min}\marg{max}
+%\end{definition}
+%This checks if \meta{arg} lies between \meta{min} and
+%\meta{max} (end points included.) As with
+%\cs{DTLifclosedbetween*}, if the arguments are numerical,
+%a numerical comparison is used, otherwise a case insensitive
+%alphabetical comparison is used.
%
%\DescribeMacro{\DTLisopenbetween}
%\begin{definition}
@@ -940,8 +1197,19 @@
%This checks if \meta{arg} lies between \meta{min} and
%\meta{max} (end points excluded.) As with
%\cs{DTLifopenbetween}, if the arguments are numerical,
-%a numerical comparison is used, otherwise an alphabetical
-%comparison is used.
+%a numerical comparison is used, otherwise a case sensitive
+%alphabetical comparison is used. (Note that there is no starred
+%version of this command, instead use \cs{DTLisiopenbetween}.)
+%
+%\DescribeMacro{\DTLisiopenbetween}
+%\begin{definition}
+%\cs{DTLisiopenbetween}\marg{arg}\marg{min}\marg{max}
+%\end{definition}
+%This checks if \meta{arg} lies between \meta{min} and
+%\meta{max} (end points excluded.) As with
+%\cs{DTLifopenbetween*}, if the arguments are numerical,
+%a numerical comparison is used, otherwise a case insensitive
+%alphabetical comparison is used.
%
%\DescribeMacro{\DTLisFPlt}
%\begin{definition}
@@ -1001,6 +1269,24 @@
%numbers in standard fixed point format (i.e.\ no number group
%separators, no currency and a full stop as a decimal point.)
%
+%\DescribeMacro{\DTLisSubString}
+%\begin{definition}
+%\cs{DTLisSubString}\marg{string}\marg{substring}
+%\end{definition}
+%This checks if \meta{substring} is contained in \meta{string}.
+%The remarks about \cs{DTLifSubString} also apply to
+%\cs{DTLisSubString}. This command performs a case sensitive
+%match.
+%
+%\DescribeMacro{\DTLisPrefix}
+%\begin{definition}
+%\cs{DTLisPrefix}\marg{string}\marg{prefix}
+%\end{definition}
+%This checks if \meta{string} starts with \meta{prefix}.
+%The remarks about \cs{DTLifStartsWith} also apply to
+%\cs{DTLisPrefix}. This command performs a case sensitive
+%match.
+%
%\section{Fixed Point Arithmetic}
%\label{sec:fp}
%
@@ -1510,6 +1796,7 @@
%\meta{cmd} globally.
%
%\section{Strings}
+%\label{sec:strings}
%
%Strings are considered to be anything non-numerical. The
%\sty{datatool} package loads the \sty{substr} package, so
@@ -1517,6 +1804,71 @@
%if one string is contained in another string. In addition,
%the \sty{datatool} provides the following macros:
%
+%\DescribeMacro{\DTLsubstitute}
+%\begin{definition}
+%\cs{DTLsubstitute}\marg{cmd}\marg{original}\marg{replacement}
+%\end{definition}
+%This replaces the first occurrence of \meta{original} in
+%\meta{cmd} with \meta{replacement}. Note that \meta{cmd} must
+%be the name of a command. For example:
+%\begin{verbatim}
+%\def\mystr{abcdce}\DTLsubstitute{\mystr}{c}{z}\mystr
+%\end{verbatim}
+%produces:
+%\def\mystr{abcdce}\DTLsubstitute{\mystr}{c}{z}\mystr.
+%
+%\DescribeMacro{\DTLsubstituteall}
+%\begin{definition}
+%\cs{DTLsubstituteall}\marg{cmd}\marg{original}\marg{replacement}
+%\end{definition}
+%This replaces all occurrences of \meta{original} in
+%\meta{cmd} with \meta{replacement}, where again, \meta{cmd} must
+%be the name of a command. For example:
+%\begin{verbatim}
+%\def\mystr{abcdce}\DTLsubstituteall{\mystr}{c}{z}\mystr
+%\end{verbatim}
+%produces:
+%\def\mystr{abcdce}\DTLsubstituteall{\mystr}{c}{z}\mystr.
+%
+%\DescribeMacro{\DTLsplitstring}
+%\begin{definition}
+%\cs{DTLsplitstring}\marg{string}\marg{split text}\marg{before
+%cmd}\marg{after cmd}
+%\end{definition}
+%This splits \meta{string} at the first occurrence of \meta{split text}
+%and stores the before part in the command \meta{before cmd} and
+%the after part in the command \meta{after cmd}. For example:
+%\begin{verbatim}
+%\DTLsplitstring{abcdce}{c}{\beforepart}{\afterpart}%
+%Before part: ``\beforepart''. After part: ``\afterpart''
+%\end{verbatim}
+%produces:
+%\DTLsplitstring{abcdce}{c}{\beforepart}{\afterpart}\relax
+%Before part: ``\beforepart''. After part: ``\afterpart''.
+%Note that for \cs{DTLsplitstring}, \meta{string} is not
+%expanded, so
+%\begin{verbatim}
+%\def\mystr{abcdce}%
+%\DTLsplitstring{\mystr}{c}{\beforepart}{\afterpart}%
+%Before part: ``\beforepart''. After part: ``\afterpart''
+%\end{verbatim}
+%produces:
+%\def\mystr{abcdce}\relax
+%\DTLsplitstring{\mystr}{c}{\beforepart}{\afterpart}%
+%Before part: ``\beforepart''. After part: ``\afterpart''. If you
+%want the string expanded, you will need to use \cs{expandafter}:
+%\begin{verbatim}
+%\def\mystr{abcdce}%
+%\expandafter\DTLsplitstring\expandafter
+%{\mystr}{c}{\beforepart}{\afterpart}%
+%Before part: ``\beforepart''. After part: ``\afterpart''
+%\end{verbatim}
+%which produces:
+%\def\mystr{abcdce}\relax
+%\expandafter\DTLsplitstring\expandafter
+%{\mystr}{c}{\beforepart}{\afterpart}\relax
+%Before part: ``\beforepart''. After part: ``\afterpart''.
+%
%\DescribeMacro{\DTLinitials}
%\begin{definition}
%\cs{DTLinitials}\marg{string}
@@ -1527,21 +1879,59 @@
%\DTLinitials{Mary Ann}
%\end{verbatim}
%produces:
-%\DTLinitials{Mary Ann}. Note that
+%\DTLinitials{Mary Ann} (including the final full stop.) Note that
%\begin{verbatim}
%\DTLinitials{Mary-Ann}
%\end{verbatim}
%produces:
-%\DTLinitials{Mary-Ann}.
+%\DTLinitials{Mary-Ann} (including the final full stop.)
+%Be careful if the initial letter has an
+%accent. The accented letter needs to be placed in a group, if
+%you want the initial to also have an accent, otherwise the
+%accent command will be ignored. For example:
+%\begin{verbatim}
+%\DTLinitials{{\'E}lise Adams}
+%\end{verbatim}
+%produces:
+%\DTLinitials{{\'E}lise Adams}, whereas
+%\begin{verbatim}
+%\DTLinitials{\'Elise Adams}
+%\end{verbatim}
+%produces:
+%\DTLinitials{\'Elise Adams} In fact, any command which appears
+%at the start of the name that is not enclosed in a group will
+%be ignored. For example:
+%\begin{verbatim}
+%\DTLinitials{\MakeUppercase{m}ary ann}
+%\end{verbatim}
+%produces:
+%\DTLinitials{\MakeUppercase{m}ary ann}, whereas
+%\begin{verbatim}
+%\DTLinitials{{\MakeUppercase{m}}ary ann}
+%\end{verbatim}
+%produces:
+%\DTLinitials{{\MakeUppercase{m}}ary ann}, but note that
+%\begin{verbatim}
+%\DTLinitials{\MakeUppercase{mary ann}}
+%\end{verbatim}
+%produces:
+%\DTLinitials{\MakeUppercase{mary ann}}
%
%\DescribeMacro{\DTLstoreinitials}
%\begin{definition}
%\cs{DTLstoreinitials}\marg{string}\marg{cmd}
%\end{definition}
%This converts \meta{string} into initials and stores the
-%result in \meta{cmd}.
+%result in \meta{cmd} which must be a command name. The remarks
+%about \cs{DTLinitials} also relate to \cs{DTLstoreinitials}.
+%For example
+%\begin{verbatim}
+%\DTLstoreinitials{Marie-{\'E}lise del~Rosario}{\theInitials}\theInitials
+%\end{verbatim}
+%produces:
+%\DTLstoreinitials{Marie-{\'E}lise del~Rosario}{\theInitials}\theInitials
%
-%The above commands rely on the following to format the
+%Both the above commands rely on the following to format the
%initials:
%\DescribeMacro{\DTLafterinitials}
%\begin{definition}
@@ -1555,7 +1945,15 @@
%\cs{DTLbetweeninitials}
%\end{definition}
%This indicates what to do between initials. This does a
-%full stop followed by a space by default.
+%full stop by default.
+%
+%\DescribeMacro{\DTLinitialhyphen}
+%\begin{definition}
+%\cs{DTLinitialhyphen}
+%\end{definition}
+%This indicates what to do at a hyphen. This simply does a hyphen
+%by default, but can be redefined to do nothing to prevent the
+%hyphen appearing in the initials.
%
%\DescribeMacro{\DTLafterinitialbeforehyphen}
%\begin{definition}
@@ -1564,6 +1962,29 @@
%This indicates what to do between an initial and a hyphen.
%This simply does a full stop by default.
%
+%For example
+%\begin{verbatim}
+%\renewcommand*{\DTLafterinitialbeforehyphen}{}%
+%\DTLinitials{Marie-{\'E}lise del~Rosario}
+%\end{verbatim}
+%produces:
+%{\renewcommand*{\DTLafterinitialbeforehyphen}{}\relax
+%\DTLinitials{Marie-{\'E}lise del~Rosario}}
+%whereas
+%\begin{verbatim}
+%\renewcommand*{\DTLafterinitialbeforehyphen}{}%
+%\renewcommand*{\DTLafterinitials}{}%
+%\renewcommand*{\DTLbetweeninitials}{}%
+%\renewcommand*{\DTLinitialhyphen}{}%
+%\DTLinitials{Marie-{\'E}lise del~Rosario}
+%\end{verbatim}
+%produces:
+%{\renewcommand*{\DTLafterinitialbeforehyphen}{}\relax
+%\renewcommand*{\DTLafterinitials}{}\relax
+%\renewcommand*{\DTLbetweeninitials}{}\relax
+%\renewcommand*{\DTLinitialhyphen}{}\relax
+%\DTLinitials{Marie-{\'E}lise del~Rosario}}
+%
%\section{Databases}
%\label{sec:databases}
%
@@ -1640,26 +2061,39 @@
%\cs{DTLnewdbentry}\marg{db name}\marg{key}\marg{value}
%\end{definition}
%This creates a new entry with the identifier \meta{key} whose value
-%is \meta{value} and adds it to the current row of the database
+%is \meta{value} and adds it to the last row of the database
%called \meta{db name}. For example:
%\begin{verbatim}
%\DTLnewdbentry{mydata}{Surname}{Smith}
%\DTLnewdbentry{mydata}{FirstName}{John}
%\end{verbatim}
%Adds an entry with identifier \texttt{Surname} and value
-%\texttt{Smith} to the current row of the database named
+%\texttt{Smith} to the last row of the database named
%\texttt{mydata}, and then adds an entry with identifier
%\texttt{FirstName} and value \texttt{John}.
%
-%Note that database entries can't contain paragraph breaks as
-%many of the macros used by \sty{datatool} are short commands.
-%If you do need a paragraph break in an entry, you can instead
-%use the command:
+%\importantpar Note that database entries can't contain paragraph
+%breaks as many of the macros used by \sty{datatool} are short
+%commands. If you do need a paragraph break in an entry, you can
+%instead use the command:
%\DescribeMacro{\DTLpar}
%\begin{definition}
%\cs{DTLpar}
%\end{definition}
%
+%\DescribeMacro{\DTLaddentryforrow}
+%\begin{definition}
+%\cs{DTLaddentryforrow}\marg{db name}\marg{assign list}\marg{condition}\marg{key}\marg{value}
+%\end{definition}
+%This adds the entry with the key given by \meta{key} and value
+%given by \meta{value} to the first row in the database
+%\meta{db name} which satisfies the condition given by
+%\meta{condition}. The \meta{assign list} argument is the same
+%as for \cs{DTLforeach} (described in \autoref{sec:dbforeach})
+%and may be used to set the values which are to be tested in
+%\meta{condition} (where, again, \meta{condition} is the same
+%as for \cs{DTLforeach}).
+%
%\subsection{Loading a Database from an External ASCII File}
%\label{sec:loaddb}
%
@@ -1735,7 +2169,7 @@
%characters that appear in the command retain their \LaTeX\ meaning
%when the file is loaded. It is likely however that the data file
%may have been created by another application that is not \TeX-aware,
-%for example a spreadsheet application. For example, suppose you
+%such as a spreadsheet application. For example, suppose you
%have a file called, say, \texttt{products.csv} which looks
%like:
%\begin{verbatim}
@@ -1752,7 +2186,7 @@
%\cs{DTLloadrawdb}\marg{db name}\marg{filename}
%\end{definition}
%This is the same as \ics{DTLloaddb} except that it maps nine of
-%the ten special characters onto commands that produce that
+%the ten special characters onto commands which produce that
%symbol. The only character that retains its active state is the
%backslash character, so you will still need to check the file
%for backslash characters. The mappings used are listed in
@@ -1773,8 +2207,9 @@
%\end{verbatim}
%
%\begin{table}[htbp]
-%\caption{Special character mappings used by \cs{DTLloadrawdb}
-%(note that the backslash retains its active state)}
+%\caption[Special character mappings used by
+%\cs{DTLloadrawdb}]{Special character mappings used by
+%\cs{DTLloadrawdb} (note that the backslash retains its active state)}
%\label{tab:rawmappings}
%\begin{center}
%\begin{tabular}{ll}
@@ -1802,7 +2237,7 @@
%\end{ttfamily}
%\vskip\baselineskip
%The pound character is not an internationally standard keyboard
-%character, and does not achieve the desired effect when used
+%character, and does not generally achieve the desired effect when used
%in a \LaTeX\ document. It will therefore be necessary to convert
%this symbol to an appropriate control sequence. This can be done
%using the command:
@@ -1816,14 +2251,16 @@
%\cs{DTLrawmap}\char`\{\pounds\char`\}\char`\{\cs{pounds}\char`\}
%\end{ttfamily}
%\vskip\baselineskip\noindent
-%will convert all occurrences\footnote{in the \LaTeX\ database, not
-%in the data file itself!} of \texttt{\pounds} with \cs{pounds}.
+%will convert all occurrences\footnote{when it is loaded into the
+%\LaTeX\ database, it does not modify the data file!} of
+%\texttt{\pounds} with \cs{pounds}. Naturally, the mappings must be
+%set \emph{prior} to loading the data with \cs{DTLloadrawdb}.
%
-%Note that the warning in the previous section about no paragraph
-%breaks in an entry also applies to entries loaded from a database.
-%If you do need a paragraph break, use \ics{DTLpar} instead of
-%\cs{par}, but remember that each row of data in an external data file
-%must not have a line break.
+%\importantpar Note that the warning in the previous section about no
+%paragraph breaks in an entry also applies to entries loaded from a
+%database. If you do need a paragraph break, use \ics{DTLpar} instead
+%of \cs{par}, but remember that each row of data in an external data
+%file must not have a line break.
%
%\subsection{Iterating Through a Database}
%\label{sec:dbforeach}
@@ -1835,21 +2272,26 @@
%
%\DescribeMacro{\DTLforeach}
%\begin{definition}
-%\cs{DTLforeach}\oarg{condition}\marg{db name}\marg{values}\marg{text}
+%\cs{DTLforeach}\oarg{condition}\marg{db name}\marg{assign list}\marg{text}
+%\end{definition}
+%\DescribeMacro{\DTLforeach*}
+%\begin{definition}
+%\cs{DTLforeach*}\oarg{condition}\marg{db name}\marg{assign list}\marg{text}
%\end{definition}
%This will iterate through each row of the database called
%\meta{db name}, applying \meta{text} to each row of the database
-%where \meta{condition} is met. The argument \meta{values} is a
+%where \meta{condition} is met. The argument \meta{assign list} is a
%comma separated list of \meta{cmd}"="\meta{key} pairs. At the
-%start of each row, each command \meta{cmd} in the \meta{values}
-%list will be set to the value of the entry given by \meta{key}.
+%start of each row, each command \meta{cmd} in \meta{assign list}
+%will be set to the value of the entry given by \meta{key}.
%These commands may then be used in \meta{text}.
-%Note that this assignment is done globally to ensure that
-%\cs{DLTforeach} works correctly in a \env{tabular} environment.
+%
+%\importantpar Note that this assignment is done globally to ensure
+%that \cs{DLTforeach} works correctly in a \env{tabular} environment.
%Since you may want to use the same set of commands in a later
%\cs{DTLforeach}, the commands are not checked to determine if they
-%already exist. It is therefore important that you check you
-%are not using an existing command whose value should not be changed.
+%already exist. It is therefore important that you check you are not
+%using an existing command whose value should not be changed.
%
%The optional argument \meta{condition} is a condition in the
%form allowed by \cs{ifthenelse}. This includes the commands
@@ -1857,6 +2299,13 @@
%described in \autoref{sec:ifthen}. The default value of
%\meta{condition} is "\boolean{true}".
%
+%The starred version \cs{DTLforeach*} is a read-only version.
+%If you want to modify the database using any of the commands
+%described in \autoref{sec:editdb}, you must use the unstarred
+%version. The starred version is slightly quicker, however the
+%difference will probably only be noticeable for very large
+%databases.
+%
%\begin{example}{Student scores}{ex:scores}
%Suppose you have a data file called \texttt{studentscores.csv} that
%contains the following:
@@ -1907,7 +2356,7 @@
%you can then display the database in a table as follows:
%\begin{verbatim}
%\begin{table}[htbp]
-%\caption{Student Scores}\label{tab:scores}
+%\caption{Student scores}
%\centering
%\begin{tabular}{llr}
%\bfseries First Name &
@@ -1925,7 +2374,8 @@
%assign a command to the key "StudentNo".)
%
%\begin{table}[htbp]
-%\caption{Student Scores}\label{tab:scores}
+%\caption[Student scores (displaying a database in a
+%table)]{Student scores}\label{tab:scores}
%\centering
%\begin{tabular}{llr}
%\bfseries First Name &
@@ -1942,8 +2392,10 @@
%level uses the corresponding counters:
%\counterfmt{DTLrowi},
%\counterfmt{DTLrowii} and
-%\counterfmt{DTLrowiii} that keep track of
-%the current row. Note that these counters are only incremented
+%\counterfmt{DTLrowiii} which keep track of
+%the current row.
+%
+%\importantpar Note that these counters are only incremented
%when \meta{condition} is satisfied. These counters are incremented
%using \cs{refstepcounter} before the start of \meta{text}, so they
%may be referenced using \cs{label}, however remember that \cs{label}
@@ -1959,6 +2411,14 @@
%At the start of each iteration, \cs{DTLcurrentindex} is set
%to the arabic value of the current row counter.
%
+%\DescribeMacro{\DTLforeachkeyinrow}
+%\begin{definition}
+%\cs{DTLforeachkeyinrow}\marg{cmd}\marg{text}
+%\end{definition}
+%This iterates through each key in the current row, assigns
+%\meta{cmd} to the value of that key, and does \meta{text}.
+%(\meta{cmd} must be a control sequence.)
+%
%\begin{example}{Student Scores---Labelling}{ex:label}
%In the previous example, the student scores, stored in the
%database "scores" were placed in a table. In this example the
@@ -1977,7 +2437,7 @@
%memorable, so I shall instead use the scores.
%\begin{verbatim}
%\begin{table}[htbp]
-%\caption{Student Scores}\label{tab:scoreslab}
+%\caption{Student scores}
%\centering
%\begin{tabular}{cllc}
%\bfseries Row &
@@ -2003,7 +2463,8 @@
%"\refstepcounter{DTLrowi}".
%
%\begin{table}[htbp]
-%\caption{Student Scores}\label{tab:scoreslab}
+%\caption[Student scores (labelling rows)]{Student
+%scores}\label{tab:scoreslab}
%\centering
%\begin{tabular}{cllc}
%\bfseries Row &
@@ -2035,7 +2496,7 @@
%\cs{DTLsavelastrowcount} is outside of \ics{DTLforeach}.)
%\begin{verbatim}
%\begin{table}[htbp]
-%\caption{Top Student Scores}\label{tab:topscores}
+%\caption{Top student scores}
%\centering
%\begin{tabular}{llr}
%\bfseries First Name &
@@ -2057,7 +2518,8 @@
%may feasibly have a decimal score I have used \ics{DTLisgt} instead.
%
%\begin{table}[htbp]
-%\caption{Top Student Scores}\label{tab:topscores}
+%\caption[Top student scores (filtering rows using
+%\cs{DTLisgt})]{Top student scores}\label{tab:topscores}
%\centering
%\begin{tabular}{llr}
%\bfseries First Name &
@@ -2076,13 +2538,13 @@
%surname begins with `B'. I can do this as follows:
%\begin{verbatim}
%\begin{table}[htbp]
-%\caption{Student Scores (B)}\label{tab:Bscores}
+%\caption{Student scores (B)}
%\centering
%\begin{tabular}{llr}
%\bfseries First Name &
%\bfseries Surname &
%\bfseries Score (\%)%
-%\DTLforeach[\DTLisgt{\surname}{B}\and\DTLislt{\surname}{C}]{scores}{%
+%\DTLforeach[\DTLisopenbetween{\surname}{B}{C}]{scores}{%
%\firstname=FirstName,\surname=Surname,\score=Score}{%
%\\
%\firstname & \surname & \score}
@@ -2092,13 +2554,14 @@
%This produces \autoref{tab:Bscores}.
%
%\begin{table}[htbp]
-%\caption{Student Scores (B)}\label{tab:Bscores}
+%\caption[Student scores (B) --- filtering rows using
+%\cs{DTLisopenbetween}]{Student scores (B)}\label{tab:Bscores}
%\centering
%\begin{tabular}{llr}
%\bfseries First Name &
%\bfseries Surname &
%\bfseries Score (\%)\relax
-%\DTLforeach[\DTLisgt{\surname}{B}\and\DTLislt{\surname}{C}]{scores}
+%\DTLforeach[\DTLisopenbetween{\surname}{B}{C}]{scores}
%{\firstname=FirstName,\surname=Surname,\score=Score}{\relax
%\\
%\firstname & \surname & \score}
@@ -2116,13 +2579,6 @@
%If the current row is the first row, then do \meta{true part},
%otherwise do \meta{false part}.
%
-%\DescribeMacro{\DTLiflastrow}
-%\begin{definition}
-%\cs{DTLiflastrow}\marg{true part}\marg{false part}
-%\end{definition}
-%If the current row is the last row, then do \meta{true part},
-%otherwise do \meta{false part}.
-%
%\DescribeMacro{\DTLifoddrow}
%\begin{definition}
%\cs{DTLifoddrow}\marg{true part}\marg{false part}
@@ -2137,7 +2593,7 @@
%to produce a striped table.
%\begin{verbatim}
%\begin{table}[htbp]
-%\caption{A Stripy Table}\label{tab:stripy}
+%\caption{A stripy table}\label{tab:stripy}
%\centering
%\begin{tabular}{llc}
%\bfseries First Name &
@@ -2153,7 +2609,8 @@
%This produces \autoref{tab:stripy}.
%
%\begin{table}[htbp]
-%\caption{A Stripy Table}\label{tab:stripy}
+%\caption[A stripy table (illustrating the use of
+%\cs{DTLifoddrow})]{A stripy table}\label{tab:stripy}
%\centering
%\begin{tabular}{llc}
%\bfseries First Name &
@@ -2173,7 +2630,7 @@
%For example
%\begin{verbatim}
%\begin{table}[htbp]
-%\caption{Two Database Rows per Tabular Row}\label{tab:2rows}
+%\caption{Two database rows per tabular row}
%\centering
%\begin{tabular}{llcllc}
%\bfseries First Name &
@@ -2181,17 +2638,19 @@
%\bfseries Score (\%) &
%\bfseries First Name &
%\bfseries Surname &
-%\bfseries Score (\%)\relax
-%\DTLforeach{scores}{\firstname=FirstName,\surname=Surname,\score=Score}{\relax
-%\DTLifoddrow{\\}{&}\relax
-%\firstname & \surname & \score}\relax
+%\bfseries Score (\%)%
+%\DTLforeach{scores}{\firstname=FirstName,\surname=Surname,\score=Score}{%
+%\DTLifoddrow{\\}{&}%
+%\firstname & \surname & \score}%
%\end{tabular}
%\end{table}
%\end{verbatim}
%produces \autoref{tab:2rows}
%
%\begin{table}[htbp]
-%\caption{Two Database Rows per Tabular Row}\label{tab:2rows}
+%\caption[Two database rows per tabular row (illustrating the
+%use of\newline \cs{DTLifoddrow})]{Two database rows per tabular
+%row}\label{tab:2rows}
%\centering
%\begin{tabular}{llcllc}
%\bfseries First Name &
@@ -2290,15 +2749,15 @@
%file, and create a table for that data. I can do this using
%nested \ics{DTLforeach} as follows:
%\begin{verbatim}
-%% load index data file
+% % load index data file
%\DTLloaddb{index}{index.csv}
%
-%% iterate through index database
+% % iterate through index database
%\DTLforeach{index}{\theFile=File,\theTemp=Temperature,%
%\theNaCl=NaCl,\thepH=pH}{%
-%% load results file into database of the same name
+% % load results file into database of the same name
%\DTLloaddb{\theFile}{\theFile}%
-%% Create a table
+% % Create a table
%\begin{table}[htbp]
%\caption{Temperature = \theTemp, NaCl = \theNaCl,
%pH = \thepH}\label{tab:\theFile}
@@ -2318,7 +2777,9 @@
%\DTLforeach{index}{\theFile=File,\theTemp=Temperature,\theNaCl
%=NaCl,\thepH=pH}{
%\begin{table}[htbp]
-%\caption{Temperature = \theTemp, NaCl = \theNaCl,
+%\caption[Temperature = \theTemp, NaCl = \theNaCl,
+%pH = \thepH\space (illustrating nested
+%\cs{DTLforeach})]{Temperature = \theTemp, NaCl = \theNaCl,
%pH = \thepH}\label{tab:\theFile}
%\centering
%\begin{tabular}{rl}
@@ -2330,7 +2791,205 @@
%}
%\end{example}
%
+%\subsection{Null Values}
+%If a database is created using \cs{DTLnewdb}, \cs{DTLnewrow}
+%and \cs{DTLnewdbentry} (rather than loading it from an ASCII
+%file), it is possible for some of the entries to have null values
+%when a value is not assigned to a given key for a given row.
+%
+%When you iterate through the database using \cs{DTLforeach}
+%(described in \autoref{sec:dbforeach}),
+%if an entry is missing for a given row, the associated command given
+%in the \meta{values} argument will be set to a null value. This
+%value depends on the data type associated with the given key.
+%
+%\DescribeMacro{\DTLstringnull}
+%\begin{definition}
+%\cs{DTLstringnull}
+%\end{definition}
+%This is the null value for a string.
+%
+%\DescribeMacro{\DTLnumbernull}
+%\begin{definition}
+%\cs{DTLnumbernull}
+%\end{definition}
+%This is the null value for a number.
+%
+%\DescribeMacro{\DTLifnull}
+%\begin{definition}
+%\cs{DTLifnull}\marg{cmd}\marg{true part}\marg{false part}
+%\end{definition}
+%This checks if \meta{cmd} is null where \meta{cmd} is a command name,
+%if it is, then \meta{true part}
+%is done, otherwise \meta{false part} is done. This macro is
+%illustrated in \autoref{ex:null} below.
+%
+%\begin{example}{Null Values}{ex:null}
+%Consider the following (which creates a database called "emailDB"):
+%\begin{verbatim}
+%\DTLnewdb{emailDB}
+%\DTLnewrow{emailDB}
+%\DTLnewdbentry{emailDB}{Surname}{Jones}
+%\DTLnewdbentry{emailDB}{FirstName}{Mary}
+%\DTLnewdbentry{emailDB}{Email1}{mj@my.uni.ac.uk}
+%\DTLnewdbentry{emailDB}{Email2}{mj@somewhere.com}
+%\DTLnewrow{emailDB}
+%\DTLnewdbentry{emailDB}{Surname}{Smith}
+%\DTLnewdbentry{emailDB}{FirstName}{Adam}
+%\DTLnewdbentry{emailDB}{Email1}{as@my.uni.ac.uk}
+%\DTLnewdbentry{emailDB}{RegNum}{12345}
+%\end{verbatim}
+%\DTLnewdb{emailDB}\relax
+%\DTLnewrow{emailDB}\relax
+%\DTLnewdbentry{emailDB}{Surname}{Jones}\relax
+%\DTLnewdbentry{emailDB}{FirstName}{Mary}\relax
+%\DTLnewdbentry{emailDB}{Email1}{mj@my.uni.ac.uk}\relax
+%\DTLnewdbentry{emailDB}{Email2}{mj@somewhere.com}\relax
+%\DTLnewrow{emailDB}\relax
+%\DTLnewdbentry{emailDB}{Surname}{Smith}\relax
+%\DTLnewdbentry{emailDB}{FirstName}{Adam}\relax
+%\DTLnewdbentry{emailDB}{Email1}{as@my.uni.ac.uk}\relax
+%\DTLnewdbentry{emailDB}{RegNum}{12345}\relax
+%In the above example, the first row of the database contains
+%an entry with the key "Email2", but the second row doesn't.
+%Whereas the second row contains an entry with the key "RegNum",
+%but the first row doesn't.
+%
+%The following code puts the information in a \env{tabular}
+%environment:
+%\begin{verbatim}
+%\begin{tabular}{lllll}
+%\bfseries First Name &
+%\bfseries Surname &
+%\bfseries Email 1 &
+%\bfseries Email 2 &
+%\bfseries Reg Num%
+%\DTLforeach{emailDB}{\firstname=FirstName,\surname=Surname,%
+%\emailI=Email1,\emailII=Email2,\regnum=RegNum}{%
+%\\\firstname & \surname & \emailI & \emailII & \regnum}%
+%\end{tabular}
+%\end{verbatim}
+%This produces the following:\par\vskip\baselineskip\noindent
+%\begin{tabular}{lllll}
+%\bfseries First Name &
+%\bfseries Surname &
+%\bfseries Email 1 &
+%\bfseries Email 2 &
+%\bfseries Reg Num\relax
+%\DTLforeach{emailDB}{\firstname=FirstName,\surname
+%=Surname,\emailI=Email1,\emailII=Email2,\regnum=RegNum}{\relax
+%\\\firstname & \surname & \emailI & \emailII & \regnum}\relax
+%\end{tabular}
+%\par\vskip\baselineskip
+%Note that on the first row of data, the registration number appears as
+%0, while on the next row, the second email address appears as
+%NULL. The \sty{datatool} package has identified the key "RegNum"
+%for this database as a numerical key, since all elements in the
+%database with that key are numerical, whereas it has
+%identified the key "Email2" as a string, since there is at least
+%one element in this database with that key that is a string.
+%Null numerical values are set to \cs{DTLnumbernull} (0),
+%and null strings are set to \cs{DTLstringnull} (NULL).
+%
+%The following code checks each value to determine whether it
+%is null using \cs{DTLifnull}. If it is, the text \emph{Missing}
+%is inserted, otherwise the value itself is used:
+%\begin{verbatim}
+%\begin{tabular}{lllll}
+%\bfseries First Name &
+%\bfseries Surname &
+%\bfseries Email 1 &
+%\bfseries Email 2 &
+%\bfseries Reg Num%
+%\DTLforeach{emailDB}{\firstname=FirstName,\surname=Surname,%
+%\emailI=Email1,\emailII=Email2,\regnum=RegNum}{%
+%\\\DTLifnull{\firstname}{\emph{Missing}}{\firstname} &
+%\DTLifnull{\surname}{\emph{Missing}}{\surname} &
+%\DTLifnull{\emailI}{\emph{Missing}}{\emailI} &
+%\DTLifnull{\emailII}{\emph{Missing}}{\emailII} &
+%\DTLifnull{\regnum}{\emph{Missing}}{\regnum}}%
+%\end{tabular}
+%\end{verbatim}
+%This produces the following:\par\vskip\baselineskip\noindent
+%\begin{tabular}{lllll}
+%\bfseries First Name &
+%\bfseries Surname &
+%\bfseries Email 1 &
+%\bfseries Email 2 &
+%\bfseries Reg Num\relax
+%\DTLforeach{emailDB}{\firstname=FirstName,\surname
+%=Surname,\emailI=Email1,\emailII=Email2,\regnum=RegNum}{\relax
+%\\\DTLifnull{\firstname}{\emph{Missing}}{\firstname} &
+%\DTLifnull{\surname}{\emph{Missing}}{\surname} &
+%\DTLifnull{\emailI}{\emph{Missing}}{\emailI} &
+%\DTLifnull{\emailII}{\emph{Missing}}{\emailII} &
+%\DTLifnull{\regnum}{\emph{Missing}}{\regnum}}\relax
+%\end{tabular}
+%\par\vskip\baselineskip\noindent
+%If you want to do this, you may find it easier to define a
+%convenience command that will display some appropriate text
+%if an entry is missing, for example:
+%\begin{verbatim}
+%\newcommand*{\checkmissing}[1]{\DTLifnull{#1}{---}{#1}}
+%\end{verbatim}
+%Then instead of typing, say,
+%\begin{verbatim}
+%\DTLifnull{\regnum}{---}{\regnum}
+%\end{verbatim}
+%you can instead type:
+%\begin{verbatim}
+%\checkmissing{\regnum}
+%\end{verbatim}
+%
+%Now suppose that instead of defining the database using \cs{DTLnewdb},
+%\cs{DTLnewrow} and \cs{DTLnewdbentry}, you have a file with the
+%contents:
+%\begin{ttfamily}\setlength{\parindent}{0pt}\par\vskip\baselineskip
+%Surname,FirstName,RegNum,Email1,Email2
+%
+%\DTLforeach{emailDB}{\surname=Surname,\firstname=FirstName,\regNo
+%=RegNum,\emailI=Email1,\emailII
+%=Email2}{\relax
+%\surname,\firstname,\DTLifnull{\regNo}{}{\regNo},\emailI,\DTLifnull{\emailII}{}{\emailII}\par
+%}
+%\end{ttfamily}\par\vskip\baselineskip\noindent
+%and you load the data from this file using \cs{DTLloaddb}
+%(defined in \autoref{sec:loaddb}). Now the
+%database has no null values, but has an empty value for the
+%key "RegNum" on the first row of the database, and an empty
+%value for the key "Email2" on the second row of the database.
+%Now, the following code
+%\begin{verbatim}
+%\begin{tabular}{lllll}
+%\bfseries First Name &
+%\bfseries Surname &
+%\bfseries Email 1 &
+%\bfseries Email 2 &
+%\bfseries Reg Number%
+%\DTLforeach{emailDB}{\firstname=FirstName,\surname=Surname,%
+%\emailI=Email1,\emailII=Email2,\regnum=RegNum}{%
+%\\\DTLifnull{\firstname}{\emph{Missing}}{\firstname} &
+%\DTLifnull{\surname}{\emph{Missing}}{\surname} &
+%\DTLifnull{\emailI}{\emph{Missing}}{\emailI} &
+%\DTLifnull{\emailII}{\emph{Missing}}{\emailII} &
+%\DTLifnull{\regnum}{\emph{Missing}}{\regnum}}%
+%\end{tabular}
+%\end{verbatim}
+%produces:\par\vskip\baselineskip\noindent
+%\begin{tabular}{lllll}
+%\bfseries First Name &
+%\bfseries Surname &
+%\bfseries Email 1 &
+%\bfseries Email 2 &
+%\bfseries Reg Number\relax
+%\DTLforeach{emailDB}{\firstname=FirstName,\surname
+%=Surname,\emailI=Email1,\emailII=Email2,\regnum=RegNum}{\relax
+%\\\firstname & \surname & \emailI & \DTLifnull{\emailII}{}{\emailII} & \DTLifnull{\regnum}{}{\regnum}}\relax
+%\end{tabular}
+%\end{example}
+%
%\subsection{Editing Database Rows}
+%\label{sec:editdb}
%
%In the body of the \ics{DTLforeach} loop, you can use the following
%to edit the current row:
@@ -2359,14 +3018,6 @@
%\end{definition}
%This removes the current row from the database.
%
-%\DescribeMacro{\DTLforeachkeyinrow}
-%\begin{definition}
-%\cs{DTLforeachkeyinrow}\marg{cmd}\marg{text}
-%\end{definition}
-%This iterates through each key in the current row, assigns
-%\meta{cmd} to the value of that key, and does \meta{text}.
-%(\meta{cmd} must be a control sequence.)
-%
%\begin{example}{Editing Database Rows}{ex:editdb}
%In this example I have a CSV file called "marks.csv" that contains
%student marks for three assignments:
@@ -2419,7 +3070,7 @@
%\DTLforeach{marks}{\surname=Surname,\firstname=FirstName,\regNo
%=StudentNo,\assignI=Assignment 1,\assignII
%=Assignment 2,\assignIII=Assignment 3}{\relax
-%\surname,\firstname,\regNo,\assignI,\assignII\assignIII\par
+%\char`\"\surname\char`\",\DTLifstringeq{\firstname}{Zoe}{Z\string\"oe}{\firstname},\regNo,\assignI,\assignII,\assignIII\par
%}
%\end{ttfamily}\par\noindent
%First load this into a database called "marks":
@@ -2447,7 +3098,7 @@
%a table:
%\begin{verbatim}
%\begin{table}[htbp]
-%\caption{Student Marks}
+%\caption{Student marks}
%\centering
%\begin{tabular}{llrrrr}
%\bfseries Surname & \bfseries First Name &
@@ -2473,7 +3124,8 @@
%I don't need to recompute the mean.
%
%\begin{table}[htbp]
-%\caption{Student Marks}\label{tab:meanmarks}
+%\caption[Student marks (with averages)]{Student
+%marks}\label{tab:meanmarks}
%\centering
%\begin{tabular}{llrrrr}
%\bfseries Surname & \bfseries First Name &
@@ -2497,8 +3149,8 @@
%entries. You can, of course, directly use the commands provided
%by the \sty{fp} package if you know that the values are in the
%correct format (i.e.\ no currency symbols, no number group
-%separators and a full stop as the decimal point) but if this may
-%not be the case, then you should use the commands described in
+%separators and a full stop as the decimal point) but if this is
+%not the case, then you should use the commands described in
%\autoref{sec:fp}. If you want to use a command provided by the
%\sty{fp} package, that does not have a wrapper function in
%\sty{datatool}, then you will need to convert the value using
@@ -2511,7 +3163,7 @@
%end which contains the average score.
%\begin{verbatim}
%\begin{table}[htbp]
-%\caption{Student Scores (Including Average)}\label{tab:mean}
+%\caption{Student scores}\label{tab:mean}
%\centering
%\def\total{0}%
%\begin{tabular}{llr}
@@ -2548,7 +3200,8 @@
%\end{itemize}
%
%\begin{table}[htbp]
-%\caption{Student Scores (Including Average)}\label{tab:mean}
+%\caption[Student scores (using arithmetic computations)]{Student
+%scores}\label{tab:mean}
%\centering
%\def\total{0}\relax
%\begin{tabular}{llr}
@@ -2658,7 +3311,7 @@
%
%\begin{example}{Mail Merging}{ex:mailmerging}
%This example uses the database given in \autoref{ex:scores} and
-%uses \ics{DTLmeanforkey} to determine the average score. A letter
+%uses \ics{DTLmeanforkeys} to determine the average score. A letter
%is then created for each student to inform them of their score
%and the class average.
%
@@ -2668,14 +3321,14 @@
%\usepackage{datatool}
%
%\begin{document}
-%% load database
+% % load database
%\DTLloaddb{scores}{studentscores.csv}
-%% compute arithmetic mean for key `Score'
-%\DTLmeanforkey{scores}{Score}{\average}
-%% Round the average to 2 decimal places
+% % compute arithmetic mean for key `Score'
+%\DTLmeanforkeys{scores}{Score}{\average}
+% % Round the average to 2 decimal places
%\DTLround{\average}{\average}{2}
-%% Save the highest score in \maxscore
-%\DTLmaxforkey{scores}{Score}{\maxscore}
+% % Save the highest score in \maxscore
+%\DTLmaxforkeys{scores}{Score}{\maxscore}
%
%\DTLforeach{scores}{\firstname=FirstName,\surname=Surname,%
%\score=Score}{%
@@ -2699,7 +3352,11 @@
%
%\DescribeMacro{\DTLsort}
%\begin{definition}
-%\cs{DTLsort}\marg{sort criteria}\marg{db name}
+%\cs{DTLsort}\oarg{replacement key list}\marg{sort criteria}\marg{db name}
+%\end{definition}
+%\DescribeMacro{\DTLsort*}
+%\begin{definition}
+%\cs{DTLsort*}\oarg{replacement key list}\marg{sort criteria}\marg{db name}
%\end{definition}
%This will sort the database called \meta{db name} according to
%the criteria given by \meta{sort criteria}, which must be a
@@ -2707,7 +3364,36 @@
%\meta{order} is either "ascending" or "descending". If the order
%is omitted, "ascending" is assumed. The database keeps track of
%the data type for a given key, and uses this to determine whether
-%an alphabetical or numerical sort is required.
+%an alphabetical or numerical sort is required. (String comparisons
+%are made using the command \cs{dtlcompare} or \cs{dtlicompare}
+%described in \autoref{src:dtlcompare}.)
+%
+%The optional argument \meta{replacement key list} is a list of
+%keys to use if the current key given in \meta{sort criteria}
+%is null for a given entry. Null keys are unlikely to occur if
+%you have loaded the database from an external ASCII file, but
+%may occur if the database is created using \cs{DTLnewdb},
+%\cs{DTLnewrow} and \cs{DTLnewdbentry}. For example:
+%\begin{verbatim}
+%\DTLsort[Editor,Organization]{Author}{mydata}
+%\end{verbatim}
+%will sort according to the "Author" key, but if that key is missing
+%for a given row of the database, the "Editor" key will be used,
+%and if the "Editor" key is missing, it will use the "Organization"
+%key. Note that this is not the same as:
+%\begin{verbatim}
+%\DTLsort{Author,Editor,Organization}{mydata}
+%\end{verbatim}
+%which will first compare the "Author" keys, but if the author names
+%are the same, it will then compare the "Editor" keys, and if the
+%editor names are also the same, it will then compare the
+%"Organization" keys.
+%
+%The unstarred version uses a case sensitive comparison for strings,
+%whereas the starred version ignores the case when comparing strings.
+%Note that the case sensitive comparison orders uppercase characters
+%before lowercase characters, so the letter B is considered to be
+%lower than the letter a.
%
%\begin{example}{Sorting a Database}{ex:sort}
%This example uses the database called "scores" defined in
@@ -2716,7 +3402,7 @@
%lowest) and display the database in a table
%\begin{verbatim}
%\begin{table}[htbp]
-%\caption{Student Scores (Sorted by Score)}\label{tab:sortscores}
+%\caption{Student scores (sorted by score)}
%\centering
%\DTLsort{Score=descending}{scores}%
%\begin{tabular}{llr}
@@ -2733,7 +3419,7 @@
%This produces \autoref{tab:sortscores}.
%
%\begin{table}[htbp]
-%\caption{Student Scores (Sorted by Score)}\label{tab:sortscores}
+%\caption{Student scores (sorted by score)}\label{tab:sortscores}
%\centering
%\DTLsort{Score=descending}{scores}\relax
%\begin{tabular}{llr}
@@ -2754,7 +3440,7 @@
%in the first column.
%\begin{verbatim}
%\begin{table}[htbp]
-%\caption{Student Scores (Sorted by Name)}\label{tab:sortname}
+%\caption{Student scores (sorted by name)}
%\centering
%\DTLsort{Surname,FirstName}{scores}%
%\begin{tabular}{llr}
@@ -2770,7 +3456,63 @@
%\end{verbatim}
%This produces \autoref{tab:sortname}.
%\begin{table}[htbp]
-%\caption{Student Scores (Sorted by Name)}\label{tab:sortname}
+%\caption{Student scores (sorted by name)}\label{tab:sortname}
+%\centering
+%\DTLsort{Surname,FirstName}{scores}\relax
+%\begin{tabular}{llr}
+%\bfseries Surname &
+%\bfseries First Name &
+%\bfseries Score (\%)\relax
+%\DTLforeach{scores}{\firstname=FirstName,\surname=Surname,\score=Score}{\relax
+%\\
+%\surname & \firstname & \score}
+%\end{tabular}
+%\end{table}
+%
+%Now suppose I add two new students to the database:
+%\begin{verbatim}
+%\DTLnewrow{scores}%
+%\DTLnewdbentry{scores}{Surname}{van der Mere}%
+%\DTLnewdbentry{scores}{FirstName}{Henk}%
+%\DTLnewdbentry{scores}{Score}{71}%
+%\DTLnewrow{scores}%
+%\DTLnewdbentry{scores}{Surname}{de la Mere}%
+%\DTLnewdbentry{scores}{FirstName}{Jos}%
+%\DTLnewdbentry{scores}{Score}{58}%
+%\end{verbatim}
+%\DTLnewrow{scores}
+%\DTLnewdbentry{scores}{Surname}{van der Mere}\relax
+%\DTLnewdbentry{scores}{FirstName}{Henk}\relax
+%\DTLnewdbentry{scores}{Score}{71}\relax
+%\DTLnewrow{scores}\relax
+%\DTLnewdbentry{scores}{Surname}{de la Mere}\relax
+%\DTLnewdbentry{scores}{FirstName}{Jos}\relax
+%\DTLnewdbentry{scores}{Score}{58}\relax
+%and again I try sorting the database, and displaying the contents
+%as a table:
+%\begin{verbatim}
+%\begin{table}[htbp]
+%\caption{Student scores (case sensitive sort)}
+%\centering
+%\DTLsort{Surname,FirstName}{scores}%
+%\begin{tabular}{llr}
+%\bfseries Surname &
+%\bfseries First Name &
+%\bfseries Score (\%)%
+%\DTLforeach{scores}{%
+%\firstname=FirstName,\surname=Surname,\score=Score}{%
+%\\
+%\surname & \firstname & \score}
+%\end{tabular}
+%\end{table}
+%\end{verbatim}
+%This produces \autoref{tab:sortname2}. Notice that the surnames
+%aren't correctly ordered. This is because a case-sensitive
+%sort was used. Changing \cs{DTLsort} to \cs{DTLsort*} in the
+%above code produces \autoref{tab:sortname3}.
+%
+%\begin{table}[htbp]
+%\caption{Student scores (case sensitive sort)}\label{tab:sortname2}
%\centering
%\DTLsort{Surname,FirstName}{scores}\relax
%\begin{tabular}{llr}
@@ -2783,6 +3525,120 @@
%\end{tabular}
%\end{table}
%
+%\begin{table}[htbp]
+%\caption{Student scores (case ignored when
+%sorting)}\label{tab:sortname3}
+%\centering
+%\DTLsort*{Surname,FirstName}{scores}\relax
+%\begin{tabular}{llr}
+%\bfseries Surname &
+%\bfseries First Name &
+%\bfseries Score (\%)\relax
+%\DTLforeach{scores}{\firstname=FirstName,\surname=Surname,\score=Score}{\relax
+%\\
+%\surname & \firstname & \score}
+%\end{tabular}
+%\end{table}
+%
+%\end{example}
+%
+%\begin{example}{Influencing the sort order}{ex:sortswitchargs}
+%Consider the data displayed in \autoref{tab:sortname3}, suppose that
+%you want the names ``van der Mere'' and ``de la Mere'' sorted
+%according to the actual surname ``Mere'' rather than by the ``von
+%part''. There are two ways you can do this: firstly, you could store
+%the von part in a separate field, and then sort by surname, then von
+%part, then first name, or you could define a command called, say,
+%\cs{switchargs}, as follows:
+%\begin{verbatim}
+%\newcommand*{\switchargs}[2]{#2#1}
+%\end{verbatim}
+%\newcommand*{\switchargs}[2]{#2#1}\relax
+%then store the data as:
+%\begin{verbatim}
+%FirstName,Surname,StudentNo,Score
+%John,"Smith, Jr",102689,68
+%Jane,Brown,102647,75
+%Andy,Brown,103569,42
+%Z\"oe,Adams,105987,52
+%Roger,Brady,106872,58
+%Clare,Verdon,104356,45
+%Henk,\switchargs{Mere}{van der },106789,71
+%Jos,\switchargs{Mere}{de la },104256,58
+%\end{verbatim}
+%\DTLnewdb{scores2}\relax
+%\DTLnewrow{scores2}\relax
+%\DTLnewdbentry{scores2}{FirstName}{John}\relax
+%\DTLnewdbentry{scores2}{Surname}{Smith, Jr}\relax
+%\DTLnewdbentry{scores2}{StudentNo}{102689}\relax
+%\DTLnewdbentry{scores2}{Score}{68}\relax
+%\DTLnewrow{scores2}\relax
+%\DTLnewdbentry{scores2}{FirstName}{Jane}\relax
+%\DTLnewdbentry{scores2}{Surname}{Brown}\relax
+%\DTLnewdbentry{scores2}{StudentNo}{102647}\relax
+%\DTLnewdbentry{scores2}{Score}{75}\relax
+%\DTLnewrow{scores2}\relax
+%\DTLnewdbentry{scores2}{FirstName}{Andy}\relax
+%\DTLnewdbentry{scores2}{Surname}{Brown}\relax
+%\DTLnewdbentry{scores2}{StudentNo}{103569}\relax
+%\DTLnewdbentry{scores2}{Score}{42}\relax
+%\DTLnewrow{scores2}\relax
+%\DTLnewdbentry{scores2}{FirstName}{Z\"oe}\relax
+%\DTLnewdbentry{scores2}{Score}{52}\relax
+%\DTLnewdbentry{scores2}{StudentNo}{105987}\relax
+%\DTLnewdbentry{scores2}{Surname}{Adams}\relax
+%\DTLnewrow{scores2}\relax
+%\DTLnewdbentry{scores2}{FirstName}{Roger}\relax
+%\DTLnewdbentry{scores2}{Score}{58}\relax
+%\DTLnewdbentry{scores2}{StudentNo}{106872}\relax
+%\DTLnewdbentry{scores2}{Surname}{Brady}\relax
+%\DTLnewrow{scores2}\relax
+%\DTLnewdbentry{scores2}{FirstName}{Clare}\relax
+%\DTLnewdbentry{scores2}{Score}{45}\relax
+%\DTLnewdbentry{scores2}{StudentNo}{104356}\relax
+%\DTLnewdbentry{scores2}{Surname}{Verdon}\relax
+%\DTLnewrow{scores2}
+%\DTLnewdbentry{scores2}{Surname}{\switchargs{Mere}{van der }}\relax
+%\DTLnewdbentry{scores2}{FirstName}{Henk}\relax
+%\DTLnewdbentry{scores2}{Score}{71}\relax
+%\DTLnewrow{scores2}\relax
+%\DTLnewdbentry{scores2}{Surname}{\switchargs{Mere}{de la }}\relax
+%\DTLnewdbentry{scores2}{FirstName}{Jos}\relax
+%\DTLnewdbentry{scores2}{Score}{58}\relax
+%Now sort the data, and put it in table (this is the same code
+%as in the previous example:
+%\begin{verbatim}
+%\begin{table}[htbp]
+%\caption{Student scores (influencing the sort order)}
+%\centering
+%\DTLsort*{Surname,FirstName}{scores}%
+%\begin{tabular}{llr}
+%\bfseries Surname &
+%\bfseries First Name &
+%\bfseries Score (\%)%
+%\DTLforeach{scores}{%
+%\firstname=FirstName,\surname=Surname,\score=Score}{%
+%\\
+%\surname & \firstname & \score}
+%\end{tabular}
+%\end{table}
+%\end{verbatim}
+%This produces \autoref{tab:influencesort}.
+%
+%\begin{table}[htbp]
+%\caption{Student scores (influencing the sort order)}\label{tab:influencesort}
+%\centering
+%\DTLsort*{Surname,FirstName}{scores2}\relax
+%\begin{tabular}{llr}
+%\bfseries Surname &
+%\bfseries First Name &
+%\bfseries Score (\%)\relax
+%\DTLforeach{scores2}{\firstname=FirstName,\surname=Surname,\score=Score}{\relax
+%\\
+%\surname & \firstname & \score}
+%\end{tabular}
+%\end{table}
+%
%\end{example}
%
%\subsection{Saving a Database to an External File}
@@ -2800,6 +3656,9 @@
%\DTLsettabdelimiter
%\DTLsavedb{scores}{scores.txt}
%\end{verbatim}
+%will create a file called "scores.txt", and save the data in a
+%tab separated format. (The delimiters will only be used if a
+%given entry contains the separator character.)
%
%\DescribeMacro{\DTLsavetexdb}
%\begin{definition}
@@ -2807,7 +3666,8 @@
%\end{definition}
%This writes the database called \meta{db name} to a \LaTeX\ file
%called \meta{filename}, where the database is stored as
-%a combination of \ics{DTLnewdb}, \ics{DTLnewrow} and \ics{DTLnewdbentry} commands.
+%a combination of \ics{DTLnewdb}, \ics{DTLnewrow} and
+%\ics{DTLnewdbentry} commands.
%
%\section{Pie Charts (\texorpdfstring{\sty{datapie}}{datapie} package)}
%
@@ -2982,7 +3842,7 @@
%\begin{figure}[htbp]
%\centering
%\DTLpiechart{variable=\quantity}{fruit}{\name=Name,\quantity=Quantity}
-%\caption{A Pie Chart}
+%\caption{A pie chart}
%\end{figure}
%\end{verbatim}
%This creates \autoref{fig:piechart}.
@@ -2990,7 +3850,7 @@
%\begin{figure}[htbp]
%\centering
%\DTLpiechart{variable=\quantity}{fruit}{\name=Name,\quantity=Quantity}
-%\caption{A Pie Chart}
+%\caption{A pie chart}
%\label{fig:piechart}
%\end{figure}
%
@@ -3002,7 +3862,7 @@
%\centering
%\DTLpiechart{variable=\quantity,outerlabel=\name}{fruit}{%
%\name=Name,\quantity=Quantity}
-%\caption{A Pie Chart (Outer labels set)}
+%\caption{A pie chart (outer labels set)}
%\end{figure}
%\end{verbatim}
%This creates \autoref{fig:piechartouter}.
@@ -3011,7 +3871,7 @@
%\centering
%\DTLpiechart{variable=\quantity,outerlabel=\name}{fruit}
%{\name=Name,\quantity=Quantity}
-%\caption{A Pie Chart (Outer labels set)}
+%\caption{A pie chart (outer labels set)}
%\label{fig:piechartouter}
%\end{figure}
%
@@ -3023,7 +3883,7 @@
%\DTLpiechart{variable=\quantity,outerlabel=\name,%
%rotateinner,rotateouter}{fruit}{%
%\name=Name,\quantity=Quantity}
-%\caption{A Pie Chart (Rotation enabled)}
+%\caption{A pie chart (rotation enabled)}
%\end{figure}
%\end{verbatim}
%This creates \autoref{fig:piechartrot}.
@@ -3033,7 +3893,7 @@
%\DTLpiechart{variable=\quantity,outerlabel=\name
%,rotateinner,rotateouter}{fruit}
%{\name=Name,\quantity=Quantity}
-%\caption{A Pie Chart (Rotation enabled)}
+%\caption{A pie chart (rotation enabled)}
%\label{fig:piechartrot}
%\end{figure}
%\end{example}
@@ -3050,7 +3910,7 @@
%\DTLpiechart{variable=\quantity,outerlabel=\name,%
%cutaway={1,3}}{fruit}{%
%\name=Name,\quantity=Quantity}
-%\caption{A Pie Chart with Cutaway Segments}
+%\caption{A pie chart with cutaway segments}
%\end{figure}
%\end{verbatim}
%This produces \autoref{fig:piecutaway}.
@@ -3059,7 +3919,7 @@
%\centering
%\DTLpiechart{variable=\quantity,outerlabel=\name
%,cutaway={1,3}}{fruit}{\name=Name,\quantity=Quantity}
-%\caption{A Pie Chart with Cutaway Segments}
+%\caption{A pie chart with cutaway segments}
%\label{fig:piecutaway}
%\end{figure}
%
@@ -3071,7 +3931,7 @@
%\DTLpiechart{variable=\quantity,outerlabel=\name,%
%cutaway={1-2}}{fruit}{%
%\name=Name,\quantity=Quantity}
-%\caption{A Pie Chart with Cutaway Segments (\texttt{cutaway=\{1-2\}})}
+%\caption{A pie chart with cutaway segments (\texttt{cutaway=\{1-2\}})}
%\end{figure}
%\end{verbatim}
%This produces \autoref{fig:piecutaway2}.
@@ -3080,7 +3940,7 @@
%\centering
%\DTLpiechart{variable=\quantity,outerlabel=\name
%,cutaway={1-2}}{fruit}{\name=Name,\quantity=Quantity}
-%\caption{A Pie Chart with Cutaway Segments (\texttt{cutaway=\{1-2\}})}
+%\caption{A pie chart with cutaway segments (\texttt{cutaway=\{1-2\}})}
%\label{fig:piecutaway2}
%\end{figure}
%
@@ -3092,7 +3952,7 @@
%\DTLpiechart{variable=\quantity,outerlabel=\name,%
%cutaway={1,2}}{fruit}{%
%\name=Name,\quantity=Quantity}
-%\caption{A Pie Chart with Cutaway Segments (\texttt{cutaway=\{1,2\}})}
+%\caption{A pie chart with cutaway segments (\texttt{cutaway=\{1,2\}})}
%\end{figure}
%\end{verbatim}
%
@@ -3100,7 +3960,7 @@
%\centering
%\DTLpiechart{variable=\quantity,outerlabel=\name
%,cutaway={1,2}}{fruit}{\name=Name,\quantity=Quantity}
-%\caption{A Pie Chart with Cutaway Segments (\texttt{cutaway=\{1,2\}})}
+%\caption{A pie chart with cutaway segments (\texttt{cutaway=\{1,2\}})}
%\label{fig:piecutaway3}
%\end{figure}
%
@@ -3138,7 +3998,7 @@
%innerlabel={\DTLpiepercent\%},%
%outerlabel={\name\ (\DTLpievariable)}}{fruit}{%
%\name=Name,\quantity=Quantity}
-%\caption{A Pie Chart (Changing the labels)}
+%\caption{A pie chart (changing the labels)}
%\end{figure}
%\end{verbatim}
%This produces \autoref{fig:piechartlabels}.
@@ -3148,7 +4008,7 @@
%\DTLpiechart{variable=\quantity,innerlabel={\DTLpiepercent
%\%},outerlabel={\name\ (\DTLpievariable)}}{fruit}{%
%\name=Name,\quantity=Quantity}
-%\caption{A Pie Chart (Changing the labels)}
+%\caption{A pie chart (changing the labels)}
%\label{fig:piechartlabels}
%\end{figure}
%\end{example}
@@ -3183,7 +4043,7 @@
%innerlabel={\DTLpiepercent\%},%
%outerlabel={\name\ (\DTLpievariable)}}{fruit}{%
%\name=Name,\quantity=Quantity}
-%\caption{A Pie Chart (Changing the label format)}
+%\caption{A pie chart (changing the label format)}
%\end{figure}
%\end{verbatim}
%This produces \autoref{fig:piechartlabelformat}.
@@ -3195,7 +4055,7 @@
%\DTLpiechart{variable=\quantity,innerlabel={\DTLpiepercent
%\%},outerlabel={\name\ (\DTLpievariable)}}{fruit}{%
%\name=Name,\quantity=Quantity}
-%\caption{A Pie Chart (Changing the label format)}
+%\caption{A pie chart (changing the label format)}
%\label{fig:piechartlabelformat}
%\end{figure}
%\end{example}
@@ -3271,7 +4131,7 @@
%\name
%}
%\end{tabular}
-%\caption{A Pie Chart (Using Segment Colours and Outline)}
+%\caption{A pie chart (using segment colours and outline)}
%\end{figure}
%\end{verbatim}
%This produces \autoref{fig:piesegcolour}. (The format of the
@@ -3297,7 +4157,7 @@
%\name
%}
%\end{tabular}
-%\caption{A Pie Chart (Using Segment Colours and Outline)}
+%\caption{A pie chart (using segment colours and outline)}
%\label{fig:piesegcolour}
%\end{figure}
%\end{example}
@@ -3333,7 +4193,7 @@
%\centering
%\DTLpiechart{variable=\quantity}{fruit}{%
%\name=Name,\quantity=Quantity}
-%\caption{An Annotated Pie Chart}
+%\caption{An annotated pie chart}
%\end{figure}
%\end{verbatim}
%This produces \autoref{fig:pieannote}. (Note that the centre
@@ -3344,7 +4204,7 @@
%\renewcommand*{\DTLpieatendtikz}{%
%\draw[<-] (45:1.5cm) -- (40:2.5cm)node[right]{Apples};}
%\DTLpiechart{variable=\quantity}{fruit}{\name=Name,\quantity=Quantity}
-%\caption{An Annotated Pie Chart}
+%\caption{An annotated pie chart}
%\label{fig:pieannote}
%\end{figure}
%\end{example}
@@ -3600,7 +4460,7 @@
%\begin{figure}[htbp]
%\centering
%\DTLplot{groupa}{x=Height,y=Weight}
-%\caption{A Scatter Plot}
+%\caption{A scatter plot}
%\end{figure}
%\end{verbatim}
%This produces \autoref{fig:basicplot}.
@@ -3608,7 +4468,7 @@
%\begin{figure}[htbp]
%\centering
%\DTLplot{groupa}{x=Height,y=Weight}
-%\caption{A Scatter Plot}
+%\caption{A scatter plot}
%\label{fig:basicplot}
%\end{figure}
%
@@ -3618,7 +4478,7 @@
%\begin{figure}[htbp]
%\centering
%\DTLplot{groupa}{x=Height,y=Weight,style=lines}
-%\caption{A Line Plot}
+%\caption{A line plot}
%\end{figure}
%\end{verbatim}
%This produces \autoref{fig:basiclineplot}.
@@ -3626,7 +4486,7 @@
%\begin{figure}[htbp]
%\centering
%\DTLplot{groupa}{x=Height,y=Weight,style=lines}
-%\caption{A Line Plot}
+%\caption{A line plot}
%\label{fig:basiclineplot}
%\end{figure}
%\end{example}
@@ -3682,7 +4542,7 @@
%\begin{figure}[htbp]
%\centering
%\DTLplot{groupa,groupb}{x=Height,y=Weight,width=3in,height=3in}
-%\caption{A Scatter Plot}
+%\caption{A scatter plot}
%\end{figure}
%\end{verbatim}
%This produces \autoref{fig:2db}.
@@ -3690,9 +4550,9 @@
%\begin{figure}[htbp]
%\centering
%\DTLplot{groupa,groupb}{x=Height,y=Weight,width=3in,height=3in}
-%\caption{A Scatter Plot}
-%\end{figure}
+%\caption[A scatter plot (multiple datasets)]{A scatter plot}
%\label{fig:2db}
+%\end{figure}
%
%Now let's add a legend using the \setting{DTLplot}{legend} setting,
%with the legend labels "Group A" and "Group B",
@@ -3707,7 +4567,7 @@
%width=3in,height=3in,legend,legendlabels={Group A,Group B},
%xlabel={Height (m)},ylabel={Weight (kg)},box,
%xticpoints={1.54,1.55,1.56,1.57,1.58,1.59,1.60,1.61,1.62}}
-%\caption{A Scatter Plot}
+%\caption{A scatter plot}
%\end{figure}
%\end{verbatim}
%This produces \autoref{fig:legend}.
@@ -3718,7 +4578,7 @@
%width=3in,height=3in,legendlabels={Group A,Group B},
%xlabel={Height (m)},ylabel={Weight (kg)},box,
%xticpoints={1.54,1.55,1.56,1.57,1.58,1.59,1.60,1.61,1.62}}
-%\caption{A Scatter Plot}
+%\caption[A scatter plot (with a legend)]{A scatter plot}
%\label{fig:legend}
%\end{figure}
%\end{example}
@@ -3769,6 +4629,8 @@
%}
%\end{verbatim}
%So \autoref{fig:legend} now looks like \autoref{fig:annote}.
+%(Obviously, \cs{DTLplotatendtikz} needs to be redefined before
+%using \cs{DTLplot}.)
%
%\begin{figure}[htbp]
%\renewcommand*{\DTLplotatendtikz}{%
@@ -3780,7 +4642,9 @@
%width=3in,height=3in,legendlabels={Group A,Group B},box,
%xlabel={Height (m)},ylabel={Weight (kg)},
%xticpoints={1.54,1.55,1.56,1.57,1.58,1.59,1.60,1.61,1.62}}
-%\caption{A Scatter Plot}
+%\caption[A scatter plot (using the end plot hook to annotate the
+%plot)]{A scatter plot}
+%
%\label{fig:annote}
%\end{figure}
%\end{example}
@@ -4014,7 +4878,7 @@
%\pgfplotstreamend
%\pgfusepath{stroke}
%\end{tikzpicture}
-%\caption{Adding to a Plot Stream}
+%\caption{Adding to a plot stream}
%\end{figure}
%\end{verbatim}
%This produces \autoref{fig:plotstream}.
@@ -4028,7 +4892,7 @@
%\pgfplotstreamend
%\pgfusepath{stroke}
%\end{tikzpicture}
-%\caption{Adding to a Plot Stream}
+%\caption{Adding to a plot stream}
%\label{fig:plotstream}
%\end{figure}
%\end{example}
@@ -4068,35 +4932,35 @@
%\begin{verbatim}
%\begin{figure}[tbhp]
%\centering
-%% computer bounds
+% % computer bounds
%\DTLminforkeys{growth}{Time}{\minX}
%\DTLminforkeys{growth}{Experiment 1,Experiment 2}{\minY}
%\DTLmaxforkeys{growth}{Time}{\maxX}
%\DTLmaxforkeys{growth}{Experiment 1,Experiment 2}{\maxY}
-%% round x tick labels
+% % round x tick labels
%\setcounter{DTLplotroundXvar}{0}
-%% redefine \DTLplotatbegintikz to plot the data for Experiment 1
+% % redefine \DTLplotatbegintikz to plot the data for Experiment 1
%\renewcommand*{\DTLplotatbegintikz}{%
-%% set plot mark
+% % set plot mark
%\pgfplothandlermark{\color{green}\pgfuseplotmark{x}}
-%% start plot stream
+% % start plot stream
%\pgfplotstreamstart
-%% add data from Experiment 1 to plot stream
+% % add data from Experiment 1 to plot stream
%\DTLplotstream{growth}{Time}{Experiment 1}%
-%% end plot stream
+% % end plot stream
%\pgfplotstreamend
-%% stroke path
+% % stroke path
%\pgfusepath{stroke}
-%% add information to legend (no line is require so use \relax)
+% % add information to legend (no line is require so use \relax)
%\DTLaddtoplotlegend{\color{green}%
%\pgfuseplotmark{x}}{\relax}{Experiment 1}
%}
-%% now plot the data for Experiment 2
+% % now plot the data for Experiment 2
%\DTLplot{growth}{x=Time,y=Experiment 2,legend,
%width=3in,height=3in,bounds={\minX,\minY,\maxX,\maxY},
%xlabel={Time},ylabel={Log Count},
%legendlabels={Experiment 2}}
-%\caption{Time to Growth Data}
+%\caption{Time to growth data}
%\end{figure}
%\end{verbatim}
%This produces \autoref{fig:multikey}.
@@ -4133,12 +4997,14 @@
%width=3in,height=3in,bounds={\minX,\minY,\maxX,\maxY},
%xlabel={Time},ylabel={Log Count},
%legendlabels={Experiment 2}}
-%\caption{Time to Growth Data}
+%\caption[Time to growth data (plotting from the same database using
+%different keys)]{Time to growth data}
%\label{fig:multikey}
%\end{figure}
%\end{example}
%
-%\section{Bar Charts (\texorpdfstring{databar}{databar} package)}
+%\section{Bar Charts (\texorpdfstring{\sty{databar}}{databar}
+%package)}
%
%The \sty{databar} package provides commands for creating bar charts.
%It is not loaded by the \sty{datatool} package, so if you want to
@@ -4290,7 +5156,7 @@
%\begin{figure}[htbp]
%\centering
%\DTLbarchart{variable=\theQuantity}{fruit}{\theQuantity=Quantity}
-%\caption{A Basic Bar Chart}
+%\caption{A basic bar chart}
%\end{figure}
%\end{verbatim}
%This produces \autoref{fig:barchart}.
@@ -4298,7 +5164,7 @@
%\begin{figure}[htbp]
%\centering
%\DTLbarchart{variable=\theQuantity}{fruit}{\theQuantity=Quantity}
-%\caption{A Basic Bar Chart}
+%\caption{A basic bar chart}
%\label{fig:barchart}
%\end{figure}
%\end{example}
@@ -4457,7 +5323,7 @@
%\DTLbarchart{variable=\theQuantity,barlabel=\theName,%
%upperbarlabel=\theQuantity}{fruit}{%
%\theQuantity=Quantity,\theName=Name}
-%\caption{A Basic Bar Chart}
+%\caption{A bar chart}
%\end{figure}
%\end{verbatim}
%This produces \autoref{fig:annotebarchart}.
@@ -4468,7 +5334,7 @@
%\DTLbarchart{variable=\theQuantity,barlabel=\theName,
%upperbarlabel=\theQuantity}{fruit}{%
%\theQuantity=Quantity,\theName=Name}
-%\caption{A Bar Chart}
+%\caption[A bar chart (labelled)]{A bar chart}
%\label{fig:annotebarchart}
%\end{figure}
%\end{example}
@@ -4503,24 +5369,24 @@
%\begin{verbatim}
%\begin{figure}[htbp]
%\centering
-%% Set the width of each bar to 10pt
+% % Set the width of each bar to 10pt
%\setlength{\DTLbarwidth}{10pt}
-%% Set the outline width to 1pt
+% % Set the outline width to 1pt
%\setlength{\DTLbaroutlinewidth}{1pt}
-%% Round the $y$ tick labels to integers
+% % Round the $y$ tick labels to integers
%\setcounter{DTLbarroundvar}{0}
-%% Adjust the tick label offset
+% % Adjust the tick label offset
%\setlength{\DTLticklabeloffset}{20pt}
-%% Change the y tick label alignment
+% % Change the y tick label alignment
%\renewcommand*{\DTLbarYticklabelalign}{left}
-%% Rotate the y tick labels
+% % Rotate the y tick labels
%\renewcommand*{\DTLbardisplayYticklabel}[1]{\rotatebox{-45}{#1}}
-%% Set the bar colours depending on the value of \theProfit
+% % Set the bar colours depending on the value of \theProfit
%\DTLforeach{profits}{\theProfit=Profit}{%
%\ifthenelse{\DTLislt{\theProfit}{0}}
%{\DTLsetbarcolor{\DTLcurrentindex}{red}}
%{\DTLsetbarcolor{\DTLcurrentindex}{blue}}}
-%% Do the bar chart
+% % Do the bar chart
%\DTLbarchart{variable=\theProfit,upperbarlabel=\theYear,
%ylabel={Profit/Loss (\pounds)},verticalbars=false,
%maxdepth=-2000,max=4000}{profits}
@@ -4597,7 +5463,8 @@
%maxdepth=-2000,max=4000
%}{profits}
%{\theProfit=Profit,\theYear=Year}
-%\caption{Profits for 2000--2003}
+%\caption[Profits for 2000--2003 (a horizontal bar chart)]{Profits for
+%2000--2003}
%\label{fig:profits}
%\end{figure}
%
@@ -4619,7 +5486,7 @@
%barlabel={\firstname\ \surname}}{marks}{%
%\surname=Surname,\firstname=FirstName,\assignI=Assignment 1,%
%\assignII=Assignment 2,\assignIII=Assignment 3}
-%\caption{Student Marks}
+%\caption{Student marks}
%\end{figure}
%\end{verbatim}
%This produces \autoref{fig:multibar}. Notes:
@@ -4642,7 +5509,8 @@
%barwidth=10pt,uppermultibarlabels={\assignI,\assignII,\assignIII},
%barlabel={\firstname\ \surname}}{marks}
%{\surname=Surname,\firstname=FirstName,\assignI=Assignment 1,\assignII=Assignment 2,\assignIII=Assignment 3}
-%\caption{Student Marks}\label{fig:multibar}
+%\caption[Student marks (a multi-bar chart)]{Student
+%marks}\label{fig:multibar}
%\end{figure}
%
%Recall that \autoref{ex:editdb} computed the average score over
@@ -4651,6 +5519,33 @@
%useful to compute the average over all students and add this
%information to the chart. This is done as follows:
%\begin{verbatim}
+% \begin{figure}[htbp]
+% \centering
+% % compute the overall mean
+% \DTLmeanforkeys{marks}{Average}{\overallmean}
+% % round it to 2 decimal places
+% \DTLround{\overallmean}{\overallmean}{2}
+% % draw a grey dotted line indicating the overall mean
+% % covering the entire width of the bar chart
+% \renewcommand*{\DTLbaratendtikz}{%
+% \draw[lightgray,loosely dotted] (0,\overallmean) --
+% (\DTLbarchartwidth,\overallmean)
+% node[right,black]{Average (\overallmean)};}
+% % Set the lower bar labels to draw a brace across the current
+% % group, along with the student's name and average score
+% \renewcommand*{\DTLdisplaylowerbarlabel}[1]{%
+% \tikz[baseline=(current bounding box.center)]{
+% \draw[snake=brace,rotate=-90](0,0) -- (\DTLbargroupwidth,0);}
+% \DTLround{\theMean}{\theMean}{2}%
+% \shortstack{#1\\(Average: \theMean)}}
+% % draw the bar chart
+% \DTLmultibarchart{variables={\assignI,\assignII,\assignIII},
+% barwidth=10pt,uppermultibarlabels={\assignI,\assignII,\assignIII},
+% barlabel={\firstname\ \surname}}{marks}
+% {\surname=Surname,\firstname=FirstName,\assignI=Assignment 1,%
+% \assignII=Assignment 2,\assignIII=Assignment 3,\theMean=Average}
+% \caption{Student marks}
+% \end{figure}
%\end{verbatim}
%which produces \autoref{fig:multibarmean}. Notes:
%\begin{enumerate}
@@ -4684,13 +5579,912 @@
%barwidth=10pt,uppermultibarlabels={\assignI,\assignII,\assignIII},
%barlabel={\firstname\ \surname}}{marks}
%{\surname=Surname,\firstname=FirstName,\assignI=Assignment 1,\assignII=Assignment 2,\assignIII=Assignment 3,\theMean=Average}
-%\caption{Student Marks (with average scores)}
+%\caption[Student marks (annotating a bar chart)]{Student marks}
%\label{fig:multibarmean}
%\end{figure}
%\end{example}
%
+%\section{Converting a \texorpdfstring{\BibTeX}{BibTeX} database
+%into a datatool database
+%(\texorpdfstring{\sty{databib}}{databib} package)}
+%\label{sec:databib}
+%
+%The \sty{databib} package provides the means of converting a \BibTeX\
+%database into a \sty{datatool} database. The database can then be
+%sorted using \cs{DTLsort}, described in \autoref{sec:sort}.
+%For example, you may want to sort the bibliography in
+%reverse chronological order. Once you have sorted the bibliography,
+%you can display it using \cs{DTLbibliography}, described in
+%\autoref{sec:thebib}, or you can iterate through the database
+%using \cs{DTLforeachbib}, described in \autoref{sec:foreachbib}.
+%
+%Note that the \sty{databib}
+%package is not automatically loaded by \sty{datatool}, so if
+%you want to use it, you must load it using
+%"\usepackage{databib}".
+%
+%\importantpar The purpose of this package is to provide a means for
+%authors to format their own bibliography style where there is no
+%bibliography style file available that produces the desired results.
+%The \cs{DTLsort} macro uses a much less efficient sorting algorithm
+%than \BibTeX, and loading the bibliography as a \sty{datatool}
+%database is much slower than loading a standard \ext{bbl} file. If
+%you have a large database, and you are worried that \LaTeX\ may have
+%become stuck, try using the \pkgopt{verbose} option to \sty{datatool}
+%or use the command \cs{dtlverbosetrue}. This will print informative
+%messages to the console and transcript file, to let you know what's
+%going on.
+%
+%\subsection{\texorpdfstring{\BibTeX}{BibTeX}: An Overview}
+%\label{sec:bibtex}
+%This document assumes that you have at least some passing
+%familiarity with \BibTeX, but here follows a brief refresher.
+%
+%\BibTeX\ is an external application used in conjunction with \LaTeX.
+%When you run \BibTeX, you need to specify the name of the document's
+%auxiliary file (without the \ext{aux} extension.) \BibTeX\ then reads
+%this file and looks for the commands \cs{bibstyle} (which indicates
+%which bibliography style (\ext{bst}) file to load), \cs{bibdata}
+%(which indicates which bibliography database (\ext{bib}) files to
+%load) and \cs{citation} (produced by \cs{cite} and \cs{nocite}, which
+%indicates which entries should be included in the bibliography.)
+%\BibTeX\ then creates a file with the extension \ext{bbl} which
+%contains the bibliography, formatted according to the layout defined
+%in the bibliography style file.
+%
+%In general, given a document called, say, \texttt{mydoc.tex}, you
+%will have to perform the following steps to ensure that the
+%bibliography and all citations are up-to-date:
+%\begin{enumerate}
+%\item
+%\begin{verbatim}
+%latex mydoc
+%\end{verbatim}
+%This writes the citation information to the auxiliary file.
+%The bibliography currently doesn't exists, so it isn't displayed.
+%Citations will appear in the document as ?? since the internal
+%cross-references don't exist yet.
+%
+%\item
+%\begin{verbatim}
+%bibtex mydoc
+%\end{verbatim}
+%This reads the auxiliary file, and creates a file with the extension
+%\ext{bbl} which typically contains the typeset bibliography.
+%
+%\item
+%\begin{verbatim}
+%latex mydoc
+%\end{verbatim}
+%Now that the \ext{bbl} file exists, the bibliography can be input
+%into the document. The internal cross-referencing information for the
+%bibliography can now be written to the auxiliary file.
+%
+%\item
+%\begin{verbatim}
+%latex mydoc
+%\end{verbatim}
+%The cross-referencing information can be read from the auxiliary
+%file.
+%\end{enumerate}
+%
+%\subsubsection{\texorpdfstring{\BibTeX}{BibTeX} database}
+%
+%The bibliographic data required by \BibTeX\ must be stored in
+%a file with the extension \ext{bib}, where each entry is stored
+%in the form:\par\vskip\baselineskip\noindent
+%{\obeylines
+%\noindent\texttt{@}\meta{entry\_type}\verb|{|\meta{cite\_key}\texttt,
+% \meta{field\_name} \texttt{=} \char`\"\meta{value}\char`\"\texttt,
+% \mbox{}\vdots
+% \meta{field\_name} \texttt{=} \char`\"\meta{value}\char`\"
+%\noindent\verb|}|
+%}
+%\par\vskip\baselineskip\noindent
+%Note that curly braces "{" and "}" may be used instead of \verb|"|
+%and \verb|"|.
+%
+%The entry type, given by \meta{entry\_type} above, indicates
+%the type of document. This may be one of: "article", "book",
+%"booklet", "inbook", "incollection", "inproceedings"\footnote
+%{Note that \texttt{conference} is a synonym for \texttt{inproceedings}.},
+%"manual",
+%"mastersthesis", "misc", "phdthesis", "proceedings", \linebreak
+%"techreport" or "unpublished".
+%
+%The \meta{cite\_key} above is a unique label identifying this
+%entry, and is the label used in the argument of \cs{cite} or
+%\cs{nocite}. The available fields depends on the entry type, for
+%example, the field "journal" is required for the "article" entry
+%type, but is ignored for the "inproceedings" entry type. The standard
+%fields are: "address", "author", "booktitle", "chapter", "edition",
+%"editor", "howpublished", "institution", "journal", "key", "month",
+%"note", "number", "organization", "pages", "publisher", "school",
+%"series", "title", "type", "volume" and "year".
+%
+%Author and editor names must be entered in one of the following
+%ways:
+%\begin{enumerate}
+%\item \meta{First names} \meta{von part} \meta{Surname}, \meta{Jr part}
+%
+%The \meta{von part} is optional and is identified by the name(s)
+%starting with lowercase letters. The final comma followed by
+%\meta{Jr part} is also optional. Examples:
+%\begin{verbatim}
+%author = "Henry James de Vere"
+%\end{verbatim}
+%In the above, the first names are Henry James, the ``von part'' is
+%de and the surname is Vere. There is no ``junior part''.
+%\begin{verbatim}
+%author = "Mary-Jane Brown, Jr"
+%\end{verbatim}
+%In the above, the first name is Mary-Jane, there is no von part,
+%the surname is Brown and the junior part is Jr.
+%\begin{verbatim}
+%author = "Peter {Murphy Allen}"
+%\end{verbatim}
+%In the above, the first name is Peter, and the surname is Murphy
+%Allen. Note that in this case, the surname must be grouped, otherwise
+%Murphy would be considered part of the forename.
+%\begin{verbatim}
+%author = "Maria Eliza {\uppercase{d}e La} Cruz"
+%\end{verbatim}
+%In the above, the first name is Maria Eliza, the von part is
+%De La, and the surname is Cruz. In this case, the von part starts
+%with an uppercase letter, but specifying
+%\begin{verbatim}
+%author = "Maria Eliza De La Cruz"
+%\end{verbatim}
+%would make \BibTeX\ incorrectly classify ``Maria Eliza De La'' as
+%the first names, and the von part would be empty. Since \BibTeX\
+%doesn't understand \LaTeX\ commands, using "{\uppercase{d}e La}"
+%will trick \BibTeX\ into thinking that it starts with a lower
+%case letter.
+%
+%\item \meta{von part} \meta{Surname}, \meta{Forenames}
+%
+%Again the \meta{von part} is optional, and is determined by the
+%case of the first letter. For example:
+%\begin{verbatim}
+%author = "de Vere, Henry James"
+%\end{verbatim}
+%\end{enumerate}
+%
+%Multiple authors or editors should be separated by the key word
+%"and", for example:
+%\begin{verbatim}
+%author = "Michel Goossens and Frank Mittlebach and Alexander Samarin"
+%\end{verbatim}
+%
+%Below is an example of a book entry:
+%\begin{verbatim}
+%@book{latexcomp,
+% title = "The \LaTeX\ Companion",
+% author = "Michel Goossens and Frank Mittlebach and
+% Alexander Samarin",
+% publisher = "Addison-Wesley",
+% year = 1994
+%}
+%\end{verbatim}
+%Note that numbers may be entered without delimiters, as in "year = 1994".
+%There are also some predefined strings, including those for the month
+%names. You should always use these strings instead of the actual
+%month name, as the way the month name is displayed depends on the
+%bibliography style. For example:
+%\begin{verbatim}
+%@article{Cawley2007b,
+%author = "Gavin C. Cawley and Nicola L. C. Talbot",
+%title = "Preventing over-fitting in model selection via {B}ayesian
+% regularisation of the hyper-parameters",
+%journal = "Journal of Machine Learning Research",
+%volume = 8,
+%pages = "841--861",
+%month = APR,
+%year = 2007
+%}
+%\end{verbatim}
+%
+%You can concatenate strings using the "#" character, for example:
+%\begin{verbatim}
+%month = JUL # "~31~--~" # AUG # "~4",
+%\end{verbatim}
+%Depending on the bibliography style, this may be displayed as:
+%July~31~--~August~4, or it may be displayed as:
+%Jul~31~--~Aug~4. For further information, see~\cite{Goossens}.
+%
+%\subsection{Loading a \texorpdfstring{\sty{databib}}{databib}
+%database}
+%\label{sec:loadbbl}
+%
+%The \sty{databib} package always requires the \texttt{databib.bst}
+%bibliography style file (which is supplied with this bundle.)
+%You need to use \cs{cite} or \cs{nocite} as usual. If you want to
+%add all entries in the \ext{bib} file to the \sty{datatool} database,
+%you can use "\nocite{*}".
+%
+%\DescribeMacro{\DTLloadbbl}
+%\begin{definition}
+%\cs{DTLloadbbl}\oarg{bbl name}\marg{db name}\marg{bib list}
+%\end{definition}
+%This command performs several functions:
+%
+%\begin{enumerate}
+%\item it writes the following line in the auxiliary file:
+%\begin{verbatim}
+%\bibstyle{databib}
+%\end{verbatim}
+%which tells \BibTeX\ to use the \texttt{databib.bst}
+%\BibTeX\ style file,
+%
+%\item it writes \cs{bibdata}\marg{bib list} to the
+%auxiliary file, which tells \BibTeX\ which \ext{bib} files to use,
+%
+%\item it creates a \sty{datatool} database called \meta{db name},
+%
+%\item it loads the file \meta{bbl name} if it exists. (The value
+%defaults to \cs{jobname}".bbl", which is the usual name for
+%a \ext{bbl} file.) If the \ext{bbl} file doesn't exist, the
+%database \meta{db name} will remain empty.
+%\end{enumerate}
+%
+%You then need to run your document through \LaTeX\ (or PDF\LaTeX)
+%and then run \BibTeX\ on the auxiliary file, as described in
+%\autoref{sec:bibtex}. This will create a \ext{bbl} file which
+%contains all the commands required to add the bibliography information
+%to the \sty{datatool} database called \meta{db name}. The next
+%time you \LaTeX\ your document, this file will be read, and the
+%information will be added to \meta{db name}.
+%
+%\importantpar Note that
+%\cs{DTLloaddb} doesn't generate any text. Once you have loaded
+%the data, you can display the bibliography uses
+%\cs{DTLbibliography} (described below) or you can iterate
+%through it using \cs{DTLforeachbibentry} described in
+%\autoref{sec:foreachbib}.
+%
+%Note that the \texttt{databib.bst} \BibTeX\ style file provides
+%the following additional fields: "isbn", "doi", "pubmed", "url"
+%and "abstract".
+%However these fields are ignored by the three predefined
+%\sty{databib} styles ("plain", "abbrv" and "alpha".) If you
+%want these fields to be displayed in the bibliography you will
+%need to modify the bibliography style (see \autoref{sec:modbibstyle}.)
+%
+%\subsection{Displaying a \texorpdfstring{\sty{databib}}{databib}
+%database}
+%\label{sec:thebib}
+%
+%A \sty{databib} database which has been loaded using
+%\cs{DTLloaddb} (described in \autoref{sec:loadbbl}) can be
+%displayed using:
+%\begin{definition}
+%\cs{DTLbibliography}\oarg{conditions}\marg{db name}
+%\end{definition}\noindent
+%where \meta{db name} is the name of the database.
+%
+%Within the optional argument \meta{condition}, you may use any of the
+%commands that may be used within the optional argument of
+%\cs{DTLforeach} \emph{In addition}, you may use the following
+%commands:
+%
+%\DescribeMacro{\DTLbibfieldexists}
+%\begin{definition}
+%\cs{DTLbibfieldexists}\marg{field label}
+%\end{definition}
+%This tests whether the field with the given label exists for the
+%current entry.
+%The field label may be one of: "Address", "Author",
+%"BookTitle", "Chapter", "Edition", "Editor", "HowPublished",
+%"Institution", "Journal", "Key", "Month", "Note", "Number",
+%"Organization", "Pages", "Publisher", "School", "Series",
+%"Title", "Type", "Volume", "Year", "ISBN", "DOI", "PubMed",
+%"Abstract" or "Url".
+%
+%For example, suppose you have loaded a \sty{databib} database
+%called "mybib" using \cs{DTLloadbbl} (described in
+%\autoref{sec:loadbbl}) then the following bibliography will only
+%include those entries which have a "Year" field:
+%\begin{verbatim}
+%\DTLbibliography[\DTLbibfieldexists{Year}]{mybib}
+%\end{verbatim}
+%
+%\DescribeMacro{\DTLbibfieldiseq}
+%\begin{definition}
+%\cs{DTLbibfieldiseq}\marg{field label}\marg{value}
+%\end{definition}
+%This tests whether the value of the field given by
+%\meta{field label} equals \meta{value}. If the field doesn't
+%exist for the current entry, this evaluates to false.
+%For example, the following will produce a bibliography which
+%only contains entries which have the "Year" field set to 2004:
+%\begin{verbatim}
+%\DTLbibliography[\DTLbibfieldiseq{Year}{2004}]{mybib}
+%\end{verbatim}
+%
+%\DescribeMacro{\DTLbibfieldcontains}
+%\begin{definition}
+%\cs{DTLbibfieldcontains}\marg{field label}\marg{sub string}
+%\end{definition}
+%This tests whether the value of the field given by \meta{field label}
+%contains \meta{sub string}. For example, the following will produce
+%a bibliography which only contains entries where the author field
+%contains the name "Knuth":
+%\begin{verbatim}
+%\DTLbibliography[\DTLbibfieldcontains{Author}{Knuth}]{mybib}
+%\end{verbatim}
+%
+%\DescribeMacro{\DTLbibfieldislt}
+%\begin{definition}
+%\cs{DTLbibfieldislt}\marg{field label}\marg{value}
+%\end{definition}
+%This tests whether the value of the field given by \meta{field label}
+%is less than \meta{value}. If the field doesn't exist for the
+%current entry, this evaluates to false.
+%For example, the following will produce a bibliography which only
+%contains entries whose "Year" field is less than 1983:
+%\begin{verbatim}
+%\DTLbibliography[\DTLbibfieldislt{Year}{1983}]{mybib}
+%\end{verbatim}
+%
+%\DescribeMacro{\DTLbibfieldisle}
+%\begin{definition}
+%\cs{DTLbibfieldisle}\marg{field label}\marg{value}
+%\end{definition}
+%This tests whether the value of the field given by \meta{field label}
+%is less than or equal to \meta{value}. If the field doesn't exist
+%for the current entry, this evaluates to false.
+%For example, the following will produce a bibliography which only
+%contains entries whose "Year" field is less than or equal to 1983:
+%\begin{verbatim}
+%\DTLbibliography[\DTLbibfieldisle{Year}{1983}]{mybib}
+%\end{verbatim}
+%
+%\DescribeMacro{\DTLbibfieldisgt}
+%\begin{definition}
+%\cs{DTLbibfieldisgt}\marg{field label}\marg{value}
+%\end{definition}
+%This tests whether the value of the field given by \meta{field label}
+%is greater than \meta{value}. If the field doesn't exist for the
+%current entry, this evaluates to false.
+%For example, the following will produce a bibliography which only
+%contains entries whose "Year" field is greater than 1983:
+%\begin{verbatim}
+%\DTLbibliography[\DTLbibfieldisgt{Year}{1983}]{mybib}
+%\end{verbatim}
+%
+%\DescribeMacro{\DTLbibfieldisge}
+%\begin{definition}
+%\cs{DTLbibfieldisge}\marg{field label}\marg{value}
+%\end{definition}
+%This tests whether the value of the field given by \meta{field label}
+%is greater than or equal to \meta{value}. If the field doesn't exist
+%for the current entry, this evaluates to false.
+%For example, the following will produce a bibliography which only
+%contains entries whose "Year" field is greater than or equal to 1983:
+%\begin{verbatim}
+%\DTLbibliography[\DTLbibfieldisge{Year}{1983}]{mybib}
+%\end{verbatim}
+%
+%Note that \cs{DTLbibliography} uses \cs{DTLforeachbibentry}
+%(described in \autoref{sec:foreachbib}) so you may also use
+%test the value of the counter \counterfmt{DTLbibrow} within
+%\meta{conditions}.
+%
+%\begin{example}{Creating a list of publications since a given year}{ex:bibsince2000}
+%Suppose my boss has asked me to produce a list of my
+%publications in reverse chronological order, but doesn't want any
+%publications published prior
+%to the year 2000. I have a file called "nlct.bib" which contains
+%all my publications which I keep in the directory
+%\verb!$HOME/texmf/bibtex/bib/!. I could look through this file,
+%work out the labels for all the publications whose year field
+%is greater or equal to 2000, and
+%create a file with a \cs{nocite} command containing all those labels
+%in a comma separated list in reverse chronological order,
+%but I really can't be bothered to do that.
+%Instead, I can create the following document:
+%\begin{verbatim}
+%\documentclass{article}
+%\usepackage{databib}
+%\begin{document}
+%\nocite{*}
+%\DTLloadbbl{mybib}{nlct}
+%\DTLsort{Year=descending,Month=descending}{mybib}
+%\DTLbibliography[\DTLbibfieldisge{Year}{2000}]{mybib}
+%\end{document}
+%\end{verbatim}
+%Suppose I save this file as "mypubs.tex", then I need to do:
+%\begin{verbatim}
+%latex mypubs
+%bibtex mypubs
+%latex mypubs
+%\end{verbatim}
+%Notes:
+%\begin{enumerate}
+%\item "\nocite{*}" is used to add all the citations in the
+%bibliography file ("nlct.bib" in this case) to the \sty{databib}
+%database.
+%
+%\item "\DTLloadbbl{mybib}{nlct}" does the following:
+%\begin{enumerate}
+%\item writes the line
+%\begin{verbatim}
+%\bibstyle{databib}
+%\end{verbatim}
+%to the auxiliary file. This tells \BibTeX\ to use "databib.bst"
+%(which is supplied with this package.) You therefore shouldn't
+%use \cs{bibliographystyle}.
+%
+%\item writes the line
+%\begin{verbatim}
+%\bibdata{nlct}
+%\end{verbatim}
+%to the auxiliary file. This tells \BibTeX\ that the bibliography
+%data is stored in the file "nlct.bib". Since I have placed this
+%file in \TeX's search path, \BibTeX\ will be able to find it.
+%
+%\item creates a \sty{datatool} database called "mybib".
+%
+%\item if the \ext{bbl} file ("mypubs.bbl" in this example) exists,
+%it loads this file (which adds the bibliography data to the
+%database), otherwise it does nothing further.
+%
+%\end{enumerate}
+%
+%\item In my \BibTeX\ database ("nlct.bib" in this example), I
+%have remember to use the \BibTeX\ month macros: "jan", "feb"
+%etc. This means that the months are stored in the database in
+%the form \cs{DTLmonthname}\marg{nn}, where \meta{nn} is a two
+%digit number from 01 to 12. \cs{DTLsort} ignores command names
+%when it compares strings, which means I can not only sort by
+%year, but also by month\footnote{as long as I haven't put anything
+%before the month name in the bibliography file, e.g.\
+%\mbox{\texttt{month = "2~" \# apr}} will sort by 2~03, instead of
+%03}.
+%
+%\item Once I have loaded and sorted my database, I can then
+%display it using \cs{DTLbibliography}. This uses the style
+%given by the \sty{databib} \pkgopt[databib]{style} package option,
+%or the \cs{DTLbibliographystyle} command, both of which are
+%described in \autoref{sec:bibstyle}.
+%
+%\item I have filtered the bibliography using the optional
+%argument\linebreak "[\DTLbibfieldisge{Year}{2000}]", which checks if the
+%year field of the current entry is greater than or equal to
+%2000. (Note that if an entry has no year field, the condition
+%evaluates to false, and the entry will be omitted from the
+%bibliography.)
+%
+%\item If the bibliography database is large, sorting and creating
+%the bibliography may take a while. Using \sty{databib} is much
+%slower than using a standard \BibTeX\ style file.
+%\end{enumerate}
+%\end{example}
+%
+%\begin{example}{Creating a list of my 10 most recent
+%publications}{ex:top10bib}
+%Suppose now my boss has asked me to produce a list of my ten most
+%recent publications (in reverse chronological order).
+%As in the previous example, I have a file called "nlct.bib"
+%which contains all my publications. I can create the required
+%document as follows:
+%\begin{verbatim}
+%\documentclass{article}
+%\usepackage{databib}
+%\begin{document}
+%\nocite{*}
+%\DTLloadbbl{mybib}{nlct}
+%\DTLsort{Year=descending,Month=descending}{mybib}
+%\DTLbibliography[\value{DTLbibrow}<11]{mybib}
+%\end{document}
+%\end{verbatim}
+%\end{example}
+%
+%\subsection{Changing the bibliography style}
+%\label{sec:bibstyle}
+%The style of the bibliography produced using \cs{DTLbibliography}
+%depends on the \pkgopt[databib]{style}
+%package option, or can be set using
+%\begin{definition}
+%\cs{DTLbibliographystyle}\marg{style}
+%\end{definition}
+%Note that this is \emph{not} the same as \cs{bibliographystyle},
+%as the \sty{databib} package uses its custom \texttt{databib.bst}
+%bibliography style file.
+%
+%Example:
+%\begin{verbatim}
+%\usepackage[style=plain]{databib}
+%\end{verbatim}
+%This sets the plain bibliography style. This is, in fact, the
+%default style, so it need not be specified.
+%
+%Available styles are: "plain", "abbrv" and "alpha". These are similar to the
+%standard \BibTeX\ styles of the same name, but are by no means
+%identical. The most notable difference is that these styles
+%do not sort the bibliography. It is up to you to sort the
+%bibliography using \cs{DTLsort} (described in \autoref{sec:sort}.)
+%
+%\subsubsection{Modifying an existing style}
+%\label{sec:modbibstyle}
+%
+%This section describes some of the commands which are used to
+%format the bibliography. You can choose whichever predefined
+%style best fits your required style, and then modify the commands
+%described in this section. A description of the remaining
+%commands not listed in this section can be found in
+%\autoref{sec:src:bibnames}, \autoref{sec:src:displaybib}
+%and \autoref{sec:src:bibstyle}.
+%
+%\DescribeMacro{\DTLformatauthor}
+%\begin{definition}
+%\cs{DTLformatauthor}\marg{von part}\marg{surname}\marg{jr part}\marg{forenames}
+%\end{definition}
+%\DescribeMacro{\DTLformateditor}
+%\begin{definition}
+%\cs{DTLformateditor}\marg{von part}\marg{surname}\marg{jr part}\marg{forenames}
+%\end{definition}
+%These commands are used to format an author/editor's name,
+%respectively. The list of authors and editors are stored in
+%the \sty{databib} database as a comma separated list of
+%\marg{von part}\marg{surname}\marg{jr part}\marg{forenames}
+%data. This ensures that when you sort on the Author or Editor
+%field, the names will be sorted by the first author or editor's
+%surname.
+%
+%Within \cs{DTLformatauthor} and \cs{DTLformateditor}, you may
+%use the following commands:
+%\DescribeMacro{\DTLformatforenames}
+%\begin{definition}
+%\cs{DTLformatforenames}\marg{forenames}
+%\end{definition}
+%This is used by the "plain" style to display the author's
+%forenames\footnote{It also checks
+%whether \meta{forenames} ends with a full stop using
+%\cs{DTLcheckendsperiod} to prevent a sentence ending full stop
+%from following an abbreviation full stop}.
+%
+%\DescribeMacro{\DTLformatabbrvforenames}
+%\begin{definition}
+%\cs{DTLformatabbrvforenames}\marg{forenames}
+%\end{definition}
+%This is used by the "abbrv" style to display the author's
+%initials (which are determined from \meta{forenames}.)
+%Note that if any of the authors has a name starting with an
+%accent, the accented letter must be grouped in order for this
+%command to work. For example:
+%\begin{verbatim}
+%author = "{\'E}lise {\"E}awyn Edwards",
+%\end{verbatim}
+%The initials are formed using \cs{DTLstoreinitials} described
+%in \autoref{sec:strings}, so if you want to change the way the
+%initials are displayed (e.g.\ put a space between them) you will
+%need to redefine the commands used by \cs{DTLstoreinitials} (such
+%as \cs{DTLbetweeninitials}.)
+%
+%\DescribeMacro{\DTLformatsurname}
+%\begin{definition}
+%\cs{DTLformatsurname}\marg{surname}
+%\end{definition}
+%This displays its argument by default\footnote{It also checks
+%whether the surname ends with a full stop using
+%\cs{DTLcheckendsperiod}}.
+%
+%\DescribeMacro{\DTLformatvon}
+%\begin{definition}
+%\cs{DTLformatvon}\marg{von part}
+%\end{definition}
+%If the \meta{von part} is empty, this command does nothing,
+%otherwise it displays its argument followed by a
+%non-breakable space.
+%\DescribeMacro{\DTLformatjr}
+%\begin{definition}
+%\cs{DTLformatjr}\marg{jr part}
+%\end{definition}
+%If the \meta{jr part} is empty, this command displays nothing,
+%otherwise it displays a comma followed by its argument\footnote
+%{again, it also checks \meta{jr part} to determine if it ends
+%with a full stop}.
+%
+%For example, suppose you want the author's surname to appear
+%first in small capitals, followed by a comma and the forenames. This
+%can be achieved by redefining \cs{DTLformatauthor} as follows:
+%\begin{verbatim}
+%\renewcommand*{\DTLformatauthor}[4]{%
+%\textsc{\DTLformatvon{#1}%
+%\DTLformatsurname{#2}\DTLformatjr{#3}},
+%\DTLformatforenames{#4}%
+%}
+%\end{verbatim}
+%
+%\begin{definition}
+%\counterfmt{DTLmaxauthors}
+%\end{definition}
+%The counter \counterfmt{DTLmaxauthors} is used to determine the
+%maximum number of authors to display for a given entry. If the
+%entry's author list contains more than that number of authors,
+%\cs{etalname} is used, the definition of which is given in
+%\autoref{sec:src:bibnames}. The default value of
+%\counterfmt{DTLmaxauthors} is \theDTLmaxauthors.
+%
+%\begin{definition}
+%\counterfmt{DTLmaxeditors}
+%\end{definition}
+%The \counterfmt{DTLmaxeditors} counter is analogous to the
+%\counterfmt{DTLmaxauthors} counter. It is used to determine the
+%maximum number of editor names to display. The default value
+%of \counterfmt{DTLmaxeditors} is \theDTLmaxeditors.
+%
+%\DescribeMacro{\DTLandlast}
+%Within a list of author or editor names, \cs{DTLandlast} is
+%used between the last two names, otherwise
+%\DescribeMacro{\DTLandnotlast}\cs{DTLandnotlast} is used between
+%names.
+%However, if there are only two author or editor names,
+%\DescribeMacro{\DTLtwoand}\cs{DTLtwoand}
+%is used instead of \cs{DTLandlast}.
+%
+%\DescribeMacro{\DTLendbibitem}
+%The command \cs{DTLendbibitem} is a hook provided to add
+%additional information at the end of each bibliography item.
+%This does nothing by default, but if you want to display the
+%additional fields provided by the "databib.bst" style file,
+%you can redefine \cs{DTLendbibitem} so that it displays a
+%particular field, if it is defined. Within this command, you
+%may use the commands \cs{DTLbibfield}, \cs{DTLifbibfieldexist}
+%and \cs{DTLifanybibfieldexist}, which are described in
+%\autoref{sec:foreachbib}. For example, if you have used the
+%"abstract" field in any of your entries, you can display the
+%abstract as follows:
+%\begin{verbatim}
+%\renewcommand{\DTLendbibitem}{%
+%\DTLifbibfieldexists{Abstract}{\DTLpar\textbf{Abstract}
+%\begin{quote}\DTLbibfield{Abstract}\end{quote}}{}}
+%\end{verbatim}
+%(Note that \cs{DTLpar} needs to be used instead of
+%\cs{par}.)
+%
+%\begin{example}{Compact bibliography}{ex:compactbib}
+%Suppose I don't have much space in my document, and I need to
+%produce a compact bibliography. Firstly, I can use the
+%bibliography style "abbrv", either through the package option:
+%\begin{verbatim}
+%\usepackage[style=abbrv]{databib}
+%\end{verbatim}
+%or using:
+%\begin{verbatim}
+%\DTLbibliographystyle{abbrv}
+%\end{verbatim}
+%Once I have set the style, I can further modify it thus:
+%\begin{verbatim}
+%\renewcommand*{\andname}{\&}
+%\renewcommand*{\editorname}{ed.}
+%\renewcommand*{\editorsname}{eds.}
+%\renewcommand*{\pagesname}{pp.}
+%\renewcommand*{\pagename}{p.}
+%\renewcommand*{\volumename}{vol.}
+%\renewcommand*{\numbername}{no.}
+%\renewcommand*{\editionname}{ed.}
+%\renewcommand*{\techreportname}{T.R.}
+%\renewcommand*{\mscthesisname}{MSc thesis}
+%\end{verbatim}
+%Now I can load\footnote{I can load the bibliography earlier, but
+%obviously the bibliography should only be displayed after the
+%bibliography styles have been set, otherwise they will have no
+%effect} and display the bibliography:
+%\begin{verbatim}
+% % create a database called mybib from the information given
+% % in mybib1.bib and mybib2.bib
+% \DTLloadbbl{mybib}{mybib1,mybib2}
+% % display the bibliography
+% \DTLbibliography{mybib}
+%\end{verbatim}
+%\end{example}
+%
+%\begin{example}{Highlighting a given author}{ex:highlightauthor}
+%Suppose my boss wants me to produce a list of all my publications
+%(which I have stored in the file "nlct.bib", as in
+%\autoref{ex:bibsince2000}.) Most of my
+%publications have multiple co-authors, but suppose my boss would
+%like me to highlight my name so that when he skims through
+%the document, he can easily see my name in the list of
+%co-authors. I can do this by redefining \cs{DTLformatauthor}
+%so that it checks if the given surname matches mine. (This
+%assumes that none of the other co-author's share my surname.)
+%\begin{verbatim}
+%\renewcommand*{\DTLformatauthor}[4]{%
+%{\DTLifstringeq{#2}{Talbot}{\bfseries }{}%
+%\DTLformatforenames{#4}
+%\DTLformatvon{#1}%
+%\DTLformatsurname{#2}%
+%\DTLformatjr{#3}}}
+%\end{verbatim}
+%Notes:
+%\begin{enumerate}
+%\item I have used \cs{DTLifstringeq} (described in
+%\autoref{sec:ifconditions}) to perform the string comparison.
+%\item If one or more of my co-authors shared the same surname as
+%me, I would also have had to check the first name, however there
+%is regrettably a lack of consistency in my \ext{bib} file when
+%it comes to my forenames. Sometimes my name is given as
+%\texttt{Nicola L. C. Talbot}, sometimes the middle initials
+%are omitted, \texttt{Nicola Talbot}, or sometimes, just initials
+%are used, \texttt{N. L. C. Talbot}. This can cause problems
+%when checking the forenames, but as long as the other authors
+%who share the same surname as me, don't also share the same
+%first initial, I can use \cs{DTLifStartsWith} or \cs{DTLisPrefix},
+%which are described in \autoref{sec:ifconditions} and
+%\autoref{sec:ifthen}, respectively. Using the first approach
+%I can do:
+%\begin{verbatim}
+%\renewcommand*{\DTLformatauthor}[4]{%
+%{\DTLifstringeq{#2}{Talbot}{\DTLifStartsWith{#4}{N}{\bfseries }{}}{}%
+%\DTLformatforenames{#4}
+%\DTLformatvon{#1}%
+%\DTLformatsurname{#2}%
+%\DTLformatjr{#3}}}
+%\end{verbatim}
+%Using the second approach I can do:
+%\begin{verbatim}
+%\renewcommand*{\DTLformatauthor}[4]{%
+%{\ifthenelse{\DTLiseq{#2}{Talbot}\and
+%\DTLisPrefix{#4}{N}}{\bfseries }{}%
+%\DTLformatforenames{#4}
+%\DTLformatvon{#1}%
+%\DTLformatsurname{#2}%
+%\DTLformatjr{#3}}}
+%\end{verbatim}
+%
+%\item I have used a group to localise the effect of \cs{bfseries}.
+%\end{enumerate}
+%\end{example}
+%
+%\subsection{Iterating through a
+%\texorpdfstring{\sty{databib}}{databib} database}
+%\label{sec:foreachbib}
+%
+%\cs{DTLbibliography} (described in \autoref{sec:thebib}) may still
+%not meet your needs. For example, you may be required
+%to list journal papers and conference proceedings in separate
+%sections. In which case, you may find it easier to iterate through
+%the bibliography using:
+%\DescribeMacro{\DTLforeachbib}
+%\begin{definition}
+%\cs{DTLforeachbib}\oarg{condition}\marg{db name}\marg{text}
+%\end{definition}
+%\DescribeMacro{\DTLforeachbib*}
+%\begin{definition}
+%\cs{DTLforeachbib*}\oarg{condition}\marg{db name}\marg{text}
+%\end{definition}
+%This iterates through the \sty{databib} database called
+%\meta{db name} and does \meta{text} if \meta{condition} is met.
+%As with \cs{DTLforeach}, the starred version is read-only.
+%
+%For each row of the database, the following commands are set:
+%\begin{itemize}
+%\item \cs{DBIBcitekey} \DescribeMacro{\DBIBcitekey}This is the
+%unique label which identifies the current entry (as used in the
+%argument of \cs{cite} and \cs{nocite}.)
+%
+%\item \cs{DBIBentrytype} \DescribeMacro{\DBIBentrytype}This
+%is the current entry type, and will be one of: "article", "book",
+%"booklet", "inbook", "incollection", "inproceedings",
+%"manual", "mastersthesis", "misc", "phdthesis", "proceedings",
+%"techreport" or "unpublished". (Note that even if you used the
+%entry type "conference" in your \ext{bib} file, its entry type
+%will be set to "inproceedings".)
+%\end{itemize}
+%
+%The remaining fields may be accessed using:
+%\DescribeMacro{\DTLbibfield}
+%\begin{definition}
+%\cs{DTLbibfield}\marg{field label}
+%\end{definition}\noindent
+%where \meta{field label} may be one of: "Address", "Author",
+%"BookTitle", "Chapter", "Edition", "Editor", "HowPublished",
+%"Institution", "Journal", "Key", "Month", "Note", "Number",
+%"Organization", "Pages", "Publisher", "School", "Series",
+%"Title", "Type", "Volume", "Year", "ISBN", "DOI", "PubMed",
+%"Abstract" or "Url".
+%
+%You can determine if a field exists for a given entry using
+%\DescribeMacro{\DTLifbibfieldexists}
+%\begin{definition}
+%\cs{DTLifbibfieldexists}\marg{field label}\marg{true part}\marg{false
+%part}
+%\end{definition}
+%If the field given by \meta{field label} exists for the current
+%bibliography entry, it does \meta{true part}, otherwise it
+%does \meta{false part}.
+%
+%\DescribeMacro{\DTLifbibanyfieldexists}
+%\begin{definition}
+%\cs{DTLifanybibfieldexists}\marg{field label list}\marg{true
+%part}\marg{false part}
+%\end{definition}
+%This is similar to \cs{DTLifbibfieldexists} except that the
+%first argument is a list of field names. If one or more of
+%the fields given in \meta{field label list} exists for the
+%current bibliography item, this does \meta{true part}, otherwise
+%it does \meta{false part}.
+%
+%\DescribeMacro{\DTLformatbibentry}
+%\begin{definition}
+%\cs{DTLformatbibentry}
+%\end{definition}
+%This formats the bibliography entry for the current row. It
+%checks for the existence of the command
+%\cs{DTLformat}\meta{entry type}, where \meta{entry type}
+%is given by \cs{DBIBentrytype}. These commands are defined
+%by the bibliography style.
+%
+%\DescribeMacro{\DTLcomputewidestbibentry}
+%\begin{definition}
+%\cs{DTLcomputewidestbibentry}\marg{conditions}\marg{db
+%name}\marg{bib label}\marg{cmd}
+%\end{definition}
+%This computes the widest bibliography entry over all entries
+%satisfying \meta{conditions} in the database \meta{db name},
+%where the label is given by \meta{bib label}, and the result
+%is stored in \meta{cmd}, which may then be used in the
+%argument of the \env{thebibliography} environment.
+%
+%The counter \counterfmt{DTLbibrow} keeps track of the current
+%bibliography entry. This is reset at the start of each
+%\cs{DTLforeachbib} and is incremented if \meta{conditions}
+%is met.
+%
+%Within the optional argument \meta{condition}, you may use any of the
+%commands that may be used within the optional argument of
+%\cs{DTLbibliography}, described in \autoref{sec:thebib}.
+%
+%\begin{example}{Separate List of Journals and Conference Papers}{ex:jcbib}
+%Suppose now my boss has decided that I need to produce a list
+%of all my publications, but they need to be separated so that
+%all the journal papers appear in one section, and all the
+%conference papers appear in another section. The journal papers
+%need to be labelled [J1], [J2] and so on, while the conference
+%papers need to be labelled [C1], [C2] and so on. (My boss isn't
+%interested in any of my other publications!) Again, all my
+%publications are stored in the \BibTeX\ database "nlct.bib". The
+%following creates the required document:
+%\begin{verbatim}
+%\documentclass{article}
+%\usepackage{databib}
+%\begin{document}
+%\nocite{*}
+%\DTLloadbbl{mybib}{nlct}
+%
+%\renewcommand*{\refname}{Journal Papers}
+%\DTLcomputewidestbibentry{\equal{\DBIBentrytype}{article}}
+%{mybib}{J\theDTLbibrow}{\widest}
+%
+%\begin{thebibliography}{\widest}
+%\DTLforeachbibentry[\equal{\DBIBentrytype}{article}]{mybib}{%
+%\bibitem[J\theDTLbibrow]{\DBIBcitekey} \DTLformatbibentry}
+%\end{thebibliography}
+%
+%\renewcommand*{\refname}{Conference Papers}
+%\DTLcomputewidestbibentry{\equal{\DBIBentrytype}{inproceedings}}
+%{mybib}{C\theDTLbibrow}{\widest}
+%
+%\begin{thebibliography}{\widest}
+%\DTLforeachbibentry[\equal{\DBIBentrytype}{inproceedings}]{mybib}{%
+%\bibitem[C\theDTLbibrow]{\DBIBcitekey} \DTLformatbibentry}
+%\end{thebibliography}
+%
+%\end{document}
+%\end{verbatim}
+%\end{example}
+%
% \StopEventually{\clearpage\phantomsection
-%\addcontentsline{toc}{section}{Index}\PrintIndex}
+%\addcontentsline{toc}{section}{\refname}
+% \DTLbibliography{docbib}
+%\phantomsection
+%\addcontentsline{toc}{section}{Change History}\PrintChanges
+%\phantomsection
+%\addcontentsline{toc}{section}{Index}\PrintIndex
+%}
%
%
%
@@ -4703,7 +6497,7 @@
%\subsection{Package Declaration}
% \begin{macrocode}
\NeedsTeXFormat{LaTeX2e}
-\ProvidesPackage{datatool}[2007/07/23 v1.0 (NLCT)]
+\ProvidesPackage{datatool}[2007/08/17 v1.01 (NLCT)]
% \end{macrocode}
% Load required packages:
% \begin{macrocode}
@@ -4715,18 +6509,21 @@
% \end{macrocode}
%
%\subsection{Package Options}
-% Define macro to store data separator character (comma by default)
+%\begin{macro}{\@dtl@separator}
+% The data separator character (comma by default) is stored in
+% \cs{@dtl@separator}.
% This is the separator used in external data files, not in the
% \LaTeX\ code, which always uses a comma separator.
-%\begin{macro}{\@dtl@separator}
% \begin{macrocode}
\newcommand*{\@dtl@separator}{,}
% \end{macrocode}
%\end{macro}
-% Provide a command for setting the data separator. This sets
-% \cs{@dtl@separator}, and constructs the relevent macros that
-% require this character to be hardcoded into their definition.
%\begin{macro}{\DTLsetseparator}
+%\begin{definition}
+%\cs{DTLsetseparator}\marg{char}
+%\end{definition}
+% The sets \cs{@dtl@separator}, and constructs the relevent macros
+% that require this character to be hardcoded into their definition.
% \begin{macrocode}
\newcommand*{\DTLsetseparator}[1]{%
\renewcommand*{\@dtl@separator}{#1}%
@@ -4734,8 +6531,9 @@
}
% \end{macrocode}
%\end{macro}
-% Make it easier to set a tab separator
%\begin{macro}{\DTLsettabseparator}
+%\cs{DTLsettabseparator} makes it easier to set a tab separator.
+% \begin{macrocode}
\begingroup
\catcode`\ 12
\gdef\DTLsettabseparator{%
@@ -4743,12 +6541,13 @@
\DTLsetseparator{ }%
}
\endgroup
+% \end{macrocode}
%\end{macro}
%
-% Define a macro to store data delimiter character (double quote
-% by default.) This is used in external data files, not in the
-% \LaTeX\ code.
%\begin{macro}{\@dtl@delimiter}
+% The data delimiter character (double quote by default) is stored
+% in \cs{@dtl@delimiter}. This is used in external data files, not
+% in the \LaTeX\ code.
% \begin{macrocode}
\begingroup
\catcode`\"12\relax
@@ -4756,19 +6555,27 @@
\endgroup
% \end{macrocode}
%\end{macro}
-% Define a macro that sets the delimiter.
%\begin{macro}{\DTLsetdelimiter}
+%\begin{definition}
+%\cs{DTLsetdelimiter}\marg{char}
+%\end{definition}
+% This sets the delimiter.
% \begin{macrocode}
\newcommand*\DTLsetdelimiter[1]{%
\renewcommand*{\@dtl@delimiter}{#1}%
\@dtl@construct@lopoffs}
% \end{macrocode}
%\end{macro}
-% \cs{@dtl@construct@lopoff}\meta{separator char}\meta{delimiter char}
-% defines
-% \cs{@dtl@lopoff}\meta{first element}\meta{sep}\meta{rest of list}\cs{to}\meta{cmd1}\meta{cmd2}
-% for the current separator and delimiter.
+%
%\begin{macro}{\@dtl@construct@lopoff}
+%\begin{definition}
+%\cs{@dtl@construct@lopoff}\meta{separator char}\meta{delimiter char}
+%\end{definition}
+% This defines
+%\begin{definition}
+% \cs{@dtl@lopoff}\meta{first element}\meta{sep}\meta{rest of list}\cs{to}\meta{cmd1}\meta{cmd2}
+%\end{definition}\noindent
+%for the current separator and delimiter.
% \begin{macrocode}
\edef\@dtl@construct@lopoff#1#2{%
\noexpand\long\noexpand\def\noexpand\@dtl@lopoff#1##1##2\noexpand
@@ -4781,13 +6588,13 @@
}}
% \end{macrocode}
%\end{macro}
-% Define command to construct macro \cs{@dtl@qlopoff} to be used
-% when the entry is surrounded by the current delimiter value.
-% Syntax:
+%
+%\begin{macro}{\@dtl@construct@qlopoff}
%\begin{definition}
% \cs{@dtl@construct@qlopoff}\meta{separator char}\meta{delimiter char}
%\end{definition}
-%\begin{macro}{\@dtl@construct@qlopoff}
+% This constructs \cs{@dtl@qlopoff} to be used
+% when the entry is surrounded by the current delimiter value.
% \begin{macrocode}
\edef\@dtl@construct@qlopoff#1#2{%
\noexpand\long\noexpand\def\noexpand\@dtl@qlopoff#1#2##1#2#1##2\noexpand
@@ -4796,13 +6603,12 @@
}}
% \end{macrocode}
%\end{macro}
-% Define command to construct macro \cs{@dtl@lop@ff} to be used when
-% the entry isn't surrouded by the delimiter.
-%Syntax:
+%\begin{macro}{\@dtl@construct@lop@ff}
%\begin{definition}
% \cs{@dtl@construct@lop@ff}\meta{separator char}
%\end{definition}
-%\begin{macro}{\@dtl@construct@lop@ff}
+% This constructs \cs{@dtl@lop@ff} to be used when
+% the entry isn't surrouded by the delimiter.
% \begin{macrocode}
\edef\@dtl@construct@lop@ff#1{%
\noexpand\long\noexpand\def\noexpand\@dtl@lop@ff#1##1#1##2\noexpand
@@ -4811,8 +6617,13 @@
}}
% \end{macrocode}
%\end{macro}
-% Construct all the lopoff macros.
+%
%\begin{macro}{\@dtl@construct@lopoffs}
+%\begin{definition}
+%\cs{@dtl@construct@lopoffs}
+%\end{definition}
+% This constructs all the lopoff macros
+% using the given separator and delimiter characters.
% \begin{macrocode}
\newcommand{\@dtl@construct@lopoffs}{%
\edef\@dtl@chars{{\@dtl@separator}{\@dtl@delimiter}}%
@@ -4822,24 +6633,26 @@
}
% \end{macrocode}
%\end{macro}
-% Define the decimal character
%\begin{macro}{\@dtl@decimal}
+% The current decimal character is stored in \cs{@dtl@decimal}.
% \begin{macrocode}
\newcommand*{\@dtl@decimal}{.}
% \end{macrocode}
%\end{macro}
-%Define the number group character
%\begin{macro}{\@dtl@numbergroupchar}
+% The current number group character is stored in
+% \cs{@dtl@numbergroupchar}.
% \begin{macrocode}
\newcommand*{\@dtl@numbergroupchar}{,}
% \end{macrocode}
%\end{macro}
+%
+%\begin{macro}{\DTLsetnumberchars}
%\begin{definition}
%\cs{DTLsetnumberchars}\marg{number group char}\marg{decimal char}
%\end{definition}
-% Sets the decimal character and number group
+% This sets the decimal character and number group
% characters.
-%\begin{macro}{\DTLsetnumberchars}
% \begin{macrocode}
\newcommand*{\DTLsetnumberchars}[2]{%
\renewcommand*{\@dtl@numbergroupchar}{#1}%
@@ -4849,9 +6662,13 @@
% \end{macrocode}
%\end{macro}
%
-% Construct macros for extracting integer and
+%\begin{macro}{\@dtl@construct@getintfrac}
+%\begin{definition}
+%\cs{@dtl@construct@getintfrac}\marg{char}
+%\end{definition}
+% This constructs the macros for extracting integer and
% fractional parts from a real number using the decimal character
-% given by "#1".
+% \meta{char}.
%
%\begin{definition}
% \cs{DTLconverttodecimal}\marg{num}\marg{cmd}
@@ -4862,8 +6679,6 @@
% number is stored in \meta{cmd}. This command has to be redefined
% whenever the decimal and number group characters are changed
% as they form part of the command definitions.
-%
-%\begin{macro}{\@dtl@construct@getintfrac}
% \begin{macrocode}
\edef\@dtl@construct@getintfrac#1{%
\noexpand\def\noexpand\@dtl@getintfrac##1#1##2\noexpand\relax{%
@@ -4895,17 +6710,19 @@
}
% \end{macrocode}
%\end{macro}
-% Define command to call the above with the relevant decimal
-% character:
%\begin{macro}{\@dtl@construct@getnums}
+% The following calls the above with the relevant
+% decimal character:
% \begin{macrocode}
\newcommand*{\@dtl@construct@getnums}{%
\expandafter\@dtl@construct@getintfrac\expandafter{\@dtl@decimal}}
% \end{macrocode}
%\end{macro}
-% Get the integer (adjusting for repeating +/- signs if neccessary)
-% Sets \cs{@dtl@intpart}.
+%
%\begin{macro}{\@dtl@get@intpart}
+% The following gets the integer part (adjusting for
+% repeating +/- signs if necessary.)
+% Sets \cs{@dtl@intpart}.
% \begin{macrocode}
\newcommand*{\@dtl@get@intpart}[1]{%
\@dtl@tmpcount=1\relax
@@ -4963,11 +6780,11 @@
% \end{macrocode}
%\end{macro}
%
+%\begin{macro}{\@dtl@choptrailingzeroes}
%\begin{definition}
% \cs{@dtl@choptrailingzeroes}\marg{cmd}
%\end{definition}
-% Chop trailing zeroes from number given by \meta{cmd}.
-%\begin{macro}{\@dtl@choptrailingzeroes}
+% Chops trailing zeroes from number given by \meta{cmd}.
% \begin{macrocode}
\newcommand*{\@dtl@choptrailingzeroes}[1]{%
\def\@dtl@tmpcpz{}%
@@ -4977,15 +6794,15 @@
% \end{macrocode}
%\end{macro}
%
+%\begin{macro}{\@dtl@chop@trailingzeroes}
% Trailing zeroes are chopped using a recursive algorithm.
% \cs{@dtl@tmpcpz} needs to be set before using this. (The chopped
% number is put in this control sequence.)
-%\begin{macro}{\@dtl@chop@trailingzeroes}
% \begin{macrocode}
\def\@dtl@chop@trailingzeroes#1#2\@nil{%
\FPifeq{#2}{0}%
\edef\@dtl@tmpcpz{\@dtl@tmpcpz#1}%
- \let\@dtl@chopzeroesnext=\@dtl@chop@trailingzeroesnoop
+ \let\@dtl@chopzeroesnext=\@dtl@gobbletonil
\else
\edef\@dtl@tmpcpz{\@dtl@tmpcpz#1}%
\let\@dtl@chopzeroesnext=\@dtl@chop@trailingzeroes
@@ -4994,19 +6811,19 @@
}
% \end{macrocode}
%\end{macro}
-% No-op macro to end recursion
-%\begin{macro}{\@dtl@chop@trailingzeroesnoop}
+% No-op macro to end recursion:
+%\begin{macro}{\@dtl@gobbletonil}
% \begin{macrocode}
-\def\@dtl@chop@trailingzeroesnoop#1\@nil{}
+\def\@dtl@gobbletonil#1\@nil{}
% \end{macrocode}
%\end{macro}
%
+%\begin{macro}{\dtl@truncatedecimal}
%\begin{definition}
%\cs{dtl@truncatedecimal}\meta{cmd}
%\end{definition}
-%Truncates decimal given by \meta{cmd} to an integer (assumes in
-% decimal format with full stop as decimal point)
-%\begin{macro}{\dtl@truncatedecimal}
+%Truncates decimal given by \meta{cmd} to an integer (assumes the
+% number is in decimal format with full stop as decimal point.)
% \begin{macrocode}
\newcommand*{\dtl@truncatedecimal}[1]{%
\expandafter\@dtl@truncatedecimal#1.\@nil#1}
@@ -5019,12 +6836,12 @@
% \end{macrocode}
%\end{macro}
%
+%\begin{macro}{\@dtl@strip@numgrpchar}
%\begin{definition}
% \cs{@dtl@strip@numgrpchar}\marg{cmd}
%\end{definition}
% Strip the number group character from the number given by
% \meta{cmd}.
-%\begin{macro}{\@dtl@strip@numgrpchar}
% \begin{macrocode}
\newcommand*{\@dtl@strip@numgrpchar}[1]{%
\def\@dtl@stripped{}%
@@ -5037,8 +6854,8 @@
% \end{macrocode}
%\end{macro}
%
-% Define command to construct macro \cs{@@dtl@strip@numgrpchar}
%\begin{macro}{\@dtl@construct@stripnumgrpchar}
+% The following macro constructs \cs{@@dtl@strip@numgrpchar}.
% \begin{macrocode}
\edef\@dtl@construct@stripnumgrpchar#1{%
\noexpand\def\noexpand\@@dtl@strip@numgrpchar##1#1##2\noexpand\relax{%
@@ -5058,13 +6875,13 @@
% \end{macrocode}
%\end{macro}
%
+%\begin{macro}{\DTLdecimaltolocale}
%\begin{definition}
% \cs{DTLdecimaltolocale}\marg{number}\marg{cmd}
%\end{definition}
% Define command to convert a decimal number into the locale
% dependent format. Stores result in \meta{cmd} which must be
% a control sequence.
-%\begin{macro}{\DTLdecimaltolocale}
% \begin{macrocode}
\newcommand*{\DTLdecimaltolocale}[2]{%
\edef\@dtl@tmpdtl{#1}%
@@ -5077,8 +6894,8 @@
}
% \end{macrocode}
%\end{macro}
-% Convert the integer part (store in \cs{@dtl@intpart})
%\begin{macro}{\@dtl@decimaltolocale}
+% Convert the integer part (store in \cs{@dtl@intpart})
% \begin{macrocode}
\def\@dtl@decimaltolocale#1.#2\relax{%
\@dtl@decimaltolocaleint{#1}%
@@ -5108,9 +6925,9 @@
}
% \end{macrocode}
%\end{macro}
+%\begin{macro}{\@dtl@countdigits}
% Counts the number of digits until "#2" is a full stop.
% (increments \cs{@dtl@tmpcount}.)
-%\begin{macro}{\@dtl@countdigits}
% \begin{macrocode}
\def\@dtl@countdigits#1#2\relax{%
\advance\@dtl@tmpcount by 1\relax
@@ -5147,8 +6964,8 @@
% \end{macrocode}
%\end{macro}
%
-% Convert the fractional part (store in \cs{@dtl@fracpart})
%\begin{macro}{\@dtl@decimaltolocalefrac}
+% Convert the fractional part (store in \cs{@dtl@fracpart})
% \begin{macrocode}
% \end{macrocode}
\def\@dtl@decimaltolocalefrac#1.\relax{%
@@ -5157,13 +6974,13 @@
}
%\end{macro}
%
+%\begin{macro}{\DTLdecimaltocurrency}
%\begin{definition}
% \cs{DTLdecimaltocurrency}\marg{number}\marg{cmd}
%\end{definition}
-% Define command to convert a decimal number into the locale
+% This converts a decimal number into the locale
% dependent currency format. Stores result in \meta{cmd} which must be
% a control sequence.
-%\begin{macro}{\DTLdecimaltocurrency}
% \begin{macrocode}
\newcommand*{\DTLdecimaltocurrency}[2]{%
\edef\@dtl@tmpdtl{#1}%
@@ -5223,27 +7040,26 @@
\define@boolkey{datatool.sty}[dtl]{verbose}[true]{%
\ifdtlverbose \FPmessagestrue\else \FPmessagesfalse\fi}
% \end{macrocode}
-% Display message only if verbose option set:
+%\begin{macro}{\dtl@message}
+%\begin{definition}
+%\cs{dtl@message}\marg{message string}
+%\end{definition}
+% Displays message only if the verbose option is set.
% \begin{macrocode}
\newcommand*{\dtl@message}[1]{%
-\ifdtlverbose \typeout{#1}\fi}
+\ifdtlverbose\typeout{#1}\fi}
% \end{macrocode}
+%\end{macro}
% Process package options:
% \begin{macrocode}
\ProcessOptionsX
% \end{macrocode}
-% Requires \texttt{compare.tex}, unless \cs{compare} has already
-% been defined. If paragraph breaks are allowed, these commands
-% need to be defined to be long.
-% \begin{macrocode}
-\@ifundefined{compare}{\input{compare}}{}
-% \end{macrocode}
%
-% Many of the commands used by this package are short commands
-% (such as \cs{compare}.) This means that you can't use \cs{par}
+%\begin{macro}{\DTLpar}
+% Many of the commands used by this package are short commands.
+% This means that you can't use \cs{par}
% in the data. To get around this, define the robust command
% \cs{DTLpar} to use instead.
-%\begin{macro}{\DTLpar}
% \begin{macrocode}
\DeclareRobustCommand\DTLpar{\@par}
% \end{macrocode}
@@ -5260,24 +7076,34 @@
\newcount\@dtl@datatype
% \end{macrocode}
%\end{macro}
-% Define temporary count register
%\begin{macro}{\@dtl@tmpcount}
+% Define temporary count register
% \begin{macrocode}
\newcount\@dtl@tmpcount
% \end{macrocode}
%\end{macro}
-% Define count register to count the digits between the number
-% group separator.
+%\begin{macro}{\dtl@tmplength}
+% Define temporary length register:
+% \begin{macrocode}
+\newlength\dtl@tmplength
+% \end{macrocode}
+%\end{macro}
+%
%\begin{macro}{\@dtl@numgrpsepcount}
+% Define count register to count the digits between the number
+% group separators.
% \begin{macrocode}
\newcount\@dtl@numgrpsepcount
% \end{macrocode}
%\end{macro}
%
-% Define a macro that checks if the argument is numerical
+%\begin{macro}{\@dtl@checknumerical}
+%\begin{definition}
+%\cs{@dtl@checknumerical}\marg{arg}
+%\end{definition}
+% Checks if \meta{arg} is numerical
% (includes decimal numbers, but not scientific notation.)
% Sets \cs{@dtl@datatype}, as described above.
-%\begin{macro}{\@dtl@checknumerical}
% \begin{macrocode}
\newcommand{\@dtl@checknumerical}[1]{%
\@dtl@numgrpsepfalse
@@ -5310,15 +7136,15 @@
}
% \end{macrocode}
%\end{macro}
+%\begin{macro}{\@dtl@checknumericalstart}
% Check first character for checknumerical process to see if
% it's a plus or minus sign.
-%\begin{macro}{\@dtl@checknumericalstart}
% \begin{macrocode}
\def\@dtl@checknumericalstart#1#2\@nil\@nil{%
\ifx#1\protect
\@dtl@checknumericalstart#2\@nil\@nil\relax
\else
- \if-#1\relax
+ \ifx-#1\relax
\def\@dtl@tmp{#2}%
\ifx\@empty\@dtl@tmp
\@dtl@datatype=0\relax
@@ -5329,7 +7155,7 @@
\@dtl@checknumericalstart#2\@nil\@nil\relax
\fi
\else
- \if+#1\relax
+ \ifx+#1\relax
\def\@dtl@tmp{#2}%
\ifx\@empty\@dtl@tmp
\@dtl@datatype=0\relax
@@ -5360,38 +7186,82 @@
}
% \end{macrocode}
%\end{macro}
+%\begin{macro}{\if@dtl@numgrpsep}
% The conditional \cs{if@dtl@numgrpsep} is set the first time
% \cs{@dtl@checknumericalloop} encounters the number group
% separator.
-%\begin{macro}{\if@dtl@numgrpsep}
% \begin{macrocode}
\newif\if@dtl@numgrpsep
% \end{macrocode}
%\end{macro}
+%\begin{macro}{\@dtl@ifDigitOrDecimalSep}
+% Check if argument is either a digit or the decimal separator.
+%\changes{1.01}{2007 Aug 17}{new}
+% \begin{macrocode}
+\newcommand*{\@dtl@ifDigitOrDecimalSep}[3]{%
+\ifx0#1\relax
+ #2%
+\else
+ \ifx1#1\relax
+ #2%
+ \else
+ \ifx2#1\relax
+ #2%
+ \else
+ \ifx3#1\relax
+ #2%
+ \else
+ \ifx4#1\relax
+ #2%
+ \else
+ \ifx5#1\relax
+ #2%
+ \else
+ \ifx6#1\relax
+ #2%
+ \else
+ \ifx7#1\relax
+ #2%
+ \else
+ \ifx8#1\relax
+ #2%
+ \else
+ \ifx9#1\relax
+ #2%
+ \else
+ \expandafter\ifx\@dtl@decimal#1\relax
+ #2%
+ \else
+ #3%
+ \fi
+ \fi
+ \fi
+ \fi
+ \fi
+ \fi
+ \fi
+ \fi
+ \fi
+ \fi
+\fi
+}
+% \end{macrocode}
+%\end{macro}
+%\begin{macro}{\@dtl@checknumericalloop}
% Check numerical loop. This iterates through each character
% until \cs{@nil} is reached, or invalid character found.
% Increments \cs{@dtl@tmpcount} each time it encounters a
-% decimal character.
-%\begin{macro}{\@dtl@checknumericalloop}
+% decimal character.\changes{1.01}{2007 Aug 17}{fixed bug caused
+% by commands occuring within text being tested}
% \begin{macrocode}
\def\@dtl@checknumericalloop#1#2\@nil{%
\def\@dtl@tmp{#1}%
\ifx\@nnil\@dtl@tmp\relax
\let\@dtl@chcknumnext=\@dtl@checknumericalnoop%
\else
- \ifthenelse{\equal{#1}{0}\or
- \equal{#1}{1}\or
- \equal{#1}{2}\or
- \equal{#1}{3}\or
- \equal{#1}{4}\or
- \equal{#1}{5}\or
- \equal{#1}{6}\or
- \equal{#1}{7}\or
- \equal{#1}{8}\or
- \equal{#1}{9}\or
- \equal{#1}{\@dtl@decimal}}{%
+ \@dtl@ifDigitOrDecimalSep{#1}{%
\let\@dtl@chcknumnext=\@dtl@checknumericalloop%
- \ifthenelse{\equal{#1}{\@dtl@decimal}}{%
+ \expandafter\ifx\@dtl@decimal#1\relax
\if@dtl@numgrpsep
\ifnum\@dtl@numgrpsepcount=3\relax
\@dtl@numgrpsepcount=-1\relax
@@ -5402,22 +7272,26 @@
\else
\@dtl@numgrpsepcount=-1\relax
\fi
- }{%
+ \else
\ifnum\@dtl@numgrpsepcount=-1\relax
\else
\advance\@dtl@numgrpsepcount by 1\relax
- \fi}%
-}{\ifthenelse{\equal{#1}{\@dtl@numbergroupchar}}{%
+ \fi
+ \fi
+}{%
+\ifx\@dtl@numbergroupchar\@dtl@tmp\relax
\@dtl@numgrpseptrue
\ifnum\@dtl@numgrpsepcount<3\relax
\@dtl@datatype=0\relax
\let\@dtl@chcknumnext=\@dtl@checknumericalnoop
\else
\@dtl@numgrpsepcount=0\relax
- \fi}{%
+ \fi
+\else
\@dtl@datatype=0\relax
\let\@dtl@chcknumnext=\@dtl@checknumericalnoop
-}}%
+\fi
+}%
\ifx\@dtl@decimal\@dtl@tmp\relax
\ifnum\@dtl@datatype<3\relax
\@dtl@datatype=2\relax
@@ -5433,16 +7307,19 @@
}
% \end{macrocode}
%\end{macro}
-% End loop
%\begin{macro}{\@dtl@checknumericalnoop}
+% End loop
% \begin{macrocode}
\def\@dtl@checknumericalnoop#1\@nil#2{}
% \end{macrocode}
%\end{macro}
%
-% Define \cs{DTLifnumerical} which tests the first argument, if
-% its numerical do second argument, otherwise do third argument.
%\begin{macro}{\DTLifnumerical}
+%\begin{definition}
+%\cs{DTLifnumerical}\marg{arg}\marg{true part}\marg{false part}
+%\end{definition}
+% Tests the first argument, if
+% its numerical do second argument, otherwise do third argument.
% \begin{macrocode}
\newcommand{\DTLifnumerical}[3]{%
\@dtl@checknumerical{#1}%
@@ -5451,10 +7328,13 @@
% \end{macrocode}
%\end{macro}
%
-% Define \cs{DTLifreal} which tests the first argument, if
+%\begin{macro}{\DTLifreal}
+%\begin{definition}
+%\cs{DTLifreal}\marg{arg}\marg{true part}\marg{false part}
+%\end{definition}
+% Tests the first argument, if
% it's a real number (not an integer) do second argument,
% otherwise do third argument.
-%\begin{macro}{\DTLifreal}
% \begin{macrocode}
\newcommand{\DTLifreal}[3]{%
\@dtl@checknumerical{#1}%
@@ -5463,10 +7343,13 @@
% \end{macrocode}
%\end{macro}
%
-% Define \cs{DTLifint} which tests the first argument, if
+%\begin{macro}{\DTLifint}
+%\begin{definition}
+%\cs{DTLifint}\marg{arg}\marg{true part}\marg{false part}
+%\end{definition}
+% Tests the first argument, if
% it's an integer do second argument,
% otherwise do third argument.
-%\begin{macro}{\DTLifint}
% \begin{macrocode}
\newcommand{\DTLifint}[3]{%
\@dtl@checknumerical{#1}%
@@ -5475,10 +7358,13 @@
% \end{macrocode}
%\end{macro}
%
-% Define \cs{DTLifstring} which tests the first argument, if
+%\begin{macro}{\DTLifstring}
+%\begin{definition}
+%\cs{DTLifstring}\marg{arg}\marg{true part}\marg{false part}
+%\end{definition}
+% Tests the first argument, if
% it's a string do second argument,
% otherwise do third argument.
-%\begin{macro}{\DTLifstring}
% \begin{macrocode}
\newcommand{\DTLifstring}[3]{%
\@dtl@checknumerical{#1}%
@@ -5487,10 +7373,13 @@
% \end{macrocode}
%\end{macro}
%
-% Define \cs{DTLifcurrency} which tests the first argument, if
+%\begin{macro}{\DTLifcurrency}
+%\begin{definition}
+%\cs{DTLifcurrency}\marg{arg}\marg{true part}\marg{false part}
+%\end{definition}
+% Tests the first argument, if
% it starts with the currency symbol do second argument,
% otherwise do third argument.
-%\begin{macro}{\DTLifcurrency}
% \begin{macrocode}
\newcommand{\DTLifcurrency}[3]{%
\@dtl@checknumerical{#1}%
@@ -5499,11 +7388,14 @@
% \end{macrocode}
%\end{macro}
%
-% Define \cs{DTLifcurrencyunit} which tests if the first argument
-% is currency, and uses the currency unit given by the
-% second argument. If true do third argument, otherwise
-% do fourth argument.
%\begin{macro}{\DTLifcurrencyunit}
+%\begin{definition}
+%\cs{DTLifcurrencyunit}\marg{arg}\marg{symbol}\marg{true
+% part}\marg{false part}
+%\end{definition}
+% This tests if \meta{arg} is currency, and uses the currency unit
+% \meta{symbol}. If true do third argument, otherwise
+% do fourth argument.
% \begin{macrocode}
\newcommand*{\DTLifcurrencyunit}[4]{%
\@dtl@checknumerical{#1}%
@@ -5516,11 +7408,15 @@
% \end{macrocode}
%\end{macro}
%
-% Define \cs{DTLifcasedatatype} which tests the first argument.
-% If it is a string, do second argument, if it is an integer
-% do third argument, if it is a real number, do fourth argument,
-% if it is currency, do fifth argument.
%\begin{macro}{\DTLifcasedatatype}
+%\begin{definition}
+%\cs{DTLifcasedatatype}\marg{arg}\marg{string case}\marg{int
+%case}\marg{real case}\marg{currency case}
+%\end{definition}
+% If \meta{arg} is a string, do \meta{string case}, if \meta{arg}
+% is an integer do \meta{int case}, if \meta{arg} is a real number,
+% do \meta{real case}, if \meta{arg} is currency, do \meta{curreny
+%case}.
% \begin{macrocode}
\newcommand{\DTLifcasedatatype}[5]{%
\@dtl@checknumerical{#1}%
@@ -5537,9 +7433,12 @@
% \end{macrocode}
%\end{macro}
%
-% Test if both arguments are numerical. This sets
-% the conditional \cs{if@dtl@condition}
%\begin{macro}{\dtl@testbothnumerical}
+%\begin{definition}
+%\cs{dtl@testbothnumerical}\marg{arg1}\marg{arg2}
+%\end{definition}
+% Tests if both arguments are numerical. This sets
+% the conditional \cs{if@dtl@condition}.
% \begin{macrocode}
\newcommand*{\dtl@testbothnumerical}[2]{%
\dtl@ifsingle{#1}{%
@@ -5561,13 +7460,13 @@
% \end{macrocode}
%\end{macro}
%
+%\begin{macro}{\DTLifnumlt}
%\begin{definition}
%\cs{DTLifnumlt}\marg{num1}\marg{num2}\marg{true part}\marg{false part}
%\end{definition}
-% Determine if \marg{num1} < \marg{num2}. Both numbers
+% Determines if \marg{num1} $<$ \marg{num2}. Both numbers
% need to have the decimal separator changed to a dot
% to ensure that it works with \cs{FPiflt}
-%\begin{macro}{\DTLifnumlt}
% \begin{macrocode}
\newcommand*{\DTLifnumlt}[4]{%
\DTLconverttodecimal{#1}{\@dtl@numi}%
@@ -5581,48 +7480,458 @@
% \end{macrocode}
%\end{macro}
%
+%\label{src:dtlcompare}
+%\begin{macro}{\dtlcompare}
%\begin{definition}
-%\cs{DTLifstringlt}\marg{string1}\marg{string2}\marg{true part}\marg{false part}
+%\cs{dtlcompare}\marg{count}\marg{string1}\marg{string2}
%\end{definition}
-% String comparison
-%\begin{macro}{\DTLifstringlt}
+% Compares \meta{string1} and \meta{string2}, and stores the
+% result in the count register \meta{count}. The result may be
+% one of:
+%\par\vskip\baselineskip\noindent
+%\begin{tabular}{rl}
+%-1 & if \meta{string1} is considered to be less than
+%\meta{string2}\\
+%0 & if \meta{string1} is considered to be the same as
+%\meta{string2}\\
+%1 & if \meta{string1} is considered to be greater than
+%\meta{string2}
+%\end{tabular}
+%\par\vskip\baselineskip\noindent
+%Note that for the purposes of string comparisons, commands within
+%\meta{string1} and \meta{string2} are ignored, except for
+%\cs{space} and "~", which are both treated as a space (character
+%code 32.) The following
+%examples assume that the count register \cs{mycount} has been
+%defined as follows:
+%\begin{verbatim}
+%\newcount\mycount
+%\end{verbatim}
+%\newcount\mycount\par\noindent
+%\textbf{Examples:}
+%\begin{enumerate}
+%\item
+%\begin{verbatim}
+%\dtlcompare{\mycount}{Z\"oe}{Zoe}\number\mycount
+%\end{verbatim}
+%produces:
+%\dtlcompare{\mycount}{Z\"oe}{Zoe}\number\mycount, since the accent
+%command is ignored.
+%
+%\item
+%\begin{verbatim}
+%\dtlcompare{\mycount}{foo}{Foo}\number\mycount
+%\end{verbatim}
+%produces:
+%\dtlcompare{\mycount}{foo}{Foo}\number\mycount, since the comparison
+%is case sensitive, however, note the following example:
+%\item
+%\begin{verbatim}
+%\dtlcompare{\mycount}{foo}{\uppercase{f}oo}\number\mycount
+%\end{verbatim}
+%which produces:
+%\dtlcompare{\mycount}{foo}{\uppercase{f}oo}\number\mycount, since
+%the \cs{uppercase} command is ignored.
+%
+%\item You can ``trick'' \cs{dtlcompare} using a command which doesn't
+%output any text. Suppose you have defined the following command:
+%\begin{verbatim}
+%\newcommand*{\noopsort}[1]{}
+%\end{verbatim}
+%\providecommand*{\noopsort}[1]{}
+%then "\noopsort{a}foo" produces the text: \noopsort{a}foo, however
+%the following
+%\begin{verbatim}
+%\dtlcompare{\mycount}{\noopsort{a}foo}{bar}\number\mycount
+%\end{verbatim}
+%produces:
+%\dtlcompare{\mycount}{\noopsort{a}foo}{bar}\number\mycount,
+%since the command \cs{noopsort} is disregarded when the comparison
+%is made, so \cs{dtlcompare} just compares "{a}foo" with "bar", and
+%since "a" is less than "b", the first string is considered to be less
+%than the second string.
+%
+%\item Note that this also means that:
+%\begin{verbatim}
+%\def\mystr{abc}%
+%\dtlcompare{\mycount}{\mystr}{abc}\number\mycount
+%\end{verbatim}
+%produces:
+%\def\mystr{abc}\relax
+%\dtlcompare{\mycount}{\mystr}{abc}\number\mycount, since the command
+%\cs{mystr} is disregarded, which means that \cs{dtlcompare} is
+%comparing an empty string with the string "abc".
+%
+%\item Spaces count in the comparison:
+%\begin{verbatim}
+%\dtlcompare{\mycount}{ab cd}{abcd}\number\mycount
+%\end{verbatim}
+%produces:
+%\dtlcompare{\mycount}{ab cd}{abcd}\number\mycount,
+%but sequential spaces are treated as a single space:
+%\begin{verbatim}
+%\dtlcompare{\mycount}{ab cd}{ab cd}\number\mycount
+%\end{verbatim}
+%produces:
+%\dtlcompare{\mycount}{ab cd}{ab cd}\number\mycount.
+%
+%\item As usual, spaces following command names are ignored, so
+%\begin{verbatim}
+%\dtlcompare{\mycount}{ab\relax cd}{ab cd}\number\mycount
+%\end{verbatim}
+%produces:
+%\dtlcompare{\mycount}{ab\relax cd}{ab cd}\number\mycount.
+%
+%\item "~" and \cs{space} are considered to be the same as a
+% space:
+%\begin{verbatim}
+%\dtlcompare{\mycount}{ab cd}{ab~cd}\number\mycount
+%\end{verbatim}
+%produces:
+%\dtlcompare{\mycount}{ab cd}{ab~cd}\number\mycount.
+%\end{enumerate}
+%\changes{1.01}{2007 Aug 17}{replaces \cs{compare} (no
+% longer using compare.tex)}
+% \begin{macrocode}
+\newcommand*{\dtlcompare}[3]{%
+\dtl@subnobrsp{#2}{\@dtl@argA}%
+\dtl@subnobrsp{#3}{\@dtl@argB}%
+\ifx\@dtl@argA\@empty
+ \ifx\@dtl@argB\@empty
+ #1=0\relax
+ \else
+ #1=-1\relax
+ \fi
+\else
+ \ifx\@dtl@argB\@empty
+ #1=1\relax
+ \else
+ \DTLsubstituteall{\@dtl@argA}{ }{\space }%
+ \DTLsubstituteall{\@dtl@argB}{ }{\space }%
+ \expandafter\dtl@getfirst\@dtl@argA\end
+ \let\dtl@firstA=\dtl@first
+ \let\dtl@restA=\dtl@rest
+ \expandafter\dtl@getfirst\@dtl@argB\end
+ \let\dtl@firstB=\dtl@first
+ \let\dtl@restB=\dtl@rest
+ \expandafter\dtl@ifsingle\expandafter{\dtl@firstA}{%
+ \expandafter\dtl@ifsingle\expandafter{\dtl@firstB}{%
+ \expandafter\dtl@setcharcode\expandafter{\dtl@firstA}{\dtl@codeA}%
+ \expandafter\dtl@setcharcode\expandafter{\dtl@firstB}{\dtl@codeB}%
+ \ifnum\dtl@codeA=-1\relax
+ \ifnum\dtl@codeB=-1\relax
+ \protected@edef\dtl@donext{%
+ \noexpand\dtlcompare{\noexpand#1}{\dtl@restA}{\dtl@restB}}%
+ \dtl@donext
+ \else
+ \protected@edef\dtl@donext{%
+ \noexpand\dtlcompare
+ {\noexpand#1}{\dtl@restA}{\dtl@firstB\dtl@restB}}%
+ \dtl@donext
+ \fi
+ \else
+ \ifnum\dtl@codeB=-1\relax
+ \protected@edef\dtl@donext{%
+ \noexpand\dtlcompare
+ {\noexpand#1}{\dtl@firstA\dtl@restA}{\dtl@restB}}%
+ \dtl@donext
+ \else
+ \ifnum\dtl@codeA<\dtl@codeB
+ #1=-1\relax
+ \else
+ \ifnum\dtl@codeA>\dtl@codeB
+ #1=1\relax
+ \else
+ \ifx\dtl@restA\@empty
+ \ifx\dtl@restB\@empty
+ #1=0\relax
+ \else
+ #1=-1\relax
+ \fi
+ \else
+ \ifx\restB\@empty
+ #1=1\relax
+ \else
+ \protected@edef\dtl@donext{%
+ \noexpand\dtlcompare
+ {\noexpand#1}{\dtl@restA}{\dtl@restB}}%
+ \dtl@donext
+ \fi
+ \fi
+ \fi
+ \fi
+ \fi
+ \fi
+ }{%
+ \protected@edef\dtl@donext{%
+ \noexpand\dtlcompare
+ {\noexpand#1}{\dtl@firstA\dtl@restA}{\dtl@firstB\dtl@restB}}%
+ \dtl@donext
+ }}{%
+ \protected@edef\dtl@donext{%
+ \noexpand\dtlcompare
+ {\noexpand#1}{\dtl@firstA\dtl@restA}{\dtl@firstB\dtl@restB}}%
+ \dtl@donext
+ }%
+ \fi
+\fi
+}
+% \end{macrocode}
+%\end{macro}
+%\begin{macro}{\dtl@getfirst}
+% Gets the first object, and stores in \cs{dtl@first}. The remainder
+% is stored in \cs{dtl@rest}.
% \begin{macrocode}
-\newcommand*{\DTLifstringlt}[4]{%
-\protected@edef\@dtl@tmpcmp{\noexpand\compare{#1}{#2}}%
- \expandafter\ifnum\@dtl@tmpcmp<0\relax
- #3%
+\def\dtl@getfirst#1#2\end{%
+\def\dtl@first{#1}%
+\ifx\dtl@first\@empty
+ \def\dtl@rest{#2}%
+\else
+ \dtl@ifsingle{#1}{\def\dtl@rest{#2}}{\dtl@getfirst#1#2\end}%
+\fi
+}
+% \end{macrocode}
+%\end{macro}
+% Count registers to store character codes:
+% \begin{macrocode}
+\newcount\dtl@codeA
+\newcount\dtl@codeB
+% \end{macrocode}
+%\begin{macro}{\dtl@setcharcode}
+%\begin{definition}
+%\cs{dtl@setcharcode}\marg{c}\marg{count register}
+%\end{definition}
+% Sets \meta{count register} to the character code of \meta{c}, or to
+% -1 if \meta{c} is a control sequence, unless \meta{c} is either
+% \cs{space} or |~| in which case it sets \meta{count register}
+% to the character code of the space character.
+% \begin{macrocode}
+\newcommand*{\dtl@setcharcode}[2]{%
+\def\@dtl@tmp{#1}%
+\ifx\@dtl@tmp\@empty
+ #2=-1\relax
+\else
+ \ifx#1\space\relax
+ #2=`\ \relax
\else
- #4%
+ \ifx#1~\relax
+ #2=`\ \relax
+ \else
+ \ifcat\noexpand#1\relax%
+ #2=-1\relax
+ \else
+ #2=`#1\relax
+ \fi
+ \fi
+ \fi
+\fi
+}
+% \end{macrocode}
+%\end{macro}
+%
+%\begin{macro}{\dtl@setlccharcode}
+%\begin{definition}
+%\cs{dtl@setlccharcode}\marg{c}\marg{count register}
+%\end{definition}
+% As \cs{dtl@setlccharcode} except it sets \meta{count register}
+% to the lower case character code of \meta{c}, unless \meta{c}
+% is a control sequence, in which case it does the same as
+% \cs{dtl@setcharcode}.
+% \begin{macrocode}
+\newcommand*{\dtl@setlccharcode}[2]{%
+\def\@dtl@tmp{#1}%
+\ifx\@dtl@tmp\@empty
+ #2=-1\relax
+\else
+ \ifx#1\space\relax
+ #2=`\ \relax
+ \else
+ \ifx#1~\relax
+ #2=`\ \relax
+ \else
+ \ifcat\noexpand#1\relax%
+ #2=-1\relax
+ \else
+ #2=\lccode`#1\relax
+ \fi
+ \fi
+ \fi
+\fi
+}
+% \end{macrocode}
+%\end{macro}
+%\begin{macro}{\dtlicompare}
+%\begin{definition}
+%\cs{dtlicompare}\marg{count}\marg{string1}\marg{string2}
+%\end{definition}
+% As \cs{dtlcompare} but ignores case.
+%\changes{1.01}{2007 Aug 17}{new}
+% \begin{macrocode}
+\newcommand*{\dtlicompare}[3]{%
+\dtl@subnobrsp{#2}{\@dtl@argA}%
+\dtl@subnobrsp{#3}{\@dtl@argB}%
+\ifx\@dtl@argA\@empty
+ \ifx\@dtl@argB\@empty
+ #1=0\relax
+ \else
+ #1=-1\relax
\fi
+\else
+ \ifx\@dtl@argB\@empty
+ #1=1\relax
+ \else
+ \DTLsubstituteall{\@dtl@argA}{ }{\space }%
+ \DTLsubstituteall{\@dtl@argB}{ }{\space }%
+ \expandafter\dtl@getfirst\@dtl@argA\end
+ \let\dtl@firstA=\dtl@first
+ \let\dtl@restA=\dtl@rest
+ \expandafter\dtl@getfirst\@dtl@argB\end
+ \let\dtl@firstB=\dtl@first
+ \let\dtl@restB=\dtl@rest
+ \expandafter\dtl@ifsingle\expandafter{\dtl@firstA}{%
+ \expandafter\dtl@ifsingle\expandafter{\dtl@firstB}{%
+ \expandafter\dtl@setlccharcode\expandafter{\dtl@firstA}{\dtl@codeA}%
+ \expandafter\dtl@setlccharcode\expandafter{\dtl@firstB}{\dtl@codeB}%
+ \ifnum\dtl@codeA=-1\relax
+ \ifnum\dtl@codeB=-1\relax
+ \protected@edef\dtl@donext{%
+ \noexpand\dtlicompare{\noexpand#1}{\dtl@restA}{\dtl@restB}}%
+ \dtl@donext
+ \else
+ \protected@edef\dtl@donext{%
+ \noexpand\dtlicompare
+ {\noexpand#1}{\dtl@restA}{\dtl@firstB\dtl@restB}}%
+ \dtl@donext
+ \fi
+ \else
+ \ifnum\dtl@codeB=-1\relax
+ \protected@edef\dtl@donext{%
+ \noexpand\dtlicompare
+ {\noexpand#1}{\dtl@firstA\dtl@restA}{\dtl@restB}}%
+ \dtl@donext
+ \else
+ \ifnum\dtl@codeA<\dtl@codeB
+ #1=-1\relax
+ \else
+ \ifnum\dtl@codeA>\dtl@codeB
+ #1=1\relax
+ \else
+ \ifx\dtl@restA\@empty
+ \ifx\dtl@restB\@empty
+ #1=0\relax
+ \else
+ #1=-1\relax
+ \fi
+ \else
+ \ifx\restB\@empty
+ #1=1\relax
+ \else
+ \protected@edef\dtl@donext{%
+ \noexpand\dtlicompare
+ {\noexpand#1}{\dtl@restA}{\dtl@restB}}%
+ \dtl@donext
+ \fi
+ \fi
+ \fi
+ \fi
+ \fi
+ \fi
+ }{%
+ \protected@edef\dtl@donext{%
+ \noexpand\dtlicompare
+ {\noexpand#1}{\dtl@firstA\dtl@restA}{\dtl@firstB\dtl@restB}}%
+ \dtl@donext
+ }}{%
+ \protected@edef\dtl@donext{%
+ \noexpand\dtlicompare
+ {\noexpand#1}{\dtl@firstA\dtl@restA}{\dtl@firstB\dtl@restB}}%
+ \dtl@donext
+ }%
+ \fi
+\fi
+}
+% \end{macrocode}
+%\end{macro}
+%
+%\begin{macro}{\DTLifstringlt}
+%\begin{definition}
+%\cs{DTLifstringlt}\marg{string1}\marg{string2}\marg{true part}\marg{false part}
+%\end{definition}
+% String comparison (Starred version ignores case)
+%\changes{1.01}{2007 Aug 17}{added starred version}
+% \begin{macrocode}
+\newcommand*{\DTLifstringlt}{\@ifstar\@sDTLifstringlt\@DTLifstringlt}
+% \end{macrocode}
+% Unstarred version
+% \begin{macrocode}
+\newcommand*{\@DTLifstringlt}[4]{%
+\protected@edef\@dtl@tmpcmp{%
+ \noexpand\dtlcompare{\noexpand\@dtl@tmpcount}{#1}{#2}}%
+\@dtl@tmpcmp
+\ifnum\@dtl@tmpcount<0\relax
+ #3%
+\else
+ #4%
+\fi
+}
+% \end{macrocode}
+% Starred version
+% \begin{macrocode}
+\newcommand*{\@sDTLifstringlt}[4]{%
+\protected@edef\@dtl@tmpcmp{%
+ \noexpand\dtlicompare{\noexpand\@dtl@tmpcount}{#1}{#2}}%
+\@dtl@tmpcmp
+\ifnum\@dtl@tmpcount<0\relax
+ #3%
+\else
+ #4%
+\fi
}
% \end{macrocode}
%\end{macro}
%
+%\begin{macro}{\DTLiflt}
%\begin{definition}
%\cs{DTLiflt}\marg{arg1}\marg{arg2}\marg{true part}\marg{false part}
%\end{definition}
-% Do \cs{DTLifnumlt} if both \meta{arg1} and \meta{arg2} are
-% numerical, otherwise do \cs{DTifstringlt}.
-%\begin{macro}{\DTLiflt}
+% Does \cs{DTLifnumlt} if both \meta{arg1} and \meta{arg2} are
+% numerical, otherwise do \cs{DTLifstringlt} (unstarred version)
+% or \cs{DTLifstringlt*} (starred version).
+%\changes{1.01}{2007 Aug 17}{added starred version}
+% \begin{macrocode}
+\newcommand*{\DTLiflt}{\@ifstar\@sDTLiflt\@DTLiflt}
+% \end{macrocode}
+% Unstarred version
+% \begin{macrocode}
+\newcommand*{\@DTLiflt}[4]{%
+\dtl@testbothnumerical{#1}{#2}%
+\if@dtl@condition
+ \DTLifnumlt{#1}{#2}{#3}{#4}%
+\else
+ \@DTLifstringlt{#1}{#2}{#3}{#4}%
+\fi
+}
+% \end{macrocode}
+% Starred version
% \begin{macrocode}
-\newcommand*{\DTLiflt}[4]{%
+\newcommand*{\@sDTLiflt}[4]{%
\dtl@testbothnumerical{#1}{#2}%
\if@dtl@condition
\DTLifnumlt{#1}{#2}{#3}{#4}%
\else
- \DTLifstringlt{#1}{#2}{#3}{#4}%
+ \@sDTLifstringlt{#1}{#2}{#3}{#4}%
\fi
}
% \end{macrocode}
%\end{macro}
%
+%\begin{macro}{\DTLifnumgt}
%\begin{definition}
%\cs{DTLifnumgt}\marg{num1}\marg{num2}\marg{true part}\marg{false part}
%\end{definition}
-% Determine if \marg{num1} > \marg{num2}. Both numbers
+% Determines if \marg{num1} $>$ \marg{num2}. Both numbers
% need to have the decimal separator changed to a dot
% to ensure that it works with \cs{FPifgt}
-%\begin{macro}{\DTLifnumgt}
% \begin{macrocode}
\newcommand*{\DTLifnumgt}[4]{%
\DTLconverttodecimal{#1}{\@dtl@numi}%
@@ -5636,48 +7945,84 @@
% \end{macrocode}
%\end{macro}
%
+%\begin{macro}{\DTLifstringgt}
%\begin{definition}
%\cs{DTLifstringgt}\marg{string1}\marg{string2}\marg{true part}\marg{false part}
%\end{definition}
-% String comparison
-%\begin{macro}{\DTLifstringgt}
+% String comparison (starred version ignores case)
+%\changes{1.01}{2007 Aug 17}{added starred version}
% \begin{macrocode}
-\newcommand*{\DTLifstringgt}[4]{%
-\protected@edef\@dtl@tmpcmp{\noexpand\compare{#1}{#2}}%
- \expandafter\ifnum\@dtl@tmpcmp>0\relax
- #3%
- \else
- #4%
- \fi
+\newcommand*{\DTLifstringgt}{\@ifstar\@sDTLifstringgt\@DTLifstringgt}
+% \end{macrocode}
+% Unstarred version
+% \begin{macrocode}
+\newcommand*{\@DTLifstringgt}[4]{%
+\protected@edef\@dtl@tmpcmp{%
+ \noexpand\dtlcompare{\noexpand\@dtl@tmpcount}{#1}{#2}}%
+\@dtl@tmpcmp
+\ifnum\@dtl@tmpcount>0\relax
+ #3%
+\else
+ #4%
+\fi
+}
+% \end{macrocode}
+% Starred version
+% \begin{macrocode}
+\newcommand*{\@sDTLifstringgt}[4]{%
+\protected@edef\@dtl@tmpcmp{%
+ \noexpand\dtlicompare{\noexpand\@dtl@tmpcount}{#1}{#2}}%
+\@dtl@tmpcmp
+\ifnum\@dtl@tmpcount>0\relax
+ #3%
+\else
+ #4%
+\fi
}
% \end{macrocode}
%\end{macro}
%
+%\begin{macro}{\DTLifgt}
%\begin{definition}
%\cs{DTLifgt}\marg{arg1}\marg{arg2}\marg{true part}\marg{false part}
%\end{definition}
-% Do \cs{DTLifnumgt} if both \meta{arg1} and \meta{arg2} are
-% numerical, otherwise do \cs{DTifstringgt}.
-%\begin{macro}{\DTLifgt}
+% Does \cs{DTLifnumgt} if both \meta{arg1} and \meta{arg2} are
+% numerical, otherwise do \cs{DTLifstringgt} or \cs{DTLifstringgt*}.
+%\changes{1.01}{2007 Aug 17}{added starred version}
+% \begin{macrocode}
+\newcommand*{\DTLifgt}{\@ifstar\@sDTLifgt\@DTLifgt}
+% \end{macrocode}
+% Unstarred version
+% \begin{macrocode}
+\newcommand*{\@DTLifgt}[4]{%
+\dtl@testbothnumerical{#1}{#2}%
+\if@dtl@condition
+ \DTLifnumgt{#1}{#2}{#3}{#4}%
+\else
+ \@DTLifstringgt{#1}{#2}{#3}{#4}%
+\fi
+}
+% \end{macrocode}
+% Starred version
% \begin{macrocode}
-\newcommand*{\DTLifgt}[4]{%
+\newcommand*{\@sDTLifgt}[4]{%
\dtl@testbothnumerical{#1}{#2}%
\if@dtl@condition
\DTLifnumgt{#1}{#2}{#3}{#4}%
\else
- \DTLifstringgt{#1}{#2}{#3}{#4}%
+ \@sDTLifstringgt{#1}{#2}{#3}{#4}%
\fi
}
% \end{macrocode}
%\end{macro}
%
+%\begin{macro}{\DTLifnumeq}
%\begin{definition}
%\cs{DTLifnumeq}\marg{num1}\marg{num2}\marg{true part}\marg{false part}
%\end{definition}
-% Determine if \marg{num1} = \marg{num2}. Both numbers
+% Determines if \marg{num1} = \marg{num2}. Both numbers
% need to have the decimal separator changed to a dot
% to ensure that it works with \cs{FPifeq}
-%\begin{macro}{\DTLifnumeq}
% \begin{macrocode}
\newcommand*{\DTLifnumeq}[4]{%
\DTLconverttodecimal{#1}{\@dtl@numi}%
@@ -5691,46 +8036,230 @@
% \end{macrocode}
%\end{macro}
%
+%\begin{macro}{\DTLifstringeq}
%\begin{definition}
%\cs{DTLifstringeq}\marg{string1}\marg{string2}\marg{true part}\marg{false part}
%\end{definition}
-% String comparison
-%\begin{macro}{\DTLifstringeq}
+% String comparison (starred version ignores case)
+%\changes{1.01}{2007 Aug 17}{added starred version}
% \begin{macrocode}
-\newcommand*{\DTLifstringeq}[4]{%
-\protected@edef\@dtl@tmpcmp{\noexpand\compare{#1}{#2}}%
- \expandafter\ifnum\@dtl@tmpcmp=0\relax
- #3%
- \else
- #4%
- \fi
+\newcommand*{\DTLifstringeq}{\@ifstar\@sDTLifstringeq\@DTLifstringeq}
+% \end{macrocode}
+% Unstarred version
+% \begin{macrocode}
+\newcommand*{\@DTLifstringeq}[4]{%
+\protected@edef\@dtl@tmpcmp{%
+ \noexpand\dtlcompare{\noexpand\@dtl@tmpcount}{#1}{#2}}%
+\@dtl@tmpcmp
+\ifnum\@dtl@tmpcount=0\relax
+ #3%
+\else
+ #4%
+\fi
+}
+% \end{macrocode}
+% Starred version
+% \begin{macrocode}
+\newcommand*{\@sDTLifstringeq}[4]{%
+\protected@edef\@dtl@tmpcmp{%
+ \noexpand\dtlicompare{\noexpand\@dtl@tmpcount}{#1}{#2}}%
+\@dtl@tmpcmp
+\ifnum\@dtl@tmpcount=0\relax
+ #3%
+\else
+ #4%
+\fi
}
% \end{macrocode}
%\end{macro}
%
+%\begin{macro}{\DTLifeq}
%\begin{definition}
%\cs{DTLifeq}\marg{arg1}\marg{arg2}\marg{true part}\marg{false part}
%\end{definition}
-% Do \cs{DTLifnumeq} if both \meta{arg1} and \meta{arg2} are
-% numerical, otherwise do \cs{DTifstringeq}.
-%\begin{macro}{\DTLifeq}
+% Does \cs{DTLifnumeq} if both \meta{arg1} and \meta{arg2} are
+% numerical, otherwise do \cs{DTLifstringeq} or \cs{DTLifstringeq*}.
+%\changes{1.01}{2007 Aug 17}{added starred version}
% \begin{macrocode}
-\newcommand*{\DTLifeq}[4]{%
+\newcommand*{\DTLifeq}{\@ifstar\@sDTLifeq\@DTLifeq}
+% \end{macrocode}
+% Unstarred version
+% \begin{macrocode}
+\newcommand*{\@DTLifeq}[4]{%
\dtl@testbothnumerical{#1}{#2}%
\if@dtl@condition
\DTLifnumeq{#1}{#2}{#3}{#4}%
\else
- \DTLifstringeq{#1}{#2}{#3}{#4}%
+ \@DTLifstringeq{#1}{#2}{#3}{#4}%
+\fi
+}
+% \end{macrocode}
+% Starred version
+% \begin{macrocode}
+\newcommand*{\@sDTLifeq}[4]{%
+\dtl@testbothnumerical{#1}{#2}%
+\if@dtl@condition
+ \DTLifnumeq{#1}{#2}{#3}{#4}%
+\else
+ \@sDTLifstringeq{#1}{#2}{#3}{#4}%
\fi
}
% \end{macrocode}
%\end{macro}
%
+%\begin{macro}{\DTLifSubString}
%\begin{definition}
-%\cs{DTLifnumclosedbetween}\marg{num}\marg{min}\marg{max}\marg{true part}\marg{false part}
+%\cs{DTLifSubString}\marg{string}\marg{sub string}\marg{true
+%part}\marg{false part}
%\end{definition}
-% Determine if \meta{min} $\leq$ \meta{num} $\leq$ \meta{max}.
+% If \meta{sub string} is contained in \meta{string} does
+%\meta{true part}, otherwise does \meta{false part}.
+%\changes{1.01}{2007 Aug 17}{new}
+% \begin{macrocode}
+\newcommand*{\DTLifSubString}[4]{%
+\protected@edef\@dtl@tmp{\noexpand\dtl@testifsubstring
+{#1}{#2}}%
+\@dtl@tmp
+\if@dtl@condition
+ #3%
+\else
+ #4%
+\fi
+}
+% \end{macrocode}
+%\end{macro}
+%\begin{macro}{\dtl@testifsubstring}
+% \begin{macrocode}
+\newcommand*{\dtl@testifsubstring}[2]{%
+\dtl@subnobrsp{#1}{\@dtl@argA}%
+\dtl@subnobrsp{#2}{\@dtl@argB}%
+\ifx\@dtl@argB\@empty
+ \@dtl@conditiontrue
+\else
+ \ifx\@dtl@argA\@empty
+ \@dtl@conditionfalse
+ \else
+ \dtl@teststartswith{#1}{#2}%
+ \if@dtl@condition
+ \else
+ \DTLsubstituteall{\@dtl@argA}{ }{\space }%
+ \expandafter\dtl@getfirst\@dtl@argA\end
+ \expandafter\dtl@ifsingle\expandafter{\dtl@first}{%
+ \expandafter\dtl@testifsubstring\expandafter{\dtl@rest}{#2}%
+ }{%
+ \protected@edef\@dtl@donext{\noexpand\dtl@testifsubstring
+ {\dtl@first\dtl@rest}{\@dtl@argB}}%
+ \@dtl@donext
+ }%
+ \fi
+ \fi
+\fi
+}
+% \end{macrocode}
+%\end{macro}
+%
+%\begin{macro}{\DTLifStartsWith}
+%\begin{definition}
+%\cs{DTLifStartsWith}\marg{string}\marg{substring}\marg{true
+%part}\marg{false part}
+%\end{definition}
+%If \meta{string} starts with \meta{substring}, this does
+%\meta{true part}, otherwise it does \meta{false part}.
+%\changes{1.01}{2007 Aug 17}{new}
+% \begin{macrocode}
+\newcommand*{\DTLifStartsWith}[4]{%
+\@dtl@conditionfalse
+\protected@edef\@dtl@tmp{\noexpand\dtl@teststartswith{#1}{#2}}%
+\@dtl@tmp
+\if@dtl@condition
+ #3%
+\else
+ #4%
+\fi
+}
+% \end{macrocode}
+%\end{macro}
+%
+%\begin{macro}{\dtl@teststartswith}
+%\begin{definition}
+%\cs{dtl@teststartswith}\marg{string}\marg{prefix}
+%\end{definition}
+% Tests if \meta{string} starts with \meta{prefix}. This sets
+% \cs{if@dtl@condition}.
+% \begin{macrocode}
+\newcommand*{\dtl@teststartswith}[2]{%
+\dtl@subnobrsp{#1}{\@dtl@argA}%
+\dtl@subnobrsp{#2}{\@dtl@argB}%
+\ifx\@dtl@argA\@empty
+ \ifx\@dtl@argB\@empty
+ \@dtl@conditiontrue
+ \else
+ \@dtl@conditionfalse
+ \fi
+\else
+ \ifx\@dtl@argB\@empty
+ \@dtl@conditiontrue
+ \else
+ \DTLsubstituteall{\@dtl@argA}{ }{\space }%
+ \DTLsubstituteall{\@dtl@argB}{ }{\space }%
+ \expandafter\dtl@getfirst\@dtl@argA\end
+ \let\dtl@firstA=\dtl@first
+ \let\dtl@restA=\dtl@rest
+ \expandafter\dtl@getfirst\@dtl@argB\end
+ \let\dtl@firstB=\dtl@first
+ \let\dtl@restB=\dtl@rest
+ \expandafter\dtl@ifsingle\expandafter{\dtl@firstA}{%
+ \expandafter\dtl@ifsingle\expandafter{\dtl@firstB}{%
+ \expandafter\dtl@setcharcode\expandafter{\dtl@firstA}{\dtl@codeA}%
+ \expandafter\dtl@setcharcode\expandafter{\dtl@firstB}{\dtl@codeB}%
+ \ifnum\dtl@codeA=-1\relax
+ \ifnum\dtl@codeB=-1\relax
+ \protected@edef\dtl@donext{%
+ \noexpand\dtl@teststartswith{\dtl@restA}{\dtl@restB}}%
+ \dtl@donext
+ \else
+ \protected@edef\dtl@donext{%
+ \noexpand\dtl@teststartswith
+ {\dtl@restA}{\dtl@firstB\dtl@restB}}%
+ \dtl@donext
+ \fi
+ \else
+ \ifnum\dtl@codeB=-1\relax
+ \protected@edef\dtl@donext{%
+ \noexpand\dtl@teststartswith
+ {\dtl@firstA\dtl@restA}{\dtl@restB}}%
+ \dtl@donext
+ \else
+ \ifnum\dtl@codeA=\dtl@codeB
+ \protected@edef\dtl@donext{%
+ \noexpand\dtl@teststartswith{\dtl@restA}{\dtl@restB}}%
+ \dtl@donext
+ \else
+ \@dtl@conditionfalse
+ \fi
+ \fi
+ \fi
+ }{%
+ \protected@edef\dtl@donext{%
+ \noexpand\dtl@teststartswith
+ {\dtl@firstA\dtl@restA}{\dtl@firstB\dtl@restB}}%
+ \dtl@donext
+ }}{%
+ \protected@edef\dtl@donext{%
+ \noexpand\dtl@teststartswith
+ {\dtl@firstA\dtl@restA}{\dtl@firstB\dtl@restB}}%
+ }%
+ \fi
+\fi
+}
+% \end{macrocode}
+%\end{macro}
+%
%\begin{macro}{\DTLifnumclosedbetween}
+%\begin{definition}
+%\cs{DTLifnumclosedbetween}\marg{num}\marg{min}\marg{max}\marg{true part}\marg{false part}
+%\end{definition}
+% Determines if \meta{min} $\leq$ \meta{num} $\leq$ \meta{max}.
% \begin{macrocode}
\newcommand*{\DTLifnumclosedbetween}[5]{%
\DTLconverttodecimal{#1}{\@dtl@numi}%
@@ -5741,21 +8270,54 @@
% \end{macrocode}
%\end{macro}
%
+%\begin{macro}{\DTLifstringclosedbetween}
%\begin{definition}
%\cs{DTLifstringclosedbetween}\marg{string}\marg{min}\marg{max}\marg{true part}\marg{false part}
%\end{definition}
-% String comparison
-%\begin{macro}{\DTLifstringclosedbetween}
+% String comparison (starred version ignores case)
+%\changes{1.01}{2007 Aug 17}{added starred version}
+% \begin{macrocode}
+\newcommand*{\DTLifstringclosedbetween}{%
+\@ifstar\@sDTLifstringclosedbetween\@DTLifstringclosedbetween}
+% \end{macrocode}
+% Unstarred version
% \begin{macrocode}
-\newcommand*{\DTLifstringclosedbetween}[5]{%
-\protected@edef\@dtl@tmpcmp{\noexpand\compare{#1}{#2}}%
+\newcommand*{\@DTLifstringclosedbetween}[5]{%
+\protected@edef\@dtl@tmpcmp{%
+ \noexpand\dtlcompare{\noexpand\@dtl@tmpcount}{#1}{#2}}%
+\@dtl@tmpcmp
\let\@dtl@dovalue\relax
-\expandafter\ifnum\@dtl@tmpcmp<0\relax
+\ifnum\@dtl@tmpcount<0\relax
+ \def\@dtl@dovalue{#5}%
+\fi
+\ifx\@dtl@dovalue\relax
+ \protected@edef\@dtl@tmpcmp{%
+ \noexpand\dtlcompare{\noexpand\@dtl@tmpcount}{#1}{#3}}%
+ \@dtl@tmpcmp
+ \ifnum\@dtl@tmpcount>0\relax
+ \def\@dtl@dovalue{#5}%
+ \else
+ \def\@dtl@dovalue{#4}%
+ \fi
+\fi
+\@dtl@dovalue
+}
+% \end{macrocode}
+% Starred version
+% \begin{macrocode}
+\newcommand*{\@sDTLifstringclosedbetween}[5]{%
+\protected@edef\@dtl@tmpcmp{%
+ \noexpand\dtlicompare{\noexpand\@dtl@tmpcount}{#1}{#2}}%
+\@dtl@tmpcmp
+\let\@dtl@dovalue\relax
+\ifnum\@dtl@tmpcount<0\relax
\def\@dtl@dovalue{#5}%
\fi
\ifx\@dtl@dovalue\relax
- \protected@edef\@dtl@tmpcmp{\noexpand\compare{#1}{#3}}%
- \expandafter\ifnum\@dtl@tmpcmp>0\relax
+ \protected@edef\@dtl@tmpcmp{%
+ \noexpand\dtlicompare{\noexpand\@dtl@tmpcount}{#1}{#3}}%
+ \@dtl@tmpcmp
+ \ifnum\@dtl@tmpcount>0\relax
\def\@dtl@dovalue{#5}%
\else
\def\@dtl@dovalue{#4}%
@@ -5766,14 +8328,21 @@
% \end{macrocode}
%\end{macro}
%
+%\begin{macro}{\DTLifclosedbetween}
%\begin{definition}
%\cs{DTLifclosedbetween}\marg{arg}\marg{min}\marg{max}\marg{true part}\marg{false part}
%\end{definition}
-% Do \cs{DTLifnumclosedbetween} if \marg{arg}, \meta{min} and \meta{max} are
-% numerical, otherwise do \cs{DTifstringclosedbetween}.
-%\begin{macro}{\DTLifclosedbetween}
+% Does \cs{DTLifnumclosedbetween} if \marg{arg}, \meta{min} and \meta{max} are
+% numerical, otherwise do \cs{DTLifstringclosedbetween}
+% or \cs{DTLifstringclosedbetween*}.
+%\changes{1.01}{2007 Aug 17}{added starred version}
+% \begin{macrocode}
+\newcommand*{\DTLifclosedbetween}{%
+\@ifstar\@sDTLifclosedbetween\@DTLifclosedbetween}
+% \end{macrocode}
+% Unstarred version
% \begin{macrocode}
-\newcommand*{\DTLifclosedbetween}[5]{%
+\newcommand*{\@DTLifclosedbetween}[5]{%
\dtl@testbothnumerical{#2}{#3}%
\if@dtl@condition
\dtl@ifsingle{#1}{%
@@ -5783,20 +8352,39 @@
\ifnum\@dtl@datatype>0\relax
\DTLifnumclosedbetween{#1}{#2}{#3}{#4}{#5}%
\else
- \DTLifstringclosedbetween{#1}{#2}{#3}{#4}{#5}%
+ \@DTLifstringclosedbetween{#1}{#2}{#3}{#4}{#5}%
\fi
\else
- \DTLifstringclosedbetween{#1}{#2}{#3}{#4}{#5}%
+ \@DTLifstringclosedbetween{#1}{#2}{#3}{#4}{#5}%
+\fi
+}
+% \end{macrocode}
+% Starred version
+% \begin{macrocode}
+\newcommand*{\@sDTLifclosedbetween}[5]{%
+\dtl@testbothnumerical{#2}{#3}%
+\if@dtl@condition
+ \dtl@ifsingle{#1}{%
+ \edef\@dtl@tmp{#1}}{%
+ \def\@dtl@tmp{#1}}%
+ \expandafter\@dtl@checknumerical\expandafter{\@dtl@tmp}%
+ \ifnum\@dtl@datatype>0\relax
+ \DTLifnumclosedbetween{#1}{#2}{#3}{#4}{#5}%
+ \else
+ \@sDTLifstringclosedbetween{#1}{#2}{#3}{#4}{#5}%
+ \fi
+\else
+ \@sDTLifstringclosedbetween{#1}{#2}{#3}{#4}{#5}%
\fi
}
% \end{macrocode}
%\end{macro}
%
+%\begin{macro}{\DTLifnumopenbetween}
%\begin{definition}
%\cs{DTLifnumopenbetween}\marg{num}\marg{min}\marg{max}\marg{true part}\marg{false part}
%\end{definition}
-% Determine if \meta{min} $<$ \meta{num} $<$ \meta{max}.
-%\begin{macro}{\DTLifnumopenbetween}
+% Determines if \meta{min} $<$ \meta{num} $<$ \meta{max}.
% \begin{macrocode}
\newcommand*{\DTLifnumopenbetween}[5]{%
\DTLconverttodecimal{#1}{\@dtl@numi}%
@@ -5807,22 +8395,56 @@
% \end{macrocode}
%\end{macro}
%
+%\begin{macro}{\DTLifstringopenbetween}
%\begin{definition}
%\cs{DTLifstringopenbetween}\marg{string}\marg{min}\marg{max}\marg{true part}\marg{false part}
%\end{definition}
-% String comparison
-%\begin{macro}{\DTLifstringopenbetween}
+% String comparison (starred version ignores case)
+%\changes{1.01}{2007 Aug 17}{added starred version}
+% \begin{macrocode}
+\newcommand*{\DTLifstringopenbetween}{%
+\@ifstar\@sDTLifstringopenbetween\@DTLifstringopenbetween}
+% \end{macrocode}
+% Unstarred version:
+% \begin{macrocode}
+\newcommand*{\@DTLifstringopenbetween}[5]{%
+\protected@edef\@dtl@tmpcmp{%
+ \noexpand\dtlcompare{\noexpand\@dtl@tmpcount}{#1}{#2}}%
+\@dtl@tmpcmp
+\let\@dtl@dovalue\relax
+\ifnum\@dtl@tmpcount>0\relax
+\else
+ \def\@dtl@dovalue{#5}%
+\fi
+\ifx\@dtl@dovalue\relax
+ \protected@edef\@dtl@tmpcmp{%
+ \noexpand\dtlcompare{\noexpand\@dtl@tmpcount}{#1}{#3}}%
+ \@dtl@tmpcmp
+ \ifnum\@dtl@tmpcount<0\relax
+ \def\@dtl@dovalue{#4}%
+ \else
+ \def\@dtl@dovalue{#5}%
+ \fi
+\fi
+\@dtl@dovalue
+}
+% \end{macrocode}
+% Starred version
% \begin{macrocode}
-\newcommand*{\DTLifstringopenbetween}[5]{%
-\protected@edef\@dtl@tmpcmp{\noexpand\compare{#1}{#2}}%
+\newcommand*{\@sDTLifstringopenbetween}[5]{%
+\protected@edef\@dtl@tmpcmp{%
+ \noexpand\dtlicompare{\noexpand\@dtl@tmpcount}{#1}{#2}}%
+\@dtl@tmpcmp
\let\@dtl@dovalue\relax
-\expandafter\ifnum\@dtl@tmpcmp>0\relax
+\ifnum\@dtl@tmpcount>0\relax
\else
\def\@dtl@dovalue{#5}%
\fi
\ifx\@dtl@dovalue\relax
- \protected@edef\@dtl@tmpcmp{\noexpand\compare{#1}{#3}}%
- \expandafter\ifnum\@dtl@tmpcmp<0\relax
+ \protected@edef\@dtl@tmpcmp{%
+ \noexpand\dtlicompare{\noexpand\@dtl@tmpcount}{#1}{#3}}%
+ \@dtl@tmpcmp
+ \ifnum\@dtl@tmpcount<0\relax
\def\@dtl@dovalue{#4}%
\else
\def\@dtl@dovalue{#5}%
@@ -5833,14 +8455,40 @@
% \end{macrocode}
%\end{macro}
%
+%\begin{macro}{\DTLifopenbetween}
%\begin{definition}
%\cs{DTLifopenbetween}\marg{arg}\marg{min}\marg{max}\marg{true part}\marg{false part}
%\end{definition}
-% Do \cs{DTLifnumopenbetween} if \marg{arg}, \meta{min} and \meta{max} are
-% numerical, otherwise do \cs{DTifstringopenbetween}.
-%\begin{macro}{\DTLifopenbetween}
+% Does \cs{DTLifnumopenbetween} if \marg{arg}, \meta{min} and \meta{max} are
+% numerical, otherwise do \cs{DTLifstringopenbetween}
+% or \cs{DTLifstringopenbetween*}.
+%\changes{1.01}{2007 Aug 17}{added starred version}
+% \begin{macrocode}
+\newcommand*{\DTLifopenbetween}{%
+\@ifstar\@sDTLifopenbetween\@DTLifopenbetween}
+% \end{macrocode}
+% Unstarred version
+% \begin{macrocode}
+\newcommand*{\@DTLifopenbetween}[5]{%
+\dtl@testbothnumerical{#2}{#3}%
+\if@dtl@condition
+ \dtl@ifsingle{#1}{%
+ \edef\@dtl@tmp{#1}}{%
+ \def\@dtl@tmp{#1}}%
+ \expandafter\@dtl@checknumerical\expandafter{\@dtl@tmp}%
+ \ifnum\@dtl@datatype>0\relax
+ \DTLifnumopenbetween{#1}{#2}{#3}{#4}{#5}%
+ \else
+ \@DTLifstringopenbetween{#1}{#2}{#3}{#4}{#5}%
+ \fi
+\else
+ \@DTLifstringopenbetween{#1}{#2}{#3}{#4}{#5}%
+\fi
+}
+% \end{macrocode}
+% Starred version
% \begin{macrocode}
-\newcommand*{\DTLifopenbetween}[5]{%
+\newcommand*{\@sDTLifopenbetween}[5]{%
\dtl@testbothnumerical{#2}{#3}%
\if@dtl@condition
\dtl@ifsingle{#1}{%
@@ -5850,21 +8498,21 @@
\ifnum\@dtl@datatype>0\relax
\DTLifnumopenbetween{#1}{#2}{#3}{#4}{#5}%
\else
- \DTLifstringopenbetween{#1}{#2}{#3}{#4}{#5}%
+ \@sDTLifstringopenbetween{#1}{#2}{#3}{#4}{#5}%
\fi
\else
- \DTLifstringopenbetween{#1}{#2}{#3}{#4}{#5}%
+ \@sDTLifstringopenbetween{#1}{#2}{#3}{#4}{#5}%
\fi
}
% \end{macrocode}
%\end{macro}
%
+%\begin{macro}{\DTLifFPopenbetween}
%\begin{definition}
%\cs{DTLifFPopenbetween}\marg{num}\marg{min}\marg{max}\marg{true part}\marg{false part}
%\end{definition}
-% Determine if \meta{min} $<$ \meta{num} $<$ \meta{max} where
+% Determines if \meta{min} $<$ \meta{num} $<$ \meta{max} where
% all arguments are in standard fixed point notation.
-%\begin{macro}{\DTLifFPopenbetween}
% \begin{macrocode}
\newcommand*{\DTLifFPopenbetween}[5]{%
\let\@dtl@dovalue\relax
@@ -5884,11 +8532,11 @@
% \end{macrocode}
%\end{macro}
%
+%\begin{macro}{\DTLifFPclosedbetween}
%\begin{definition}
%\cs{DTLifFPclosedbetween}\marg{num}\marg{min}\marg{max}\marg{true part}\marg{false part}
%\end{definition}
-% Determine if \meta{min} $\leq$ \meta{num} $\leq$ \meta{max}.
-%\begin{macro}{\DTLifFPclosedbetween}
+% Determines if \meta{min} $\leq$ \meta{num} $\leq$ \meta{max}.
% \begin{macrocode}
\newcommand*{\DTLifFPclosedbetween}[5]{%
\let\@dtl@dovalue\relax
@@ -5911,10 +8559,13 @@
% \cs{DTLforeach} as they depend on the counter
% \texttt{DTLrow}\meta{n}.
%
+%\begin{macro}{\DTLiffirstrow}
%\begin{definition}
%\cs{DTLiffirstrow}\marg{true part}\marg{false part}
%\end{definition}
-%\begin{macro}{\DTLiffirstrow}
+% Test if the current row is the first row. (This takes
+% \meta{condition}, the optional argument of \cs{DTLforeach},
+% into account.)
% \begin{macrocode}
\newcommand{\DTLiffirstrow}[2]{%
\ifnum\dtlforeachlevel=0\relax
@@ -5928,28 +8579,43 @@
% \end{macrocode}
%\end{macro}
%
+%\begin{macro}{\DTLiflastrow}
%\begin{definition}
%\cs{DTLiflastrow}\marg{true part}\marg{false part}
%\end{definition}
-%\begin{macro}{\DTLiflastrow}
+% Checks if the current row is the last row of the database.
+% It doesn't take the condition (the optional argument of
+% \cs{DTLforeach}) into account, so its possible it may never
+% do \meta{true part}, as the last row of the database may not
+% meet the condition. It is therefore not very useful and is
+% confusing since it behaves differently to \cs{DTLiffirstrow}
+% which does take the condition into account, so I have removed
+% its description from the main part of the manual. If you need
+% to use the optional argument of \cs{DTLforeach}, you will first
+% have to iterate through the database to count up the number
+% of rows which meet the condition, and then do another pass,
+% checking if the current row has reached that number.
+% This command requires at least v1.02 of the \sty{xfor} package.
+%\changes{1.01}{2007 Aug 17}{fixed bug}
% \begin{macrocode}
\newcommand{\DTLiflastrow}[2]{%
\ifnum\dtlforeachlevel=0\relax
\PackageError{datatool}{\string\DTLiflastrow\space can only
be used inside \string\DTLforeach}{}%
\else
-\expandafter\ifnum\csname c@DTLrow\romannumeral
-\dtlforeachlevel\endcsname=
-\value{DTLrow\romannumeral\dtlforeachlevel}%
+\ifx\@dtl@nextrow\@nnil
#1\else #2\fi
\fi
}
% \end{macrocode}
%\end{macro}
+%
+%\begin{macro}{\DTLifoddrow}
%\begin{definition}
%\cs{DTLifoddrow}\marg{true part}\marg{false part}
%\end{definition}
-%\begin{macro}{\DTLifoddrow}
+% Determines whether the current row is odd (takes the optional
+% argument of \cs{DTLforeach} into account.)
% \begin{macrocode}
\newcommand{\DTLifoddrow}[2]{%
\ifnum\dtlforeachlevel=0\relax
@@ -5966,7 +8632,7 @@
%
% \subsection{ifthen Conditionals}
% The following commands provide conditionals \cs{DTLis}\ldots\
-% that can be used in \cs{ifthenelse}. First need to define
+% which can be used in \cs{ifthenelse}. First need to define
% a new conditional:
%\begin{macro}{\if@dtl@condition}
% \begin{macrocode}
@@ -5974,66 +8640,144 @@
% \end{macrocode}
%\end{macro}
%
+%\begin{macro}{\dtl@testlt}
% Command to test if first argument is less than second argument.
-% If either argument is a string, a string comparison is used
-% instead.
+% If either argument is a string, a case sensitive string comparison
+% is used instead.
% This sets \cs{if@dtl@condition}.
-%\begin{macro}{\dtl@testlt}
% \begin{macrocode}
\newcommand*{\dtl@testlt}[2]{%
\DTLiflt{#1}{#2}{\@dtl@conditiontrue}{\@dtl@conditionfalse}}
% \end{macrocode}
%\end{macro}
-% Provide conditional command for use in \cs{ifthenelse}
+%
%\begin{macro}{\DTLislt}
+% Provide conditional command for use in \cs{ifthenelse}
% \begin{macrocode}
\newcommand*{\DTLislt}[2]{%
\TE@throw\noexpand\dtl@testlt{#1}{#2}\noexpand\if@dtl@condition}
% \end{macrocode}
%\end{macro}
%
-% Command to test if first number is greater than second number.
+%\begin{macro}{\dtl@testiclt}
+% Command to test if first argument is less than second argument.
+% If either argument is a string, a case insensitive string comparison
+% is used instead.
% This sets \cs{if@dtl@condition}.
+% \begin{macrocode}
+\newcommand*{\dtl@testiclt}[2]{%
+\@sDTLiflt{#1}{#2}{\@dtl@conditiontrue}{\@dtl@conditionfalse}}
+% \end{macrocode}
+%\end{macro}
+%
+%\begin{macro}{\DTLisilt}
+% Provide conditional command for use in \cs{ifthenelse}
+%\changes{1.01}{2007 Aug 17}{new}
+% \begin{macrocode}
+\newcommand*{\DTLisilt}[2]{%
+\TE@throw\noexpand\dtl@testiclt{#1}{#2}\noexpand\if@dtl@condition}
+% \end{macrocode}
+%\end{macro}
+%
%\begin{macro}{\dtl@testgt}
+% Command to test if first number is greater than second number.
+% This sets \cs{if@dtl@condition}.
% \begin{macrocode}
\newcommand*{\dtl@testgt}[2]{%
\DTLifgt{#1}{#2}{\@dtl@conditiontrue}{\@dtl@conditionfalse}}
% \end{macrocode}
%\end{macro}
-% Provide conditional command for use in \cs{ifthenelse}
%\begin{macro}{\DTLisgt}
+% Provide conditional command for use in \cs{ifthenelse}
% \begin{macrocode}
\newcommand*{\DTLisgt}[2]{%
\TE@throw\noexpand\dtl@testgt{#1}{#2}\noexpand\if@dtl@condition}
% \end{macrocode}
%\end{macro}
%
-% Command to test if first number is equal to the second number.
+%\begin{macro}{\dtl@testicgt}
+% Command to test if first number is greater than second number
+% (ignores case).
% This sets \cs{if@dtl@condition}.
+% \begin{macrocode}
+\newcommand*{\dtl@testicgt}[2]{%
+\@sDTLifgt{#1}{#2}{\@dtl@conditiontrue}{\@dtl@conditionfalse}}
+% \end{macrocode}
+%\end{macro}
+%\begin{macro}{\DTLisigt}
+% Provide conditional command for use in \cs{ifthenelse}
+%\changes{1.01}{2007 Aug 17}{new}
+% \begin{macrocode}
+\newcommand*{\DTLisigt}[2]{%
+\TE@throw\noexpand\dtl@testicgt{#1}{#2}\noexpand\if@dtl@condition}
+% \end{macrocode}
+%\end{macro}
+%
%\begin{macro}{\dtl@testeq}
+% Command to test if first number is equal to the second number.
+% This sets \cs{if@dtl@condition}.
% \begin{macrocode}
\newcommand*{\dtl@testeq}[2]{%
\DTLifeq{#1}{#2}{\@dtl@conditiontrue}{\@dtl@conditionfalse}}
% \end{macrocode}
%\end{macro}
-% Provide conditional command for use in \cs{ifthenelse}
%\begin{macro}{\DTLiseq}
+% Provide conditional command for use in \cs{ifthenelse}
% \begin{macrocode}
\newcommand*{\DTLiseq}[2]{%
\TE@throw\noexpand\dtl@testeq{#1}{#2}\noexpand\if@dtl@condition}
% \end{macrocode}
%\end{macro}
%
-% Command to test if first number lies between second and third
-% numbers. (End points included.) This sets \cs{if@dtl@condition}.
+%\begin{macro}{\dtl@testiceq}
+% Command to test if first number is equal to the second number
+% (ignores case).
+% This sets \cs{if@dtl@condition}.
+% \begin{macrocode}
+\newcommand*{\dtl@testiceq}[2]{%
+\@sDTLifeq{#1}{#2}{\@dtl@conditiontrue}{\@dtl@conditionfalse}}
+% \end{macrocode}
+%\end{macro}
+%\begin{macro}{\DTLisieq}
+% Provide conditional command for use in \cs{ifthenelse}
+%\changes{1.01}{2007 Aug 17}{new}
+% \begin{macrocode}
+\newcommand*{\DTLisieq}[2]{%
+\TE@throw\noexpand\dtl@testiceq{#1}{#2}\noexpand\if@dtl@condition}
+% \end{macrocode}
+%\end{macro}
+%
+%\begin{macro}{\DTLisSubString}
+% Tests if second argument is contained in first argument.
+%\changes{1.01}{2007 Aug 17}{new}
+% \begin{macrocode}
+\newcommand*{\DTLisSubString}[2]{%
+\TE@throw\noexpand\dtl@testifsubstring{#1}{#2}%
+\noexpand\if@dtl@condition}
+% \end{macrocode}
+%\end{macro}
+%
+%\begin{macro}{\DTLisPrefix}
+% Tests if first argument starts with second argument.
+%\changes{1.01}{2007 Aug 17}{new}
+% \begin{macrocode}
+\newcommand*{\DTLisPrefix}[2]{%
+\TE@throw\noexpand\dtl@teststartswith{#1}{#2}%
+\noexpand\if@dtl@condition}
+% \end{macrocode}
+%\end{macro}
+%
%\begin{macro}{\dtl@testclosedbetween}
+% Command to test if first value lies between second and third
+% values. (End points included, case sensitive.)
+% This sets \cs{if@dtl@condition}.
% \begin{macrocode}
\newcommand*{\dtl@testclosedbetween}[3]{%
\DTLifclosedbetween{#1}{#2}{#3}{\@dtl@conditiontrue}{\@dtl@conditionfalse}}
% \end{macrocode}
%\end{macro}
-% Provide conditional command for use in \cs{ifthenelse}
%\begin{macro}{\DTLisclosedbetween}
+% Provide conditional command for use in \cs{ifthenelse}
% \begin{macrocode}
\newcommand*{\DTLisclosedbetween}[3]{%
\TE@throw\noexpand\dtl@testclosedbetween{#1}{#2}{#3}%
@@ -6041,16 +8785,37 @@
% \end{macrocode}
%\end{macro}
%
-% Command to test if first number lies between second and third
-% numbers. (End points excluded.) This sets \cs{if@dtl@condition}.
+%\begin{macro}{\dtl@testiclosedbetween}
+% Command to test if first value lies between second and third
+% values. (End points included, case ignored.)
+% This sets \cs{if@dtl@condition}.
+% \begin{macrocode}
+\newcommand*{\dtl@testiclosedbetween}[3]{%
+\@sDTLifclosedbetween{#1}{#2}{#3}{\@dtl@conditiontrue}{\@dtl@conditionfalse}}
+% \end{macrocode}
+%\end{macro}
+%\begin{macro}{\DTLisiclosedbetween}
+% Provide conditional command for use in \cs{ifthenelse}
+%\changes{1.01}{2007 Aug 17}{new}
+% \begin{macrocode}
+\newcommand*{\DTLisiclosedbetween}[3]{%
+\TE@throw\noexpand\dtl@testiclosedbetween{#1}{#2}{#3}%
+\noexpand\if@dtl@condition}
+% \end{macrocode}
+%\end{macro}
+%
%\begin{macro}{\dtl@testopenbetween}
+% Command to test if first value lies between second and third
+% values. (End points excluded, case sensitive.)
+% This sets \cs{if@dtl@condition}.
% \begin{macrocode}
\newcommand*{\dtl@testopenbetween}[3]{%
-\DTLifopenbetween{#1}{#2}{#3}{\@dtl@conditiontrue}{\@dtl@conditionfalse}}
+\DTLifopenbetween{#1}{#2}{#3}{\@dtl@conditiontrue
+}{\@dtl@conditionfalse}}
% \end{macrocode}
%\end{macro}
-% Provide conditional command for use in \cs{ifthenelse}
%\begin{macro}{\DTLisopenbetween}
+% Provide conditional command for use in \cs{ifthenelse}
% \begin{macrocode}
\newcommand*{\DTLisopenbetween}[3]{%
\TE@throw\noexpand\dtl@testopenbetween{#1}{#2}{#3}%
@@ -6058,10 +8823,30 @@
% \end{macrocode}
%\end{macro}
%
+%\begin{macro}{\dtl@testiopenbetween}
+% Command to test if first value lies between second and third
+% values. (End points excluded, case ignored.)
+% This sets \cs{if@dtl@condition}.
+% \begin{macrocode}
+\newcommand*{\dtl@testiopenbetween}[3]{%
+\@sDTLifopenbetween{#1}{#2}{#3}{\@dtl@conditiontrue
+}{\@dtl@conditionfalse}}
+% \end{macrocode}
+%\end{macro}
+%\begin{macro}{\DTLisiopenbetween}
+% Provide conditional command for use in \cs{ifthenelse}
+%\changes{1.01}{2007 Aug 17}{new}
+% \begin{macrocode}
+\newcommand*{\DTLisiopenbetween}[3]{%
+\TE@throw\noexpand\dtl@testiopenbetween{#1}{#2}{#3}%
+\noexpand\if@dtl@condition}
+% \end{macrocode}
+%\end{macro}
+%
+%\begin{macro}{\dtl@testclosedbetween}
% Command to test if first number lies between second and third
% numbers. (End points included, all arguments are fixed point
% numbers in standard format.) This sets \cs{if@dtl@condition}.
-%\begin{macro}{\dtl@testclosedbetween}
% \begin{macrocode}
\newcommand*{\dtl@testFPclosedbetween}[3]{%
\DTLifFPclosedbetween{#1}{#2}{#3}%
@@ -6077,17 +8862,17 @@
% \end{macrocode}
%\end{macro}
%
+%\begin{macro}{\dtl@testopenbetween}
% Command to test if first number lies between second and third
% numbers. (End points excluded, all arguments are fixed point
% numbers in standard format.) This sets \cs{if@dtl@condition}.
-%\begin{macro}{\dtl@testopenbetween}
% \begin{macrocode}
\newcommand*{\dtl@testFPopenbetween}[3]{%
\DTLifFPopenbetween{#1}{#2}{#3}{\@dtl@conditiontrue}{\@dtl@conditionfalse}}
% \end{macrocode}
%\end{macro}
-% Provide conditional command for use in \cs{ifthenelse}
%\begin{macro}{\DTLisFPopenbetween}
+% Provide conditional command for use in \cs{ifthenelse}
% \begin{macrocode}
\newcommand*{\DTLisFPopenbetween}[3]{%
\TE@throw\noexpand\dtl@testFPopenbetween{#1}{#2}{#3}%
@@ -6095,17 +8880,17 @@
% \end{macrocode}
%\end{macro}
%
+%\begin{macro}{\dtl@testFPislt}
% Command to test if first number is less than second
% number where both numbers are in standard format.
% This sets \cs{if@dtl@condition}.
-%\begin{macro}{\dtl@testFPislt}
% \begin{macrocode}
\newcommand*{\dtl@testFPislt}[2]{%
\FPiflt{#1}{#2}\@dtl@conditiontrue\else\@dtl@conditionfalse\fi}
% \end{macrocode}
%\end{macro}
-% Provide conditional command for use in \cs{ifthenelse}
%\begin{macro}{\DTLisFPlt}
+% Provide conditional command for use in \cs{ifthenelse}
% \begin{macrocode}
\newcommand*{\DTLisFPlt}[2]{%
\TE@throw\noexpand\dtl@testFPislt{#1}{#2}%
@@ -6113,17 +8898,17 @@
% \end{macrocode}
%\end{macro}
%
+%\begin{macro}{\dtl@testFPisgt}
% Command to test if first number is greater than second
% number where both numbers are in standard format.
% This sets \cs{if@dtl@condition}.
-%\begin{macro}{\dtl@testFPisgt}
% \begin{macrocode}
\newcommand*{\dtl@testFPisgt}[2]{%
\FPifgt{#1}{#2}\@dtl@conditiontrue\else\@dtl@conditionfalse\fi}
% \end{macrocode}
%\end{macro}
-% Provide conditional command for use in \cs{ifthenelse}
%\begin{macro}{\DTLisFPgt}
+% Provide conditional command for use in \cs{ifthenelse}
% \begin{macrocode}
\newcommand*{\DTLisFPgt}[2]{%
\TE@throw\noexpand\dtl@testFPisgt{#1}{#2}%
@@ -6131,16 +8916,16 @@
% \end{macrocode}
%\end{macro}
%
+%\begin{macro}{\dtl@testFPiseq}
% Command to test if two numbers are equal, where both numbers
% are in standard decimal format
-%\begin{macro}{\dtl@testFPiseq}
% \begin{macrocode}
\newcommand*{\dtl@testFPiseq}[2]{%
\FPifeq{#1}{#2}\@dtl@conditiontrue\else\@dtl@conditionfalse\fi}
% \end{macrocode}
%\end{macro}
-% Provide conditional command for use in \cs{ifthenelse}
%\begin{macro}{\DTLisFPeq}
+% Provide conditional command for use in \cs{ifthenelse}
% \begin{macrocode}
\newcommand*{\DTLisFPeq}[2]{%
\TE@throw\noexpand\dtl@testFPiseq{#1}{#2}%
@@ -6148,10 +8933,10 @@
% \end{macrocode}
%\end{macro}
%
+%\begin{macro}{\dtl@testFPislteq}
% Command to test if first number is less than or equal to second
% number where both numbers are in standard format.
% This sets \cs{if@dtl@condition}.
-%\begin{macro}{\dtl@testFPislteq}
% \begin{macrocode}
\newcommand*{\dtl@testFPislteq}[2]{%
\FPiflt{#1}{#2}\@dtl@conditiontrue\else\@dtl@conditionfalse\fi
@@ -6162,8 +8947,8 @@
}
% \end{macrocode}
%\end{macro}
-% Provide conditional command for use in \cs{ifthenelse}
%\begin{macro}{\DTLisFPlteq}
+% Provide conditional command for use in \cs{ifthenelse}
% \begin{macrocode}
\newcommand*{\DTLisFPlteq}[2]{%
\TE@throw\noexpand\dtl@testFPislteq{#1}{#2}%
@@ -6171,10 +8956,10 @@
% \end{macrocode}
%\end{macro}
%
+%\begin{macro}{\dtl@testFPisgteq}
% Command to test if first number is greater than or equal to second
% number where both numbers are in standard format.
% This sets \cs{if@dtl@condition}.
-%\begin{macro}{\dtl@testFPisgteq}
% \begin{macrocode}
\newcommand*{\dtl@testFPisgteq}[2]{%
\FPifgt{#1}{#2}\@dtl@conditiontrue\else\@dtl@conditionfalse\fi
@@ -6185,8 +8970,8 @@
}
% \end{macrocode}
%\end{macro}
-% Provide conditional command for use in \cs{ifthenelse}
%\begin{macro}{\DTLisFPgteq}
+% Provide conditional command for use in \cs{ifthenelse}
% \begin{macrocode}
\newcommand*{\DTLisFPgteq}[2]{%
\TE@throw\noexpand\dtl@testFPisgteq{#1}{#2}%
@@ -6194,98 +8979,97 @@
% \end{macrocode}
%\end{macro}
%
-%
+%\begin{macro}{\dtl@teststring}
% Command to test if argument is a string. This sets
% \cs{if@dtl@condition}
-%\begin{macro}{\dtl@teststring}
% \begin{macrocode}
\newcommand*{\dtl@teststring}[1]{%
\DTLifstring{#1}{\@dtl@conditiontrue}{\@dtl@conditionfalse}}
% \end{macrocode}
%\end{macro}
-% Provide conditional command for use in \cs{ifthenelse}
%\begin{macro}{\DTLisstring}
+% Provide conditional command for use in \cs{ifthenelse}
% \begin{macrocode}
\newcommand*{\DTLisstring}[1]{%
\TE@throw\noexpand\dtl@teststring{#1}\noexpand\if@dtl@condition}
% \end{macrocode}
%\end{macro}
%
+%\begin{macro}{\dtl@testnumerical}
% Command to test if argument is a numerical. This sets
% \cs{if@dtl@condition}
-%\begin{macro}{\dtl@testnumerical}
% \begin{macrocode}
\newcommand*{\dtl@testnumerical}[1]{%
\DTLifnumerical{#1}{\@dtl@conditiontrue}{\@dtl@conditionfalse}%
}
% \end{macrocode}
%\end{macro}
-% Provide conditional command for use in \cs{ifthenelse}
%\begin{macro}{\DTLisnumerical}
+% Provide conditional command for use in \cs{ifthenelse}
% \begin{macrocode}
\newcommand*{\DTLisnumerical}[1]{%
\TE@throw\noexpand\dtl@testnumerical{#1}\noexpand\if@dtl@condition}
% \end{macrocode}
%\end{macro}
%
+%\begin{macro}{\dtl@testint}
% Command to test if argument is an integer. This sets
% \cs{if@dtl@condition}
-%\begin{macro}{\dtl@testint}
% \begin{macrocode}
\newcommand*{\dtl@testint}[1]{%
\DTLifint{#1}{\@dtl@conditiontrue}{\@dtl@conditionfalse}}
% \end{macrocode}
%\end{macro}
-% Provide conditional command for use in \cs{ifthenelse}
%\begin{macro}{\DTLisint}
+% Provide conditional command for use in \cs{ifthenelse}
% \begin{macrocode}
\newcommand*{\DTLisint}[1]{%
\TE@throw\noexpand\dtl@testint{#1}\noexpand\if@dtl@condition}
% \end{macrocode}
%\end{macro}
%
+%\begin{macro}{\dtl@testreal}
% Command to test if argument is a real. This sets
% \cs{if@dtl@condition}
-%\begin{macro}{\dtl@testreal}
% \begin{macrocode}
\newcommand*{\dtl@testreal}[1]{%
\DTLifreal{#1}{\@dtl@conditiontrue}{\@dtl@conditionfalse}}
% \end{macrocode}
%\end{macro}
-% Provide conditional command for use in \cs{ifthenelse}
%\begin{macro}{\DTLisreal}
+% Provide conditional command for use in \cs{ifthenelse}
% \begin{macrocode}
\newcommand*{\DTLisreal}[1]{%
\TE@throw\noexpand\dtl@testreal{#1}\noexpand\if@dtl@condition}
% \end{macrocode}
%\end{macro}
%
+%\begin{macro}{\dtl@testcurrency}
% Command to test if argument is a currency. This sets
% \cs{if@dtl@condition}
-%\begin{macro}{\dtl@testcurrency}
% \begin{macrocode}
\newcommand*{\dtl@testcurrency}[1]{%
\DTLifcurrency{#1}{\@dtl@conditiontrue}{\@dtl@conditionfalse}}
% \end{macrocode}
%\end{macro}
-% Provide conditional command for use in \cs{ifthenelse}
%\begin{macro}{\DTLiscurrency}
+% Provide conditional command for use in \cs{ifthenelse}
% \begin{macrocode}
\newcommand*{\DTLiscurrency}[1]{%
\TE@throw\noexpand\dtl@testcurrency{#1}\noexpand\if@dtl@condition}
% \end{macrocode}
%\end{macro}
%
+%\begin{macro}{\dtl@testcurrencyunit}
% Command to test if argument is a currency with given unit. This sets
% \cs{if@dtl@condition}
-%\begin{macro}{\dtl@testcurrencyunit}
% \begin{macrocode}
\newcommand*{\dtl@testcurrencyunit}[2]{%
\DTLifcurrencyunit{#1}{#2}{\@dtl@conditiontrue}{\@dtl@conditionfalse}}
% \end{macrocode}
%\end{macro}
-% Provide conditional command for use in \cs{ifthenelse}
%\begin{macro}{\DTLiscurrencyunit}
+% Provide conditional command for use in \cs{ifthenelse}
% \begin{macrocode}
\newcommand*{\DTLiscurrencyunit}[2]{%
\TE@throw\noexpand\dtl@testcurrencyunit{#1}{#2}%
@@ -6298,12 +9082,14 @@
% is a row of data. The data is stored as a comma separated list of
% \marg{id}\marg{value} pairs, where \meta{id} is an
% identifier
-% and \meta{value} is the value. \cs{DTLnewdb}\marg{name}
+% and \meta{value} is the value.
+%
+%\begin{macro}{\DTLnewdb}
+% \cs{DTLnewdb}\marg{name}
% initialises a database called \meta{name}. The keys associated
% with this database are stored in \cs{dtlkeys@}\meta{name}
% A new count register \cs{dtlrows@}\meta{db name} is created.
% This stores the total number of rows in the data base.
-%\begin{macro}{\DTLnewdb}
% \begin{macrocode}
\newcommand*{\DTLnewdb}[1]{%
\DTLifdbexists{#1}{%
@@ -6315,22 +9101,22 @@
% \end{macrocode}
%\end{macro}
%
+%\begin{macro}{\DTLrowcount}
%\begin{definition}
% \cs{DTLrowcount}\marg{db name}
%\end{definition}
-% Number of rows in \meta{db name}
-%\begin{macro}{\DTLrowcount}
+% The number of rows in the database called \meta{db name}.
% \begin{macrocode}
\newcommand*{\DTLrowcount}[1]{%
\expandafter\number\csname dtlrows@#1\endcsname}
% \end{macrocode}
%\end{macro}
%
+%\begin{macro}{\DTLifdbempty}
%\begin{definition}
% \cs{DTLifempty}\marg{name}\marg{true part}\marg{false part}
%\end{definition}
% Check if named database is empty (i.e.\ no rows have been added.)
-%\begin{macro}{\DTLifdbempty}
% \begin{macrocode}
\newcommand{\DTLifdbempty}[3]{%
\DTLifdbexists{#1}{%
@@ -6343,11 +9129,11 @@
% \end{macrocode}
%\end{macro}
%
+%\begin{macro}{\DTLnewrow}
%\begin{definition}
% \cs{DTLnewrow}\marg{db name}
%\end{definition}
% Add a new row to named database.
-%\begin{macro}{\DTLnewrow}
% \begin{macrocode}
\newcommand*{\DTLnewrow}[1]{%
\DTLifdbempty{#1}{%
@@ -6366,10 +9152,11 @@
% \end{macrocode}
%\end{macro}
%
+%\begin{macro}{\DTLnewdbentry}
%\begin{definition}
% \cs{DTLnewdbentry}\marg{db name}\marg{id}\marg{value}.
%\end{definition}
-% Add an entry to the last row (adds new row if database is empty.)
+% Adds an entry to the last row (adds new row if database is empty.)
%
% When a new entry is added, the control sequence
% \cs{@dtl@idtype@}\meta{db name}\texttt{@}\meta{id} is checked.
@@ -6381,13 +9168,12 @@
% remains unchanged. If it has another value, then it is set to
% 2 (real) if it was either 1 or 2 and \meta{value} is 2, it is
% set to 1 if \meta{value} is 1, otherwise it remains unchanged.
-%\begin{macro}{\DTLnewdbentry}
% \begin{macrocode}
\newcommand{\DTLnewdbentry}[3]{%
% \end{macrocode}
-% Set \cs{@dtl@dbvalue} to the value of this entry
+% Set \cs{@dtl@dbvalue} to the value of this entry.
% \begin{macrocode}
-\expandafter\@dtl@toks\expandafter{#3}%
+\@dtl@toks{#3}%
\edef\@dtl@dbvalue{\the\@dtl@toks}%
% \end{macrocode}
% Set \cs{@dtl@dbid} to the entry ID. This uses \cs{edef} to allow
@@ -6397,7 +9183,7 @@
% \end{macrocode}
% Set up the correct entry format:
% \begin{macrocode}
-\long\edef\@dtl@dbentry{{\@dtl@dbid}{\the\@dtl@toks}}%
+\edef\@dtl@dbentry{{\@dtl@dbid}{\the\@dtl@toks}}%
% \end{macrocode}
% If database is empty, add new row.
% \begin{macrocode}
@@ -6452,18 +9238,35 @@ the current row}}{%
% \end{macrocode}
%\end{macro}
%
+%\begin{macro}{\@dtl@setidtype}
%\begin{definition}
% \cs{@dtl@setidtype}\marg{db name}\marg{id}\marg{value}
%\end{definition}
% Set the type for \meta{id} according to \meta{value}.
% If \meta{value} is empty, leave \cs{@dtl@idtype}\meta{id}
% unchanged (if defined) or define as empty if not defined.
-%\begin{macro}{\@dtl@setidtype}
+%\changes{1.01}{2007 Aug 17}{Added currency check}
+%\changes{1.01}{2007 Aug 17}{Fixed bug when setting
+% \cs{@dtl@tmpcount}}
% \begin{macrocode}
\newcommand{\@dtl@setidtype}[3]{%
+% \end{macrocode}
+% Check the data type of this value.
+% \begin{macrocode}
\@dtl@checknumerical{#3}%
+% \end{macrocode}
+% Store value if \cs{@dtl@value} to make it easier to test if it
+% is empty.
+% \begin{macrocode}
\def\@dtl@value{#3}%
+% \end{macrocode}
+% Determine if this key already has a data type assigned to it.
+% \begin{macrocode}
\@ifundefined{@dtl@idtype@#1@#2}{%
+% \end{macrocode}
+% This key doesn't have an associated data type, so set it to
+% this value's data type, unless the value is empty.
+% \begin{macrocode}
\ifx\@dtl@value\@empty
\expandafter\gdef\csname @dtl@idtype@#1@#2\endcsname{}%
\else
@@ -6471,40 +9274,84 @@ the current row}}{%
\the\@dtl@datatype}%
\fi
}{%
+% \end{macrocode}
+% This key already has an associated data type, but may need updating.
+% \begin{macrocode}
\ifx\@dtl@value\@empty
+% \end{macrocode}
+% The value is empty, so do nothing.
+% \begin{macrocode}
\else
\expandafter\ifx\csname @dtl@idtype@#1@#2\endcsname\@empty
+% \end{macrocode}
+% The data type is currently unset (all previous values for this
+% key were empty) so set the data type for this key to the data type
+% of the given value.
+% \begin{macrocode}
\expandafter\xdef\csname @dtl@idtype@#1@#2\endcsname{%
\the\@dtl@datatype}%
\else
+% \end{macrocode}
+% Store the data type currently associated with this key in
+% \cs{@dtl@tmpcount}.
+% \begin{macrocode}
\expandafter\@dtl@tmpcount\expandafter=
- \csname @dtl@idtype@#1@#2\endcsname
+ \csname @dtl@idtype@#1@#2\endcsname\relax
+% \end{macrocode}
+% Determine whether to update the data type associated with this key.
+% \begin{macrocode}
\ifcase\@dtl@tmpcount
- % string, leave as it is
+% \end{macrocode}
+% The current data type is a string, so leave as it is
+% (string overrides all the other types.)
+% \begin{macrocode}
\or
- % int, set to whatever \@dtl@datatype is
+% \end{macrocode}
+% The current data type is an int, so set the data type of the given
+% value (all other data types override int.)
+% \begin{macrocode}
\expandafter\xdef\csname @dtl@idtype@#1@#2\endcsname{%
\the\@dtl@datatype}%
\or
- % real, set to real unless <value> is a string
+% \end{macrocode}
+% The current data type is a real, set to real unless the given value
+% is a string or currency (real overrides int, but not string or
+% currency.)
+% \begin{macrocode}
+ \ifnum\@dtl@datatype=0\relax
+ \expandafter\gdef\csname @dtl@idtype@#1@#2\endcsname{0}%
+ \else
+ \ifnum\@dtl@datatype=3\relax
+ \expandafter\gdef\csname @dtl@idtype@#1@#2\endcsname{3}%
+ \else
+ \expandafter\gdef\csname @dtl@idtype@#1@#2\endcsname{2}%
+ \fi
+ \fi
+ \or
+% \end{macrocode}
+% The current data type is currency, so set to currency unless
+% the given value is a string (currency overrides real and int,
+% but not string.)
+% \begin{macrocode}
\ifnum\@dtl@datatype=0\relax
\expandafter\gdef\csname @dtl@idtype@#1@#2\endcsname{0}%
\else
- \expandafter\gdef\csname @dtl@idtype@#1@#2\endcsname{2}%
+ \expandafter\gdef\csname @dtl@idtype@#1@#2\endcsname{3}%
\fi
\fi
\fi
\fi
-}}
+}%
+}
% \end{macrocode}
%\end{macro}
%
+%\begin{macro}{\@dtl@setkeys}
%\begin{definition}
%\cs{@dtl@setkeys}\marg{key}\marg{db name}
%\end{definition}
% Adds \marg{key} to \cs{dtlkeys@}\meta{db name} if not already
% in it.
-%\begin{macro}{\@dtl@setkeys}
% \begin{macrocode}
\newcommand*{\@dtl@setkeys}[2]{%
\edef\@dtl@tmp{\csname dtlkeys@#2\endcsname}%
@@ -6524,36 +9371,36 @@ the current row}}{%
% \end{macrocode}
%\end{macro}
%
+%\begin{macro}{\@dtl@getidtype}
%\begin{definition}
% \cs{@dtl@getidtype}\marg{db name}\marg{id}
%\end{definition}
-% Get the data type for \meta{id} in given database.
-%\begin{macro}{\@dtl@getidtype}
+% Gets the data type for \meta{id} in given database.
% \begin{macrocode}
\newcommand*{\@dtl@getidtype}[2]{%
\csname @dtl@idtype@#1@#2\endcsname}
% \end{macrocode}
%\end{macro}
%
+%\begin{macro}{\DTLifdbexists}
%\begin{definition}
%\cs{DTLifdbexists}\marg{db name}\marg{true part}\marg{false part}
%\end{definition}
-% Check if a data base with the given name exists:
-%\begin{macro}{\DTLifdbexists}
+% Checks if a data base with the given name exists.
% \begin{macrocode}
\newcommand{\DTLifdbexists}[3]{%
\@ifundefined{dtldb@#1}{#3}{#2}}
% \end{macrocode}
%\end{macro}
%
+%\begin{macro}{\dtl@ifrowcontains}
%\begin{definition}
% \cs{dtl@ifrowcontains}\meta{id}\meta{cmd}\meta{true part}\meta{false
%part}
%\end{definition}
-% Check to see if the row given by \meta{cmd} contains an
+% Checks to see if the row given by \meta{cmd} contains an
% entry with ID given by \meta{id}. If true, do \meta{true part},
% otherwise do \meta{false part}.
-%\begin{macro}{\dtl@ifrowcontains}
% \begin{macrocode}
\newcommand{\dtl@ifrowcontains}[4]{%
\@for\@dtl@element:=#2\do{%
@@ -6565,23 +9412,24 @@ the current row}}{%
% \end{macrocode}
%\end{macro}
%
+%\begin{macro}{\dtl@getentryid}
%\begin{definition}
% \cs{dtl@getentryid}\meta{entry cmd}\meta{id cmd}
%\end{definition}
-% Get the ID for an entry given by \meta{entry cmd}, and stores in
+% Gets the ID for an entry given by \meta{entry cmd}, and stores in
% in \meta{id cmd}.
-%\begin{macro}{\dtl@getentryid}
% \begin{macrocode}
\newcommand*{\dtl@getentryid}[2]{\expandafter\@dtl@getentryid#1#2}
\long\def\@dtl@getentryid#1#2#3{\def#3{#1}}
% \end{macrocode}
%\end{macro}
+%
+%\begin{macro}{\dtl@getentryvalue}
%\begin{definition}
% \cs{dtl@getentryvalue}\meta{entry cmd}\meta{cmd}
%\end{definition}
% Stores the entry value in \meta{cmd} for
% entry given by \meta{entry cmd}.
-%\begin{macro}{\dtl@getentryvalue}
% \begin{macrocode}
\newcommand*{\dtl@getentryvalue}[2]{%
\expandafter\@dtl@getentryvalue#1#2}
@@ -6589,9 +9437,9 @@ the current row}}{%
% \end{macrocode}
%\end{macro}
%
+%\begin{macro}{\dtlforeachlevel}
%\cs{DTLforeach} can only be nested up to three levels.
% \cs{dtlforeachlevel} keeps track of the current level.
-%\begin{macro}{\dtlforeachlevel}
% \begin{macrocode}
\global\newcount\dtlforeachlevel
% \end{macrocode}
@@ -6608,17 +9456,17 @@ the current row}}{%
% Keep \sty{hyperref} happy
% \begin{macrocode}
\newcounter{DTLrow}
-\newcommand*{\theHDTLrow}{\arabic{DTLrow}}
-\newcommand*{\theHDTLrowi}{\theHDTLrow.\arabic{DTLrowi}}
-\newcommand*{\theHDTLrowii}{\theHDTLrowi.\arabic{DTLrowii}}
-\newcommand*{\theHDTLrowiii}{\theHDTLrowii.\arabic{DTLrowiii}}
+\def\theHDTLrow{\arabic{DTLrow}}
+\def\theHDTLrowi{\theHDTLrow.\arabic{DTLrowi}}
+\def\theHDTLrowii{\theHDTLrowi.\arabic{DTLrowii}}
+\def\theHDTLrowiii{\theHDTLrowii.\arabic{DTLrowiii}}
% \end{macrocode}
%
+%\begin{macro}{\DTLsaverowcount}
%\begin{definition}
%\cs{DTLsavelastrowcount}\marg{cmd}
%\end{definition}
% Stores the maximum row count for the last \cs{DTLforeach}.
-%\begin{macro}{\DTLsaverowcount}
% \begin{macrocode}
\newcommand*{\DTLsavelastrowcount}[1]{%
\ifnum\dtlforeachlevel>2\relax
@@ -6636,6 +9484,7 @@ the current row}}{%
% \end{macrocode}
%\end{macro}
%
+%\begin{macro}{\DTLforeach}
%\begin{definition}
% \cs{DTLforeach}\oarg{conditions}\marg{db name}\marg{values}\marg{text}
%\end{definition}
@@ -6646,11 +9495,19 @@ the current row}}{%
% each of the commands in this list are set to the value of the
% entry with the corresponding key \meta{key}.
% (\cs{gdef} is used to ensure \cs{DTLforeach} works in a tabular
-% environment.) The database is reconstructed to allow for
-% rows to be edited.
-%\begin{macro}{\DTLforeach}
+% environment.) The database may be edited in the unstarred
+% version, in the starred version the database is read only.
+%\changes{1.01}{2007 Aug 17}{added starred version}
+% \begin{macrocode}
+\newcommand*{\DTLforeach}{\@ifstar\@sDTLforeach\@DTLforeach}
+% \end{macrocode}
+%\end{macro}
+%
+%\begin{macro}{\@DTLforeach}
+% \cs{@DTLforeach} is the unstarred version of \cs{DTLforeach}.
+% The database is reconstructed to allow for rows to be edited.
% \begin{macrocode}
-\newcommand{\DTLforeach}[4][\boolean{true}]{%
+\newcommand{\@DTLforeach}[4][\boolean{true}]{%
% \end{macrocode}
% Check database exists
% \begin{macrocode}
@@ -6702,6 +9559,12 @@ deeply}{}%
\let\csname @dtl@thiscurrentrow@\romannumeral\dtlforeachlevel
\endcsname=\@dtl@currentrow
% \end{macrocode}
+% Globally assign next element (note that there is no check to
+% determine if the next element will be skipped.)
+%\changes{1.01}{2007 Aug 17}{set \cs{@dtl@nextrow}}
+% \begin{macrocode}
+ \global\let\@dtl@nextrow\@xfor@nextelement
+% \end{macrocode}
% Assign commands to the required entries
% \begin{macrocode}
\ifx\relax#3\relax
@@ -6733,19 +9596,21 @@ deeply}{}%
\csname @dtl@foreachrows@\romannumeral\dtlforeachlevel\endcsname
\@empty
\expandafter
- \xdef\csname @dtl@foreachrows@\romannumeral\dtlforeachlevel\endcsname{{\the\@dtl@toks}}%
+ \xdef\csname @dtl@foreachrows@\romannumeral\dtlforeachlevel\endcsname{%
+ {\the\@dtl@toks}}%
\else
\expandafter\let\expandafter\@dtl@foreachrows\expandafter
=\csname @dtl@foreachrows@\romannumeral\dtlforeachlevel\endcsname
\expandafter\toks@\expandafter{\@dtl@foreachrows}%
\expandafter
- \xdef\csname @dtl@foreachrows@\romannumeral\dtlforeachlevel\endcsname{\the\toks@,{\the\@dtl@toks}}%
+ \xdef\csname @dtl@foreachrows@\romannumeral\dtlforeachlevel\endcsname{%
+ \the\toks@,{\the\@dtl@toks}}%
\fi
\fi
\@endforfalse
}%
- \expandafter\let\expandafter\@dtl@foreachrows\expandafter
- =\csname @dtl@foreachrows@\romannumeral\dtlforeachlevel\endcsname
+\expandafter\let\expandafter\@dtl@foreachrows\expandafter
+ =\csname @dtl@foreachrows@\romannumeral\dtlforeachlevel\endcsname
\expandafter\global
\expandafter\let\csname dtldb@#2\endcsname=\@dtl@foreachrows
\fi
@@ -6756,13 +9621,96 @@ deeply}{}%
% \end{macrocode}
%\end{macro}
%
+%\begin{macro}{\@sDTLforeach}
+% \cs{@sDTLforeach} is the starred version of \cs{DTLforeach}.
+% The database rows can't be edited.
+% \begin{macrocode}
+\newcommand{\@sDTLforeach}[4][\boolean{true}]{%
+% \end{macrocode}
+% Check database exists
+% \begin{macrocode}
+\DTLifdbexists{#2}{%
+% \end{macrocode}
+% Keep \sty{hyperref} happy
+% \begin{macrocode}
+\refstepcounter{DTLrow}%
+\global\c@DTLrow=\c@DTLrow
+% \end{macrocode}
+% Store database name
+% \begin{macrocode}
+\gdef\@dtl@dbname{#2}%
+% \end{macrocode}
+% Increment level and check not exceeded 3
+% \begin{macrocode}
+\global\advance\dtlforeachlevel by 1\relax
+\ifnum\dtlforeachlevel>3\relax
+ \PackageError{datatool}{\string\DTLforeach\space nested too
+deeply}{}%
+\else
+% \end{macrocode}
+% Set level dependent information (needs to be global to ensure
+% it works in the \env{tabular} environment.) Row counter:
+% \begin{macrocode}
+ \expandafter\global
+ \csname c@DTLrow\romannumeral\dtlforeachlevel\endcsname = 0\relax
+% \end{macrocode}
+% Set database name to \cs{@nnil} to indicate that this is read only:
+% \begin{macrocode}
+ \expandafter\global\expandafter\let
+ \csname @dtl@dbname@\romannumeral\dtlforeachlevel\endcsname
+ =\@nnil
+% \end{macrocode}
+% Iterate through each row
+% \begin{macrocode}
+ \expandafter\let\expandafter\@dtl@db\csname dtldb@#2\endcsname%
+ \@for\@dtl@currentrow:=\@dtl@db\do{%
+% \end{macrocode}
+% Set current row macro for this level
+% \begin{macrocode}
+ \expandafter\global\expandafter
+ \let\csname @dtl@thiscurrentrow@\romannumeral\dtlforeachlevel
+ \endcsname=\@dtl@currentrow
+% \end{macrocode}
+% Globally assign next element (note that there is no check to
+% determine if the next element will be skipped.)
+%\changes{1.01}{2007 Aug 17}{set \cs{@dtl@nextrow}}
+% \begin{macrocode}
+ \global\let\@dtl@nextrow\@xfor@nextelement
+% \end{macrocode}
+% Assign commands to the required entries
+% \begin{macrocode}
+ \ifx\relax#3\relax
+ \else
+ \@dtl@assign{#3}%
+ \fi
+% \end{macrocode}
+% Do the main body of text if condition is satisfied
+% \begin{macrocode}
+ \ifthenelse{#1}{%
+ \refstepcounter{DTLrow\romannumeral\dtlforeachlevel}%
+ \expandafter\edef\expandafter\DTLcurrentindex\expandafter
+ {\arabic{DTLrow\romannumeral\dtlforeachlevel}}%
+ #4%
+ }{}%
+% \end{macrocode}
+% \begin{macrocode}
+\@endforfalse
+}%
+\fi
+\global\advance\dtlforeachlevel by -1\relax
+}{%
+\PackageError{datatool}{Database `#2' doesn't exist}{}}%
+}
+% \end{macrocode}
+%\end{macro}
+%
+%\begin{macro}{\DTLappendtorow}
%\begin{definition}
%\cs{DTLappendtorow}\marg{key}\marg{value}
%\end{definition}
% Appends entry to current row. (The current row is given by
% \cs{@dtl@thiscurrentrow@}\meta{n} where \meta{n} is roman
% numeral value of \cs{dtlforeachlevel}.
-%\begin{macro}{\DTLappendtorow}
% \begin{macrocode}
\newcommand*{\DTLappendtorow}[2]{%
\ifnum\dtlforeachlevel=0\relax
@@ -6775,6 +9723,14 @@ deeply}{}%
\expandafter\let\expandafter\@dtl@thisdb
\csname @dtl@dbname@\romannumeral\dtlforeachlevel\endcsname
% \end{macrocode}
+% Check this isn't in \cs{DTLforeach*}
+% \begin{macrocode}
+ \ifx\@dtl@thisdb\@nnil
+ \PackageError{datatool}{\string\DTLappendtorow\space can't
+ be used inside \string\DTLforeach*}{The starred version of
+ \string\DTLforeach\space is read only}%
+ \else
+% \end{macrocode}
% Set \cs{@dtl@dbvalue} to the value of this entry
% \begin{macrocode}
\expandafter\@dtl@toks\expandafter{#2}%
@@ -6806,11 +9762,13 @@ deeply}{}%
\expandafter\@dtl@toks\expandafter{\@dtl@dbentry}%
\ifx\@dtl@thisrow\@empty
\expandafter
- \xdef\csname @dtl@thiscurrentrow@\romannumeral\dtlforeachlevel\endcsname{\the\@dtl@toks}%
+ \xdef\csname @dtl@thiscurrentrow@\romannumeral\dtlforeachlevel\endcsname{%
+ \the\@dtl@toks}%
\else
\expandafter\toks@\expandafter{\@dtl@thisrow}%
\expandafter
- \xdef\csname @dtl@thiscurrentrow@\romannumeral\dtlforeachlevel\endcsname{\the\toks@,\the\@dtl@toks}%
+ \xdef\csname @dtl@thiscurrentrow@\romannumeral\dtlforeachlevel\endcsname{%
+ \the\toks@,\the\@dtl@toks}%
\fi
}
% \end{macrocode}
@@ -6819,13 +9777,15 @@ deeply}{}%
\@dtl@setidtype{\@dtl@thisdb}{#1}{#2}%
\expandafter\@dtl@setkeys\expandafter{#1}{\@dtl@thisdb}%
% \end{macrocode}
-% end the \cs{ifnum}
+% end the \cs{ifx} and \cs{ifnum}
% \begin{macrocode}
+ \fi
\fi
}
% \end{macrocode}
%\end{macro}
%
+%\begin{macro}{\DTLremoveentryfromrow}
%\begin{definition}
%\cs{DTLremoveentryfromrow}\marg{key}
%\end{definition}
@@ -6833,7 +9793,6 @@ deeply}{}%
% (The current row is given by
% \cs{@dtl@thiscurrentrow@}\meta{n} where \meta{n} is roman
% numeral value of \cs{dtlforeachlevel}.
-%\begin{macro}{\DTLremoveentryfromrow}
% \begin{macrocode}
\newcommand*{\DTLremoveentryfromrow}[1]{%
\ifnum\dtlforeachlevel=0\relax
@@ -6846,6 +9805,14 @@ deeply}{}%
\expandafter\let\expandafter\@dtl@thisdb
\csname @dtl@dbname@\romannumeral\dtlforeachlevel\endcsname
% \end{macrocode}
+% Check this isn't in \cs{DTLforeach*}
+% \begin{macrocode}
+ \ifx\@dtl@thisdb\@nnil
+ \PackageError{datatool}{\string\DTLremoveentryfromrow\space can't
+ be used inside \string\DTLforeach*}{The starred version of
+ \string\DTLforeach\space is read only}%
+ \else
+% \end{macrocode}
% Set \cs{@dtl@thisrow} to the current row.
% \begin{macrocode}
\expandafter\let\expandafter\@dtl@thisrow
@@ -6878,11 +9845,13 @@ deeply}{}%
\PackageError{datatool}{Can't remove entry given by key `#1'
from current row in database `\@dtl@thisdb', no such entry}{}%
}%
+ \fi
\fi
}
% \end{macrocode}
%\end{macro}
%
+%\begin{macro}{\DTLreplaceentryforrow}
%\begin{definition}
%\cs{DTLreplaceentryforrow}\marg{key}\marg{value}
%\end{definition}
@@ -6891,7 +9860,6 @@ deeply}{}%
% (The current row is given by
% \cs{@dtl@thiscurrentrow@}\meta{n} where \meta{n} is roman
% numeral value of \cs{dtlforeachlevel}.
-%\begin{macro}{\DTLreplaceentryforrow}
% \begin{macrocode}
\newcommand*{\DTLreplaceentryforrow}[2]{%
\ifnum\dtlforeachlevel=0\relax
@@ -6904,6 +9872,14 @@ deeply}{}%
\expandafter\let\expandafter\@dtl@thisdb
\csname @dtl@dbname@\romannumeral\dtlforeachlevel\endcsname
% \end{macrocode}
+% Check this isn't in \cs{DTLforeach*}
+% \begin{macrocode}
+ \ifx\@dtl@thisdb\@nnil
+ \PackageError{datatool}{\string\DTLreplaceentryforrow\space can't
+ be used inside \string\DTLforeach*}{The starred version of
+ \string\DTLforeach\space is read only}%
+ \else
+% \end{macrocode}
% Set \cs{@dtl@dbvalue} to the value of this entry
% \begin{macrocode}
\expandafter\@dtl@toks\expandafter{#2}%
@@ -6951,37 +9927,52 @@ deeply}{}%
\PackageError{datatool}{Can't remove entry given by key `#1'
from current row in database `\@dtl@thisdb', no such entry}{}%
}%
+ \fi
\fi
}
% \end{macrocode}
%\end{macro}
%
+%\begin{macro}{\DTLremovecurrentrow}
%\begin{definition}
%\cs{DTLremovecurrentrow}
%\end{definition}
% Removes current row. This just sets the current row to empty
-%\begin{macro}{\DTLremoveentryfromrow}
+%\changes{1.01}{2007 Aug 17}{fix bug caused by missing \cs{fi}
+% and unrequired argument}
% \begin{macrocode}
-\newcommand*{\DTLremovecurrentrow}[1]{%
+\newcommand*{\DTLremovecurrentrow}{%
\ifnum\dtlforeachlevel=0\relax
\PackageError{datatool}{\string\DTLremovecurrentrow\space can only
be used inside \string\DTLforeach}{}%
\else
% \end{macrocode}
+% Check this isn't in \cs{DTLforeach*}
+% \begin{macrocode}
+ \expandafter\ifx
+ \csname @dtl@dbname@\romannumeral\dtlforeachlevel\endcsname\@nnil
+ \PackageError{datatool}{\string\DTLremovecurrentrow\space can't
+ be used inside \string\DTLforeach*}{The starred version of
+ \string\DTLforeach\space is read only}%
+ \else
+% \end{macrocode}
% Set current row to empty.
% \begin{macrocode}
\expandafter\let
\csname @dtl@thiscurrentrow@\romannumeral\dtlforeachlevel\endcsname
=\@empty
+ \fi
+\fi
}
% \end{macrocode}
%\end{macro}
%
+%\begin{macro}{\DTLforeachkeyinrow}
%\begin{definition}
%\cs{DTLforeachkeyinrow}\marg{cmd}\marg{text}
%\end{definition}
-% Iterates through each key in the row, and does \meta{text}.
-%\begin{macro}{\DTLforeachkeyinrow}
+% Iterates through each key in the current row of \cs{DTLforeach},
+% and does \meta{text}.
% \begin{macrocode}
\newcommand*{\DTLforeachkeyinrow}[2]{%
\ifnum\dtlforeachlevel=0\relax
@@ -7005,11 +9996,15 @@ deeply}{}%
% \end{macrocode}
%\end{macro}
%
-%
+%\begin{macro}{\DTLaddentryforrow}
%\begin{definition}
%\cs{DTLaddentryforrow}\marg{db name}\marg{assign list}\marg{condition}\marg{key}\marg{value}
%\end{definition}
-%\begin{macro}{\DTLaddentryforrow}
+% Adds the entry with key given by \meta{key} and value given by
+% \meta{value} to the first row in the database \meta{db name}
+% which satisfies the condition given by \meta{condition}. The
+% \meta{assign list} is the same as for \cs{DTLforeach} and may
+% be used to set the values which are to be tested in \meta{condition}.
% \begin{macrocode}
\newcommand{\DTLaddentryforrow}[5]{%
\gdef\@dtl@dbname{#1}%
@@ -7075,24 +10070,28 @@ deeply}{}%
% \end{macrocode}
%\end{macro}
%
-%\cs{@dtl@assign}\marg{values} assigns each command in
-% \meta{values} (see above) to the value of the corresponding
-% ID for the row given by \cs{@dtl@currentrow}.
%\begin{macro}{\@dtl@assign}
+%\begin{definition}
+%\cs{@dtl@assign}\oarg{row}\marg{values}
+%\end{definition}
+% Assigns each command in
+% \meta{values} (see above) to the value of the corresponding
+% ID for the row given by \meta{row} (which defaults to
+% \cs{@dtl@currentrow} if absent.)
% \begin{macrocode}
-\newcommand*{\@dtl@assign}[1]{%
-\@dtl@assigncmd#1,\relax\@@
+\newcommand*{\@dtl@assign}[2][\@dtl@currentrow]{%
+\@dtl@assigncmd#2,\relax\@@{#1}%
}
% \end{macrocode}
%\end{macro}
+%\begin{macro}{\@dtl@assigncmd}
%\begin{definition}
% \cs{\@dtl@assigncmd}\meta{cmd}=\meta{id}\cs{@nil}
%\end{definition}
% Assign \meta{cmd} to value given by \meta{id}
-%\begin{macro}{\@dtl@assigncmd}
% \begin{macrocode}
-\def\@dtl@assigncmd#1=#2,#3\@@{%
-\@for\@dtl@entry:=\@dtl@currentrow\do{%
+\def\@dtl@assigncmd#1=#2,#3\@@#4{%
+\@for\@dtl@entry:=#4\do{%
\dtl@getentryid\@dtl@entry\@dtl@id
\ifthenelse{\equal{\@dtl@id}{#2}}{%
\dtl@getentryvalue\@dtl@entry#1%
@@ -7108,54 +10107,90 @@ deeply}{}%
\else
\let\@dtl@next=\@dtl@assigncmd
\fi
-\@dtl@next#3\@@
+\@dtl@next#3\@@{#4}%
}
% \end{macrocode}
%\end{macro}
-% End loop
%\begin{macro}{\@dtl@assigncmdnoop}
+% End loop
% \begin{macrocode}
-\def\@dtl@assigncmdnoop#1\@@{}
+\def\@dtl@assigncmdnoop#1\@@#2{}
% \end{macrocode}
%\end{macro}
+%\begin{macro}{\@dtl@setnull}
%\cs{@dtl@setnull}\marg{cmd}\marg{id} sets \meta{cmd} to either
-% NULL or 0 depending on the data type for \meta{id}. (Database
+% \cs{DTLstringnull} or \cs{DTLnumbernull} depending on the data
+% type for \meta{id}. (Database
% name should be stored in \cs{@dtl@dbname} prior to use.
-%\begin{macro}{\@dtl@setnull}
% \begin{macrocode}
\newcommand*{\@dtl@setnull}[2]{%
\@ifundefined{@dtl@idtype@\@dtl@dbname @#2}{%
-\PackageError{datatool}{Key `#2' not defined in database
-`\@dtl@dbname'}{}}{%
+\global\let#1=\DTLstringnull}{%
\edef\@dtl@tmp{0\@dtl@getidtype{\@dtl@dbname}{#2}}%
\expandafter\ifnum\@dtl@tmp=0\relax
- \gdef#1{NULL}%
+ \global\let#1=\DTLstringnull
\else
- \gdef#1{0}%
+ \global\let#1=\DTLnumbernull
\fi
}}
% \end{macrocode}
%\end{macro}
+%\begin{macro}{\DTLstringnull}
+% String null value:
+% \begin{macrocode}
+\newcommand*{\DTLstringnull}{NULL}
+% \end{macrocode}
+%\end{macro}
+%\begin{macro}{\DTLnumbernull}
+% Number null value:
+% \begin{macrocode}
+\newcommand*{\DTLnumbernull}{0}
+% \end{macrocode}
+%\end{macro}
+%\begin{macro}{\DTLifnull}
+%\begin{definition}
+%\cs{DTLifnull}\marg{value}\marg{true part}\marg{false part}
+%\end{definition}
+% Checks if \meta{value} is null (either \cs{DTLstringnull} or
+% \cs{DTLnumbernull}) if true, does \meta{true part} otherwise
+% does \meta{false part}.
+% \begin{macrocode}
+\newcommand*{\DTLifnull}[3]{%
+\ifx\DTLstringnull#1\relax
+ #2%
+\else
+ \ifx\DTLnumbernull#1\relax
+ #2%
+ \else
+ #3%
+ \fi
+\fi}
+% \end{macrocode}
+%\end{macro}
%
+%\begin{macro}{\dtl@gathervalues}
%\begin{definition}
-%\cs{dtl@gathervalues}\marg{db name}\marg{row}
+%\cs{dtl@gathervalues}\oarg{label}\marg{db name}\marg{row}
%\end{definition}
% Stores each element of \meta{row} in \meta{db name} into
-% the command \cs{@dtl@key@}\meta{key}, where \meta{key} is the
-% key for that element.
-%\begin{macro}{\dtl@gathervalues}
+% the command \cs{@dtl@}\meta{label}\texttt{@}\meta{key},
+% where \meta{key} is the
+% key for that element, and \meta{label} defaults to "key".
% \begin{macrocode}
-\newcommand{\dtl@gathervalues}[2]{%
-\edef\@dtl@tmp{\csname dtlkeys@#1\endcsname}%
+\newcommand{\dtl@gathervalues}[3][key]{%
+\expandafter\let\expandafter\@dtl@tmp\expandafter
+ =\csname dtlkeys@#2\endcsname%
\def\@dtl@list{}%
\@for\dtl@key:=\@dtl@tmp\do{%
\expandafter\@dtl@setnull\expandafter{%
- \csname @dtl@key@\dtl@key\endcsname}{\dtl@key}%
- \@for\dtl@thiselement:=#2\do{%
+ \csname @dtl@#1@\dtl@key\endcsname}{\dtl@key}%
+ \@for\dtl@thiselement:=#3\do{%
\dtl@getentryid\dtl@thiselement\@dtl@id
- \DTLifstringeq{\@dtl@id}{\dtl@key}{%
+ \ifthenelse{\equal{\@dtl@id}{\dtl@key}}{%
\dtl@getentryvalue\dtl@thiselement\@dtl@value%
- \expandafter\protected@edef\csname @dtl@key@\dtl@key\endcsname{\@dtl@value}%
+ \expandafter\toks@\expandafter{\@dtl@value}%
+ \expandafter\edef\csname @dtl@#1@\dtl@key\endcsname{%
+ \the\toks@}%
\@endfortrue}{}%
}%
\@endforfalse
@@ -7164,6 +10199,7 @@ deeply}{}%
% \end{macrocode}
%\end{macro}
%
+%\begin{macro}{\DTLsumforkeys}
%\begin{definition}
%\cs{DTLsumforkeys}\oarg{condition}\marg{db list}\marg{key list}\marg{cmd}
%\end{definition}
@@ -7172,7 +10208,6 @@ deeply}{}%
% and stores in \meta{cmd}, which must be a control sequence.
% The optional argument \meta{condition} is the same as that
% for \cs{DTLforeach}.
-%\begin{macro}{\DTLsumforkeys}
% \begin{macrocode}
\newcommand*{\DTLsumforkeys}[4][\boolean{true}\and
\DTLisnumerical{\DTLthisval}]{%
@@ -7195,6 +10230,7 @@ deeply}{}%
% \end{macrocode}
%\end{macro}
%
+%\begin{macro}{\DTLmeanforkeys}
%\begin{definition}
%\cs{DTLmeanforkeys}\oarg{condition}\marg{db list}\marg{key list}\marg{cmd}
%\end{definition}
@@ -7203,7 +10239,6 @@ deeply}{}%
% and stores in \meta{cmd}, which must be a control sequence.
% The optional argument \meta{condition} is the same as that
% for \cs{DTLforeach}.
-%\begin{macro}{\DTLmeanforkeys}
% \begin{macrocode}
\newcommand*{\DTLmeanforkeys}[4][\boolean{true}\and
\DTLisnumerical{\DTLthisval}]{%
@@ -7233,6 +10268,7 @@ deeply}{}%
% \end{macrocode}
%\end{macro}
%
+%\begin{macro}{\DTLvarianceforkeys}
%\begin{definition}
%\cs{DTLvarianceforkeys}\oarg{condition}\marg{db list}\marg{key list}\marg{cmd}
%\end{definition}
@@ -7241,7 +10277,6 @@ deeply}{}%
% and stores in \meta{cmd}, which must be a control sequence.
% The optional argument \meta{condition} is the same as that
% for \cs{DTLforeach}.
-%\begin{macro}{\DTLvarianceforkeys}
% \begin{macrocode}
\newcommand*{\DTLvarianceforkeys}[4][\boolean{true}\and
\DTLisnumerical{\DTLthisval}]{%
@@ -7274,6 +10309,7 @@ deeply}{}%
% \end{macrocode}
%\end{macro}
%
+%\begin{macro}{\DTLsdforkeys}
%\begin{definition}
%\cs{DTLsdforkeys}\oarg{condition}\marg{db list}\marg{key list}\marg{cmd}
%\end{definition}
@@ -7282,7 +10318,6 @@ deeply}{}%
% and stores in \meta{cmd}, which must be a control sequence.
% The optional argument \meta{condition} is the same as that
% for \cs{DTLforeach}.
-%\begin{macro}{\DTLsdforkeys}
% \begin{macrocode}
\newcommand*{\DTLsdforkeys}[4][\boolean{true}\and
\DTLisnumerical{\DTLthisval}]{%
@@ -7292,6 +10327,7 @@ deeply}{}%
% \end{macrocode}
%\end{macro}
%
+%\begin{macro}{\DTLminforkeys}
%\begin{definition}
%\cs{DTLminforkeys}\oarg{condition}\marg{db list}\marg{key list}\marg{cmd}
%\end{definition}
@@ -7300,7 +10336,6 @@ deeply}{}%
% and stores in \meta{cmd}, which must be a control sequence.
% The optional argument \meta{condition} is the same as that
% for \cs{DTLforeach}.
-%\begin{macro}{\DTLminforkeys}
% \begin{macrocode}
\newcommand*{\DTLminforkeys}[4][\boolean{true}\and
\DTLisnumerical{\DTLthisval}]{%
@@ -7328,6 +10363,7 @@ deeply}{}%
% \end{macrocode}
%\end{macro}
%
+%\begin{macro}{\DTLmaxforkeys}
%\begin{definition}
%\cs{DTLmaxforkeys}\oarg{condition}\marg{db list}\marg{key list}\marg{cmd}
%\end{definition}
@@ -7336,7 +10372,6 @@ deeply}{}%
% and stores in \meta{cmd}, which must be a control sequence.
% The optional argument \meta{condition} is the same as that
% for \cs{DTLforeach}.
-%\begin{macro}{\DTLmaxforkeys}
% \begin{macrocode}
\newcommand*{\DTLmaxforkeys}[4][\boolean{true}\and
\DTLisnumerical{\DTLthisval}]{%
@@ -7364,6 +10399,7 @@ deeply}{}%
% \end{macrocode}
%\end{macro}
%
+%\begin{macro}{\DTLcomputebounds}
%\begin{definition}
%\cs{DTLcomputebounds}\oarg{condition}\marg{db list}\marg{x key}\marg{y key}\marg{minX cmd}\marg{minY cmd}\marg{maxX cmd}\marg{maxY cmd}
%\end{definition}
@@ -7373,7 +10409,6 @@ deeply}{}%
% \meta{y key}. The results are stored in \meta{minX cmd},
% \meta{minY cmd}, \meta{maxX cmd} and \meta{maxY cmd} in
% standard decimal format.
-%\begin{macro}{\DTLcomputebounds}
% \begin{macrocode}
\newcommand*{\DTLcomputebounds}[8][\boolean{true}]{%
\let#5=\relax
@@ -7381,7 +10416,7 @@ deeply}{}%
\let#7=\relax
\let#8=\relax
\@for\dtl@thisdb:=#2\do{%
- \DTLforeach[#1]{\dtl@thisdb}{\DTLthisX=#3,\DTLthisY=#4}{%
+ \@sDTLforeach[#1]{\dtl@thisdb}{\DTLthisX=#3,\DTLthisY=#4}{%
\DTLconverttodecimal{\DTLthisX}{\dtl@decx}%
\DTLconverttodecimal{\DTLthisY}{\dtl@decy}%
\ifx#5\relax
@@ -7401,49 +10436,218 @@ deeply}{}%
% \end{macrocode}
%\end{macro}
%
+%\begin{macro}{\DTLgetvalueforkey}
+%\begin{definition}
+%\cs{DTLgetvalueforkey}\marg{cmd}\marg{key}\marg{db name}\marg{ref
+% key}\marg{ref value}
+%\end{definition}
+% This (globally) sets \meta{cmd} (a control sequence) to the
+% value of the key specified by \meta{key} in the first row
+% of the database called \meta{db name} which contains the key
+% \meta{ref key} which has the value \meta{value}.
+%\changes{1.01}{2007 Aug 17}{new}
+% \begin{macrocode}
+\newcommand*{\DTLgetvalueforkey}[5]{%
+{%
+\global\let#1=\DTLstringnull
+\@sDTLforeach{#3}{\dtl@valueA=#2,\dtl@refvalue=#4}{%
+\DTLifnull{\dtl@refvalue}{}{%
+\ifthenelse{\equal{\dtl@refvalue}{#5}}{%
+\global\let#1=\dtl@valueA
+\@endfortrue
+}{}}}%
+}}
+% \end{macrocode}
+%\end{macro}
+%
+%\begin{macro}{\DTLgetrowforkey}
+%\begin{definition}
+%\cs{DTLgetrowforkey}\marg{cmd}\marg{db name}\marg{ref
+% key}\marg{ref value}
+%\end{definition}
+% This (globally) sets \meta{cmd} (a control sequence) to the
+% first row
+% of the database called \meta{db name} which contains the key
+% \meta{ref key} which has the value \meta{value}.
+%\changes{1.01}{2007 Aug 17}{new}
+% \begin{macrocode}
+\newcommand*{\DTLgetrowforkey}[4]{%
+{%
+\global\let#1=\@empty
+\@sDTLforeach{#2}{\dtl@refvalue=#3}{%
+\DTLifnull{\dtl@refvalue}{}{%
+\ifthenelse{\equal{\dtl@refvalue}{#4}}{%
+\expandafter\global\expandafter\let\expandafter#1
+ \csname @dtl@thiscurrentrow@\romannumeral\dtlforeachlevel\endcsname
+\@endfortrue
+}{}}}%
+}}
+% \end{macrocode}
+%\end{macro}
+%
+%\begin{macro}{\DTLsort}
%\begin{definition}
-% \cs{DTLsort}\marg{sort criteria}\marg{db name}
+% \cs{DTLsort}\oarg{replacement keys}\marg{sort criteria}\marg{db name}
%\end{definition}
% Sorts database \meta{db name} according to \marg{sort criteria},
% which must be a comma separated list of keys, and optionally
% \texttt{=}\meta{order}, where \meta{order} is either
-% "ascending" or "descending".
-%\begin{macro}{\DTLsort}
+% "ascending" or "descending". The optional argument is a list of
+% keys to uses if the given key has a null value. The starred
+% version uses a case insensitive string comparison.
+%\changes{1.01}{2007 Aug 17}{added optional argument}
+%\changes{1.01}{2007 Aug 17}{added starred version}
+% \begin{macrocode}
+\newcommand*{\DTLsort}{\@ifstar\@sDTLsort\@DTLsort}
+% \end{macrocode}
+%\end{macro}
+%
+%\begin{macro}{\@DTLsort}
+% Unstarred (case sensitive) version.
+% \begin{macrocode}
+\newcommand*{\@DTLsort}[3][]{%
+\edef\@dtl@replacementkeys{#1}%
+\edef\@dtl@sortorder{#2}%
+\edef\@dtl@dbname{#3}%
+\let\@dtl@comparecs=\dtlcompare
+\expandafter\let\expandafter\@dtl@list\csname dtldb@#3\endcsname
+\dtl@sortlist{\@dtl@list}{\@dtl@sortcriteria}%
+\expandafter\global\expandafter
+ \let\csname dtldb@#3\endcsname=\@dtl@list}
+% \end{macrocode}
+%\end{macro}
+%\begin{macro}{\@sDTLsort}
+% Starred (case insensitive) version.
% \begin{macrocode}
-\newcommand*{\DTLsort}[2]{%
-\edef\@dtl@sortorder{#1}%
-\edef\@dtl@dbname{#2}%
-\protected@edef\@dtl@list{\csname dtldb@#2\endcsname}%
+\newcommand*{\@sDTLsort}[3][]{%
+\edef\@dtl@replacementkeys{#1}%
+\edef\@dtl@sortorder{#2}%
+\edef\@dtl@dbname{#3}%
+\let\@dtl@comparecs=\dtlicompare
+\expandafter\let\expandafter\@dtl@list\csname dtldb@#3\endcsname
\dtl@sortlist{\@dtl@list}{\@dtl@sortcriteria}%
\expandafter\global\expandafter
- \let\csname dtldb@#2\endcsname=\@dtl@list}
+ \let\csname dtldb@#3\endcsname=\@dtl@list}
% \end{macrocode}
%\end{macro}
%
+%\begin{macro}{\@dtl@sortcriteria}
%\begin{definition}
% \cs{@dtl@sortcriteria}\marg{a}\marg{b}
%\end{definition}
-% Sort criteria. \cs{@dtl@currentrow} and
+% Sort criteria. \cs{@dtl@dbname} and
% \cs{@dtl@sortorder} must be set before use.
-%\begin{macro}{\@dtl@sortcriteria}
% \begin{macrocode}
\newcommand{\@dtl@sortcriteria}[2]{%
\@for\@dtl@level:=\@dtl@sortorder\do{%
\expandafter\@dtl@getsortdirection\@dtl@level=\relax%
- \dtl@compare{\@dtl@key}{#1}{#2}%
+ \@ifundefined{@dtl@idtype@\@dtl@dbname @\@dtl@key}{%
+ \ifx\@dtl@replacementkeys\@empty
+ \PackageError{datatool}{Unknown key `\@dtl@key' for database
+ `\@dtl@dbname'}{}%
+ \else
+ \dtl@gathervalues[keya]{\@dtl@dbname}{#1}%
+ \dtl@gathervalues[keyb]{\@dtl@dbname}{#2}%
+ \@ifundefined{@dtl@keya@\@dtl@key}{%
+ \@dtl@setnull{\@dtl@tmpa}{\@dtl@key}%
+ }{%
+ \expandafter\let\expandafter\@dtl@tmpa\expandafter
+ =\csname @dtl@keya@\@dtl@key\endcsname}%
+ \@ifundefined{@dtl@keyb@\@dtl@key}{%
+ \@dtl@setnull{\@dtl@tmpb}{\@dtl@key}%
+ }{%
+ \expandafter\let\expandafter\@dtl@tmpb\expandafter
+ =\csname @dtl@keyb@\@dtl@key\endcsname}%
+ \let\@dtl@keya=\@dtl@key
+ \let\@dtl@keyb=\@dtl@key
+ \DTLifnull{\@dtl@tmpa}{%
+ % find first non null key in list of replacement keys
+ \@for\@dtl@keya:=\@dtl@replacementkeys\do{%
+ \@ifundefined{@dtl@keya@\@dtl@keya}{}{%
+ \expandafter\let\expandafter\@dtl@tmpa\expandafter
+ =\csname @dtl@keya@\@dtl@keya\endcsname
+ \DTLifnull{\@dtl@tmpa}{}{\@endfortrue}}%
+ }%
+ \if@endfor \else\let\@dtl@keya=\@dtl@key \fi
+ \@endforfalse
+ }{}%
+ \DTLifnull{\@dtl@tmpb}{%
+ % find first non null key in list of replacement keys
+ \@for\@dtl@keyb:=\@dtl@replacementkeys\do{%
+ \@ifundefined{@dtl@keyb@\@dtl@keyb}{}{%
+ \expandafter\let\expandafter\@dtl@tmpb\expandafter
+ =\csname @dtl@keyb@\@dtl@keyb\endcsname
+ \DTLifnull{\@dtl@tmpb}{}{\@endfortrue}}%
+ }%
+ \if@endfor \else\let\@dtl@keyb=\@dtl@key \fi
+ \@endforfalse
+ }{}%
+ \@ifundefined{@dtl@idtype@\@dtl@dbname @\@dtl@keya}{%
+ \@ifundefined{@dtl@idtype@\@dtl@dbname @\@dtl@keyb}{%
+ \dtl@sortresult=0\relax}{\dtl@sortresult=-1\relax}%
+ }{%
+ \@ifundefined{@dtl@idtype@\@dtl@dbname @\@dtl@keyb}{%
+ \dtl@sortresult=1\relax}{%
+ \dtl@compare@{\@dtl@keya}{\@dtl@keyb}{#1}{#2}%
+ }%
+ }%
+ \fi
+ }{%
+ \ifx\@dtl@replacementkeys\@empty
+ \dtl@compare{\@dtl@key}{#1}{#2}%
+ \else
+ \dtl@gathervalues[keya]{\@dtl@dbname}{#1}%
+ \dtl@gathervalues[keyb]{\@dtl@dbname}{#2}%
+ \@ifundefined{@dtl@keya@\@dtl@key}{%
+ \@dtl@setnull{\@dtl@tmpa}{\@dtl@key}%
+ }{%
+ \expandafter\let\expandafter\@dtl@tmpa\expandafter
+ =\csname @dtl@keya@\@dtl@key\endcsname}%
+ \@ifundefined{@dtl@keyb@\@dtl@key}{%
+ \@dtl@setnull{\@dtl@tmpb}{\@dtl@key}%
+ }{%
+ \expandafter\let\expandafter\@dtl@tmpb\expandafter
+ =\csname @dtl@keyb@\@dtl@key\endcsname}%
+ \let\@dtl@keya=\@dtl@key
+ \let\@dtl@keyb=\@dtl@key
+ \DTLifnull{\@dtl@tmpa}{%
+ % find first non null key in list of replacement keys
+ \@for\@dtl@keya:=\@dtl@replacementkeys\do{%
+ \@ifundefined{@dtl@keya@\@dtl@keya}{}{%
+ \expandafter\let\expandafter\@dtl@tmpa\expandafter
+ =\csname @dtl@keya@\@dtl@keya\endcsname
+ \DTLifnull{\@dtl@tmpa}{}{\@endfortrue}}%
+ }%
+ \if@endfor \else\let\@dtl@keya=\@dtl@key \fi
+ \@endforfalse
+ }{}%
+ \DTLifnull{\@dtl@tmpb}{%
+ % find first non null key in list of replacement keys
+ \@for\@dtl@keyb:=\@dtl@replacementkeys\do{%
+ \@ifundefined{@dtl@keyb@\@dtl@keyb}{}{%
+ \expandafter\let\expandafter\@dtl@tmpb\expandafter
+ =\csname @dtl@keyb@\@dtl@keyb\endcsname
+ \DTLifnull{\@dtl@tmpb}{}{\@endfortrue}}%
+ }%
+ \if@endfor \else\let\@dtl@keyb=\@dtl@key \fi
+ \@endforfalse
+ }{}%
+ \dtl@compare@{\@dtl@keya}{\@dtl@keyb}{#1}{#2}%
+ \fi
\multiply\dtl@sortresult by \@dtl@sortdirection\relax
\ifnum\dtl@sortresult=0\relax
\else
\@endfortrue
\fi
+ }%
}%
}
% \end{macrocode}
%\end{macro}
+%\begin{macro}{\@dtl@getsortdirection}
% Get the direction from either \meta{key} or
% \meta{key}=\meta{direction}. Sets \cs{@dtl@sortdirection} to
% either -1 (ascending) or 1 (descending).
-%\begin{macro}{\@dtl@getsortdirection}
% \begin{macrocode}
\def\@dtl@getsortdirection#1=#2\relax{%
\def\@dtl@key{#1}%
@@ -7452,9 +10656,9 @@ deeply}{}%
\def\@dtl@sortdirection{-1}%
\else
\@dtl@get@sortdirection#2%
- \DTLifstringeq{\@dtl@sortdirection}{ascending}{%
+ \ifthenelse{\equal{\@dtl@sortdirection}{ascending}}{%
\def\@dtl@sortdirection{-1}}{%
- \DTLifstringeq{\@dtl@sortdirection}{descending}{%
+ \ifthenelse{\equal{\@dtl@sortdirection}{descending}}{%
\def\@dtl@sortdirection{1}}{%
\PackageError{datatool}{Invalid sort direction
`\@dtl@sortdirection'}{%
@@ -7464,36 +10668,93 @@ deeply}{}%
}
% \end{macrocode}
%\end{macro}
-% Get direction
%\begin{macro}{\@dtl@get@sortdirection}
+% Get direction
% \begin{macrocode}
\def\@dtl@get@sortdirection#1={\def\@dtl@sortdirection{#1}}
% \end{macrocode}
%\end{macro}
%
+%\begin{macro}{\dtl@compare}
%\begin{definition}
%\cs{dtl@compare}\marg{key}\marg{a}\marg{b}
%\end{definition}
-% Compare \meta{a} and \meta{b} according to \meta{key} of
+% Compares \meta{a} and \meta{b} according to \meta{key} of
% database given by \cs{@dtl@dbname}. Sets \cs{dtl@sortresult}.
-%\begin{macro}{\dtl@compare}
+% \cs{@dtl@comparecs} must be set to the required comparison macro.
% \begin{macrocode}
+\newtoks\@dtl@toksA\newtoks\@dtl@toksB
\newcommand{\dtl@compare}[3]{%
-\protected@edef\dtl@arga{#2}\protected@edef\dtl@argb{#3}%
-\dtl@gathervalues{\@dtl@dbname}{\dtl@arga}%
-\protected@edef\@dtl@a{\csname @dtl@key@#1\endcsname}%
-\dtl@gathervalues{\@dtl@dbname}{\dtl@argb}%
-\protected@edef\@dtl@b{\csname @dtl@key@#1\endcsname}%
+\dtl@gathervalues{\@dtl@dbname}{#2}%
+\expandafter\let\expandafter\@dtl@tmp\expandafter
+ =\csname @dtl@key@#1\endcsname
+\expandafter\@dtl@toksA\expandafter{\@dtl@tmp}%
+\edef\@dtl@a{\the\@dtl@toksA}%
+\dtl@gathervalues{\@dtl@dbname}{#3}%
+\expandafter\let\expandafter\@dtl@tmp\expandafter
+ =\csname @dtl@key@#1\endcsname
+\expandafter\@dtl@toksB\expandafter{\@dtl@tmp}%
+\edef\@dtl@b{\the\@dtl@toksB}%
\expandafter\@dtl@datatype\expandafter=
\csname @dtl@idtype@\@dtl@dbname @#1\endcsname\relax
\ifnum\@dtl@datatype=0\relax
- \edef\@dtl@result{\noexpand\compare{\@dtl@a}{\@dtl@b}}%
- \expandafter\dtl@sortresult\expandafter=\@dtl@result\relax
+ \edef\@dtl@tmpcmp{%
+ \noexpand\@dtl@comparecs{\noexpand\dtl@sortresult}%
+ {\the\@dtl@toksA}{\the\@dtl@toksB}}%
+ \@dtl@tmpcmp
\else
\DTLifnumlt{\@dtl@a}{\@dtl@b}{\dtl@sortresult=-1\relax}{%
\DTLifnumgt{\@dtl@a}{\@dtl@b}{\dtl@sortresult=1\relax}{%
\dtl@sortresult=0\relax}}%
\fi
+\ifdtlverbose
+\@onelevel@sanitize\@dtl@a
+\@onelevel@sanitize\@dtl@b
+\fi
+\dtl@message{`\@dtl@a' <=> `\@dtl@b' = \number\dtl@sortresult}%
+}
+% \end{macrocode}
+%\end{macro}
+%
+%\begin{macro}{\dtl@compare@}
+%\begin{definition}
+%\cs{dtl@compare@}\marg{keya}\marg{keyb}\marg{a}\marg{b}
+%\end{definition}
+% Compare \meta{a} and \meta{b} according to \meta{keya}
+% and \meta{keyb} of
+% database given by \cs{@dtl@dbname}. Sets \cs{dtl@sortresult}.
+% \cs{@dtl@comparecs} must be set.
+% \begin{macrocode}
+\newcommand{\dtl@compare@}[4]{%
+\dtl@gathervalues{\@dtl@dbname}{#3}%
+\expandafter\let\expandafter\@dtl@tmp\expandafter
+ =\csname @dtl@key@#1\endcsname
+\expandafter\@dtl@toksA\expandafter{\@dtl@tmp}%
+\edef\@dtl@a{\the\@dtl@toksA}%
+\dtl@gathervalues{\@dtl@dbname}{#4}%
+\expandafter\let\expandafter\@dtl@tmp\expandafter
+ =\csname @dtl@key@#2\endcsname
+\expandafter\@dtl@toksB\expandafter{\@dtl@tmp}%
+\edef\@dtl@b{\the\@dtl@toksB}%
+\expandafter\@dtl@tmpcount\expandafter=
+ \csname @dtl@idtype@\@dtl@dbname @#1\endcsname\relax
+\expandafter\@dtl@datatype\expandafter=
+ \csname @dtl@idtype@\@dtl@dbname @#2\endcsname\relax
+\multiply\@dtl@datatype by \@dtl@tmpcount\relax
+\ifnum\@dtl@datatype=0\relax
+ \edef\@dtl@tmpcmp{%
+ \noexpand\@dtl@comparecs{\noexpand\dtl@sortresult}%
+ {\the\@dtl@toksA}{\the\@dtl@toksB}}%
+ \@dtl@tmpcmp
+\else
+ \DTLifnumlt{\@dtl@a}{\@dtl@b}{\dtl@sortresult=-1\relax}{%
+ \DTLifnumgt{\@dtl@a}{\@dtl@b}{\dtl@sortresult=1\relax}{%
+ \dtl@sortresult=0\relax}}%
+\fi
+\ifdtlverbose
+\@onelevel@sanitize\@dtl@a
+\@onelevel@sanitize\@dtl@b
+\fi
\dtl@message{`\@dtl@a' <=> `\@dtl@b' = \number\dtl@sortresult}%
}
% \end{macrocode}
@@ -7501,15 +10762,15 @@ deeply}{}%
%
%\subsection{General List Utilities}
%
+%\begin{macro}{\dtl@choplast}
%\begin{definition}
% \cs{dtl@choplast}\marg{list}\marg{rest}\marg{last}
%\end{definition}
-% Chop the last element off a comma separated list, putting the
+% Chops the last element off a comma separated list, putting the
% last element in the control sequence \meta{last} and putting
% the rest in the control sequence \meta{rest}. The control
% sequence \meta{list} is unchanged. If the list is empty, both
% \meta{last} and \meta{rest} will be empty.
-%\begin{macro}{\dtl@choplast}
% \begin{macrocode}
\newcommand*{\dtl@choplast}[3]{%
% \end{macrocode}
@@ -7555,13 +10816,13 @@ deeply}{}%
% \end{macrocode}
%\end{macro}
%
+%\begin{macro}{\dtl@chopfirst}
%\begin{definition}
% \cs{dtl@chopfirst}\marg{list}\marg{first}\marg{rest}
%\end{definition}
-% Chop first element off \meta{list} and store in \meta{first}.
+% Chops first element off \meta{list} and store in \meta{first}.
% The remainder of the list is stored in \meta{rest}. (\meta{list}
% remains unchanged.)
-%\begin{macro}{\dtl@chopfirst}
% \begin{macrocode}
\newcommand*{\dtl@chopfirst}[3]{%
\let#2=\@empty
@@ -7578,6 +10839,7 @@ deeply}{}%
% \end{macrocode}
%\end{macro}
%
+%\begin{macro}{\dtl@sortlist}
%\begin{definition}
% \cs{dtl@sortlist}\marg{list}\marg{criteria cmd}
%\end{definition}
@@ -7586,72 +10848,79 @@ deeply}{}%
% \meta{criteria cmd} must set the count register \cs{dtl@sortresult}
% to either -1 (\meta{a} less than \meta{b}), 0 (\meta{a} is
% equal to \meta{b}) or 1 (\meta{a} is greater than \meta{b}.)
-%\begin{macro}{\dtl@sortlist}
% \begin{macrocode}
\newcommand{\dtl@sortlist}[2]{%
\def\@dtl@sortedlist{}%
\@for\@dtl@currentrow:=#1\do{%
-\dtl@insertinto{\@dtl@currentrow}{\@dtl@sortedlist}{#2}%
+\expandafter\dtl@insertinto\expandafter
+ {\@dtl@currentrow}{\@dtl@sortedlist}{#2}%
\@endforfalse}%
\let#1=\@dtl@sortedlist
}
% \end{macrocode}
%\end{macro}
%
+%\begin{macro}{\dtl@insertinto}
%\begin{definition}
% \cs{dtl@insertinto}\marg{element}\marg{sorted-list}\marg{criteria cmd}
%\end{definition}
% Inserts \meta{element} into the sorted list \meta{sorted-list}
% according to the criteria given by \meta{criteria cmd} (see above.)
-%\begin{macro}{\dtl@insertinto}
% \begin{macrocode}
\newtoks\@dtl@toks
\newcommand{\dtl@insertinto}[3]{%
\def\@dtl@newsortedlist{}%
\@dtl@insertdonefalse
\@for\dtl@srtelement:=#2\do{%
-\expandafter\toks@\expandafter{\@dtl@newsortedlist}%
\if@dtl@insertdone
- \protected@edef\@dtl@newstuff{{\dtl@srtelement}}%
+ \expandafter\toks@\expandafter{\dtl@srtelement}%
+ \edef\@dtl@newstuff{{\the\toks@}}%
\else
\expandafter#3\expandafter{\dtl@srtelement}{#1}%
\ifnum\dtl@sortresult<0\relax
- \protected@edef\@dtl@newstuff{{#1},{\dtl@srtelement}}%
+ \expandafter\toks@\expandafter{\dtl@srtelement}%
+ \@dtl@toks{#1}%
+ \edef\@dtl@newstuff{{\the\@dtl@toks},{\the\toks@}}%
\@dtl@insertdonetrue
\else
- \protected@edef\@dtl@newstuff{{\dtl@srtelement}}%
+ \expandafter\toks@\expandafter{\dtl@srtelement}%
+ \edef\@dtl@newstuff{{\the\toks@}}%
\fi
\fi
\ifx\@dtl@newsortedlist\@empty
- \protected@edef\@dtl@newsortedlist{\@dtl@newstuff}%
+ \expandafter\toks@\expandafter{\@dtl@newstuff}%
+ \edef\@dtl@newsortedlist{\the\toks@}%
\else
\expandafter\toks@\expandafter{\@dtl@newsortedlist}%
- \protected@edef\@dtl@newsortedlist{\the\toks@,\@dtl@newstuff}%
+ \expandafter\@dtl@toks\expandafter{\@dtl@newstuff}%
+ \edef\@dtl@newsortedlist{\the\toks@,\the\@dtl@toks}%
\fi
\@endforfalse
}%
\ifx\@dtl@newsortedlist\@empty
- \protected@edef\@dtl@newsortedlist{{#1}}%
+ \@dtl@toks{#1}%
+ \edef\@dtl@newsortedlist{{\the\@dtl@toks}}%
\else
\if@dtl@insertdone
\else
\expandafter\toks@\expandafter{\@dtl@newsortedlist}%
- \protected@edef\@dtl@newsortedlist{\the\toks@,{#1}}%
+ \@dtl@toks{#1}%
+ \edef\@dtl@newsortedlist{\the\toks@,{\the\@dtl@toks}}%
\fi
\fi
\global\let#2=\@dtl@newsortedlist
}
% \end{macrocode}
%\end{macro}
+%\begin{macro}{\if@dtl@insertdone}
% Define conditional to indicate whether the new entry has
% been inserted into the sorted list.
-%\begin{macro}{\if@dtl@insertdone}
% \begin{macrocode}
\newif\if@dtl@insertdone
% \end{macrocode}
%\end{macro}
-% Define \cs{dtl@sortresult} to be set by comparision macro.
%\begin{macro}{\dtl@sortresult}
+% Define \cs{dtl@sortresult} to be set by comparision macro.
% \begin{macrocode}
\newcount\dtl@sortresult
% \end{macrocode}
@@ -7662,11 +10931,11 @@ deeply}{}%
% commands provided by the \sty{fp} package, but first convert
% the decimal number into the required format.
%
+%\begin{macro}{\DTLadd}
%\begin{definition}
% \cs{DTLadd}\marg{cmd}\marg{num1}\marg{num2}
%\end{definition}
% Sets \meta{cmd} = \meta{num1} + \meta{num2}
-%\begin{macro}{\DTLadd}
% \begin{macrocode}
\newcommand*{\DTLadd}[3]{%
\DTLconverttodecimal{#2}{\@dtl@numi}%
@@ -7680,8 +10949,8 @@ deeply}{}%
}
% \end{macrocode}
%\end{macro}
-% Global version
%\begin{macro}{\DTLgadd}
+% Global version
% \begin{macrocode}
\newcommand*{\DTLgadd}[3]{%
\DTLadd{\@dtl@tmpii}{#2}{#3}%
@@ -7690,19 +10959,20 @@ deeply}{}%
% \end{macrocode}
%\end{macro}
%
+%\begin{macro}{\DTLaddall}
%\begin{definition}
%\cs{DTLaddall}\marg{cmd}\marg{num list}
%\end{definition}
% Sums all the values in \meta{num list} and stores in
% \meta{cmd} which must be a control sequence.
-%\begin{macro}{\DTLaddall}
+%\changes{1.01}{2007 Aug 17}{removed extraneous space}
% \begin{macrocode}
\newcommand*{\DTLaddall}[2]{%
\def\@dtl@sum{0}%
\@for\dtl@thisval:=#2\do{%
\DTLconverttodecimal{\dtl@thisval}{\@dtl@num}%
\FPadd{\@dtl@sum}{\@dtl@sum}{\@dtl@num}%
-}
+}%
\ifx\@dtl@replaced\@empty
\DTLdecimaltolocale{\@dtl@sum}{#1}%
\else
@@ -7711,11 +10981,11 @@ deeply}{}%
}
% \end{macrocode}
%\end{macro}
+%\begin{macro}{\DTLgaddall}
%\begin{definition}
%\cs{DTLgaddall}\marg{cmd}\marg{num list}
%\end{definition}
% Global version
-%\begin{macro}{\DTLgaddall}
% \begin{macrocode}
\newcommand*{\DTLgaddall}[2]{%
\DTLaddall{\@dtl@tmpi}{#2}%
@@ -7724,11 +10994,11 @@ deeply}{}%
% \end{macrocode}
%\end{macro}
%
+%\begin{macro}{\DTLsub}
%\begin{definition}
% \cs{DTLsub}\marg{cmd}\marg{num1}\marg{num2}
%\end{definition}
% Sets \meta{cmd} = \meta{num1} - \meta{num2}
-%\begin{macro}{\DTLsub}
% \begin{macrocode}
\newcommand*{\DTLsub}[3]{%
\DTLconverttodecimal{#2}{\@dtl@numi}%
@@ -7742,8 +11012,8 @@ deeply}{}%
}
% \end{macrocode}
%\end{macro}
-% Global version
%\begin{macro}{\DTLgsub}
+% Global version
% \begin{macrocode}
\newcommand*{\DTLgsub}[3]{%
\DTLsub{\@dtl@tmpii}{#2}{#3}%
@@ -7752,11 +11022,11 @@ deeply}{}%
% \end{macrocode}
%\end{macro}
%
+%\begin{macro}{\DTLmul}
%\begin{definition}
% \cs{DTLmul}\marg{cmd}\marg{num1}\marg{num2}
%\end{definition}
-% Sets \meta{cmd} = \meta{num1} * \meta{num2}
-%\begin{macro}{\DTLmul}
+% Sets \meta{cmd} = \meta{num1} $\times$ \meta{num2}
% \begin{macrocode}
\newcommand*{\DTLmul}[3]{%
\let\@dtl@thisreplaced=\@empty
@@ -7779,8 +11049,8 @@ deeply}{}%
}
% \end{macrocode}
%\end{macro}
-% Global version
%\begin{macro}{\DTLgmul}
+% Global version
% \begin{macrocode}
\newcommand*{\DTLgmul}[3]{%
\DTLmul{\@dtl@tmpii}{#2}{#3}%
@@ -7789,11 +11059,11 @@ deeply}{}%
% \end{macrocode}
%\end{macro}
%
+%\begin{macro}{\DTLdiv}
%\begin{definition}
% \cs{DTLdiv}\marg{cmd}\marg{num1}\marg{num2}
%\end{definition}
% Sets \meta{cmd} = \meta{num1} / \meta{num2}
-%\begin{macro}{\DTLdiv}
% \begin{macrocode}
\newcommand*{\DTLdiv}[3]{%
\let\@dtl@thisreplaced=\@empty
@@ -7816,8 +11086,8 @@ deeply}{}%
}
% \end{macrocode}
%\end{macro}
-% Global version
%\begin{macro}{\DTLgdiv}
+% Global version
% \begin{macrocode}
\newcommand*{\DTLgdiv}[3]{%
\DTLdiv{\@dtl@tmpii}{#2}{#3}%
@@ -7826,11 +11096,11 @@ deeply}{}%
% \end{macrocode}
%\end{macro}
%
+%\begin{macro}{\DTLabs}
%\begin{definition}
% \cs{DTLabs}\marg{cmd}\marg{num}
%\end{definition}
% Sets \meta{cmd} = abs(\meta{num})
-%\begin{macro}{\DTLabs}
% \begin{macrocode}
\newcommand*{\DTLabs}[2]{%
\DTLconverttodecimal{#2}{\@dtl@numi}%
@@ -7843,8 +11113,8 @@ deeply}{}%
}
% \end{macrocode}
%\end{macro}
-% Global version
%\begin{macro}{\DTLgabs}
+% Global version
% \begin{macrocode}
\newcommand*{\DTLgabs}[2]{%
\DTLabs{\@dtl@tmpii}{#2}%
@@ -7853,11 +11123,11 @@ deeply}{}%
% \end{macrocode}
%\end{macro}
%
+%\begin{macro}{\DTLneg}
%\begin{definition}
% \cs{DTLneg}\marg{cmd}\marg{num}
%\end{definition}
% Sets \meta{cmd} = -\meta{num}
-%\begin{macro}{\DTLneg}
% \begin{macrocode}
\newcommand*{\DTLneg}[2]{%
\DTLconverttodecimal{#2}{\@dtl@numi}%
@@ -7870,8 +11140,8 @@ deeply}{}%
}
% \end{macrocode}
%\end{macro}
-% Global version
%\begin{macro}{\DTLgneg}
+% Global version
% \begin{macrocode}
\newcommand*{\DTLgneg}[2]{%
\DTLneg{\@dtl@tmpii}{#2}%
@@ -7880,11 +11150,11 @@ deeply}{}%
% \end{macrocode}
%\end{macro}
%
+%\begin{macro}{\DTLsqrt}
%\begin{definition}
% \cs{DTLsqrt}\marg{cmd}\marg{num}
%\end{definition}
% Sets \meta{cmd} = sqrt(\meta{num})
-%\begin{macro}{\DTLsqrt}
% \begin{macrocode}
\newcommand*{\DTLsqrt}[2]{%
\DTLconverttodecimal{#2}{\@dtl@numi}%
@@ -7897,8 +11167,8 @@ deeply}{}%
}
% \end{macrocode}
%\end{macro}
-% Global version
%\begin{macro}{\DTLgsqrt}
+% Global version
% \begin{macrocode}
\newcommand*{\DTLgsqrt}[2]{%
\DTLsqrt{\@dtl@tmpii}{#2}%
@@ -7907,11 +11177,11 @@ deeply}{}%
% \end{macrocode}
%\end{macro}
%
+%\begin{macro}{\DTLmin}
%\begin{definition}
% \cs{DTLmin}\marg{cmd}\marg{num1}\marg{num2}
%\end{definition}
% Sets \meta{cmd} = min(\meta{num1}, \meta{num2})
-%\begin{macro}{\DTLmin}
% \begin{macrocode}
\newcommand*{\DTLmin}[3]{%
\DTLconverttodecimal{#2}{\@dtl@numi}%
@@ -7928,8 +11198,8 @@ deeply}{}%
}
% \end{macrocode}
%\end{macro}
-% Global version
%\begin{macro}{\DTLgmin}
+% Global version
% \begin{macrocode}
\newcommand*{\DTLgmin}[3]{%
\DTLmin{\@dtl@tmpii}{#2}{#3}%
@@ -7938,12 +11208,13 @@ deeply}{}%
% \end{macrocode}
%\end{macro}
%
+%\begin{macro}{\DTLminall}
%\begin{definition}
%\cs{DTLminall}\marg{cmd}\marg{num list}
%\end{definition}
% Finds the minimum value in \meta{num list} and stores in
% \meta{cmd} which must be a control sequence.
-%\begin{macro}{\DTLminall}
+%\changes{1.01}{2007 Aug 17}{removed extraneous space}
% \begin{macrocode}
\newcommand*{\DTLminall}[2]{%
\let\@dtl@min=\@empty
@@ -7954,7 +11225,7 @@ deeply}{}%
\else
\FPmin{\@dtl@min}{\@dtl@min}{\@dtl@num}%
\fi
-}
+}%
\ifx\@dtl@replaced\@empty
\DTLdecimaltolocale{\@dtl@min}{#1}%
\else
@@ -7963,11 +11234,11 @@ deeply}{}%
}
% \end{macrocode}
%\end{macro}
+%\begin{macro}{\DTLgminall}
%\begin{definition}
%\cs{DTLgminall}\marg{cmd}\marg{num list}
%\end{definition}
% Global version
-%\begin{macro}{\DTLgminall}
% \begin{macrocode}
\newcommand*{\DTLgminall}[2]{%
\DTLminall{\@dtl@tmpi}{#2}%
@@ -7976,11 +11247,11 @@ deeply}{}%
% \end{macrocode}
%\end{macro}
%
+%\begin{macro}{\DTLmax}
%\begin{definition}
% \cs{DTLmax}\marg{cmd}\marg{num1}\marg{num2}
%\end{definition}
% Sets \meta{cmd} = max(\meta{num1}, \meta{num2})
-%\begin{macro}{\DTLmax}
% \begin{macrocode}
\newcommand*{\DTLmax}[3]{%
\DTLconverttodecimal{#2}{\@dtl@numi}%
@@ -7998,8 +11269,8 @@ deeply}{}%
}
% \end{macrocode}
%\end{macro}
-% Global version
%\begin{macro}{\DTLgmax}
+% Global version
% \begin{macrocode}
\newcommand*{\DTLgmax}[3]{%
\DTLmax{\@dtl@tmpii}{#2}{#3}%
@@ -8008,12 +11279,13 @@ deeply}{}%
% \end{macrocode}
%\end{macro}
%
+%\begin{macro}{\DTLmaxall}
%\begin{definition}
%\cs{DTLmaxall}\marg{cmd}\marg{num list}
%\end{definition}
% Finds the maximum value in \meta{num list} and stores in
% \meta{cmd} which must be a control sequence.
-%\begin{macro}{\DTLmaxall}
+%\changes{1.01}{2007 Aug 17}{removed extraneous space}
% \begin{macrocode}
\newcommand*{\DTLmaxall}[2]{%
\let\@dtl@max=\@empty
@@ -8024,7 +11296,7 @@ deeply}{}%
\else
\FPmax{\@dtl@max}{\@dtl@max}{\@dtl@num}%
\fi
-}
+}%
\ifx\@dtl@replaced\@empty
\DTLdecimaltolocale{\@dtl@max}{#1}%
\else
@@ -8033,11 +11305,11 @@ deeply}{}%
}
% \end{macrocode}
%\end{macro}
+%\begin{macro}{\DTLgmaxall}
%\begin{definition}
%\cs{DTLgmaxall}\marg{cmd}\marg{num list}
%\end{definition}
% Global version
-%\begin{macro}{\DTLgmaxall}
% \begin{macrocode}
\newcommand*{\DTLgmaxall}[2]{%
\DTLmaxall{\@dtl@tmpi}{#2}%
@@ -8046,12 +11318,13 @@ deeply}{}%
% \end{macrocode}
%\end{macro}
%
+%\begin{macro}{\DTLmeanforall}
%\begin{definition}
%\cs{DTLmeanforall}\marg{cmd}\marg{num list}
%\end{definition}
% Computes the arithmetic mean of all the values in \meta{num list}
% and stores in \meta{cmd} which must be a control sequence.
-%\begin{macro}{\DTLmeanforall}
+%\changes{1.01}{2007 Aug 17}{removed extraneous space}
% \begin{macrocode}
\newcommand*{\DTLmeanforall}[2]{%
\def\@dtl@mean{0}%
@@ -8060,7 +11333,7 @@ deeply}{}%
\DTLconverttodecimal{\dtl@thisval}{\@dtl@num}%
\FPadd{\@dtl@mean}{\@dtl@mean}{\@dtl@num}%
\FPadd{\@dtl@n}{\@dtl@n}{1}%
-}
+}%
\FPdiv{\@dtl@mean}{\@dtl@mean}{\@dtl@n}%
\ifx\@dtl@replaced\@empty
\DTLdecimaltolocale{\@dtl@mean}{#1}%
@@ -8070,11 +11343,11 @@ deeply}{}%
}
% \end{macrocode}
%\end{macro}
+%\begin{macro}{\DTLgmeanforall}
%\begin{definition}
%\cs{DTLgmeanforall}\marg{cmd}\marg{num list}
%\end{definition}
% Global version
-%\begin{macro}{\DTLgmeanforall}
% \begin{macrocode}
\newcommand*{\DTLgmeanforall}[2]{%
\DTLmeanforall{\@dtl@tmpi}{#2}%
@@ -8083,12 +11356,14 @@ deeply}{}%
% \end{macrocode}
%\end{macro}
%
+%\begin{macro}{\DTLvarianceforall}
%\begin{definition}
%\cs{DTLvarianceforall}\marg{cmd}\marg{num list}
%\end{definition}
% Computes the variance of all the values in \meta{num list}
% and stores in \meta{cmd} which must be a control sequence.
-%\begin{macro}{\DTLvarianceforall}
+%\changes{1.01}{2007 Aug 17}{fixed bug}
+%\changes{1.01}{2007 Aug 17}{removed extraneous space}
% \begin{macrocode}
\newcommand*{\DTLvarianceforall}[2]{%
\def\@dtl@mean{0}%
@@ -8099,18 +11374,19 @@ deeply}{}%
\ifx\@dtl@decvals\@empty
\let\@dtl@decvals=\@dtl@num
\else
- \edef\@dtl@decvals{\@dtl@decvals,\@dtl@num}%
+ \expandafter\toks@\expandafter{\@dtl@decvals}%
+ \edef\@dtl@decvals{\the\toks@,\@dtl@num}%
\fi
\FPadd{\@dtl@mean}{\@dtl@mean}{\@dtl@num}%
\FPadd{\@dtl@n}{\@dtl@n}{1}%
-}
+}%
\FPdiv{\@dtl@mean}{\@dtl@mean}{\@dtl@n}%
\def\@dtl@var{0}%
-\@for\dtl@num:=\@dtl@decvals\do{%
- \FPsub{\@dtl@diff}{\@dtl@var}{\@dtl@mean}%
+\@for\@dtl@num:=\@dtl@decvals\do{%
+ \FPsub{\@dtl@diff}{\@dtl@num}{\@dtl@mean}%
\FPmul{\@dtl@diff}{\@dtl@diff}{\@dtl@diff}%
\FPadd{\@dtl@var}{\@dtl@var}{\@dtl@diff}%
-}
+}%
\FPdiv{\@dtl@var}{\@dtl@var}{\@dtl@n}%
\ifx\@dtl@replaced\@empty
\DTLdecimaltolocale{\@dtl@var}{#1}%
@@ -8120,11 +11396,11 @@ deeply}{}%
}
% \end{macrocode}
%\end{macro}
+%\begin{macro}{\DTLgvarianceforall}
%\begin{definition}
%\cs{DTLgvarianceforall}\marg{cmd}\marg{num list}
%\end{definition}
% Global version
-%\begin{macro}{\DTLgvarianceforall}
% \begin{macrocode}
\newcommand*{\DTLgvarianceforall}[2]{%
\DTLvarianceforall{\@dtl@tmpi}{#2}%
@@ -8133,12 +11409,14 @@ deeply}{}%
% \end{macrocode}
%\end{macro}
%
+%\begin{macro}{\DTLsdforall}
%\begin{definition}
%\cs{DTLsdforall}\marg{cmd}\marg{num list}
%\end{definition}
% Computes the standard deviation of all the values in \meta{num list}
% and stores in \meta{cmd} which must be a control sequence.
-%\begin{macro}{\DTLsdforall}
+%\changes{1.01}{2007 Aug 17}{fixed bug}
+%\changes{1.01}{2007 Aug 17}{removed extraneous space}
% \begin{macrocode}
\newcommand*{\DTLsdforall}[2]{%
\def\@dtl@mean{0}%
@@ -8149,18 +11427,19 @@ deeply}{}%
\ifx\@dtl@decvals\@empty
\let\@dtl@decvals=\@dtl@num
\else
- \edef\@dtl@decvals{\@dtl@decvals,\@dtl@num}%
+ \expandafter\toks@\expandafter{\@dtl@decvals}%
+ \edef\@dtl@decvals{\the\toks@,\@dtl@num}%
\fi
\FPadd{\@dtl@mean}{\@dtl@mean}{\@dtl@num}%
\FPadd{\@dtl@n}{\@dtl@n}{1}%
-}
+}%
\FPdiv{\@dtl@mean}{\@dtl@mean}{\@dtl@n}%
\def\@dtl@sd{0}%
-\@for\dtl@num:=\@dtl@decvals\do{%
+\@for\@dtl@num:=\@dtl@decvals\do{%
\FPsub{\@dtl@diff}{\@dtl@num}{\@dtl@mean}%
\FPmul{\@dtl@diff}{\@dtl@diff}{\@dtl@diff}%
\FPadd{\@dtl@sd}{\@dtl@sd}{\@dtl@diff}%
-}
+}%
\FPdiv{\@dtl@sd}{\@dtl@sd}{\@dtl@n}%
\FProot{\@dtl@sd}{\@dtl@sd}{2}%
\ifx\@dtl@replaced\@empty
@@ -8171,11 +11450,11 @@ deeply}{}%
}
% \end{macrocode}
%\end{macro}
+%\begin{macro}{\DTLgsdforall}
%\begin{definition}
%\cs{DTLgsdforall}\marg{cmd}\marg{num list}
%\end{definition}
% Global version
-%\begin{macro}{\DTLgsdforall}
% \begin{macrocode}
\newcommand*{\DTLgsdforall}[2]{%
\DTLsdforall{\@dtl@tmpi}{#2}%
@@ -8184,12 +11463,12 @@ deeply}{}%
% \end{macrocode}
%\end{macro}
%
+%\begin{macro}{\DTLround}
%\begin{definition}
% \cs{DTLround}\marg{cmd}\marg{num}\marg{num digits}
%\end{definition}
% Sets \meta{cmd} to \meta{num} rounded to \meta{num digits}
% digits after the decimal character.
-%\begin{macro}{\DTLround}
% \begin{macrocode}
\newcommand*{\DTLround}[3]{%
\DTLconverttodecimal{#2}{\@dtl@numi}%
@@ -8202,8 +11481,8 @@ deeply}{}%
}
% \end{macrocode}
%\end{macro}
-% Global version
%\begin{macro}{\DTLground}
+% Global version
% \begin{macrocode}
\newcommand*{\DTLground}[3]{%
\DTLround{\@dtl@tmpii}{#2}{#3}%
@@ -8212,12 +11491,12 @@ deeply}{}%
% \end{macrocode}
%\end{macro}
%
+%\begin{macro}{\DTLtrunc}
%\begin{definition}
% \cs{DTLtrunc}\marg{cmd}\marg{num}\marg{num digits}
%\end{definition}
% Sets \meta{cmd} to \meta{num} truncated to \meta{num digits}
% digits after the decimal character.
-%\begin{macro}{\DTLtrunc}
% \begin{macrocode}
\newcommand*{\DTLtrunc}[3]{%
\DTLconverttodecimal{#2}{\@dtl@numi}%
@@ -8230,8 +11509,8 @@ deeply}{}%
}
% \end{macrocode}
%\end{macro}
-% Global version
%\begin{macro}{\DTLgtrunc}
+% Global version
% \begin{macrocode}
\newcommand*{\DTLgtrunc}[3]{%
\DTLtrunc{\@dtl@tmpii}{#2}{#3}%
@@ -8240,11 +11519,11 @@ deeply}{}%
% \end{macrocode}
%\end{macro}
%
+%\begin{macro}{\DTLclip}
%\begin{definition}
% \cs{DTLclip}\marg{cmd}\marg{num}
%\end{definition}
% Sets \meta{cmd} to \meta{num} with all unnecessary 0's removed.
-%\begin{macro}{\DTLclip}
% \begin{macrocode}
\newcommand*{\DTLclip}[2]{%
\DTLconverttodecimal{#2}{\@dtl@numi}%
@@ -8257,8 +11536,8 @@ deeply}{}%
}
% \end{macrocode}
%\end{macro}
-% Global version
%\begin{macro}{\DTLgclip}
+% Global version
% \begin{macrocode}
\newcommand*{\DTLgclip}[3]{%
\DTLclip{\@dtl@tmpii}{#2}%
@@ -8267,29 +11546,75 @@ deeply}{}%
% \end{macrocode}
%\end{macro}
%
+%\begin{macro}{\DTLinitials}
%\subsection{String Macros}
%\begin{definition}
%\cs{DTLinitials}\marg{string}
%\end{definition}
% Convert a string into initials.
-%\begin{macro}{\DTLinitials}
+% (Any "~" character found is first converted into a space.)
+%\changes{1.01}{2007 Aug 17}{now works with unbreakable space symbol}
+%\changes{1.01}{2007 Aug 17}{now uses \cs{DTLinitialhyphen}}
% \begin{macrocode}
-\newcommand*{\DTLinitials}[1]{%
+\newcommand*\DTLinitials[1]{%
\def\dtl@initialscmd{}%
-\protected@edef\dtl@string{#1}%
-\expandafter\dtl@initials\dtl@string{} \@nil
-\dtl@initialscmd}
+\dtl@subnobrsp{#1}{\dtl@string}%
+\DTLsubstituteall{\dtl@string}{~}{ }%
+\DTLsubstituteall{\dtl@string}{\ }{ }%
+\DTLsubstituteall{\dtl@string}{\space}{ }%
+\expandafter\dtl@initials\dtl@string{} \@nil%
+\dtl@initialscmd}%
+% \end{macrocode}
+%\end{macro}
+% The following substitutes "\protect \nobreakspace {}" with
+% a space. (Note that in this case the space following
+% "\nobreakspace" forms part of the command.)
+% \begin{macrocode}
+\edef\dtl@construct@subnobrsp{%
+\noexpand\def\noexpand\@dtl@subnobrsp##1\noexpand\protect
+\expandafter\noexpand\csname nobreakspace \endcsname ##2{%
+\noexpand\toks@{##1}%
+\noexpand\expandafter\noexpand\@dtl@toks\noexpand\expandafter{%
+\noexpand\@dtl@string}%
+\noexpand\edef\noexpand\@dtl@string{\noexpand\the\noexpand\@dtl@toks
+\noexpand\the\noexpand\toks@}%
+\noexpand\def\noexpand\@dtl@tmp{##2}%
+\noexpand\ifx\noexpand\@dtl@tmp\noexpand\@nnil
+ \noexpand\let\noexpand\@dtl@subnobrspnext=\noexpand\relax
+\noexpand\else
+ \noexpand\toks@{ }%
+ \noexpand\expandafter\noexpand\@dtl@toks\noexpand\expandafter{%
+ \noexpand\@dtl@string}%
+ \noexpand\edef\noexpand\@dtl@string{\noexpand\the\noexpand\@dtl@toks
+ \noexpand\the\noexpand\toks@}%
+ \noexpand\let\noexpand\@dtl@subnobrspnext=\noexpand\@dtl@subnobrsp
+\noexpand\fi
+\noexpand\@dtl@subnobrspnext
+}%
+\noexpand\def\noexpand\dtl@subnobrsp##1##2{%
+\noexpand\def\noexpand\@dtl@string{}%
+\noexpand\@dtl@subnobrsp ##1\noexpand\protect\expandafter\noexpand
+\csname nobreakspace \endcsname \noexpand\@nil
+\noexpand\let##2=\noexpand\@dtl@string
+}}
+\dtl@construct@subnobrsp
% \end{macrocode}
-%\end{macro}
+%
+%\begin{macro}{\DTLstoreinitials}
%\begin{definition}
%\cs{DTLstoreinitials}\marg{string}\marg{cmd}
%\end{definition}
-% Convert a string into initials and store in \meta{cmd}
-%\begin{macro}{\DTLstoreinitials}
+% Convert a string into initials and store in \meta{cmd}.
+% (Any "~" character found is first converted into a space.)
+%\changes{1.01}{2007 Aug 17}{now works with unbreakable space symbol}
+%\changes{1.01}{2007 Aug 17}{now uses \cs{DTLinitialhyphen}}
% \begin{macrocode}
\newcommand*{\DTLstoreinitials}[2]{%
\def\dtl@initialscmd{}%
-\protected@edef\dtl@string{#1}%
+\dtl@subnobrsp{#1}{\dtl@string}%
+\DTLsubstituteall{\dtl@string}{~}{ }%
+\DTLsubstituteall{\dtl@string}{\ }{ }%
+\DTLsubstituteall{\dtl@string}{\space}{ }%
\expandafter\dtl@initials\dtl@string{} \@nil
\let#2=\dtl@initialscmd
}
@@ -8298,7 +11623,22 @@ deeply}{}%
%\begin{macro}{\dtl@initials}
% \begin{macrocode}
\def\dtl@initials#1#2 #3{%
-\def\dtl@tmp{#3}%
+\dtl@ifsingle{#1}{%
+\ifcat\noexpand#1\relax\relax
+ \def\@dtl@donextinitials{\@dtl@initials#2 {#3}}%
+\else
+ \def\@dtl@donextinitials{\@dtl@initials#1#2 {#3}}%
+\fi
+}{%
+ \def\@dtl@donextinitials{\@dtl@initials{#1}#2 {#3}}%
+}%
+\@dtl@donextinitials
+}
+% \end{macrocode}
+%\end{macro}
+%\begin{macro}{\@dtl@initials}
+% \begin{macrocode}
+\def\@dtl@initials#1#2 #3{%
\dtl@initialshyphen#2-{}\dtl@endhyp
\expandafter\@dtl@toks\expandafter{\dtl@initialscmd}%
\toks@{#1}%
@@ -8308,6 +11648,7 @@ deeply}{}%
\expandafter\@dtl@toks\expandafter{\dtl@initialscmd}%
\expandafter\toks@\expandafter{\dtl@inithyphen}%
\fi
+\def\dtl@tmp{#3}%
\ifx\@nnil\dtl@tmp
\edef\dtl@initialscmd{\the\@dtl@toks\the\toks@\DTLafterinitials}%
\let\dtl@initialsnext=\@gobble
@@ -8315,7 +11656,7 @@ deeply}{}%
\edef\dtl@initialscmd{\the\@dtl@toks\the\toks@\DTLbetweeninitials}%
\let\dtl@initialsnext=\dtl@initials
\fi
-\dtl@initialsnext#3}
+\dtl@initialsnext{#3}}
% \end{macrocode}
%\end{macro}
%\begin{macro}{\dtl@initialshyphen}
@@ -8324,31 +11665,44 @@ deeply}{}%
\def\dtl@inithyphen{#2}%
\ifx\dtl@inithyphen\@empty
\else
- \edef\dtl@inithyphen{\DTLafterinitialbeforehyphen-#2}%
+ \edef\dtl@inithyphen{%
+ \DTLafterinitialbeforehyphen\DTLinitialhyphen#2}%
\fi
}
% \end{macrocode}
%\end{macro}
-% Define what to do after the final initial:
%\begin{macro}{\DTLafterinitials}
+% Defines what to do after the final initial.
% \begin{macrocode}
\newcommand*{\DTLafterinitials}{.}
% \end{macrocode}
%\end{macro}
-% Define what to do between initials:
%\begin{macro}{\DTLbetweeninitials}
+% Defines what to do between initials.
% \begin{macrocode}
\newcommand*{\DTLbetweeninitials}{.}
% \end{macrocode}
%\end{macro}
-% Define what to do before a hyphen:
%\begin{macro}{\DTLafterinitialbeforehyphen}
+% Defines what to do before a hyphen.
% \begin{macrocode}
\newcommand*{\DTLafterinitialbeforehyphen}{.}
% \end{macrocode}
%\end{macro}
+%\begin{macro}{\DTLinitialhyphen}
+%Defines what to do at the hyphen
+%\changes{1.01}{2007 Aug 17}{new}
+% \begin{macrocode}
+\newcommand*{\DTLinitialhyphen}{-}
+% \end{macrocode}
+%\end{macro}
%
%\begin{macro}{\DTLifAllUpperCase}
+%\begin{definition}
+%\cs{DTLifAllUpperCase}\marg{string}\marg{true part}\marg{false part}
+%\end{definition}
+% If \meta{string} only contains uppercase characters do \meta{true
+%part}, otherwise do \meta{false part}.
% \begin{macrocode}
\newcommand*{\DTLifAllUpperCase}[3]{%
\protected@edef\dtl@tuc{#1}%
@@ -8377,7 +11731,7 @@ deeply}{}%
\edef\dtl@tc@arg{\string#1}%
\expandafter\dtl@test@ifuppercase\dtl@tc@arg\end
\ifx\dtl@argii\@nnil
- \let\dtl@testifuppernext=\dtl@testifcasenoop
+ \let\dtl@testifuppernext=\@dtl@gobbletonil
\fi
\fi
\fi
@@ -8424,18 +11778,18 @@ deeply}{}%
\let\dtl@testifuppernext=\dtl@testifuppercase
\else
\@dtl@conditionfalse
- \let\dtl@testifuppernext=\dtl@testifcasenoop
+ \let\dtl@testifuppernext=\@dtl@gobbletonil
\fi
\fi
}}}
% \end{macrocode}
%\end{macro}
-%\begin{macro}{\dtl@testifcasenoop}
-% \begin{macrocode}
-\def\dtl@testifcasenoop#1\@nil{}
-% \end{macrocode}
-%\end{macro}
%\begin{macro}{\DTLifAllLowerCase}
+%\begin{definition}
+%\cs{DTLifAllLowerCase}\marg{string}\marg{true part}\marg{false part}
+%\end{definition}
+% If \meta{string} only contains lowercase characters do \meta{true
+%part}, otherwise do \meta{false part}.
% \begin{macrocode}
\newcommand*{\DTLifAllLowerCase}[3]{%
\protected@edef\dtl@tlc{#1}%
@@ -8463,7 +11817,7 @@ deeply}{}%
\edef\dtl@tc@arg{\string#1}%
\expandafter\dtl@test@iflowercase\dtl@tc@arg\end
\ifx\dtl@argii\@nnil
- \let\dtl@testiflowernext=\dtl@testifcasenoop
+ \let\dtl@testiflowernext=\@dtl@gobbletonil
\fi
\fi
\fi
@@ -8510,7 +11864,7 @@ deeply}{}%
\let\dtl@testiflowernext=\dtl@testiflowercase
\else
\@dtl@conditionfalse
- \let\dtl@testiflowernext=\dtl@testifcasenoop
+ \let\dtl@testiflowernext=\@dtl@gobbletonil
\fi
\fi
}}}
@@ -8524,12 +11878,12 @@ deeply}{}%
\newwrite\@dtl@write
% \end{macrocode}
%\end{macro}
+%\begin{macro}{\DTLsavedb}
%\begin{definition}
% \cs{DTLsavedb}\marg{db name}\marg{filename}
%\end{definition}
% Save a database as an ASCII data file using the separator
% and delimiter given by \cs{@dtl@separator} and \cs{@dtl@delimiter}.
-%\begin{macro}{\DTLsavedb}
% \begin{macrocode}
\newcommand*{\DTLsavedb}[2]{%
\DTLifdbexists{#1}{%
@@ -8589,14 +11943,15 @@ deeply}{}%
% \end{macrocode}
%\end{macro}
%
+%\begin{macro}{\DTLsavetexdb}
%\begin{definition}
% \cs{DTLsavetexdb}\marg{db name}\marg{filename}
%\end{definition}
% Save a database as a \LaTeX\ file.
-%\begin{macro}{\DTLsavetexdb}
% \begin{macrocode}
\newcommand*{\DTLsavetexdb}[2]{%
\DTLifdbexists{#1}{%
+\def\@dtl@dbname{#1}%
\openout\@dtl@write=#2%
\edef\@dtl@keys{\csname dtlkeys@#1\endcsname}%
\protected@write\@dtl@write{}{\string\DTLnewdb{#1}}%
@@ -8605,11 +11960,14 @@ deeply}{}%
\dtl@gathervalues{#1}{\@dtl@currentrow}%
\protected@write\@dtl@write{}{\string\DTLnewrow{#1}}%
\@for\@dtl@key:=\@dtl@keys\do{%
+\expandafter\DTLifnull\csname @dtl@key@\@dtl@key\endcsname
+{}{%
\protected@edef\@dtl@element{\csname @dtl@key@\@dtl@key\endcsname}%
\protected@write\@dtl@write{}{\string\DTLnewdbentry
{#1}{\@dtl@key}{\@dtl@element}}%
}%
}%
+}%
\closeout\@dtl@write
}{%
\PackageError{datatool}{Database `#1' doesn't exist}{}%
@@ -8624,19 +11982,19 @@ deeply}{}%
\newread\@dtl@read
% \end{macrocode}
%\end{macro}
-% Keep track of current column in data file
%\begin{macro}{\dtl@entrycr}
+% Keep track of current column in data file
% \begin{macrocode}
\newcount\dtl@entrycr
% \end{macrocode}
%\end{macro}
+%\begin{macro}{\DTLloaddb}
%\begin{definition}
% \cs{DTLloaddb}\marg{db name}\marg{filename}
%\end{definition}
-% Create a new database called \meta{db name}, and load the data in
+% Creates a new database called \meta{db name}, and load the data in
% \meta{filename} into it. The separator and delimiter used in
% the file must match \cs{@dtl@separator} and \cs{@dtl@delimiter}.
-%\begin{macro}{\DTLloaddb}
% \begin{macrocode}
\gdef\DTLloaddb#1#2{%
\IfFileExists{#2}{%
@@ -8690,7 +12048,10 @@ deeply}{}%
\advance\dtl@entrycr by 1\relax
\edef\@dtl@thiskey{%
\csname @dtl@inky@\romannumeral\dtl@entrycr\endcsname}%
- \DTLnewdbentry{#1}{\@dtl@thiskey}{\@dtl@thisentry}%
+ \expandafter\@dtl@toks\expandafter{\@dtl@thisentry}%
+ \edef\@do@dtlnewentry{\noexpand\DTLnewdbentry
+ {#1}{\@dtl@thiskey}{\the\@dtl@toks}}%
+ \@do@dtlnewentry
}%
}%
\ifeof\@dtl@read \@dtl@conditionfalse\fi
@@ -8708,11 +12069,11 @@ doesn't exist)}{}%
% \end{macrocode}
%\end{macro}
%
+%\begin{macro}{\dtl@trim}
%\begin{definition}
%\cs{dtl@trim}\marg{line}
%\end{definition}
% Trims the trailing space from \meta{line}.
-%\begin{macro}{\dtl@trim}
% \begin{macrocode}
\newcommand{\dtl@trim}[1]{%
\def\@dtl@trmstr{}%
@@ -8721,8 +12082,8 @@ doesn't exist)}{}%
}
% \end{macrocode}
%\end{macro}
-% Start trimming
%\begin{macro}{\@dtl@starttrim}
+% Start trimming
% \begin{macrocode}
\long\def\@dtl@starttrim#1#2{%
\ifx\par#1%
@@ -8740,11 +12101,14 @@ doesn't exist)}{}%
% \end{macrocode}
%\end{macro}
%
-% Load a raw database (substitutes "%" $\to$ "\%",
+%\begin{macro}{\DTLloadrawdb}
+%\begin{definition}
+%\cs{DTLloadrawdb}\marg{db name}\marg{filename}
+%\end{definition}
+% Loads a raw database (substitutes "%" $\to$ "\%",
% "$" $\to$ "\$", "&" $\to$ "\&", "#" $\to$ "\#",
% "~" $\to$ "\textasciitilde", "_" $\to$ "\_"
% and "^" $\to$ "\textasciicircum".)
-%\begin{macro}{\DTLloadrawdb}
% \begin{macrocode}
\gdef\DTLloadrawdb#1#2{%
\IfFileExists{#2}{%
@@ -8798,7 +12162,10 @@ doesn't exist)}{}%
\advance\dtl@entrycr by 1\relax
\edef\@dtl@thiskey{%
\csname @dtl@inky@\romannumeral\dtl@entrycr\endcsname}%
- \DTLnewdbentry{#1}{\@dtl@thiskey}{\@dtl@thisentry}%
+ \expandafter\@dtl@toks\expandafter{\@dtl@thisentry}%
+ \edef\@do@dtlnewentry{\noexpand\DTLnewdbentry
+ {#1}{\@dtl@thiskey}{\the\@dtl@toks}}%
+ \@do@dtlnewentry
}%
}%
\ifeof\@dtl@read \@dtl@conditionfalse\fi
@@ -8815,12 +12182,12 @@ doesn't exist)}{}%
% \end{macrocode}
%\end{macro}
%
+%\begin{macro}{\@dtl@rawread}
%\begin{definition}
% \cs{@dtl@rawread}\meta{number}to\meta{cmd}
%\end{definition}
% Reads in a raw line from file given by \meta{number}
% converts special characters and stores in \meta{cmd}
-%\begin{macro}{\@dtl@rawread}
% \begin{macrocode}
\begingroup
\catcode`\%=\active
@@ -8861,8 +12228,8 @@ doesn't exist)}{}%
\endgroup
% \end{macrocode}
%\end{macro}
-% \cs{@dtl@activatebraces} resets braces for \cs{@dtl@rawread}
%\begin{macro}{\@dtl@activatebraces}
+% \cs{@dtl@activatebraces} resets braces for \cs{@dtl@rawread}
% \begin{macrocode}
\begingroup
\catcode`\{=\active
@@ -8879,11 +12246,11 @@ doesn't exist)}{}%
% \end{macrocode}
%\end{macro}
%
+%\begin{macro}{\DTLrawmap}
%\begin{definition}
%\cs{DTLrawmap}\marg{string}\marg{replacement}
%\end{definition}
% Additional mappings to perform when reading a raw data file
-%\begin{macro}{\DTLrawmap}
% \begin{macrocode}
\newcommand*{\DTLrawmap}[2]{%
\expandafter\@dtl@toks\expandafter{\@dtl@rawmappings}%
@@ -8898,15 +12265,16 @@ doesn't exist)}{}%
%\end{macro}
%
%\begin{macro}{\@dtl@rawmappings}
+% List of mappings.
% \begin{macrocode}
\newcommand*{\@dtl@rawmappings}{}
% \end{macrocode}
%\end{macro}
+%\begin{macro}{\dtl@domappings}
%\begin{definition}
% \cs{dtl@domappings}\marg{cmd}
%\end{definition}
% Do all mappings in string given by \meta{cmd}.
-%\begin{macro}{\dtl@domappings}
% \begin{macrocode}
\newcommand*{\dtl@domappings}[1]{%
\@for\@dtl@map:=\@dtl@rawmappings\do{%
@@ -8915,27 +12283,16 @@ doesn't exist)}{}%
% \end{macrocode}
%\end{macro}
%
+%\begin{macro}{\DTLsubstitute}
%\begin{definition}
%\cs{DTLsubstitute}\marg{cmd}\marg{original}\marg{replacement}
%\end{definition}
% Substitutes first occurence of \meta{original} with
% \marg{replacement} within the string given by \meta{cmd}
-%\begin{macro}{\DTLsubstitute}
% \begin{macrocode}
\newcommand{\DTLsubstitute}[3]{%
-\def\dtl@splitstr##1#2##2\@nil{%
-\def\@dtl@beforepart{##1}%
-\def\@dtl@afterpart{##2}%
-\ifx\@dtl@afterpart\@empty
- \let\@dtl@replaced=\@empty
-\else
- \def\@dtl@replaced{#2}%
- \dtl@split@str##2\@nil
-\fi
-}%
-\def\dtl@split@str##1#2\@nil{%
-\def\@dtl@afterpart{##1}}%
-\expandafter\dtl@splitstr#1#2\@nil
+\expandafter\DTLsplitstring\expandafter
+ {#1}{#2}{\@dtl@beforepart}{\@dtl@afterpart}%
\ifx\@dtl@replaced\@empty
\else
\def#1{}%
@@ -8949,53 +12306,92 @@ doesn't exist)}{}%
}
% \end{macrocode}
%\end{macro}
+%\begin{macro}{\DTLsplitstring}
+%\begin{definition}
+%\cs{DTLsplitstring}\marg{string}\marg{split text}\marg{before
+%cmd}\marg{after cmd}
+%\end{definition}
+% Splits string at \meta{split text} stores the pre split text
+% in \meta{before cmd} and the post split text in \meta{after cmd}.
+%\changes{1.01}{2007 Aug 17}{new}
+% \begin{macrocode}
+\newcommand*{\DTLsplitstring}[4]{%
+\def\dtl@splitstr##1#2##2\@nil{%
+\def#3{##1}%
+\def#4{##2}%
+\ifx#4\@empty
+ \let\@dtl@replaced=\@empty
+\else
+ \def\@dtl@replaced{#2}%
+ \dtl@split@str##2\@nil
+\fi
+}%
+\def\dtl@split@str##1#2\@nil{%
+\def#4{##1}}%
+\dtl@splitstr#1#2\@nil
+}
+% \end{macrocode}
+%\end{macro}
%
+%\begin{macro}{\DTLsubstituteall}
%\begin{definition}
%\cs{DTLsubstituteall}\marg{cmd}\marg{original}\marg{replacement}
%\end{definition}
% Substitutes all occurences of \meta{original} with
% \marg{replacement} within the string given by \meta{cmd}
-%\begin{macro}{\DTLsubstituteall}
+%\changes{1.01}{2007 Aug 17}{fixed bug caused when certain commands
+% occur in the string}
% \begin{macrocode}
\newcommand{\DTLsubstituteall}[3]{%
-\def\dtl@splitstr##1#2##2\@nil{%
-\def\@dtl@beforepart{##1}\def\@dtl@afterpart{##2}}%
-\let\@dtl@replaced=\@empty
-\IfSubStringInString{#2}{#1}{%
- \expandafter\dtl@splitstr#1\@nil
- \expandafter\toks@\expandafter{#2}%
- \edef\@dtl@replaced{\the\toks@}%
- \def#1{}%
- \@dtl@conditiontrue
- \loop
- \expandafter\@dtl@toks\expandafter{\@dtl@beforepart}%
- \expandafter\toks@\expandafter{#1}%
- \protected@edef#1{\the\toks@\the\@dtl@toks#3}%
- \IfSubStringInString{#2}{\@dtl@afterpart}{%
- \expandafter\dtl@splitstr\@dtl@afterpart\@nil
- }{\@dtl@conditionfalse}%
- \if@dtl@condition
- \repeat
- \expandafter\@dtl@toks\expandafter{\@dtl@afterpart}%
- \expandafter\toks@\expandafter{#1}%
- \edef#1{\the\toks@\the\@dtl@toks}%
-}{}%
+\def\@dtl@splitsubstr{}%
+\let\@dtl@afterpart=#1\relax
+\@dtl@dosubstitute{#2}{#3}%
+\expandafter\toks@\expandafter{\@dtl@splitsubstr}%
+\expandafter\@dtl@toks\expandafter{\@dtl@afterpart}%
+\edef#1{\the\toks@\the\@dtl@toks}%
}
% \end{macrocode}
%\end{macro}
+%\begin{macro}{\@dtl@dosubstitute}
+% Recursive substitution macro.
+% \begin{macrocode}
+\def\@dtl@dosubstitute#1#2{%
+\expandafter\DTLsplitstring\expandafter
+ {\@dtl@afterpart}{#1}{\@dtl@beforepart}{\@dtl@afterpart}%
+\expandafter\toks@\expandafter{\@dtl@splitsubstr}%
+\expandafter\@dtl@toks\expandafter{\@dtl@beforepart}%
+\edef\@dtl@splitsubstr{\the\toks@\the\@dtl@toks}%
+\ifx\@dtl@replaced\@empty
+ \let\@dtl@dosubstnext=\@dtl@dosubstitutenoop
+\else
+ \expandafter\toks@\expandafter{\@dtl@splitsubstr}%
+ \@dtl@toks{#2}%
+ \edef\@dtl@splitsubstr{\the\toks@\the\@dtl@toks}%
+ \let\@dtl@dosubstnext=\@dtl@dosubstitute
+\fi
+\@dtl@dosubstnext{#1}{#2}%
+}
+% \end{macrocode}
+%\end{macro}
+%\begin{macro}{\@dtl@dosubstitutenoop}
+% Terminates recursive substitution macro.
+% \begin{macrocode}
+\def\@dtl@dosubstitutenoop#1#2{}
+% \end{macrocode}
+%\end{macro}
%
%\subsection{Currencies}
-% \cs{@dtl@currencies} stores all known currencies.
%\begin{macro}{\@dtl@currencies}
+% \cs{@dtl@currencies} stores all known currencies.
% \begin{macrocode}
\newcommand*{\@dtl@currencies}{\$,\pounds}
% \end{macrocode}
%\end{macro}
+%\begin{macro}{\DTLnewcurrencysymbol}
%\begin{definition}
% \cs{DTLaddcurrency}\marg{symbol}
%\end{definition}
% Adds \meta{symbol} to the list of known currencies
-%\begin{macro}{\DTLnewcurrencysymbol}
% \begin{macrocode}
\newcommand*{\DTLnewcurrencysymbol}[1]{%
\expandafter\toks@\expandafter{\@dtl@currencies}%
@@ -9018,6 +12414,7 @@ doesn't exist)}{}%
\@ifundefined{yen}{}{\DTLnewcurrencysymbol{\yen}}%
}
% \end{macrocode}
+%\begin{macro}{\@dtl@standardize@currency}
%\begin{definition}
%\cs{@dtl@standardize@currency}\marg{cmd}
%\end{definition}
@@ -9027,7 +12424,6 @@ doesn't exist)}{}%
% in \cs{@dtl@org@currency}, so that it can be replaced later.
% If no currency symbol is found, \cs{@dtl@org@currency} will
% be empty.
-%\begin{macro}{\@dtl@standardize@currency}
% \begin{macrocode}
\newcommand{\@dtl@standardize@currency}[1]{%
\def\@dtl@org@currency{}%
@@ -9046,31 +12442,36 @@ doesn't exist)}{}%
% \end{macrocode}
%\end{macro}
%
+%\begin{macro}{\@dtl@currency}
%\cs{@dtl@currency} is set by \cs{DTLlocaltodecimal} and
%\cs{@dtl@checknumerical}. It is used by \cs{DTLdecimaltocurrency}.
% Set to "\$" by default.
-%\begin{macro}{\@dtl@currency}
% \begin{macrocode}
\newcommand*{\@dtl@currency}{\$}
% \end{macrocode}
%\end{macro}
-%\cs{DTLsetdefaultcurrency}\marg{symbol} sets the default currency.
%\begin{macro}{\DTLsetdefaultcurrency}
+%\cs{DTLsetdefaultcurrency}\marg{symbol} sets the default currency.
% \begin{macrocode}
\newcommand*{\DTLsetdefaultcurrency}[1]{%
\renewcommand*{\@dtl@currency}{#1}}
% \end{macrocode}
%\end{macro}
%
+%\begin{macro}{\dtl@ifsingle}
%\begin{definition}
%\cs{dtl@ifsingle}\marg{arg}\marg{true part}\marg{false part}
%\end{definition}
% If there is only one object in \meta{arg} (without expansion)
% do \meta{true part}, otherwise do false part.
-%\begin{macro}{\dtl@ifsingle}
% \begin{macrocode}
\newcommand{\dtl@ifsingle}[3]{%
-\@dtl@ifsingle#1\@nil{#2}{#3}%
+\def\@dtl@arg{#1}%
+\ifx\@dtl@arg\@empty
+ #3%
+\else
+ \@dtl@ifsingle#1\@nil{#2}{#3}%
+\fi
}
% \end{macrocode}
%\end{macro}
@@ -9089,34 +12490,34 @@ doesn't exist)}{}%
%
%\subsection{Debugging commands}
% These commands are provided to assist debugging
+%\begin{macro}{\dtlshowdb}
%\begin{definition}
%\cs{dtlshowdb}\marg{db name}
%\end{definition}
% Shows the database.
-%\begin{macro}{\dtlshowdb}
% \begin{macrocode}
\newcommand*{\dtlshowdb}[1]{%
\expandafter\show\csname dtldb@#1\endcsname}
% \end{macrocode}
%\end{macro}
%
+%\begin{macro}{\dtlshowdbkeys}
%\begin{definition}
%\cs{dtlshowdbkeys}\marg{db name}
%\end{definition}
% Shows the key list for the named database.
-%\begin{macro}{\dtlshowdbkeys}
% \begin{macrocode}
\newcommand*{\dtlshowdbkeys}[1]{%
\expandafter\show\csname dtlkeys@#1\endcsname}
% \end{macrocode}
%\end{macro}
%
+%\begin{macro}{\dtlshowtype}
%\begin{definition}
%\cs{dtlshowtype}\marg{db name}\marg{key}
%\end{definition}
% Show the data type for given key in the named database.
% This should be an integer from 0 to 3.
-%\begin{macro}{\dtlshowtype}
% \begin{macrocode}
\newcommand*{\dtlshowtype}[2]{%
\expandafter\show\csname @dtl@idtype@#1@#2\endcsname}
@@ -9136,15 +12537,15 @@ doesn't exist)}{}%
% Declare package:
% \begin{macrocode}
\NeedsTeXFormat{LaTeX2e}
-\ProvidesPackage{datapie}[2007/07/23 v1.0 (NLCT)]
+\ProvidesPackage{datapie}[2007/08/17 v1.01 (NLCT)]
% \end{macrocode}
% Require \sty{xkeyval} package
% \begin{macrocode}
\RequirePackage{xkeyval}
% \end{macrocode}
-% Define a conditional to determine whether to use colour or
-% grey scale.
%\begin{macro}{\ifDTLcolorpiechart}
+% The conditional \cs{ifDTLcolorpiechart} is to determine
+% whether to use colour or grey scale.
% \begin{macrocode}
\newif\ifDTLcolorpiechart
\DTLcolorpiecharttrue
@@ -9155,8 +12556,8 @@ doesn't exist)}{}%
\DeclareOption{color}{\DTLcolorpiecharttrue}
\DeclareOption{gray}{\DTLcolorpiechartfalse}
% \end{macrocode}
-% Define boolean keys to govern label rotations.
%\begin{macro}{\ifDTLrotateinner}
+% Define boolean keys to govern label rotations.
% \begin{macrocode}
\define@boolkey{datapie}[DTL]{rotateinner}[true]{}
% \end{macrocode}
@@ -9193,33 +12594,33 @@ doesn't exist)}{}%
% Define some variables that govern the appearance of the pie
% chart.
%
-% The radius of the pie chart:
%\begin{macro}{\DTLradius}
+% The radius of the pie chart is given by \cs{DTLradius}.
% \begin{macrocode}
\newlength\DTLradius
\DTLradius=2cm
% \end{macrocode}
%\end{macro}
-% Inner label offset ratio
%\begin{macro}{\DTLinnerratio}
+% The inner label offset ratio is given by \cs{DTLinnerratio}
% \begin{macrocode}
\newcommand*{\DTLinnerratio}{0.5}
% \end{macrocode}
%\end{macro}
-% Outer label offset ratio
%\begin{macro}{\DTLouterratio}
+% The outer label offset ratio is given by \cs{DTLouterratio}.
% \begin{macrocode}
\newcommand*{\DTLouterratio}{1.25}
% \end{macrocode}
%\end{macro}
-% Cutaway offset ration
%\begin{macro}{\DTLcutawayratio}
+% The cutaway offset ratio is given by \cs{DTLcutawayratio}.
% \begin{macrocode}
\newcommand*\DTLcutawayratio{0.2}
% \end{macrocode}
%\end{macro}
-% The angle of the first segment
%\begin{macro}{\DTLstartangle}
+% The angle of the first segment is given by \cs{DTLstartangle}.
% \begin{macrocode}
\newcommand*{\DTLstartangle}{0}
% \end{macrocode}
@@ -9243,17 +12644,17 @@ doesn't exist)}{}%
% \end{macrocode}
%\end{macro}
%
+%\begin{macro}{\dtl@piecutaways}
% \cs{dtl@piecutaways} is a comma separated list of segments that
% need to be cut away from the pie chart.
-%\begin{macro}{\dtl@piecutaways}
% \begin{macrocode}
\newcommand*{\dtl@piecutaways}{}
% \end{macrocode}
%\end{macro}
+%\begin{macro}{\dtl@innerlabel}
% \cs{dtl@innerlabel} specifies the label to appear inside
% the segment. By default this is the variable used to create
% the pie chart.
-%\begin{macro}{\dtl@innerlabel}
% \begin{macrocode}
\def\dtl@innerlabel{\DTLpievariable}%
% \end{macrocode}
@@ -9270,31 +12671,31 @@ doesn't exist)}{}%
\setcounter{DTLpieroundvar}{1}
% \end{macrocode}
%
+%\begin{macro}{\DTLdisplayinnerlabel}
%\begin{definition}
%\cs{DTLdisplayinnerlabel}\marg{label}
%\end{definition}
-% Command used to format the inner label. This just does the
+% This is used to format the inner label. This just does the
% label by default.
-%\begin{macro}{\DTLdisplayinnerlabel}
% \begin{macrocode}
\newcommand*{\DTLdisplayinnerlabel}[1]{#1}
% \end{macrocode}
%\end{macro}
%
+%\begin{macro}{\DTLdisplayouterlabel}
%\begin{definition}
%\cs{DTLdisplayouterlabel}\marg{label}
%\end{definition}
-% Command used to format the outer label. This just does the
+% This is used to format the outer label. This just does the
% label by default.
-%\begin{macro}{\DTLdisplayouterlabel}
% \begin{macrocode}
\newcommand*{\DTLdisplayouterlabel}[1]{#1}
% \end{macrocode}
%\end{macro}
%
+%\begin{macro}{\DTLpiepercent}
%\cs{DTLpiepercent}
% returns the percentage value of the current segment.
-%\begin{macro}{\DTLpiepercent}
% \begin{macrocode}
\newcommand*{\DTLpiepercent}{%
\ifnum\dtlforeachlevel=0\relax
@@ -9307,34 +12708,29 @@ doesn't exist)}{}%
% \end{macrocode}
%\end{macro}
%
+%\begin{macro}{\DTLpieatbegintikz}
% \cs{DTLpieatbegintikz} specifies any commands
% to apply at the start of the \env{tikzpicture} environment.
-% By default it does nothing, but can be set
-% to any of the \sty{pgf} package's transformation commands, e.g.\
-%\begin{verbatim}
-%\renewcommand*{\DTLpieatbegintikz}{%
-%\pgftransformcm{2}{0}{0}{1}{\pgforigin}}
-%\end{verbatim}
-%\begin{macro}{\DTLpieatbegintikz}
+% By default it does nothing.
% \begin{macrocode}
\newcommand*{\DTLpieatbegintikz}{}
% \end{macrocode}
%\end{macro}
%
+%\begin{macro}{\DTLpieatendtikz}
% \cs{DTLpieatendtikz} specifies any commands
% to apply at the end of the \env{tikzpicture} environment.
% By default it does nothing.
-%\begin{macro}{\DTLpieatendtikz}
% \begin{macrocode}
\newcommand*{\DTLpieatendtikz}{}
% \end{macrocode}
%\end{macro}
%
+%\begin{macro}{\DTLsetpiesegmentcolor}
%\begin{definition}
% \cs{DTLsetpiesegmentcolor}\marg{n}\marg{color}
%\end{definition}
% Assign colour name \meta{color} to the \meta{n}th segment.
-%\begin{macro}{\DTLsetpiesegmentcolor}
% \begin{macrocode}
\newcommand*{\DTLsetpiesegmentcolor}[2]{%
\expandafter\def\csname dtlpie@segcol\romannumeral#1\endcsname{#2}%
@@ -9342,31 +12738,31 @@ doesn't exist)}{}%
% \end{macrocode}
%\end{macro}
%
+%\begin{macro}{\DTLgetpiesegmentcolor}
%\begin{definition}
%\cs{DTLgetpiesegmentcolor}\marg{n}
%\end{definition}
% Get the colour specification for segment \meta{n}
-%\begin{macro}{\DTLgetpiesegmentcolor}
% \begin{macrocode}
\newcommand*{\DTLgetpiesegmentcolor}[1]{%
\csname dtlpie@segcol\romannumeral#1\endcsname}
% \end{macrocode}
%\end{macro}
%
+%\begin{macro}{\DTLdopiesegmentcolor}
%\begin{definition}
%\cs{DTLdopiesegmentcolor}\marg{n}
%\end{definition}
% Set the colour to that for segment \meta{n}
-%\begin{macro}{\DTLdopiesegmentcolor}
% \begin{macrocode}
\newcommand*{\DTLdopiesegmentcolor}[1]{%
\expandafter\color\expandafter
{\csname dtlpie@segcol\romannumeral#1\endcsname}}
% \end{macrocode}
%\end{macro}
+%\begin{macro}{\DTLdocurrentpiesegmentcolor}
%\cs{DTLdocurrentpiesegmentcolor}
% sets the colour to that of the current segment.
-%\begin{macro}{\DTLdocurrentpiesegmentcolor}
% \begin{macrocode}
\newcommand*{\DTLdocurrentpiesegmentcolor}{%
\ifnum\dtlforeachlevel=0\relax
@@ -9380,17 +12776,17 @@ doesn't exist)}{}%
% \end{macrocode}
%\end{macro}
%
+%\begin{macro}{\DTLpieoutlinecolor}
%\cs{DTLpieoutlinecolor} specifies what colour to draw the
% outline.
-%\begin{macro}{\DTLpieoutlinecolor}
% \begin{macrocode}
\newcommand*{\DTLpieoutlinecolor}{black}
% \end{macrocode}
%\end{macro}
%
+%\begin{macro}{\DTLpieoutlinewidth}
%\cs{DTLpieoutlinewidth} specifies the line width of the outline:
% Outline is only drawn if the linewidth is greater than 0pt.
-%\begin{macro}{\DTLpieoutlinewidth}
% \begin{macrocode}
\newlength\DTLpieoutlinewidth
\DTLpieoutlinewidth=0pt
@@ -9491,6 +12887,7 @@ doesn't exist)}{}%
\def\dtl@outerlabel{#1}}
% \end{macrocode}
%
+%\begin{macro}{\DTLpiechart}
%\begin{definition}
% \cs{DTLpiechart}\oarg{conditions}\marg{option list}\marg{db name}\marg{assign list}
%\end{definition}
@@ -9500,7 +12897,6 @@ doesn't exist)}{}%
% include \texttt{variable}\texttt{=}\meta{cmd}, where \meta{cmd}
% is included in \meta{assign list}. The optional argument
% \meta{conditions} is the same as that for \cs{DTLforeach}.
-%\begin{macro}{\DTLpiechart}
% \begin{macrocode}
\newcommand*{\DTLpiechart}[4][\boolean{true}]{%
{\let\DTLpievariable=\relax
@@ -9510,9 +12906,11 @@ doesn't exist)}{}%
\else
% \end{macrocode}
% Compute the total.
+%\changes{1.01}{2007 Aug 17}{uses \cs{@sDTLforeach} instead of
+%\cs{DTLforeach}}
% \begin{macrocode}
\def\dtl@total{0}%
-\DTLforeach[#1]{#3}{#4}{%
+\@sDTLforeach[#1]{#3}{#4}{%
\let\dtl@oldtotal=\dtl@total
\expandafter\DTLconverttodecimal\expandafter
{\DTLpievariable}{\dtl@variable}%
@@ -9523,7 +12921,7 @@ doesn't exist)}{}%
% \begin{macrocode}
\expandafter\DTLconverttodecimal\expandafter
{\DTLstartangle}{\@dtl@start}%
-\DTLforeach[#1]{#3}{#4}{%
+\@sDTLforeach[#1]{#3}{#4}{%
\expandafter\DTLconverttodecimal\expandafter
{\DTLpievariable}{\dtl@variable}%
\dtl@computeangles{%
@@ -9553,7 +12951,7 @@ doesn't exist)}{}%
% \begin{macrocode}
\begin{tikzpicture}
\DTLpieatbegintikz
-\DTLforeach[#1]{#3}{#4}{%
+\@sDTLforeach[#1]{#3}{#4}{%
% \end{macrocode}
% Store the segment number in \cs{@dtl@seg}
% \begin{macrocode}
@@ -9697,6 +13095,7 @@ node[\dtl@outernodeopt]{%
% \end{macrocode}
%\end{macro}
%
+%\begin{macro}{\dtl@computeangles}
%\begin{definition}
%\cs{dtl@computeangles}\marg{n}\marg{variable}
%\end{definition}
@@ -9705,7 +13104,6 @@ node[\dtl@outernodeopt]{%
% \cs{dtl@angle@}\meta{n} (extent angle),
% \cs{dtl@cut@angle@}\meta{n} (cut away angle) and
% \cs{dtl@cut@len@}\meta{n} (cut away length).
-%\begin{macro}{\dtl@computeangles}
% \begin{macrocode}
\newcommand*{\dtl@computeangles}[2]{%
\FPifgt{\@dtl@start}{180}%
@@ -9766,8 +13164,8 @@ node[\dtl@outernodeopt]{%
\newcount\@dtl@seg
% \end{macrocode}
%\end{macro}
-% Set offset for a range of segments
%\begin{macro}{\@@dtl@setoffr}
+% Set offset for a range of segments
% \begin{macrocode}
\def\@@dtl@set@offr#1-#2-\relax{%
\ifnum#1>#2\relax
@@ -9815,7 +13213,7 @@ Try #2-#1 instead of #1-#2}%
% Declare package:
% \begin{macrocode}
\NeedsTeXFormat{LaTeX2e}
-\ProvidesPackage{dataplot}[2007/07/23 v1.0 (NLCT)]
+\ProvidesPackage{dataplot}[2007/08/17 v1.01 (NLCT)]
% \end{macrocode}
% Required packages
% \begin{macrocode}
@@ -9828,6 +13226,8 @@ Try #2-#1 instead of #1-#2}%
\usetikzlibrary{plotmarks}
\usetikzlibrary{plothandlers}
% \end{macrocode}
+%
+%\begin{macro}{\DTLplotstream}
%\begin{definition}
%\cs{DTLplotstream}\oarg{condition}\marg{db name}\marg{x key}\marg{y key}
%\end{definition}
@@ -9836,19 +13236,20 @@ Try #2-#1 instead of #1-#2}%
% and the $y$ co-ordinates are given by the key \meta{y key}.
% The optional argument \meta{condition} is the same as that
% for \cs{DTLforeach}
-%\begin{macro}{\DTLplotstream}
+%\changes{1.01}{2007 Aug 17}{uses \cs{@sDTLforeach} instead of
+%\cs{DTLforeach}}
% \begin{macrocode}
\newcommand*{\DTLplotstream}[4][\boolean{true}]{%
-\DTLforeach[#1]{#2}{\dtl@x=#3,\dtl@y=#4}{%
+\@sDTLforeach[#1]{#2}{\dtl@x=#3,\dtl@y=#4}{%
\DTLconverttodecimal{\dtl@x}{\dtl@decx}%
\DTLconverttodecimal{\dtl@y}{\dtl@decy}%
\pgfplotstreampoint{\pgfpointxy{\dtl@decx}{\dtl@decy}}}}
% \end{macrocode}
%\end{macro}
%
+%\begin{macro}{\DTLplotmarks}
%\cs{DTLplotmarks} contains a list of plot marks used by
%\cs{DTLplot}.
-%\begin{macro}{\DTLplotmarks}
% \begin{macrocode}
\newcommand*{\DTLplotmarks}{%
\pgfuseplotmark{o},%
@@ -9863,8 +13264,8 @@ Try #2-#1 instead of #1-#2}%
% \end{macrocode}
%\end{macro}
%
-%\cs{DTLplotmarkcolors} contains a list of the plot mark colours.
%\begin{macro}{\DTLplotmarkcolors}
+%\cs{DTLplotmarkcolors} contains a list of the plot mark colours.
% \begin{macrocode}
\newcommand*{\DTLplotmarkcolors}{%
red,%
@@ -9878,9 +13279,9 @@ black,%
gray}
% \end{macrocode}
%\end{macro}
+%\begin{macro}{\DTLplotlines}
%\cs{DTLplotlines} contains a list of dash patterns used by
%\cs{DLTplot}.
-%\begin{macro}{\DTLplotlines}
% \begin{macrocode}
\newcommand*{\DTLplotlines}{%
\pgfsetdash{}{{0pt}},% solid line
@@ -9892,8 +13293,8 @@ gray}
}
% \end{macrocode}
%\end{macro}
-%\cs{DTLplotlinecolors} contains a list of the plot line colours.
%\begin{macro}{\DTLplotlinecolors}
+%\cs{DTLplotlinecolors} contains a list of the plot line colours.
% \begin{macrocode}
\newcommand*{\DTLplotlinecolors}{%
red,%
@@ -9908,68 +13309,72 @@ gray}
% \end{macrocode}
%\end{macro}
%
+%\begin{macro}{\DTLplotwidth}
% The default total plot width is stored in the length
% \cs{dtlplotwidth}
-%\begin{macro}{\DTLplotwidth}
% \begin{macrocode}
\newlength\DTLplotwidth
\setlength\DTLplotwidth{4in}
% \end{macrocode}
%\end{macro}
%
+%\begin{macro}{\DTLplotheight}
% The default total plot height is stored in the length
% \cs{dtlplotheight}
-%\begin{macro}{\DTLplotheight}
% \begin{macrocode}
\newlength\DTLplotheight
\setlength\DTLplotheight{4in}
% \end{macrocode}
%\end{macro}
%
-% The length of the tick marks is given by
%\begin{macro}{\DTLticklength}
+% The length of the tick marks is given by \cs{DTLticklength}
% \begin{macrocode}
\newlength\DTLticklength
\setlength\DTLticklength{5pt}
% \end{macrocode}
%\end{macro}
-% The length of the minor tick marks is given by
%\begin{macro}{\DTLminorticklength}
+% The length of the minor tick marks is given by
+% \cs{DTLminorticklength}.
% \begin{macrocode}
\newlength\DTLminorticklength
\setlength\DTLminorticklength{2pt}
% \end{macrocode}
%\end{macro}
-% The offset from the axis to the tick label is given by
%\begin{macro}{\DTLticklabeloffset}
+% The offset from the axis to the tick label is given by
+% \cs{DTLticklabeloffset}.
% \begin{macrocode}
\newlength\DTLticklabeloffset
\setlength\DTLticklabeloffset{8pt}
% \end{macrocode}
%\end{macro}
-% Length to store the height of the $x$ tick labels
%\begin{macro}{\dtl@xticlabelheight}
+% \cs{dtl@xticlabelheight} is used to store the height of
+% the $x$ tick labels.
% \begin{macrocode}
\newlength\dtl@xticlabelheight
% \end{macrocode}
%\end{macro}
-% Length to store the width of the $y$ tick labels
%\begin{macro}{\dtl@yticlabelwidth}
+% \cs{dtl@yticlabelwidth} is used to store the width of
+% the $y$ tick labels.
% \begin{macrocode}
\newlength\dtl@yticlabelwidth
% \end{macrocode}
%\end{macro}
-% Suggested minimum distance between tick marks where the gap
-% is not specified.
%\begin{macro}{\DTLmintickgap}
+% \cs{DTLmintickgap} stores the suggested minimum distance between
+% tick marks where the gap is not specified.
% \begin{macrocode}
\newlength\DTLmintickgap
\setlength\DTLmintickgap{20pt}
% \end{macrocode}
%\end{macro}
-% Suggested minimum distance between minor tick marks where the gap
-% is not specified.
%\begin{macro}{\DTLminminortickgap}
+% The suggested minimum distance between minor tick marks where the
+% gap is not specified is given by \cs{DTLminminortickgap}.
% \begin{macrocode}
\newlength\DTLminminortickgap
\setlength\DTLminminortickgap{5pt}
@@ -9987,71 +13392,78 @@ gray}
\newcounter{DTLplotroundYvar}
\setcounter{DTLplotroundYvar}{2}
% \end{macrocode}
-% Conditional to determine whether or not to display the $x$ axis
%\begin{macro}{\ifDTLxaxis}
+% The conditional \cs {ifDTLxaxis} is used to determine whether or
+% not to display the $x$ axis.
% \begin{macrocode}
\newif\ifDTLxaxis
\DTLxaxistrue
% \end{macrocode}
%\end{macro}
-% The style of the $x$ axis is just a solid line by default
%\begin{macro}{\DTLXAxisStyle}
+% The style of the $x$ axis is given by \cs{DTLXAxisStyle}. This
+% is just a solid line by default.
% \begin{macrocode}
\newcommand*{\DTLXAxisStyle}{-}
% \end{macrocode}
%\end{macro}
%
-% Conditional to determine whether or not to display the $y$ axis
%\begin{macro}{\ifDTLyaxis}
+% The conditional \cs{ifDTLyaxis} is used to determine whether or
+% not to display the $y$ axis
% \begin{macrocode}
\newif\ifDTLyaxis
\DTLyaxistrue
% \end{macrocode}
%\end{macro}
-% The style of the $y$ axis is just a solid line by default
%\begin{macro}{\DTLYAxisStyle}
+% The style of the $y$ axis is given by \cs{DTLYAxisStyle}. This
+% is just a solid line by default.
% \begin{macrocode}
\newcommand*{\DTLYAxisStyle}{-}
% \end{macrocode}
%\end{macro}
-% The style of the major grid lines:
%\begin{macro}{\DTLmajorgridstyle}
+% The style of the major grid lines is given by
+% \cs{DTLmajorgridstyle}.
% \begin{macrocode}
\newcommand*{\DTLmajorgridstyle}{color=gray,-}
% \end{macrocode}
%\end{macro}
-% The style of the minor grid lines:
%\begin{macro}{\DTLminorgridstyle}
+% The style of the minor grid lines is given by
+% \cs{DTLminorgridstyle}.
% \begin{macrocode}
\newcommand*{\DTLminorgridstyle}{color=gray,loosely dotted}
% \end{macrocode}
%\end{macro}
%
-% Conditional to determine whether the $x$ tics should point in or
-% out.
%\begin{macro}{\ifDTLxticsin}
+% The conditional \cs{ifDTLxticsin} is used to determine whether
+% the $x$ tics should point in or out.
% \begin{macrocode}
\newif\ifDTLxticsin
\DTLxticsintrue
% \end{macrocode}
%\end{macro}
-% Conditional to determine whether the $y$ tics should point in or
-% out.
%\begin{macro}{\ifDTLyticsin}
+% The conditional \cs{ifDTLyticsin} is used to determine whether
+% the $y$ tics should point in or out.
% \begin{macrocode}
\newif\ifDTLyticsin
\DTLyticsintrue
% \end{macrocode}
%\end{macro}
-% Count register to determine the legend setting.
%\begin{macro}{\dtl@legendsetting}
+% The legend setting is stored in the count register
+% \cs{dtl@legendsetting}.
% \begin{macrocode}
\newcount\dtl@legendsetting
% \end{macrocode}
%\end{macro}
-% Gap between border of plot and legend is given by the
-% lengths \cs{DTLlegendxoffset} and \cs{DTLlegendyoffset}
%\begin{macro}{\DTLlegendxoffset}
+% The gap between the border of plot and legend is given by the
+% lengths \cs{DTLlegendxoffset} and \cs{DTLlegendyoffset}
% \begin{macrocode}
\newlength\DTLlegendxoffset
\setlength\DTLlegendxoffset{10pt}
@@ -10063,38 +13475,44 @@ gray}
\setlength\DTLlegendyoffset{10pt}
% \end{macrocode}
%\end{macro}
-% Macro to display the legend:
%\begin{macro}{\DTLformatlegend}
+%\begin{definition}
+%\cs{DTLformatlegend}\marg{legend}
+%\end{definition}
+% This formats the legend.
% \begin{macrocode}
\newcommand*{\DTLformatlegend}[1]{%
\setlength{\fboxrule}{1.1pt}%
\fcolorbox{black}{white}{#1}}
% \end{macrocode}
%\end{macro}
-% Conditional to specify whether or not to use markers
%\begin{macro}{\ifDTLshowmarkers}
+% The conditional \cs{ifDTLshowmarkers} is used to specify
+% whether or not to use markers.
% \begin{macrocode}
\newif\ifDTLshowmarkers
\DTLshowmarkerstrue
% \end{macrocode}
%\end{macro}
-% Conditional to specify whether or not to use lines
%\begin{macro}{\ifDTLshowlines}
+% The conditional \cs{ifDTLshowlines} is used to specify
+% whether or not to use lines.
% \begin{macrocode}
\newif\ifDTLshowlines
\DTLshowlinesfalse
% \end{macrocode}
%\end{macro}
-% Hook to insert stuff at the start of the \env{tikzpicture}
-% environment (after the unit vectors have been set).
%\begin{macro}{\DTLplotatbegintikz}
+% \cs{DTLplotatbegintikz} is a hook to insert stuff at the
+% start of the \env{tikzpicture}
+% environment (after the unit vectors have been set).
% \begin{macrocode}
\newcommand*{\DTLplotatbegintikz}{}
% \end{macrocode}
%\end{macro}
-% Hook to insert stuff at the end of the \env{tikzpicture}
-% environment.
%\begin{macro}{\DTLplotatendtikz}
+% \cs{DTLplotatendtikz} is a hook to insert stuff at the end
+% of the \env{tikzpicture} environment.
% \begin{macrocode}
\newcommand*{\DTLplotatendtikz}{}
% \end{macrocode}
@@ -10195,39 +13613,51 @@ gray}
\fi
}
% \end{macrocode}
+%\begin{macro}{\ifDTLbox}
% Enclose plot in a box
% \begin{macrocode}
\define@boolkey{dataplot}[DTL]{box}[true]{}
\DTLboxfalse
% \end{macrocode}
+%\end{macro}
+%\begin{macro}{\ifDTLxticstrue}
% Condition to determine whether to show the $x$ tick marks
% \begin{macrocode}
\define@boolkey{dataplot}[DTL]{xtics}[true]{}
\DTLxticstrue
% \end{macrocode}
+%\end{macro}
+%\begin{macro}{\ifDTLyticstrue}
% Condition to determine whether to show the $y$ tick marks
% \begin{macrocode}
\define@boolkey{dataplot}[DTL]{ytics}[true]{}
\DTLyticstrue
% \end{macrocode}
+%\end{macro}
+%\begin{macro}{\ifDTLxminortics}
% Condition to determine whether to show the $x$ minor tick marks
% \begin{macrocode}
\define@boolkey{dataplot}[DTL]{xminortics}[true]{%
\ifDTLxminortics \DTLxticstrue\fi}
\DTLxminorticsfalse
% \end{macrocode}
+%\end{macro}
+%\begin{macro}{\ifDTLyminortics}
% Condition to determine whether to show the $y$ minor tick marks
% \begin{macrocode}
\define@boolkey{dataplot}[DTL]{yminortics}[true]{%
\ifDTLyminortics \DTLyticstrue\fi}
\DTLyminorticsfalse
% \end{macrocode}
+%\end{macro}
+%\begin{macro}{\ifDTLgrid}
% Determine whether to draw the grid
% \begin{macrocode}
\define@boolkey{dataplot}[DTL]{grid}[true]{}
% \end{macrocode}
+%\end{macro}
% Determine whether the $x$ tick marks should point
-% in or out
+% in or out:
% \begin{macrocode}
\define@choicekey{dataplot}{xticdir}[\val\nr]{in,out}{%
\ifcase\nr\relax
@@ -10238,7 +13668,7 @@ gray}
}
% \end{macrocode}
% Determine whether the $y$ tick marks should point
-% in or out
+% in or out:
% \begin{macrocode}
\define@choicekey{dataplot}{yticdir}[\val\nr]{in,out}{%
\ifcase\nr\relax
@@ -10249,7 +13679,7 @@ gray}
}
% \end{macrocode}
% Determine whether the $x$ and $y$ tick marks should point
-% in or out
+% in or out;
% \begin{macrocode}
\define@choicekey{dataplot}{ticdir}[\val\nr]{in,out}{%
\ifcase\nr\relax
@@ -10361,19 +13791,12 @@ east,southeast,south,southwest,west,northwest}[northeast]{%
\define@key{dataplot}{legendlabels}{\def\dtl@legendlabels{#1}}
% \end{macrocode}
%
-% Temporary length:
-%\begin{macro}{\dtl@tmplength}
-% \begin{macrocode}
-\newlength\dtl@tmplength
-% \end{macrocode}
-%\end{macro}
-%
+%\begin{macro}{\DTLplot}
%\begin{definition}
%\cs{DTLplot}\oarg{condition}\marg{db list}\marg{settings}
%\end{definition}
% Creates a plot (inside a \env{tikzpicture} environment) of all
% the data given in the databases listed in \meta{db list}.
-%\begin{macro}{\DTLplot}
% \begin{macrocode}
\newcommand*{\DTLplot}[3][\boolean{true}]{{%
\let\dtl@xkey=\relax
@@ -10858,8 +14281,10 @@ east,southeast,south,southwest,west,northwest}[northeast]{%
\def\dtl@stream{\pgfplotstreamstart}%
% \end{macrocode}
% Only plot points that lie inside bounds.
+%\changes{1.01}{2007 Aug 17}{uses \cs{@sDTLforeach} instead of
+%\cs{DTLforeach}}
% \begin{macrocode}
- \DTLforeach[#1]{\dtl@thisdb}{\dtl@x=\dtl@xkey,%
+ \@sDTLforeach[#1]{\dtl@thisdb}{\dtl@x=\dtl@xkey,%
\dtl@y=\dtl@ykey}{%
\DTLconverttodecimal{\dtl@x}{\dtl@decx}%
\DTLconverttodecimal{\dtl@y}{\dtl@decy}%
@@ -10960,8 +14385,8 @@ east,southeast,south,southwest,west,northwest}[northeast]{%
% \end{macrocode}
%\end{macro}
%
-% Extract bounds:
%\begin{macro}{\dtl@getbounds}
+% Extract bounds:
% \begin{macrocode}
\def\dtl@getbounds#1,#2,#3,#4\@nil{%
\def\DTLminX{#1}%
@@ -10980,12 +14405,12 @@ east,southeast,south,southwest,west,northwest}[northeast]{%
% \end{macrocode}
%\end{macro}
%
+%\begin{macro}{\dtl@constructticklist}
%\begin{definition}
%\cs{dtl@constructticklist}\marg{min}\marg{max}\marg{scale factor}\marg{list}
%\end{definition}
-% Construct a list of tick points between \meta{min} and \meta{max}
+% Constructs a list of tick points between \meta{min} and \meta{max}
% and store in \meta{list} (a control sequence.)
-%\begin{macro}{\dtl@constructticklist}
% \begin{macrocode}
\newcommand*{\dtl@constructticklist}[4]{%
\DTLifFPopenbetween{0}{#1}{#2}{%
@@ -11044,13 +14469,13 @@ east,southeast,south,southwest,west,northwest}[northeast]{%
% \end{macrocode}
%\end{macro}
%
+%\begin{macro}{\dtl@constructticklistwithgap}
%\begin{definition}
%\cs{dtl@constructticklistwithgap}\marg{min}\marg{max}\marg{list}\marg{gap}
%\end{definition}
-% Construct a list of tick points between \meta{min} and \meta{max}
+% Constructs a list of tick points between \meta{min} and \meta{max}
% and store in \meta{list} (a control sequence) using the gap given
% by \meta{gap} where the gap is given in user co-ordinates.
-%\begin{macro}{\dtl@constructticklistwithgap}
% \begin{macrocode}
\newcommand*{\dtl@constructticklistwithgap}[4]{%
\edef\@dtl@thistick{#1}%
@@ -11067,13 +14492,13 @@ east,southeast,south,southwest,west,northwest}[northeast]{%
% \end{macrocode}
%\end{macro}
%
+%\begin{macro}{\dtl@constructticklistwithgapz}
%\begin{definition}
%\cs{dtl@constructticklistwithgapz}\marg{min}\marg{max}\marg{list}\marg{gap}
%\end{definition}
-% Construct a list of tick points between \meta{min} and \meta{max}
+% Constructs a list of tick points between \meta{min} and \meta{max}
% and store in \meta{list} (a control sequence) using the gap given
% by \meta{gap} where the tick list straddles zero.
-%\begin{macro}{\dtl@constructticklistwithgapz}
% \begin{macrocode}
\newcommand*{\dtl@constructticklistwithgapz}[4]{%
\edef\@dtl@thistick{0}%
@@ -11102,12 +14527,12 @@ east,southeast,south,southwest,west,northwest}[northeast]{%
% \end{macrocode}
%\end{macro}
%
+%\begin{macro}{\dtl@constructminorticklist}
%\begin{definition}
%\cs{dtl@constructminorticklist}\marg{min}\marg{max}\marg{scale factor}\marg{list}
%\end{definition}
-% Construct a list of minor tick points between \meta{min} and \meta{max}
+% Constructs a list of minor tick points between \meta{min} and \meta{max}
% and append to \meta{list} (a control sequence.)
-%\begin{macro}{\dtl@constructminorticklist}
% \begin{macrocode}
\newcommand*{\dtl@constructminorticklist}[4]{%
\FPsub{\@dtl@width}{#2}{#1}%
@@ -11137,14 +14562,14 @@ east,southeast,south,southwest,west,northwest}[northeast]{%
% \end{macrocode}
%\end{macro}
%
+%\begin{macro}{\dtl@constructticklistwithgapex}
%\begin{definition}
%\cs{dtl@constructticklistwithgapex}\marg{min}\marg{max}\marg{list}\marg{gap}
%\end{definition}
-% Construct a list of tick points between \meta{min} and \meta{max}
+% Constructs a list of tick points between \meta{min} and \meta{max}
% and store in \meta{list} (a control sequence) using the gap given
% by \meta{gap} where the gap is given in user co-ordinates.
% The end points are excluded from the list.
-%\begin{macro}{\dtl@constructticklistwithgapex}
% \begin{macrocode}
\newcommand*{\dtl@constructticklistwithgapex}[4]{%
\edef\@dtl@thistick{#1}%
@@ -11163,11 +14588,11 @@ east,southeast,south,southwest,west,northwest}[northeast]{%
% \end{macrocode}
%\end{macro}
%
+%\begin{macro}{\DTLaddtoplotlegend}
%\begin{definition}
%\cs{DTLaddtoplotlegend}\marg{marker}\marg{line style}\marg{label}
%\end{definition}
-% Add entry to legend.
-%\begin{macro}{\DTLaddtoplotlegend}
+% Adds entry to legend.
% \begin{macrocode}
\newcommand*{\DTLaddtoplotlegend}[3]{%
\def\dtl@legendline{}%
@@ -11210,7 +14635,7 @@ east,southeast,south,southwest,west,northwest}[northeast]{%
% Declare package:
% \begin{macrocode}
\NeedsTeXFormat{LaTeX2e}
-\ProvidesPackage{databar}[2007/07/23 v1.0 (NLCT)]
+\ProvidesPackage{databar}[2007/08/17 v1.01 (NLCT)]
% \end{macrocode}
% Require \sty{xkeyval} package
% \begin{macrocode}
@@ -11220,9 +14645,9 @@ east,southeast,south,southwest,west,northwest}[northeast]{%
% \begin{macrocode}
\RequirePackage{dataplot}
% \end{macrocode}
-% Define a conditional to determine whether to use colour or
-% grey scale.
%\begin{macro}{\ifDTLcolorbarchart}
+% The conditional \cs{ifDTLcolorbarchart} is used to determine
+% whether to use colour or grey scale.
% \begin{macrocode}
\newif\ifDTLcolorbarchart
\DTLcolorbarcharttrue
@@ -11243,8 +14668,8 @@ east,southeast,south,southwest,west,northwest}[northeast]{%
% \begin{macrocode}
\newcommand*{\DTLbarYticklabelalign}{right}
% \end{macrocode}
-% Define boolean keys to govern bar chart orientation.
%\begin{macro}{\ifDTLverticalbars}
+% Define boolean keys to govern bar chart orientation.
% \begin{macrocode}
\define@boolkey{databar}[DTL]{verticalbars}[true]{%
\ifDTLverticalbars
@@ -11283,37 +14708,38 @@ east,southeast,south,southwest,west,northwest}[northeast]{%
% Define some variables that govern the appearance of the bar
% chart.
%
-% The total height of the bar chart
%\begin{macro}{\DTLbarchartlength}
+% The total height of the bar chart is given by \cs{DTLbarchartheight}
% \begin{macrocode}
\newlength\DTLbarchartlength
\DTLbarchartlength=3in
% \end{macrocode}
%\end{macro}
%
-% The width of each bar
%\begin{macro}{\DTLbarwidth}
+% The width of each bar is given by \cs{DTLbarwidth}.
% \begin{macrocode}
\newlength\DTLbarwidth
\DTLbarwidth=1cm
% \end{macrocode}
%\end{macro}
%
-% The offset from the $x$ axis to the bar label
%\begin{macro}{\DTLbarlabeloffset}
+% The offset from the $x$ axis to the bar label if given by
+% \cs{DTLbarlabeloffset}.
% \begin{macrocode}
\newlength\DTLbarlabeloffset
\setlength\DTLbarlabeloffset{10pt}
% \end{macrocode}
%\end{macro}
-% The style of the $x$ axis
%\begin{macro}{\DTLBarXAxisStyle}
+% The style of the $x$ axis is given by \cs{DTLBarXAxisStyle}
% \begin{macrocode}
\newcommand*{\DTLBarXAxisStyle}{-}
% \end{macrocode}
%\end{macro}
-% The style of the $y$ axis
%\begin{macro}{\DTLBarYAxisStyle}
+% The style of the $y$ axis is given by \cs{DTLBarYAxisStyle}.
% \begin{macrocode}
\newcommand*{\DTLBarYAxisStyle}{-}
% \end{macrocode}
@@ -11326,91 +14752,92 @@ east,southeast,south,southwest,west,northwest}[northeast]{%
\setcounter{DTLbarroundvar}{1}
% \end{macrocode}
%
-%\cs{DTLbardisplayYticklabel} governs how the $y$ tick labels appear.
%\begin{macro}{\DTLbardisplayYticklabel}
+%\cs{DTLbardisplayYticklabel} governs how the $y$ tick labels appear.
% \begin{macrocode}
\newcommand*{\DTLbardisplayYticklabel}[1]{#1}
% \end{macrocode}
%\end{macro}
-%\cs{DTLdisplaylowerbarlabel} governs how the lower bar labels appear.
%\begin{macro}{\DTLdisplaylowerbarlabel}
+%\cs{DTLdisplaylowerbarlabel} governs how the lower bar labels appear.
% \begin{macrocode}
\newcommand*{\DTLdisplaylowerbarlabel}[1]{#1}
% \end{macrocode}
%\end{macro}
-%\cs{DTLdisplaylowermultibarlabel} governs how the lower multi bar labels appear.
%\begin{macro}{\DTLdisplaylowermultibarlabel}
+%\cs{DTLdisplaylowermultibarlabel} governs how the lower multi bar labels appear.
% \begin{macrocode}
\newcommand*{\DTLdisplaylowermultibarlabel}[1]{#1}
% \end{macrocode}
%\end{macro}
+%\begin{macro}{\DTLdisplayupperbarlabel}
%\cs{DTLdisplayupperbarlabel} governs how the upper bar labels
% appear.
-%\begin{macro}{\DTLdisplayupperbarlabel}
% \begin{macrocode}
\newcommand*{\DTLdisplayupperbarlabel}[1]{#1}
% \end{macrocode}
%\end{macro}
+%\begin{macro}{\DTLdisplayuppermultibarlabel}
%\cs{DTLdisplayuppermultibarlabel} governs how the upper multi bar
% labels appear.
-%\begin{macro}{\DTLdisplayuppermultibarlabel}
% \begin{macrocode}
\newcommand*{\DTLdisplayuppermultibarlabel}[1]{#1}
% \end{macrocode}
%\end{macro}
%
+%\begin{macro}{\DTLbaratbegintikz}
% \cs{DTLbaratbegintikz} specifies any commands
% to apply at the start of the \env{tikzpicture} environment.
% By default it does nothing.
-%\begin{macro}{\DTLbaratbegintikz}
% \begin{macrocode}
\newcommand*{\DTLbaratbegintikz}{}
% \end{macrocode}
%\end{macro}
%
+%\begin{macro}{\DTLbaratendtikz}
% \cs{DTLbaratendtikz} specifies any commands
% to apply at the end of the \env{tikzpicture} environment.
% By default it does nothing.
-%\begin{macro}{\DTLbaratendtikz}
% \begin{macrocode}
\newcommand*{\DTLbaratendtikz}{}
% \end{macrocode}
%\end{macro}
%
-% Conditional to determine whether or not to display the $x$
-% axis
%\begin{macro}{\ifDTLbarxaxis}
+% The conditional \cs{ifDTLbarxaxis} is used to determine
+% whether or not to display the $x$ axis
% \begin{macrocode}
\newif\ifDTLbarxaxis
% \end{macrocode}
%\end{macro}
-% Conditional to determine whether or not to display the $y$
-% axis
%\begin{macro}{\ifDTLbaryaxis}
+% The conditional \cs{ifDTLbaryaxis} is used to determine
+% whether or not to display the $y$ axis.
% \begin{macrocode}
\newif\ifDTLbaryaxis
% \end{macrocode}
%\end{macro}
-% Conditional to determine whether or not to display the $y$
-% tick marks
%\begin{macro}{\ifDTLbarytics}
+% The conditional \cs{ifDTLbarytics} to determine whether
+% or not to display the $y$ tick marks.
% \begin{macrocode}
\newif\ifDTLbarytics
% \end{macrocode}
%\end{macro}
%
-% Define count register to store the current bar index:
%\begin{macro}{\@dtl@barcount}
+% The count register \cs{@dtl@barcount} is used to store
+% the current bar index.
% \begin{macrocode}
\newcount\@dtl@barcount
% \end{macrocode}
%\end{macro}
%
+%\begin{macro}{\DTLsetbarcolor}
%\begin{definition}
% \cs{DTLsetbarcolor}\marg{n}\marg{color}
%\end{definition}
-% Assign colour name \meta{color} to the \meta{n}th bar.
-%\begin{macro}{\DTLsetbarcolor}
+% Assigns colour name \meta{color} to the \meta{n}th bar.
% \begin{macrocode}
\newcommand*{\DTLsetbarcolor}[2]{%
\expandafter\def\csname dtlbar@segcol\romannumeral#1\endcsname{#2}%
@@ -11418,22 +14845,22 @@ east,southeast,south,southwest,west,northwest}[northeast]{%
% \end{macrocode}
%\end{macro}
%
+%\begin{macro}{\DTLgetbarcolor}
%\begin{definition}
%\cs{DTLgetbarcolor}\marg{n}
%\end{definition}
-% Get the colour specification for the \meta{n}th bar
-%\begin{macro}{\DTLgetbarcolor}
+% Gets the colour specification for the \meta{n}th bar.
% \begin{macrocode}
\newcommand*{\DTLgetbarcolor}[1]{%
\csname dtlbar@segcol\romannumeral#1\endcsname}
% \end{macrocode}
%\end{macro}
%
+%\begin{macro}{\DTLdobarcolor}
%\begin{definition}
%\cs{DTLdobarcolor}\marg{n}
%\end{definition}
-% Set the colour to that for the \meta{n}th bar
-%\begin{macro}{\DTLdobarcolor}
+% Sets the colour to that for the \meta{n}th bar.
% \begin{macrocode}
\newcommand*{\DTLdobarcolor}[1]{%
\expandafter\color\expandafter
@@ -11441,9 +14868,9 @@ east,southeast,south,southwest,west,northwest}[northeast]{%
% \end{macrocode}
%\end{macro}
%
+%\begin{macro}{\DTLdocurrentbarcolor}
%\cs{DTLdocurrentbarcolor}
% sets the colour to that of the current bar.
-%\begin{macro}{\DTLdocurrentbarcolor}
% \begin{macrocode}
\newcommand*{\DTLdocurrentbarcolor}{%
\ifnum\dtlforeachlevel=0\relax
@@ -11457,17 +14884,17 @@ east,southeast,south,southwest,west,northwest}[northeast]{%
% \end{macrocode}
%\end{macro}
%
+%\begin{macro}{\DTLbaroutlinecolor}
%\cs{DTLbaroutlinecolor} specifies what colour to draw the
% outline.
-%\begin{macro}{\DTLbaroutlinecolor}
% \begin{macrocode}
\newcommand*{\DTLbaroutlinecolor}{black}
% \end{macrocode}
%\end{macro}
%
+%\begin{macro}{\DTLbaroutlinewidth}
%\cs{DTLbaroutlinewidth} specifies the line width of the outline:
% Outline is only drawn if the linewidth is greater than 0pt.
-%\begin{macro}{\DTLbaroutlinewidth}
% \begin{macrocode}
\newlength\DTLbaroutlinewidth
\DTLbaroutlinewidth=0pt
@@ -11615,6 +15042,7 @@ east,southeast,south,southwest,west,northwest}[northeast]{%
\let\dtlbar@ylabel=\relax
% \end{macrocode}
%
+%\begin{macro}{\DTLbarchart}
%\begin{definition}
% \cs{DTLbarchart}\oarg{conditions}\marg{option list}\marg{db name}\marg{assign list}
%\end{definition}
@@ -11624,7 +15052,6 @@ east,southeast,south,southwest,west,northwest}[northeast]{%
% include \texttt{variable}\texttt{=}\meta{cmd}, where \meta{cmd}
% is included in \meta{assign list}. The optional argument
% \meta{conditions} is the same as that for \cs{DTLforeach}.
-%\begin{macro}{\DTLbarchart}
% \begin{macrocode}
\newcommand*{\DTLbarchart}[4][\boolean{true}]{%
{\let\DTLbarvariable=\relax
@@ -11639,9 +15066,11 @@ uppermultibarlabels,groupgap}%
% \end{macrocode}
% Compute the maximum bar height, unless \cs{DTLbarmax} has been
% set.
+%\changes{1.01}{2007 Aug 17}{uses \cs{@sDTLforeach} instead of
+%\cs{DTLforeach}}
% \begin{macrocode}
\ifx\DTLbarmax\relax
- \DTLforeach[#1]{#3}{#4}{%
+ \@sDTLforeach[#1]{#3}{#4}{%
\expandafter\DTLconverttodecimal\expandafter
{\DTLbarvariable}{\dtl@barvar}%
\ifx\DTLbarmax\relax
@@ -11666,7 +15095,7 @@ uppermultibarlabels,groupgap}%
% \begin{macrocode}
\ifx\DTLnegextent\relax
\def\DTLnegextent{0}%
- \DTLforeach[#1]{#3}{#4}{%
+ \@sDTLforeach[#1]{#3}{#4}{%
\expandafter\DTLconverttodecimal\expandafter
{\DTLbarvariable}{\dtl@barvar}%
\let\dtl@old=\DTLnegextent
@@ -11775,7 +15204,7 @@ uppermultibarlabels,groupgap}%
% \end{macrocode}
% Iterate through data
% \begin{macrocode}
-\DTLforeach[#1]{#3}{#4}{%
+\@sDTLforeach[#1]{#3}{#4}{%
% \end{macrocode}
% Store the bar number in \cs{@dtl@bar}
% \begin{macrocode}
@@ -11971,6 +15400,7 @@ uppermultibarlabels,groupgap}%
% \end{macrocode}
%\end{macro}
%
+%\begin{macro}{\DTLmultibarchart}
%\begin{definition}
% \cs{DTLmultibarchart}\oarg{conditions}\marg{option list}\marg{db name}\marg{assign list}
%\end{definition}
@@ -11981,7 +15411,6 @@ uppermultibarlabels,groupgap}%
% list of commands, where each command
% is included in \meta{assign list}. The optional argument
% \meta{conditions} is the same as that for \cs{DTLforeach}.
-%\begin{macro}{\DTLmultibarchart}
% \begin{macrocode}
\newcommand*{\DTLmultibarchart}[4][\boolean{true}]{%
{\let\dtlbar@variables=\relax
@@ -11995,9 +15424,11 @@ uppermultibarlabels,groupgap}%
% \end{macrocode}
% Compute the maximum bar height, unless \cs{DTLbarmax} has been
% set.
+%\changes{1.01}{2007 Aug 17}{uses \cs{@sDTLforeach} instead of
+%\cs{DTLforeach}}
% \begin{macrocode}
\ifx\DTLbarmax\relax
- \DTLforeach[#1]{#3}{#4}{%
+ \@sDTLforeach[#1]{#3}{#4}{%
\@for\DTLbarvariable:=\dtlbar@variables\do{%
\expandafter\DTLconverttodecimal\expandafter
{\DTLbarvariable}{\dtl@barvar}%
@@ -12024,7 +15455,7 @@ uppermultibarlabels,groupgap}%
% \begin{macrocode}
\ifx\DTLnegextent\relax
\def\DTLnegextent{0}%
- \DTLforeach[#1]{#3}{#4}{%
+ \@sDTLforeach[#1]{#3}{#4}{%
\@for\DTLbarvariable:=\dtlbar@variables\do{%
\expandafter\DTLconverttodecimal\expandafter
{\DTLbarvariable}{\dtl@barvar}%
@@ -12166,7 +15597,7 @@ uppermultibarlabels,groupgap}%
% \end{macrocode}
% Iterate through data
% \begin{macrocode}
-\DTLforeach[#1]{#3}{#4}{%
+\@sDTLforeach[#1]{#3}{#4}{%
% \end{macrocode}
% Store the bar number in \cs{@dtl@bar}
% \begin{macrocode}
@@ -12424,5 +15855,3762 @@ uppermultibarlabels,groupgap}%
%</databar.sty>
% \end{macrocode}
%\fi
+%\iffalse
+% \begin{macrocode}
+%<*databib.sty>
+% \end{macrocode}
+%\fi
+%\section{databib.sty}
+%\label{sec:src:databib}
+%\subsection{Package Declaration}
+% \begin{macrocode}
+\NeedsTeXFormat{LaTeX2e}
+\ProvidesPackage{databib}[2007/08/17 v1.0 (NLCT)]
+% \end{macrocode}
+% Load required packages:
+% \begin{macrocode}
+\RequirePackage{datatool}
+% \end{macrocode}
+%\subsection{Package Options}
+%\begin{macro}{\dtlbib@style}
+%The default bib style is stored in \cs{dtlbib@style}.
+% \begin{macrocode}
+\newcommand*{\dtlbib@style}{plain}
+% \end{macrocode}
+%\end{macro}
+% The \pkgopt[databib]{style} package option sets \cs{dtlbib@style}.
+% \begin{macrocode}
+\define@choicekey{databib.sty}{style}{plain,abbrv,alpha}{%
+\def\dtlbib@style{#1}}
+% \end{macrocode}
+% Process package options:
+% \begin{macrocode}
+\ProcessOptionsX
+% \end{macrocode}
+%\subsection{Loading BBL file}
+%\begin{macro}{\DTLloadbbl}
+%\begin{definition}
+%\cs{DTLloadbib}\oarg{bbl file}\marg{db name}\marg{bib list}
+%\end{definition}
+% \begin{macrocode}
+\newcommand*{\DTLloadbbl}[3][\jobname.bbl]{%
+\bibliographystyle{databib}%
+\if@filesw
+ \immediate\write\@auxout{\string\bibdata{#3}}%
+\fi
+\DTLnewdb{#2}%
+\edef\DTLBIBdbname{#2}%
+\@input@{#1}}
+% \end{macrocode}
+%\end{macro}
+%\begin{macro}{\DTLnewbibrow}
+% \cs{DTLnewbibrow} adds a new row to the bibliography database.
+% (\cs{DTLBIBdbname} must be set prior to use to the name
+% of the \sty{datatool} database.)
+% \begin{macrocode}
+\newcommand*{\DTLnewbibrow}{\DTLnewrow{\DTLBIBdbname}}
+% \end{macrocode}
+%\end{macro}
+%\begin{macro}{\DTLnewbibitem}
+%\begin{definition}
+%\cs{DTLnewbibitem}\marg{key}\marg{value}
+%\end{definition}
+% Adds a new database entry with the given key and value.
+% \begin{macrocode}
+\newcommand*{\DTLnewbibitem}[2]{%
+\DTLnewdbentry{\DTLBIBdbname}{#1}{#2}}
+% \end{macrocode}
+%\end{macro}
+%\subsection{Predefined text}
+%\label{sec:src:bibnames}
+%\begin{macro}{\andname}
+% \begin{macrocode}
+\providecommand*{\andname}{and}
+% \end{macrocode}
+%\end{macro}
+%\begin{macro}{\ofname}
+% \begin{macrocode}
+\providecommand*{\ofname}{of}
+% \end{macrocode}
+%\end{macro}
+%\begin{macro}{\inname}
+% \begin{macrocode}
+\providecommand*{\inname}{in}
+% \end{macrocode}
+%\end{macro}
+%\begin{macro}{\etalname}
+% \begin{macrocode}
+\providecommand*{\etalname}{et al.}
+% \end{macrocode}
+%\end{macro}
+%\begin{macro}{\editorname}
+% \begin{macrocode}
+\providecommand*{\editorname}{editor}
+% \end{macrocode}
+%\end{macro}
+%\begin{macro}{\editorsname}
+% \begin{macrocode}
+\providecommand*{\editorsname}{editors}
+% \end{macrocode}
+%\end{macro}
+%\begin{macro}{\volumename}
+% \begin{macrocode}
+\providecommand*{\volumename}{volume}
+% \end{macrocode}
+%\end{macro}
+%\begin{macro}{\numbername}
+% \begin{macrocode}
+\providecommand*{\numbername}{number}
+% \end{macrocode}
+%\end{macro}
+%\begin{macro}{\pagesname}
+% \begin{macrocode}
+\providecommand*{\pagesname}{pages}
+% \end{macrocode}
+%\end{macro}
+%\begin{macro}{\pagename}
+% \begin{macrocode}
+\providecommand*{\pagename}{page}
+% \end{macrocode}
+%\end{macro}
+%\begin{macro}{\editionname}
+% \begin{macrocode}
+\providecommand*{\editionname}{edition}
+% \end{macrocode}
+%\end{macro}
+%\begin{macro}{\techreportname}
+% \begin{macrocode}
+\providecommand*{\techreportname}{Technical report}
+% \end{macrocode}
+%\end{macro}
+%\begin{macro}{\mscthesisname}
+% \begin{macrocode}
+\providecommand*{\mscthesisname}{Master's thesis}
+% \end{macrocode}
+%\end{macro}
+%\begin{macro}{\phdthesisname}
+% \begin{macrocode}
+\providecommand*{\phdthesisname}{PhD thesis}
+% \end{macrocode}
+%\end{macro}
+%
+%
+%\subsection{Displaying the bibliography}
+%\label{sec:src:displaybib}
+%\begin{definition}
+%\cs{DTLbibliography}\marg{bib dbname}
+%\end{definition}
+% Displays the bibliography for the database \meta{bib dbname}
+% which must have previously been loaded using
+% \cs{DTLloadbbl}.
+%\begin{macro}{\DTLbibliography}
+% \begin{macrocode}
+\newcommand*{\DTLbibliography}[2][\boolean{true}]{%
+\begin{DTLthebibliography}[#1]{#2}%
+\DTLforeachbibentry[#1]{#2}{%
+\DTLbibitem \DTLformatbibentry \DTLendbibitem
+}%
+\end{DTLthebibliography}%
+}
+% \end{macrocode}
+%\end{macro}
+%
+%\begin{macro}{\DTLformatbibentry}
+%\begin{definition}
+%\cs{DTLformatbibentry}
+%\end{definition}
+% Formats the current bib entry.
+% \begin{macrocode}
+\newcommand*{\DTLformatbibentry}{%
+\@ifundefined{DTLformat\DBIBentrytype}{%
+\PackageError{databib}{Don't know how to format bibliography entries
+of type `\DBIBentrytype'}{}}{%
+\dtl@message{[\DBIBcitekey]}%
+\DTLstartsentencefalse\DTLmidsentencefalse\DTLperiodfalse
+\csname DTLformat\DBIBentrytype\endcsname}%
+}
+% \end{macrocode}
+%\end{macro}
+%\begin{macro}{\DTLendbibitem}
+% Hook to add extra information at the end of a bibliography item.
+% This does nothing by default.
+% \begin{macrocode}
+\newcommand*{\DTLendbibitem}{}
+% \end{macrocode}
+%\end{macro}
+%
+%\begin{macro}{\DTLwidest}
+%Define a length to store the widest bib entry label
+% \begin{macrocode}
+\newlength\dtl@widest
+% \end{macrocode}
+%\end{macro}
+%
+%\begin{macro}{\DTLcomputewidestbibentry}
+%\begin{definition}
+%\cs{DTLcomputewidestbibentry}\marg{conditions}\marg{db
+%name}\marg{bib label}\marg{cmd}
+%\end{definition}
+%Computes the widest bibliography entry over all entries satisfying
+%\meta{condition} for the database called \meta{db name}, where
+% the bibliography label is formated according to \meta{bib label} and
+% stores the result in \meta{cmd} which must be a command name.
+% \begin{macrocode}
+\newcommand*{\DTLcomputewidestbibentry}[4]{%
+\dtl@widest=0pt\relax
+\let#4=\@empty
+\DTLforeachbibentry[#1]{#2}{%
+\settowidth{\dtl@tmplength}{#3}%
+\ifdim\dtl@tmplength>\dtl@widest\relax
+ \dtl@widest=\dtl@tmplength
+ \protected@edef#4{#3}%
+\fi
+}%
+}
+% \end{macrocode}
+%\end{macro}
+%
+%\begin{macro}{\DTLforeachbibentry}
+%\begin{definition}
+%\cs{DTLforeachbibentry}\oarg{condition}\marg{db name}\marg{text}
+%\end{definition}
+%\begin{definition}
+%\cs{DTLforeachbibentry*}\oarg{condition}\marg{db name}\marg{text}
+%\end{definition}
+% Iterates through the database called \meta{db name} and does
+% \meta{text} if \meta{condition} is met. As with
+% \cs{DTLforeach}, the starred version is read only.
+% \begin{macrocode}
+\newcommand*{\DTLforeachbibentry}{%
+\@ifstar\@DTLforeachbibentry\@DTLforeachbibentry}
+% \end{macrocode}
+%\end{macro}
+%\begin{macro}{\@DTLforeachbibentry}
+% Unstarred version
+% \begin{macrocode}
+\newcommand*{\@DTLforeachbibentry}[3][\boolean{true}]{%
+\edef\DBIBname{#2}\setcounter{DTLbibrow}{0}%
+\@DTLforeach{#2}{\DBIBcitekey=CiteKey,\DBIBentrytype
+=EntryType}{\dtl@gathervalues{#2}{\@dtl@currentrow}%
+\ifthenelse{#1}{\refstepcounter{DTLbibrow}#3}{}}}
+% \end{macrocode}
+%\end{macro}
+%\begin{macro}{\@sDTLforeachbibentry}
+% Starred version
+% \begin{macrocode}
+\newcommand*{\@sDTLforeachbibentry}[3][\boolean{true}]{%
+\edef\DBIBname{#2}\setcounter{DTLbibrow}{0}%
+\@sDTLforeach{#2}{\DBIBcitekey=CiteKey,\DBIBentrytype
+=EntryType}{\dtl@gathervalues{#2}{\@dtl@currentrow}%
+\ifthenelse{#1}{\refstepcounter{DTLbibrow}#3}{}}}
+% \end{macrocode}
+%\end{macro}
+%
+%The counter \counterfmt{DTLbibrow} keeps track of the current
+%row in the body of \cs{DTLforeachbibentry}. (You can't rely on
+%\counterfmt{DTLrowi}, \counterfmt{DTLrowii} and
+% \counterfmt{DTLrowiii}, as \cs{DTLforeachbibentry} pass the
+% conditions to the optional argument of \cs{DTLforeach}, but
+% instead uses \cs{ifthenelse}, which means that \counterfmt{DTLrowi}
+% etc will be incremented, even when the given condition is not met.)
+% \begin{macrocode}
+\newcounter{DTLbibrow}
+% \end{macrocode}
+% Keep \sty{hyperref} happy:
+% \begin{macrocode}
+\def\theHDTLbibrow{\theHDTLrow.bib.\arabic{DTLbibrow}}%
+% \end{macrocode}
+%
+%\begin{macro}{\DTLbibfield}
+%\begin{definition}
+%\cs{DTLbibfield}\marg{field name}
+%\end{definition}
+% Gets the value assigned to the field \meta{field name} for
+% the current row of \cs{DTLforeachbibentry}. (Doesn't check if
+% the field exists, or if it is being used within
+% \cs{DTLforeachbibentry}.)
+% \begin{macrocode}
+\newcommand*{\DTLbibfield}[1]{\csname @dtl@key@#1\endcsname}
+% \end{macrocode}
+%\end{macro}
+%
+%\begin{macro}{\DTLifbibfieldexists}
+%\begin{definition}
+%\cs{DTLifbibfieldexists}\marg{field name}\marg{true part}\marg{false
+%part}
+%\end{definition}
+%Determines whether the given field name exists for the current
+% row of \cs{DTLforeachbibentry}.
+% \begin{macrocode}
+\newcommand*{\DTLifbibfieldexists}[3]{%
+\@ifundefined{@dtl@key@#1}{#3}{%
+\expandafter\DTLifnull\csname @dtl@key@#1\endcsname
+{#3}{#2}}}
+% \end{macrocode}
+%\end{macro}
+%
+%\begin{macro}{\DTLifanybibfieldexists}
+%\begin{definition}
+%\cs{DTLifanybibfieldexists}\marg{list of field name}\marg{true part}\marg{false
+%part}
+%\end{definition}
+% Determines whether any of the listed fields exist for the current
+% row of \cs{DTLforeachbibentry}.
+% \begin{macrocode}
+\newcommand*{\DTLifanybibfieldexists}[3]{%
+\@for\dtl@thisfield:=#1\do{%
+\@ifundefined{@dtl@key@\dtl@thisfield}{}{%
+\expandafter\DTLifnull\csname @dtl@key@\dtl@thisfield\endcsname
+{}{%
+\@endfortrue}}}%
+\if@endfor
+ #2%
+\else
+ #3%
+\fi
+\@endforfalse
+}
+% \end{macrocode}
+%\end{macro}
+%
+%\begin{macro}{\ifDTLperiod}
+% The conditional \cs{ifDTLperiod} is used to keep track of any
+% abbreviations ending with a period, this is to ensure that
+% abbreviations aren't followed by a full stop if they already
+% have a full stop terminating the abbreviation.
+% \begin{macrocode}
+\newif\ifDTLperiod
+% \end{macrocode}
+%\end{macro}
+%\begin{macro}{\DTLcheckendsperiod}
+%\begin{definition}
+%\cs{DTLcheckendperiod}\marg{string}
+%\end{definition}
+% Checks if \meta{string} ends with a full stop. This sets
+% \cs{ifDTLperiod}.
+% \begin{macrocode}
+\newcommand*{\DTLcheckendsperiod}[1]{%
+\dtl@checkendsperiod#1\@nil\relax}
+% \end{macrocode}
+% \begin{macrocode}
+\def\dtl@checkendsperiod#1#2{%
+\def\@dtl@argi{#1}\def\@dtl@argii{#2}%
+\def\@dtl@period{.}%
+\ifx\@dtl@argi\@nnil
+ \global\DTLperiodfalse
+ \let\@dtl@donext=\relax
+\else
+ \ifx\@dtl@argii\@nnil
+ \ifx\@dtl@argi\@dtl@period
+ \global\DTLperiodtrue
+ \else
+ \global\DTLperiodfalse
+ \fi
+ \let\@dtl@donext=\@gobble
+ \else
+ \let\@dtl@donext=\dtl@checkendsperiod
+ \fi
+\fi
+\@dtl@donext{#2}%
+}
+% \end{macrocode}
+%\end{macro}
+%\begin{macro}{\DTLcheckbibfieldendsperiod}
+%\begin{definition}
+%\cs{DTLcheckbibfieldendperiod}\marg{label}
+%\end{definition}
+% Checks if the bib field \meta{label} ends with a full stop.
+% This sets \cs{ifDTLperiod}.
+% \begin{macrocode}
+\newcommand*{\DTLcheckbibfieldendsperiod}[1]{%
+\protected@edef\@dtl@tmp{\DTLbibfield{#1}}%
+\expandafter\DTLcheckendsperiod\expandafter{\@dtl@tmp}}
+% \end{macrocode}
+%\end{macro}
+%
+%\begin{macro}{\ifDTLmidsentence}
+%\begin{definition}
+%\cs{ifDTLmidsentence}
+%\end{definition}
+% Determine whether we are in the middle
+% of a sentence.
+% \begin{macrocode}
+\newif\ifDTLmidsentence
+% \end{macrocode}
+%\end{macro}
+%\begin{macro}{\ifDTLstartsentence}
+%\begin{definition}
+%\cs{ifDTLstartsentence}
+%\end{definition}
+% Determine whether we are at the start
+% of a sentence.
+% \begin{macrocode}
+\newif\ifDTLstartsentence
+% \end{macrocode}
+%\end{macro}
+%
+%\begin{macro}{\DTLaddperiod}
+%\begin{definition}
+%\cs{DTLaddperiod}
+%\end{definition}
+%Adds a full stop and sets \cs{DTLmidsentencefalse},
+%\cs{DTLstartsentencetrue} and
+%\cs{DTLperiodfalse}.
+% \begin{macrocode}
+\newcommand*{\DTLaddperiod}{\DTLmidsentencefalse\DTLperiodfalse
+\DTLstartsentencetrue
+\ifDTLperiod\else.\fi}
+% \end{macrocode}
+%\end{macro}
+%
+%\begin{macro}{\DTLaddcomma}
+%\begin{definition}
+%\cs{DTLaddcomma}
+%\end{definition}
+%Adds a comma and sets \cs{DTLmidsentencetrue}, \cs{DTLperiodfalse}
+%and \cs{DTLstartsentencefalse}
+% \begin{macrocode}
+\newcommand*{\DTLaddcomma}{, \DTLmidsentencetrue
+\DTLperiodfalse\DTLstartsentencefalse}
+% \end{macrocode}
+%\end{macro}
+%
+%\begin{macro}{\DTLstartsentencespace}
+%Adds a space if at the start of the sentence, otherwise does
+% nothing. (The space between sentences is added this way, rather
+% than in \cs{DTLaddperiod} otherwise spurious extra space can
+% occur at the end of the bib item. The spacefactor needs to be
+% set manually, because there's stuff in the way of the previous
+% sentence's full stop and this space which confuses the inter
+% sentence spacing (and, of course, the previous sentence could
+% have ended with a capital letter.)
+% \begin{macrocode}
+\newcommand*{\DTLstartsentencespace}{%
+\ifDTLstartsentence\spacefactor=\sfcode`\.\relax\space
+\fi\DTLstartsentencefalse}
+% \end{macrocode}
+%\end{macro}
+%
+%\begin{macro}{\DTLtwoand}
+% In a list of only two author (or editor) names, the text between the
+% two names is given by \cs{DTLtwoand}:
+% \begin{macrocode}
+\newcommand*{\DTLtwoand}{\ \andname\ }
+% \end{macrocode}
+%\end{macro}
+%\begin{macro}{\DTLandlast}
+% In a list of author (or editor) names, the text between the
+% penultimate and last name is given by \cs{DTLandlast}:
+% \begin{macrocode}
+\newcommand*{\DTLandlast}{, \andname\ }
+% \end{macrocode}
+%\end{macro}
+%\begin{macro}{\DTLandnotlast}
+% In a list of author (or editor) names, the text between the
+% names (except the penultimate and last name) is given by
+% \cs{DTLandnotlast}:
+% \begin{macrocode}
+\newcommand*{\DTLandnotlast}{, }
+% \end{macrocode}
+%\end{macro}
+%\begin{macro}{\dtl@authorcount}
+% Define a count register to keep track of the number of authors:
+% \begin{macrocode}
+\newcount\@dtl@authorcount
+% \end{macrocode}
+%\end{macro}
+% The counter \counterfmt{DTLmaxauthors} indicates the maximum number of
+% author names to display, if there are more than that number,
+% \cs{etalname} is used.
+% \begin{macrocode}
+\newcounter{DTLmaxauthors}
+\setcounter{DTLmaxauthors}{10}
+% \end{macrocode}
+%\begin{macro}{\DTLformatauthorlist}
+% Format a list of author names (the list is stored in
+% \cs{@dtl@key@Author}):
+% \begin{macrocode}
+\newcommand*{\DTLformatauthorlist}{%
+\DTLifbibfieldexists{Author}{%
+\DTLstartsentencespace
+\@dtl@authorcount=0\relax
+\@for\@dtl@author:=\@dtl@key@Author\do{%
+\advance\@dtl@authorcount by 1\relax}%
+\@dtl@tmpcount=0\relax
+\ifnum\@dtl@authorcount>\c@DTLmaxauthors
+{%
+ \@for\@dtl@author:=\@dtl@key@Author\do{%
+ \advance\@dtl@tmpcount by 1\relax
+ \ifnum\@dtl@tmpcount=1\relax
+ \expandafter\DTLformatauthor\@dtl@author
+ \else
+ \ifnum\@dtl@tmpcount>\c@DTLmaxauthors
+ \DTLandnotlast \etalname
+ \expandafter\DTLcheckendsperiod\expandafter{\etalname}%
+ \@endfortrue
+ \else
+ \DTLandnotlast \expandafter\DTLformatauthor\@dtl@author
+ \fi
+ \fi
+ }%
+}%
+\else
+ \@for\@dtl@author:=\@dtl@key@Author\do{%
+ \advance\@dtl@tmpcount by 1\relax
+ \ifnum\@dtl@tmpcount=1\relax
+ \expandafter\DTLformatauthor\@dtl@author
+ \else
+ \ifnum\@dtl@tmpcount=\@dtl@authorcount
+ \ifnum\@dtl@authorcount=2\relax
+ \DTLtwoand
+ \else
+ \DTLandlast
+ \fi
+ \expandafter\DTLformatauthor\@dtl@author
+ \else
+ \DTLandnotlast \expandafter\DTLformatauthor\@dtl@author
+ \fi
+ \fi
+ }%
+\fi
+}{}%
+}
+% \end{macrocode}
+%\end{macro}
+% The counter \counterfmt{DTLmaxeditors} indicates the maximum number of
+% editor names to display, if there are more than that number,
+% \cs{etalname} is used.
+% \begin{macrocode}
+\newcounter{DTLmaxeditors}
+\setcounter{DTLmaxeditors}{10}
+% \end{macrocode}
+%
+%\begin{macro}{\DTLformateditorlist}
+% Format a list of editor names (the list is stored in
+% \cs{@dtl@key@Editor}):
+% \begin{macrocode}
+\newcommand*{\DTLformateditorlist}{%
+\DTLifbibfieldexists{Editor}{%
+\DTLstartsentencespace
+\@dtl@authorcount=0\relax
+\@for\@dtl@author:=\@dtl@key@Editor\do{%
+\advance\@dtl@authorcount by 1\relax}%
+\@dtl@tmpcount=0\relax
+\ifnum\@dtl@authorcount>\c@DTLmaxeditors
+{%
+ \@for\@dtl@author:=\@dtl@key@Editor\do{%
+ \advance\@dtl@tmpcount by 1\relax
+ \ifnum\@dtl@tmpcount=1\relax
+ \expandafter\DTLformateditor\@dtl@author
+ \else
+ \ifnum\@dtl@tmpcount>\c@DTLmaxeditors
+ \DTLandnotlast \etalname
+ \expandafter\DTLcheckendsperiod\expandafter{\etalname}%
+ \@endfortrue
+ \else
+ \DTLandnotlast \expandafter\DTLformateditor\@dtl@author
+ \fi
+ \fi
+ }%
+}%
+\else
+\@for\@dtl@author:=\@dtl@key@Editor\do{%
+ \advance\@dtl@tmpcount by 1\relax
+ \ifnum\@dtl@tmpcount=1\relax
+ \expandafter\DTLformateditor\@dtl@author
+ \else
+ \ifnum\@dtl@tmpcount=\@dtl@authorcount
+ \ifnum\@dtl@authorcount=2\relax
+ \DTLtwoand
+ \else
+ \DTLandlast
+ \fi
+ \expandafter\DTLformateditor\@dtl@author
+ \else
+ \DTLandnotlast \expandafter\DTLformateditor\@dtl@author
+ \fi
+ \fi
+ }%
+\fi
+,
+\ifnum\@dtl@authorcount=1\relax
+ \editorname
+ \expandafter\DTLcheckendsperiod\expandafter{\editorname}%
+\else
+ \editorsname
+ \expandafter\DTLcheckendsperiod\expandafter{\editorsname}%
+\fi
+}{}%
+}
+% \end{macrocode}
+%\end{macro}
+%\begin{macro}{\DTLformatsurnameonly}
+%\begin{definition}
+%\cs{DTLformatsurnameonly}\marg{von part}\marg{surname}\marg{jr
+%part}\marg{forenames}
+%\end{definition}
+% This is used when only the surname should be displayed. (The
+% final argument, \meta{forenames}, is ignored.)
+% \begin{macrocode}
+\newcommand*{\DTLformatsurnameonly}[4]{%
+\DTLstartsentencespace
+\def\@dtl@tmp{#1}%
+\ifx\@dtl@tmp\@empty\else#1~\fi
+#2%
+\def\@dtl@tmp{#3}%
+\ifx\@dtl@tmp\@empty
+ \DTLcheckendsperiod{#2}%
+\else
+ , #3%
+ \DTLcheckendsperiod{#3}%
+\fi
+}
+% \end{macrocode}
+%\end{macro}
+%
+%\begin{macro}{\DTLformatforenames}
+%\begin{definition}
+%\cs{DTLformatforenames}\marg{forenames}
+%\end{definition}
+% The format of an author/editor's forenames. If the forenames
+% occur at the start of sentence, a new sentence space is added.
+% The argument is checked to determine whether it ends with a
+% full stop (sometimes the forenames may include initials.)
+% \begin{macrocode}
+\newcommand*{\DTLformatforenames}[1]{%
+\DTLstartsentencespace
+#1%
+\DTLcheckendsperiod{#1}}
+% \end{macrocode}
+%\end{macro}
+%
+%\begin{macro}{\DTLformatabbrvforenames}
+%\begin{definition}
+%\cs{DTLformatabbrvforenames}\marg{forenames}
+%\end{definition}
+% The format of an author/editor's abbreviated forenames. The initials
+% may or may not end in a full stop depending on the commands
+% governing the format of \cs{DTLstoreinitials}, so the initials
+% need to be check using \cs{DTLcheckendsperiod}.
+% \begin{macrocode}
+\newcommand*{\DTLformatabbrvforenames}[1]{%
+\DTLstartsentencespace
+\DTLstoreinitials{#1}{\@dtl@tmp}\@dtl@tmp
+\expandafter\DTLcheckendsperiod\expandafter{\@dtl@tmp}}
+% \end{macrocode}
+%\end{macro}
+%
+%\begin{macro}{\DTLformatvon}
+%\begin{definition}
+%\cs{DTLformatvon}\marg{von part}
+%\end{definition}
+% The format of the ``von'' part. This does nothing if the argument
+% is empty, otherwise it does the argument followed by a
+% non-breakable space.
+% \begin{macrocode}
+\newcommand*{\DTLformatvon}[1]{%
+\DTLstartsentencespace
+\def\@dtl@tmp{#1}%
+\ifx\@dtl@tmp\@empty
+\else
+ #1~%
+\fi
+}
+% \end{macrocode}
+%\end{macro}
+%
+%\begin{macro}{\DTLformatsurname}
+%\begin{definition}
+%\cs{DTLformatsurname}\marg{surname}
+%\end{definition}
+% The format of an author/editor's surname.
+% \begin{macrocode}
+\newcommand*{\DTLformatsurname}[1]{%
+\DTLstartsentencespace
+#1\DTLcheckendsperiod{#1}}
+% \end{macrocode}
+%\end{macro}
+%
+%\begin{macro}{\DTLformatjr}
+%\begin{definition}
+%\cs{DTLformatjr}\marg{jr part}
+%\end{definition}
+% The format of the ``jr'' part. This does nothing if the
+% argument is empty.
+% \begin{macrocode}
+\newcommand*{\DTLformatjr}[1]{%
+\DTLstartsentencespace
+\def\@dtl@tmp{#1}%
+\ifx\@dtl@tmp\@empty
+\else
+ , #1\DTLcheckendsperiod{#1}%
+\fi
+}
+% \end{macrocode}
+%\end{macro}
+%
+%\begin{macro}{\DTLformatcrossrefeditor}
+% Format cross reference editors:
+% \begin{macrocode}
+\newcommand*{\DTLformatcrossrefeditor}{%
+\DTLifbibfieldexists{Editor}{%
+\DTLstartsentencespace
+\@dtl@authorcount=0\relax
+\@for\@dtl@author:=\@dtl@key@Editor\do{%
+\advance\@dtl@authorcount by 1\relax}%
+{\@dtl@tmpcount=0\relax
+\@for\@dtl@author:=\@dtl@key@Editor\do{%
+\ifnum\@dtl@authorcount=1\relax
+ \expandafter\DTLformatsurnameonly\@dtl@author
+\else
+ \advance\@dtl@tmpcount by 1\relax
+ \ifnum\@dtl@tmpcount=1\relax
+ \expandafter\DTLformatsurnameonly\@dtl@author
+ \else
+ \ifnum\@dtl@authorcount=2\relax
+ \ \andname\ \expandafter\DTLformatsurnameonly\@dtl@author
+ \else
+ \ \etalname
+ \expandafter\DTLcheckendsperiod\expandafter{\etalname}
+ \fi
+ \@endfortrue
+ \fi
+\fi
+}}%
+}{}%
+}
+% \end{macrocode}
+%\end{macro}
+%
+%\begin{macro}{\DTLformatvolnumpages}
+% Format volume, number and pages (of an article).
+% \begin{macrocode}
+\newcommand*{\DTLformatvolnumpages}{%
+\DTLifbibfieldexists{Volume}{%
+\DTLstartsentencespace
+\DTLbibfield{Volume}\DTLperiodfalse}{}%
+\DTLifbibfieldexists{Number}{%
+\DTLstartsentencespace
+(\DTLbibfield{Number})\DTLperiodfalse}{}%
+\DTLifbibfieldexists{Pages}{%
+\DTLifanybibfieldexists{Volume,Number}{:}{%
+\DTLstartsentencespace
+\protected@edef\@dtl@pages{0\DTLbibfield{Pages}}%
+\DTLifnumerical{\@dtl@pages}{\pagename}{\pagesname}~}%
+\DTLbibfield{Pages}\DTLperiodfalse}{}%
+}
+% \end{macrocode}
+%\end{macro}
+%
+%\begin{macro}{\DTLformatbvolume}
+% Format book volume.
+% \begin{macrocode}
+\newcommand*{\DTLformatbvolume}{%
+\DTLifbibfieldexists{Volume}{%
+\ifDTLmidsentence
+ \volumename
+\else
+ \DTLstartsentencespace
+ \expandafter\MakeUppercase\volumename
+\fi
+~\DTLbibfield{Volume}%
+\DTLifbibfieldexists{Series}{\ \ofname\
+{\em\DTLbibfield{Series}}\DTLcheckbibfieldendsperiod{Series}}{%
+\DTLcheckbibfieldendsperiod{Volume}}%
+}{}}
+% \end{macrocode}
+%\end{macro}
+%
+%\begin{macro}{\DTLformatchapterpages}
+% Format chapter and pages:
+% \begin{macrocode}
+\newcommand*{\DTLformatchapterpages}{%
+\DTLifbibfieldexists{Chapter}{%
+\DTLifbibfieldexists{Type}{%
+\DTLstartsentencespace
+\DTLbibfield{Type}}{%
+\DTLstartsentencespace
+\chaptername}~\DTLbibfield{Chapter}%
+\DTLifbibfieldexists{Pages}{\DTLaddcomma}{%
+\DTLcheckbibfieldendsperiod{Chapter}}}{}%
+\DTLstartsentencespace
+\DTLformatpages}
+% \end{macrocode}
+%\end{macro}
+%
+%\begin{macro}{\DTLformatpages}
+% Format pages:
+% \begin{macrocode}
+\newcommand*{\DTLformatpages}{%
+\DTLifbibfieldexists{Pages}{%
+\DTLstartsentencespace
+\protected@edef\@dtl@pages{0\DTLbibfield{Pages}}%
+\DTLifnumerical{\@dtl@pages}{\pagename}{\pagesname}~%
+\DTLbibfield{Pages}\DTLcheckbibfieldendsperiod{Pages}}{}%
+}
+% \end{macrocode}
+%\end{macro}
+%
+%\begin{macro}{\DTLformatnumberseries}
+% Format number and series (of book)
+% \begin{macrocode}
+\newcommand*{\DTLformatnumberseries}{%
+\DTLifbibfieldexists{Volume}{}{%
+\DTLifbibfieldexists{Number}{%
+\ifDTLmidsentence
+ \numbername
+\else
+ \DTLstartsentencespace
+ \expandafter\MakeUppercase\numbername
+\fi~\DTLbibfield{Number}%
+\DTLifbibfieldexists{Series}{\ \inname\ \DTLbibfield{Series}%
+\DTLcheckbibfieldendsperiod{Series}}{%
+\DTLcheckbibfieldendsperiod{Number}}%
+}{%
+\DTLifbibfieldexists{Series}{%
+\DTLstartsentencespace
+\DTLbibfield{Series}%
+\DTLcheckbibfieldendsperiod{Series}}{}}%
+}%
+}
+% \end{macrocode}
+%\end{macro}
+%\begin{macro}{\DTLformatbookcrossref}
+% Format a book cross reference.
+% \begin{macrocode}
+\newcommand*{\DTLformatbookcrossref}{%
+\DTLifbibfieldexists{Volume}{%
+\ifDTLmidsentence
+ \volumename
+\else
+ \DTLstartsentencespace
+ \expandafter\MakeUppercase\volumename
+\fi
+~\DTLbibfield{Volume}\ \ofname\
+}{%
+\ifDTLmidsentence
+ \inname
+\else
+ \DTLstartsentencespace
+ \expandafter\MakeUppercase\inname
+\fi\ }%
+\DTLifbibfieldexists{Editor}{\DTLformatcrossrefeditor}{%
+\DTLifbibfieldexists{Key}{%
+\DTLbibfield{Key}}{%
+\DTLifbibfieldexists{Series}{%
+{\em\DTLbibfield{Series}}}{}%
+}%
+}%
+\edef\@dtl@tmp{\DTLbibfield{CrossRef}}%
+~\cite{\@dtl@tmp}%
+}
+% \end{macrocode}
+%\end{macro}
+%\begin{macro}{\DTLformatincollproccrossref}
+% Format `incollections' cross reference.
+% \begin{macrocode}
+\newcommand*{\DTLformatincollproccrossref}{%
+\DTLifbibfieldexists{Editor}{%
+\ifDTLmidsentence
+ \inname
+\else
+ \DTLstartsentencespace
+ \expandafter\MakeUppercase\inname
+\fi\
+\DTLformatcrossrefeditor
+}{%
+\DTLifbibfieldexists{Key}{%
+\ifDTLmidsentence
+ \inname
+\else
+ \DTLstartsentencespace
+ \expandafter\MakeUppercase\inname
+\fi\ \DTLbibfield{Key}%
+}{%
+\DTLifbibfieldexists{BookTitle}{%
+\ifDTLmidsentence
+ \inname
+\else
+ \DTLstartsentencespace
+ \expandafter\MakeUppercase\inname
+\fi\ {\em\DTLbibfield{BookTitle}}}{}%
+}}%
+\edef\@dtl@tmp{\DTLbibfield{CrossRef}}%
+~\cite{\@dtl@tmp}%
+}
+% \end{macrocode}
+%\end{macro}
+%
+%\begin{macro}{\DTLformatinedbooktitle}
+%Format editor and booktitle:
+% \begin{macrocode}
+\newcommand*{\DTLformatinedbooktitle}{%
+\DTLifbibfieldexists{BookTitle}{%
+\ifDTLmidsentence
+ \inname
+\else
+ \DTLstartsentencespace
+ \expandafter\MakeUppercase\inname
+\fi\
+\DTLifbibfieldexists{Editor}{%
+\DTLformateditorlist\DTLaddcomma {\em\DTLbibfield{BookTitle}}%
+\DTLcheckbibfieldendsperiod{BookTitle}%
+}{{\em\DTLbibfield{BookTitle}}%
+\DTLcheckbibfieldendsperiod{BookTitle}%
+}}{}}
+% \end{macrocode}
+%\end{macro}
+%
+%\begin{macro}{\DTLformatdate}
+%Format date.
+% \begin{macrocode}
+\newcommand*{\DTLformatdate}{%
+\DTLifbibfieldexists{Year}{%
+\DTLifbibfieldexists{Month}{%
+\protected@edef\@dtl@tmp{\DTLbibfield{Month}}%
+\ifDTLmidsentence
+ \@dtl@tmp
+\else
+ \DTLstartsentencespace
+ \expandafter\MakeUppercase\@dtl@tmp
+\fi\
+\DTLmidsentencefalse}{}%
+\DTLstartsentencespace
+\DTLbibfield{Year}}{%
+\DTLifbibfieldexists{Month}{%
+\protected@edef\@dtl@tmp{\DTLbibfield{Month}}%
+\ifDTLmidsentence
+ \@dtl@tmp
+\else
+ \DTLstartsentencespace
+ \expandafter\MakeUppercase\@dtl@tmp
+\fi
+\DTLcheckbibfieldendsperiod{Month}%
+}{}}}
+% \end{macrocode}
+%\end{macro}
+%\begin{macro}{\DTLformatarticlecrossref}
+% Format article cross reference.
+% \begin{macrocode}
+\newcommand*{\DTLformatarticlecrossref}{%
+\DTLifbibfieldexists{Key}{%
+\ifDTLmidsentence
+ \inname
+\else
+ \DTLstartsentencespace
+ \expandafter\MakeUppercase\inname
+\fi
+\ {\em\DTLbibfield{Key}}}{%
+\DTLifbibfieldexists{Journal}{%
+\ifDTLmidsentence
+ \inname
+\else
+ \DTLstartsentencespace
+ \expandafter\MakeUppercase\inname
+\fi
+\ {\em\DTLbibfield{Journal}}}{}}%
+\edef\@dtl@tmp{\DTLbibfield{CrossRef}}%
+~\cite{\@dtl@tmp}%
+}
+% \end{macrocode}
+%\end{macro}
+%
+%\subsubsection{ifthen conditionals}
+% The conditionals defined in this section may be used in the
+% optional argument of \cs{DTLforeachbib}. They may also be
+% used in the first argument of \cs{ifthenelse}, but only if the
+% command occurs within the body of \cs{DTLforeachbib}.
+%
+%\begin{macro}{\DTLbibfieldexists}
+%\begin{definition}
+%\cs{DTLbibfieldexists}\marg{field label}
+%\end{definition}
+% Checks if named bib field exists for current entry
+% \begin{macrocode}
+\newcommand*{\DTLbibfieldexists}[1]{%
+\TE@throw\noexpand\dtl@testbibfieldexists{#1}%
+\noexpand\if@dtl@condition}
+% \end{macrocode}
+%\end{macro}
+%\begin{macro}{\dtl@testbibfieldexists}
+% \begin{macrocode}
+\newcommand*{\dtl@testbibfieldexists}[1]{%
+\DTLifbibfieldexists{#1}{\@dtl@conditiontrue}{\@dtl@conditionfalse}}
+% \end{macrocode}
+%\end{macro}
+%
+%\begin{macro}{\DTLbibfieldiseq}
+%\begin{definition}
+%\cs{DTLbibfieldiseq}\marg{field label}\marg{value}
+%\end{definition}
+% Checks if the value of the bib field given by \meta{field label}
+% is equal to \meta{value}. (Uses \cs{dtlcompare} to determine if
+% the values are equal. If the bib field doesn't exist, the
+% condition is false.)
+% \begin{macrocode}
+\newcommand*{\DTLbibfieldiseq}[2]{%
+\TE@throw\noexpand\dtl@testbibfieldiseq{#1}{#2}%
+\noexpand\if@dtl@condition}
+% \end{macrocode}
+%\end{macro}
+%\begin{macro}{\dtl@testbibfieldiseq}
+% \begin{macrocode}
+\newcommand*{\dtl@testbibfieldiseq}[2]{%
+\DTLifbibfieldexists{#1}{%
+\expandafter\let\expandafter\@dtl@tmp\expandafter
+ =\csname @dtl@key@#1\endcsname
+\expandafter\toks@\expandafter{\@dtl@tmp}%
+\@dtl@toks{#2}%
+\edef\@dtl@docompare{\noexpand\dtlcompare{\noexpand\@dtl@tmpcount}%
+{\the\toks@}{\the\@dtl@toks}}%
+\@dtl@docompare
+\ifnum\@dtl@tmpcount=0\relax
+ \@dtl@conditiontrue
+\else
+ \@dtl@conditionfalse
+\fi
+}{%
+\@dtl@conditionfalse}%
+}
+% \end{macrocode}
+%\end{macro}
+%
+%\begin{macro}{\DTLbibfieldislt}
+%\begin{definition}
+%\cs{DTLbibfieldislt}\marg{field label}\marg{value}
+%\end{definition}
+% Checks if the value of the bib field given by \meta{field label}
+% is less than \meta{value}. (If the bib field doesn't exist, the
+% condition is false.)
+% \begin{macrocode}
+\newcommand*{\DTLbibfieldislt}[2]{%
+\TE@throw\noexpand\dtl@testbibfieldislt{#1}{#2}%
+\noexpand\if@dtl@condition}
+% \end{macrocode}
+%\end{macro}
+%\begin{macro}{\dtl@testbibfieldislt}
+% \begin{macrocode}
+\newcommand*{\dtl@testbibfieldislt}[2]{%
+\DTLifbibfieldexists{#1}{%
+\expandafter\let\expandafter\@dtl@tmp\expandafter
+ =\csname @dtl@key@#1\endcsname
+\expandafter\toks@\expandafter{\@dtl@tmp}%
+\@dtl@toks{#2}%
+\edef\@dtl@docompare{\noexpand\dtlcompare{\noexpand\@dtl@tmpcount}%
+{\the\toks@}{\the\@dtl@toks}}%
+\@dtl@docompare
+\ifnum\@dtl@tmpcount=-1\relax
+ \@dtl@conditiontrue
+\else
+ \@dtl@conditionfalse
+\fi
+}{%
+\@dtl@conditionfalse}%
+}
+% \end{macrocode}
+%\end{macro}
+%
+%\begin{macro}{\DTLbibfieldisle}
+%\begin{definition}
+%\cs{DTLbibfieldisle}\marg{field label}\marg{value}
+%\end{definition}
+% Checks if the value of the bib field given by \meta{field label}
+% is less than or equal to \meta{value}.
+% (If the bib field doesn't exist, the
+% condition is false.)
+% \begin{macrocode}
+\newcommand*{\DTLbibfieldisle}[2]{%
+\TE@throw\noexpand\dtl@testbibfieldisle{#1}{#2}%
+\noexpand\if@dtl@condition}
+% \end{macrocode}
+%\end{macro}
+%\begin{macro}{\dtl@testbibfieldisle}
+% \begin{macrocode}
+\newcommand*{\dtl@testbibfieldisle}[2]{%
+\DTLifbibfieldexists{#1}{%
+\expandafter\let\expandafter\@dtl@tmp\expandafter
+ =\csname @dtl@key@#1\endcsname
+\expandafter\toks@\expandafter{\@dtl@tmp}%
+\@dtl@toks{#2}%
+\edef\@dtl@docompare{\noexpand\dtlcompare{\noexpand\@dtl@tmpcount}%
+{\the\toks@}{\the\@dtl@toks}}%
+\@dtl@docompare
+\ifnum\@dtl@tmpcount<1\relax
+ \@dtl@conditiontrue
+\else
+ \@dtl@conditionfalse
+\fi
+}{%
+\@dtl@conditionfalse}%
+}
+% \end{macrocode}
+%\end{macro}
+%
+%\begin{macro}{\DTLbibfieldisgt}
+%\begin{definition}
+%\cs{DTLbibfieldisgt}\marg{field label}\marg{value}
+%\end{definition}
+% Checks if the value of the bib field given by \meta{field label}
+% is greater than \meta{value}. (If the bib field doesn't exist, the
+% condition is false.)
+% \begin{macrocode}
+\newcommand*{\DTLbibfieldisgt}[2]{%
+\TE@throw\noexpand\dtl@testbibfieldisgt{#1}{#2}%
+\noexpand\if@dtl@condition}
+% \end{macrocode}
+%\end{macro}
+%\begin{macro}{\dtl@testbibfieldisgt}
+% \begin{macrocode}
+\newcommand*{\dtl@testbibfieldisgt}[2]{%
+\DTLifbibfieldexists{#1}{%
+\expandafter\let\expandafter\@dtl@tmp\expandafter
+ =\csname @dtl@key@#1\endcsname
+\expandafter\toks@\expandafter{\@dtl@tmp}%
+\@dtl@toks{#2}%
+\edef\@dtl@docompare{\noexpand\dtlcompare{\noexpand\@dtl@tmpcount}%
+{\the\toks@}{\the\@dtl@toks}}%
+\@dtl@docompare
+\ifnum\@dtl@tmpcount=1\relax
+ \@dtl@conditiontrue
+\else
+ \@dtl@conditionfalse
+\fi
+}{%
+\@dtl@conditionfalse}%
+}
+% \end{macrocode}
+%\end{macro}
+%
+%\begin{macro}{\DTLbibfieldisge}
+%\begin{definition}
+%\cs{DTLbibfieldisge}\marg{field label}\marg{value}
+%\end{definition}
+% Checks if the value of the bib field given by \meta{field label}
+% is less than or equal to \meta{value}.
+% (If the bib field doesn't exist, the
+% condition is false.)
+% \begin{macrocode}
+\newcommand*{\DTLbibfieldisge}[2]{%
+\TE@throw\noexpand\dtl@testbibfieldisge{#1}{#2}%
+\noexpand\if@dtl@condition}
+% \end{macrocode}
+%\end{macro}
+%\begin{macro}{\dtl@testbibfieldisge}
+% \begin{macrocode}
+\newcommand*{\dtl@testbibfieldisge}[2]{%
+\DTLifbibfieldexists{#1}{%
+\expandafter\let\expandafter\@dtl@tmp\expandafter
+ =\csname @dtl@key@#1\endcsname
+\expandafter\toks@\expandafter{\@dtl@tmp}%
+\@dtl@toks{#2}%
+\edef\@dtl@docompare{\noexpand\dtlcompare{\noexpand\@dtl@tmpcount}%
+{\the\toks@}{\the\@dtl@toks}}%
+\@dtl@docompare
+\ifnum\@dtl@tmpcount>-1\relax
+ \@dtl@conditiontrue
+\else
+ \@dtl@conditionfalse
+\fi
+}{%
+\@dtl@conditionfalse}%
+}
+% \end{macrocode}
+%\end{macro}
+%
+%\begin{macro}{\DTLbibfieldcontains}
+%\begin{definition}
+%\cs{DTLbibfieldcontains}\marg{field label}\marg{sub string}
+%\end{definition}
+% Checks if the value of the bib field given by \meta{field label}
+% contains \meta{sub string}.
+% (If the bib field doesn't exist, the
+% condition is false.)
+% \begin{macrocode}
+\newcommand*{\DTLbibfieldcontains}[2]{%
+\TE@throw\noexpand\dtl@testbibfieldcontains{#1}{#2}%
+\noexpand\if@dtl@condition}
+% \end{macrocode}
+%\end{macro}
+%\begin{macro}{\dtl@testbibfieldcontains}
+% \begin{macrocode}
+\newcommand*{\dtl@testbibfieldcontains}[2]{%
+\DTLifbibfieldexists{#1}{%
+\expandafter\let\expandafter\@dtl@tmp\expandafter
+ =\csname @dtl@key@#1\endcsname
+\expandafter\dtl@testifsubstring\expandafter{\@dtl@tmp}{#2}%
+}{\@dtl@conditionfalse}}
+% \end{macrocode}
+%\end{macro}
+%
+%\subsection{Bibliography Style Macros}
+%\label{sec:src:bibstyle}
+% The macros defined in this section should be redefined by
+% bibliography styles.
+%
+%\begin{environment}{DTLthebibliography}
+% How to format the entire bibliography:
+% \begin{macrocode}
+\newenvironment{DTLthebibliography}[2][\boolean{true}]{%
+\@dtl@tmpcount=0\relax
+\@sDTLforeach[#1]{#2}{}{\advance\@dtl@tmpcount by 1\relax}%
+\begin{thebibliography}{\number\@dtl@tmpcount}
+}{\end{thebibliography}}
+% \end{macrocode}
+%\end{environment}
+%\begin{macro}{\DTLmonthname}
+% The monthname style. The argument must be a number from~1
+% to~12. By default, uses \cs{dtl@monthname}.
+% \begin{macrocode}
+\newcommand*{\DTLmonthname}[1]{%
+\dtl@monthname{#1}}
+% \end{macrocode}
+%\end{macro}
+%\begin{macro}{\dtl@monthname}
+% Full month names:
+% \begin{macrocode}
+\newcommand*{\dtl@monthname}[1]{%
+\ifcase#1%
+\or January%
+\or February%
+\or March%
+\or April%
+\or May%
+\or June%
+\or July%
+\or August%
+\or September%
+\or October%
+\or November%
+\or December%
+\fi}
+% \end{macrocode}
+%\end{macro}
+%\begin{macro}{\dtl@abbrvmonthname}
+% Abbreviated months:
+% \begin{macrocode}
+\newcommand*{\dtl@abbrvmonthname}[1]{%
+\ifcase#1%
+\or Jan.%
+\or Feb.%
+\or Mar.%
+\or Apr.%
+\or May%
+\or June%
+\or July%
+\or Aug.%
+\or Sept.%
+\or Oct.%
+\or Nov.%
+\or Dec.%
+\fi}
+% \end{macrocode}
+%\end{macro}
+%
+%\begin{macro}{\DTLbibitem}
+% Define how to start a new bibitem:
+% \begin{macrocode}
+\newcommand*{\DTLbibitem}{\bibitem{\DBIBcitekey}}
+% \end{macrocode}
+%\end{macro}
+%
+%\begin{macro}{\DTLformatauthor}
+%\begin{definition}
+%\cs{DTLformatauthor}\marg{von part}\marg{surname}\marg{junior
+%part}\marg{forenames}
+%\end{definition}
+% The format of an author's name.
+% \begin{macrocode}
+\newcommand*{\DTLformatauthor}[4]{%
+\DTLformatforenames{#4}
+\DTLformatvon{#1}%
+\DTLformatsurname{#2}%
+\DTLformatjr{#3}}
+% \end{macrocode}
+%\end{macro}
+%
+%\begin{macro}{\DTLformateditor}
+% The format of an editor's name.
+% \begin{macrocode}
+\newcommand*{\DTLformateditor}[4]{%
+\DTLformatforenames{#4}
+\DTLformatvon{#1}%
+\DTLformatsurname{#2}%
+\DTLformatjr{#3}}
+% \end{macrocode}
+%\end{macro}
+%
+%\begin{macro}{\DTLformatedition}
+% The format of an edition:
+% \begin{macrocode}
+\newcommand*{\DTLformatedition}[1]{#1 \editionname}
+% \end{macrocode}
+%\end{macro}
+%
+%\begin{macro}{\DTLformatarticle}
+% The format of an article:
+% \begin{macrocode}
+\newcommand{\DTLformatarticle}{}
+% \end{macrocode}
+%\end{macro}
+%
+%\begin{macro}{\DTLformatbook}
+% The format of a book:
+% \begin{macrocode}
+\newcommand{\DTLformatbook}{}
+% \end{macrocode}
+%\end{macro}
+%
+%\begin{macro}{\DTLformatbooklet}
+% The format of a booklet:
+% \begin{macrocode}
+\newcommand{\DTLformatbooklet}{}
+% \end{macrocode}
+%\end{macro}
+%
+%\begin{macro}{\DTLformatinbook}
+% The format of an ``inbook'' type:
+% \begin{macrocode}
+\newcommand{\DTLformatinbook}{}
+% \end{macrocode}
+%\end{macro}
+%
+%\begin{macro}{\DTLformatincollection}
+% The format of an ``incollection'' type:
+% \begin{macrocode}
+\newcommand{\DTLformatincollection}{}
+% \end{macrocode}
+%\end{macro}
+%
+%\begin{macro}{\DTLformatinproceedings}
+% The format of an ``inproceedings'' type:
+% \begin{macrocode}
+\newcommand{\DTLformatinproceedings}{}
+% \end{macrocode}
+%\end{macro}
+%
+%\begin{macro}{\DTLformatmanual}
+% The format of a manual:
+% \begin{macrocode}
+\newcommand{\DTLformatmanual}{}
+% \end{macrocode}
+%\end{macro}
+%
+%\begin{macro}{\DTLformatmastersthesis}
+% The format of a master's thesis:
+% \begin{macrocode}
+\newcommand{\DTLformatmastersthesis}{}
+% \end{macrocode}
+%\end{macro}
+%
+%\begin{macro}{\DTLformatmisc}
+% The format of a miscellaneous entry:
+% \begin{macrocode}
+\newcommand{\DTLformatmisc}{}
+% \end{macrocode}
+%\end{macro}
+%
+%\begin{macro}{\DTLformatphdthesis}
+% The format of a Ph.D. thesis:
+% \begin{macrocode}
+\newcommand{\DTLformatphdthesis}{}
+% \end{macrocode}
+%\end{macro}
+%
+%\begin{macro}{\DTLformatproceedings}
+% The format of a proceedings:
+% \begin{macrocode}
+\newcommand{\DTLformatproceedings}{}
+% \end{macrocode}
+%\end{macro}
+%
+%\begin{macro}{\DTLformattechreport}
+% The format of a technical report:
+% \begin{macrocode}
+\newcommand{\DTLformattechreport}{}
+% \end{macrocode}
+%\end{macro}
+%
+%\begin{macro}{\DTLformatunpublished}
+% The format of an unpublished work:
+% \begin{macrocode}
+\newcommand{\DTLformatunpublished}{}
+% \end{macrocode}
+%\end{macro}
+%
+% Predefined names (these correspond to the standard \BibTeX\
+% predefined strings of the same name without the leading
+% \cs{DTL}):
+%\begin{macro}{\DTLacmcs}
+% \begin{macrocode}
+\newcommand*{\DTLacmcs}{ACM Computing Surveys}
+% \end{macrocode}
+%\end{macro}
+%
+%\begin{macro}{\DTLacta}
+% \begin{macrocode}
+\newcommand*{\DTLacta}{Acta Informatica}
+% \end{macrocode}
+%\end{macro}
+%
+%\begin{macro}{\DTLcacm}
+% \begin{macrocode}
+\newcommand*{\DTLcacm}{Communications of the ACM}
+% \end{macrocode}
+%\end{macro}
+%
+%\begin{macro}{\DTLibmjrd}
+% \begin{macrocode}
+\newcommand*{\DTLibmjrd}{IBM Journal of Research and Development}
+% \end{macrocode}
+%\end{macro}
+%
+%\begin{macro}{\DTLibmsj}
+% \begin{macrocode}
+\newcommand*{\DTLibmsj}{IBM Systems Journal}
+% \end{macrocode}
+%\end{macro}
+%
+%\begin{macro}{\DTLieeese}
+% \begin{macrocode}
+\newcommand*{\DTLieeese}{IEEE Transactions on Software Engineering}
+% \end{macrocode}
+%\end{macro}
+%
+%\begin{macro}{\DTLieeetc}
+% \begin{macrocode}
+\newcommand*{\DTLieeetc}{IEEE Transactions on Computers}
+% \end{macrocode}
+%\end{macro}
+%
+%\begin{macro}{\DTLieeetcad}
+% \begin{macrocode}
+\newcommand*{\DTLieeetcad}{IEEE Transactions on Computer-Aided Design
+of Integrated Circuits}
+% \end{macrocode}
+%\end{macro}
+%
+%\begin{macro}{\DTLipl}
+% \begin{macrocode}
+\newcommand*{\DTLipl}{Information Processing Letters}
+% \end{macrocode}
+%\end{macro}
+%
+%\begin{macro}{\DTLjacm}
+% \begin{macrocode}
+\newcommand*{\DTLjacm}{Journal of the ACM}
+% \end{macrocode}
+%\end{macro}
+%
+%\begin{macro}{\DTLjcss}
+% \begin{macrocode}
+\newcommand*{\DTLjcss}{Journal of Computer and System Sciences}
+% \end{macrocode}
+%\end{macro}
+%
+%\begin{macro}{\DTLscp}
+% \begin{macrocode}
+\newcommand*{\DTLscp}{Science of Computer Programming}
+% \end{macrocode}
+%\end{macro}
+%
+%\begin{macro}{\DTLsicomp}
+% \begin{macrocode}
+\newcommand*{\DTLsicomp}{SIAM Journal on Computing}
+% \end{macrocode}
+%\end{macro}
+%
+%\begin{macro}{\DTLtocs}
+% \begin{macrocode}
+\newcommand*{\DTLtocs}{ACM Transactions on Computer Systems}
+% \end{macrocode}
+%\end{macro}
+%
+%\begin{macro}{\DTLtods}
+% \begin{macrocode}
+\newcommand*{\DTLtods}{ACM Transactions on Database Systems}
+% \end{macrocode}
+%\end{macro}
+%
+%\begin{macro}{\DTLtog}
+% \begin{macrocode}
+\newcommand*{\DTLtog}{ACM Transactions on Graphics}
+% \end{macrocode}
+%\end{macro}
+%
+%\begin{macro}{\DTLtoms}
+% \begin{macrocode}
+\newcommand*{\DTLtoms}{ACM Transactions on Mathematical Software}
+% \end{macrocode}
+%\end{macro}
+%
+%\begin{macro}{\DTLtoois}
+% \begin{macrocode}
+\newcommand*{\DTLtoois}{ACM Transactions on Office Information
+Systems}
+% \end{macrocode}
+%\end{macro}
+%
+%\begin{macro}{\DTLtoplas}
+% \begin{macrocode}
+\newcommand*{\DTLtoplas}{ACM Transactions on Programming Languages
+and Systems}
+% \end{macrocode}
+%\end{macro}
+%
+%\begin{macro}{\DTLtcs}
+% \begin{macrocode}
+\newcommand*{\DTLtcs}{Theoretical Computer Science}
+% \end{macrocode}
+%\end{macro}
+%
+%\subsection{Bibliography Styles}
+% Each bibliography style is set by the command
+% \cs{dtlbst@}\meta{style}, where \meta{style} is the name
+% of the bibliography style.
+%
+%\begin{macro}{\dtlbst@plain}
+% The `plain' style:
+% \begin{macrocode}
+\newcommand{\dtlbst@plain}{%
+% \end{macrocode}
+% Set how to format the entire bibliography:
+% \begin{macrocode}
+\renewenvironment{DTLthebibliography}[2][\boolean{true}]{%
+\@dtl@tmpcount=0\relax
+\@sDTLforeach[##1]{##2}{}{\advance\@dtl@tmpcount by 1\relax}%
+\begin{thebibliography}{\number\@dtl@tmpcount}%
+}{\end{thebibliography}}%
+% \end{macrocode}
+% Set how to start the bibliography entry:
+% \begin{macrocode}
+\renewcommand*{\DTLbibitem}{\bibitem{\DBIBcitekey}}%
+% \end{macrocode}
+% Sets the author name format.
+% \begin{macrocode}
+\renewcommand*{\DTLformatauthor}[4]{%
+\DTLformatforenames{##4}
+\DTLformatvon{##1}%
+\DTLformatsurname{##2}%
+\DTLformatjr{##3}}
+% \end{macrocode}
+% Sets the editor name format.
+% \begin{macrocode}
+\renewcommand*{\DTLformateditor}[4]{%
+\DTLformatforenames{##4}
+\DTLformatvon{##1}%
+\DTLformatsurname{##2}%
+\DTLformatjr{##3}}
+% \end{macrocode}
+% Sets the edition format.
+% \begin{macrocode}
+\renewcommand*{\DTLformatedition}[1]{##1 \editionname}%
+% \end{macrocode}
+% Sets the monthname format.
+% \begin{macrocode}
+\let\DTLmonthname\dtl@monthname
+% \end{macrocode}
+% Sets other predefined names:
+% \begin{macrocode}
+\renewcommand*{\DTLacmcs}{ACM Computing Surveys}
+\renewcommand*{\DTLacta}{Acta Informatica}
+\renewcommand*{\DTLcacm}{Communications of the ACM}
+\renewcommand*{\DTLibmjrd}{IBM Journal of Research and Development}
+\renewcommand*{\DTLibmsj}{IBM Systems Journal}
+\renewcommand*{\DTLieeese}{IEEE Transactions on Software Engineering}
+\renewcommand*{\DTLieeetc}{IEEE Transactions on Computers}
+\renewcommand*{\DTLieeetcad}{IEEE Transactions on Computer-Aided Design
+of Integrated Circuits}
+\renewcommand*{\DTLipl}{Information Processing Letters}
+\renewcommand*{\DTLjacm}{Journal of the ACM}
+\renewcommand*{\DTLjcss}{Journal of Computer and System Sciences}
+\renewcommand*{\DTLscp}{Science of Computer Programming}
+\renewcommand*{\DTLsicomp}{SIAM Journal on Computing}
+\renewcommand*{\DTLtocs}{ACM Transactions on Computer Systems}
+\renewcommand*{\DTLtods}{ACM Transactions on Database Systems}
+\renewcommand*{\DTLtog}{ACM Transactions on Graphics}
+\renewcommand*{\DTLtoms}{ACM Transactions on Mathematical Software}
+\renewcommand*{\DTLtoois}{ACM Transactions on Office Information
+Systems}
+\renewcommand*{\DTLtoplas}{ACM Transactions on Programming Languages
+and Systems}
+\renewcommand*{\DTLtcs}{Theoretical Computer Science}
+% \end{macrocode}
+% The format of an article.
+% \begin{macrocode}
+\renewcommand*{\DTLformatarticle}{%
+\DTLformatauthorlist
+\DTLifbibfieldexists{Author}{\DTLaddperiod}{}%
+\DTLifbibfieldexists{Title}{%
+\DTLstartsentencespace\DTLbibfield{Title}%
+\DTLcheckbibfieldendsperiod{Title}%
+\DTLaddperiod}{}%
+\DTLifbibfieldexists{CrossRef}{%
+% cross ref field
+\DTLformatarticlecrossref
+\DTLifbibfieldexists{Pages}{\DTLaddcomma}{}%
+\DTLformatpages
+\DTLaddperiod
+}{% no cross ref field
+\DTLifbibfieldexists{Journal}{\DTLstartsentencespace
+{\em\DTLbibfield{Journal}}%
+\DTLcheckbibfieldendsperiod{Journal}%
+\DTLifanybibfieldexists{Number,Volume,Pages,Month,Year}{%
+\DTLaddcomma}{\DTLaddperiod}}{}%
+\DTLformatvolnumpages
+\DTLifanybibfieldexists{Volume,Number,Pages}{%
+\DTLifanybibfieldexists{Year,Month}{\DTLaddcomma}{%
+\DTLaddperiod}%
+\DTLmidsentencefalse}{}%
+\DTLformatdate
+\DTLifanybibfieldexists{Year,Month}{\DTLaddperiod}{}%
+}%
+\DTLifbibfieldexists{Note}{\DTLstartsentencespace\DTLbibfield{Note}%
+\DTLcheckbibfieldendsperiod{Note}%
+\DTLaddperiod}{}%
+}
+% \end{macrocode}
+% The format of a book.
+% \begin{macrocode}
+\renewcommand*{\DTLformatbook}{%
+\DTLifbibfieldexists{Author}{%
+\DTLformatauthorlist\DTLaddperiod
+}{\DTLformateditorlist\DTLifbibfieldexists{Editor}{%
+\DTLaddperiod}{}}%
+\DTLifbibfieldexists{Title}{\DTLstartsentencespace
+{\em\DTLbibfield{Title}}%
+\DTLcheckbibfieldendsperiod{Title}}{}%
+\DTLifbibfieldexists{CrossRef}{%
+% cross ref field
+\DTLifbibfieldexists{Title}{\DTLaddperiod}{}%
+\DTLformatbookcrossref
+\DTLifanybibfieldexists{Edition,Month,Year}{\DTLaddcomma
+}{\DTLaddperiod}%
+}{% no cross ref field
+\DTLifbibfieldexists{Title}{%
+\DTLifbibfieldexists{Volume}{\DTLaddcomma}{\DTLaddperiod}}{}%
+\DTLformatbvolume
+\DTLformatnumberseries
+\DTLifanybibfieldexists{Number,Series,Volume}{\DTLaddperiod}{}%
+\DTLifbibfieldexists{Publisher}{\DTLstartsentencespace
+\DTLbibfield{Publisher}%
+\DTLcheckbibfieldendsperiod{Publisher}%
+\DTLifbibfieldexists{Address}{\DTLaddcomma}{%
+\DTLifanybibfieldexists{Month,Year}{\DTLaddcomma
+}{\DTLaddperiod}%
+}}{}%
+\DTLifbibfieldexists{Address}{\DTLstartsentencespace
+\DTLbibfield{Address}%
+\DTLcheckbibfieldendsperiod{Address}%
+\DTLifanybibfieldexists{Month,Year}{\DTLaddcomma}{\DTLaddperiod}}{}%
+}%
+\DTLifbibfieldexists{Edition}{%
+\protected@edef\@dtl@tmp{\DTLformatedition{\DTLbibfield{Edition}}}%
+\ifDTLmidsentence
+ \@dtl@tmp
+\else
+ \DTLstartsentencespace\expandafter\MakeUppercase\@dtl@tmp
+\fi
+\expandafter\DTLcheckendsperiod\expandafter{\@dtl@tmp}%
+\DTLifanybibfieldexists{Month,Year}{\DTLaddcomma}{\DTLaddperiod}%
+}{}%
+\DTLformatdate
+\DTLifanybibfieldexists{Year,Month}{\DTLaddperiod}{}%
+\DTLifbibfieldexists{Note}{\DTLstartsentencespace
+\DTLbibfield{Note}%
+\DTLcheckbibfieldendsperiod{Note}%
+\DTLaddperiod}{}%
+}%
+% \end{macrocode}
+% The format of a booklet.
+% \begin{macrocode}
+\renewcommand*{\DTLformatbooklet}{%
+\DTLifbibfieldexists{Author}{%
+\DTLformatauthorlist\DTLaddperiod}{}%
+\DTLifbibfieldexists{Title}{\DTLstartsentencespace
+\DTLbibfield{Title}%
+\DTLcheckbibfieldendsperiod{Title}%
+\DTLaddperiod}{}%
+\DTLifbibfieldexists{HowPublished}{%
+\DTLstartsentencespace\DTLbibfield{HowPublished}%
+\DTLcheckbibfieldendsperiod{HowPublished}%
+\DTLifanybibfieldexists{Address,Month,Year}{\DTLaddcomma
+}{\DTLaddperiod}}{}%
+\DTLifbibfieldexists{Address}{\DTLstartsentencespace
+\DTLbibfield{Address}%
+\DTLcheckbibfieldendsperiod{Address}%
+\DTLifanybibfieldexists{Month,Year}{\DTLaddcomma}{\DTLaddperiod}}{}%
+\DTLformatdate
+\DTLifanybibfieldexists{Year,Month}{\DTLaddperiod}{}%
+\DTLifbibfieldexists{Note}{\DTLstartsentencespace\DTLbibfield{Note}%
+\DTLcheckbibfieldendsperiod{Note}%
+\DTLaddperiod}{}%
+}%
+% \end{macrocode}
+% The format of an `inbook' entry.
+% \begin{macrocode}
+\renewcommand*{\DTLformatinbook}{%
+\DTLifbibfieldexists{Author}{%
+\DTLformatauthorlist\DTLaddperiod}{%
+\DTLifbibfieldexists{Editor}{\DTLformateditorlist\DTLaddperiod}{}}%
+\DTLifbibfieldexists{Title}{%
+\DTLstartsentencespace
+{\em\DTLbibfield{Title}}%
+\DTLcheckbibfieldendsperiod{Title}%
+}{}%
+\DTLifbibfieldexists{CrossRef}{%
+% Cross ref entry
+\DTLifbibfieldexists{Title}{%
+\DTLifbibfieldexists{Chapter}{\DTLaddcomma}{\DTLaddperiod}}{}%
+\DTLformatchapterpages
+\DTLifanybibfieldexists{Chapter,Pages}{\DTLaddperiod}{}%
+\DTLformatbookcrossref
+}{% no cross ref
+\DTLifbibfieldexists{Title}{%
+\DTLifanybibfieldexists{Chapter,Volume}{\DTLaddcomma
+}{\DTLaddperiod}}{}%
+\DTLformatbvolume
+\DTLifanybibfieldexists{Volume,Series}{%
+\DTLifanybibfieldexists{Chapter,Pages}{%
+\DTLaddcomma}{\DTLaddperiod}}{}%
+\DTLformatchapterpages
+\DTLifanybibfieldexists{Chapter,Pages}{\DTLaddperiod}{}%
+\DTLifbibfieldexists{Publisher}{%
+\DTLstartsentencespace
+\DTLbibfield{Publisher}%
+\DTLcheckbibfieldendsperiod{Publisher}%
+\DTLifbibfieldexists{Address}{\DTLaddcomma}{}}{}%
+\DTLifbibfieldexists{Address}{%
+\DTLstartsentencespace
+\DTLbibfield{Address}%
+\DTLcheckbibfieldendsperiod{Address}}{}%
+}%
+\DTLifanybibfieldexists{Edition,Month,Year}{\DTLaddcomma
+}{\DTLaddperiod}%
+\DTLifbibfieldexists{Edition}{%
+\protected@edef\@dtl@tmp{\DTLformatedition{\DTLbibfield{Edition}}}%
+\ifDTLmidsentence
+ \@dtl@tmp
+\else
+ \DTLstartsentencespace
+ \expandafter\MakeUppercase\@dtl@tmp
+\fi
+\expandafter\DTLcheckendsperiod\expandafter{\@dtl@tmp}%
+\DTLifanybibfieldexists{Month,Year}{\DTLaddcomma
+}{\DTLaddperiod}%
+}{}%
+\DTLformatdate
+\DTLifanybibfieldexists{Month,Year}{\DTLaddperiod}{}%
+\DTLifbibfieldexists{Note}{%
+\DTLstartsentencespace
+\DTLbibfield{Note}%
+\DTLcheckbibfieldendsperiod{Note}%
+\DTLaddperiod}{}%
+}%
+% \end{macrocode}
+% The format of an `incollection' entry.
+% \begin{macrocode}
+\renewcommand*{\DTLformatincollection}{%
+\DTLifbibfieldexists{Author}{\DTLformatauthorlist\DTLaddperiod}{}%
+\DTLifbibfieldexists{Title}{%
+\DTLstartsentencespace
+\DTLbibfield{Title}%
+\DTLcheckbibfieldendsperiod{Title}%
+\DTLaddperiod}{}%
+\DTLifbibfieldexists{CrossRef}{%
+% cross ref entry
+\DTLformatincollproccrossref
+\DTLifanybibfieldexists{Chapter,Pages}{\DTLaddcomma}{}%
+\DTLformatchapterpages\DTLaddperiod
+}{% no cross ref entry
+\DTLformatinedbooktitle
+\DTLifbibfieldexists{BookTitle}{%
+\DTLifanybibfieldexists{Volume,Series,Chapter,Pages,Number}{%
+\DTLaddcomma}{\DTLaddperiod}}{}%
+\DTLformatbvolume
+\DTLifbibfieldexists{Volume}{%
+\DTLifanybibfieldexists{Number,Series,Chapter,Pages}{%
+\DTLaddcomma}{\DTLaddperiod}}{}%
+\DTLformatnumberseries
+\DTLifanybibfieldexists{Number,Series}{%
+\DTLifanybibfieldexists{Chapter,Pages}{\DTLaddcomma
+}{\DTLaddperiod}}{}%
+\DTLformatchapterpages
+\DTLifanybibfieldexists{Chapter,Pages}{\DTLaddperiod}{}%
+\DTLifbibfieldexists{Publisher}{%
+\DTLstartsentencespace
+\DTLbibfield{Publisher}%
+\DTLcheckbibfieldendsperiod{Publisher}%
+\DTLifanybibfieldexists{Address,Edition,Month,Year}{%
+\DTLaddcomma}{\DTLaddperiod}}{}%
+\DTLifbibfieldexists{Address}{%
+\DTLstartsentencespace
+\DTLbibfield{Address}%
+\DTLcheckbibfieldendsperiod{Address}%
+\DTLifanybibfieldexists{Edition,Month,Year}{%
+\DTLaddcomma}{\DTLaddperiod}}{}%
+\DTLifbibfieldexists{Edition}{%
+\protected@edef\@dtl@tmp{\DTLformatedition{\DTLbibfield{Edition}}}%
+\ifDTLmidsentence
+ \@dtl@tmp
+\else
+ \DTLstartsentencespace
+ \expandafter\MakeUppercase\@dtl@tmp
+\fi
+\expandafter\DTLcheckendsperiod\expandafter{\@dtl@tmp}%
+\DTLifanybibfieldexists{Month,Year}{\DTLaddcomma
+}{\DTLaddperiod}%
+}{}%
+\DTLformatdate
+\DTLifanybibfieldexists{Month,Year}{\DTLaddperiod}{}%
+}%
+\DTLifbibfieldexists{Note}{%
+\DTLstartsentencespace
+\DTLbibfield{Note}%
+\DTLcheckbibfieldendsperiod{Note}%
+\DTLaddperiod}{}%
+}%
+% \end{macrocode}
+% The format of an `inproceedings' entry.
+% \begin{macrocode}
+\renewcommand*{\DTLformatinproceedings}{%
+\DTLifbibfieldexists{Author}{\DTLformatauthorlist
+\DTLaddperiod}{}%
+\DTLifbibfieldexists{Title}{%
+\DTLstartsentencespace
+\DTLbibfield{Title}%
+\DTLcheckbibfieldendsperiod{Title}%
+\DTLaddperiod}{}%
+\DTLifbibfieldexists{CrossRef}{%
+% cross ref entry
+\DTLformatincollproccrossref
+\DTLifbibfieldexists{Pages}{\DTLaddcomma}{%
+\DTLaddperiod}%
+\DTLformatpages
+\DTLifbibfieldexists{Pages}{\DTLaddperiod}{}%
+}{% no cross ref
+\DTLformatinedbooktitle
+\DTLifbibfieldexists{BookTitle}{%
+\DTLifanybibfieldexists{Volume,Series,Pages,Number,Address,%
+Month,Year}{%
+\DTLaddcomma}{\DTLaddperiod}}{}%
+\DTLformatbvolume
+\DTLifbibfieldexists{Volume}{%
+\DTLifanybibfieldexists{Number,Series,Pages,Address,Month,Year}{%
+\DTLaddcomma}{\DTLaddperiod}}{}%
+\DTLformatnumberseries
+\DTLifanybibfieldexists{Number,Series}{%
+\DTLifanybibfieldexists{Pages,Address,Month,Year}{%
+\DTLaddcomma}{\DTLaddperiod}}{}%
+\DTLformatpages
+\DTLifbibfieldexists{Pages}{%
+\DTLifanybibfieldexists{Address,Month,Year}{%
+\DTLaddcomma}{\DTLaddperiod}}{}%
+\DTLifbibfieldexists{Address}{%
+\DTLstartsentencespace
+\DTLbibfield{Address}%
+\DTLcheckbibfieldendsperiod{Address}%
+\DTLifanybibfieldexists{Month,Year}{\DTLaddcomma}{%
+\DTLaddperiod}%
+\DTLformatdate
+\DTLifanybibfieldexists{Month,Year}{\DTLaddperiod}{}%
+\DTLifbibfieldexists{Organization}{%
+\DTLstartsentencespace
+\DTLbibfield{Organization}%
+\DTLcheckbibfieldendsperiod{Organization}%
+\DTLifbibfieldexists{Publisher}{\DTLaddcomma}{%
+\DTLaddperiod}}{}%
+\DTLifbibfieldexists{Publisher}{%
+\DTLstartsentencespace
+\DTLbibfield{Publisher}%
+\DTLcheckbibfieldendsperiod{Publisher}%
+\DTLaddperiod}{}%
+}{%
+\DTLifanybibfieldexists{Publisher,Organization}{%
+\DTLaddperiod}{}%
+\DTLifbibfieldexists{Organization}{%
+\DTLstartsentencespace
+\DTLbibfield{Organization}%
+\DTLcheckbibfieldendsperiod{Organization}%
+\DTLifanybibfieldexists{Publisher,Month,Year}{%
+\DTLaddcomma}{}}{}%
+\DTLifbibfieldexists{Publisher}{%
+\DTLstartsentencespace
+\DTLbibfield{Publisher}%
+\DTLcheckbibfieldendsperiod{Publisher}%
+\DTLifanybibfieldexists{Month,Year}{\DTLaddcomma}{%
+\DTLaddperiod}}{}%
+\DTLformatdate
+\DTLifanybibfieldexists{Month,Year}{\DTLaddperiod}{}%
+}%
+}%
+\DTLifbibfieldexists{Note}{%
+\DTLstartsentencespace
+\DTLbibfield{Note}%
+\DTLcheckbibfieldendsperiod{Note}%
+\DTLaddperiod}{}%
+}%
+% \end{macrocode}
+% The format of a manual.
+% \begin{macrocode}
+\renewcommand*{\DTLformatmanual}{%
+\DTLifbibfieldexists{Author}{\DTLformatauthorlist
+\DTLaddperiod}{%
+\DTLifbibfieldexists{Organization}{%
+\DTLstartsentencespace
+\DTLbibfield{Organization}%
+\DTLcheckbibfieldendsperiod{Organization}%
+\DTLifbibfieldexists{Address}{\DTLaddcomma \DTLbibfield{Address}%
+\DTLcheckbibfieldendsperiod{Address}%
+}{}%
+\DTLaddperiod}{}%
+}%
+\DTLifbibfieldexists{Title}{%
+\DTLstartsentencespace
+{\em\DTLbibfield{Title}}%
+\DTLcheckbibfieldendsperiod{Title}%
+\DTLifbibfieldexists{Author}{%
+\DTLifanybibfieldexists{Organization,Address}{%
+\DTLaddperiod}{\DTLaddcomma}}{%
+\DTLifanybibfieldexists{Organization,Address,Edition,Month,Year}{%
+\DTLaddcomma}{\DTLaddperiod}}}{}%
+\DTLifbibfieldexists{Author}{%
+\DTLifbibfieldexists{Organization}{%
+\DTLstartsentencespace
+\DTLbibfield{Organization}%
+\DTLcheckbibfieldendsperiod{Organization}%
+\DTLifanybibfieldexists{Address,Edition,Month,Year}{%
+\DTLaddcomma}{\DTLaddperiod}}{}%
+\DTLifbibfieldexists{Address}{%
+\DTLstartsentencespace
+\DTLbibfield{Address}%
+\DTLcheckbibfieldendsperiod{Address}%
+\DTLifanybibfieldexists{Edition,Month,Year}{%
+\DTLaddcomma}{\DTLaddperiod}}{}%
+}{%
+\DTLifbibfieldexists{Organization}{}{%
+\DTLifbibfieldexists{Address}{%
+\DTLstartsentencespace
+\DTLbibfield{Address}%
+\DTLcheckbibfieldendsperiod{Address}%
+\DTLifanybibfieldexists{Edition,Month,Year}{\DTLaddcomma}{%
+\DTLaddperiod}}{}}%
+}%
+\DTLifbibfieldexists{Edition}{%
+\protected@edef\@dtl@tmp{\DTLformatedition{\DTLbibfield{Edition}}}%
+\ifDTLmidsentence
+ \@dtl@tmp
+\else
+ \DTLstartsentencespace
+ \expandafter\MakeUppercase\@dtl@tmp
+\fi
+\expandafter\DTLcheckendsperiod\expandafter{\@dtl@tmp}%
+\DTLifanybibfieldexists{Month,Year}{\DTLaddcomma}{%
+\DTLaddperiod}}{}%
+\DTLformatdate
+\DTLifanybibfieldexists{Month,Year}{\DTLaddperiod}{}%
+\DTLifbibfieldexists{Note}{%
+\DTLstartsentencespace
+\DTLbibfield{Note}%
+\DTLcheckbibfieldendsperiod{Note}%
+\DTLaddperiod}{}%
+}%
+% \end{macrocode}
+% The format of a master's thesis.
+% \begin{macrocode}
+\renewcommand*{\DTLformatmastersthesis}{%
+\DTLifbibfieldexists{Author}{\DTLformatauthorlist\DTLaddperiod}{}%
+\DTLifbibfieldexists{Title}{%
+\DTLstartsentencespace
+\DTLbibfield{Title}%
+\DTLcheckbibfieldendsperiod{Title}%
+\DTLaddperiod}{}%
+\DTLifbibfieldexists{Type}{%
+\DTLstartsentencespace
+\DTLbibfield{Type}%
+\DTLcheckbibfieldendsperiod{Type}%
+\DTLifanybibfieldexists{School,Address,Month,Year}{%
+\DTLaddcomma}{\DTLaddperiod}}{}%
+\DTLifbibfieldexists{School}{%
+\DTLstartsentencespace
+\DTLbibfield{School}%
+\DTLcheckbibfieldendsperiod{School}%
+\DTLifanybibfieldexists{Address,Month,Year}{%
+\DTLaddcomma}{\DTLaddperiod}}{}%
+\DTLifbibfieldexists{Address}{%
+\DTLstartsentencespace
+\DTLbibfield{Address}%
+\DTLcheckbibfieldendsperiod{Address}%
+\DTLifanybibfieldexists{Month,Year}{%
+\DTLaddcomma}{\DTLaddperiod}}{}%
+\DTLformatdate
+\DTLifanybibfieldexists{Month,Year}{\DTLaddperiod}{}%
+\DTLifbibfieldexists{Note}{%
+\DTLstartsentencespace
+\DTLbibfield{Note}%
+\DTLcheckbibfieldendsperiod{Note}%
+\DTLaddperiod}{}%
+}%
+% \end{macrocode}
+% The format of a miscellaneous entry.
+% \begin{macrocode}
+\renewcommand*{\DTLformatmisc}{%
+\DTLifbibfieldexists{Author}{\DTLformatauthorlist\DTLaddperiod}{}%
+\DTLifbibfieldexists{Title}{%
+\DTLstartsentencespace
+\DTLbibfield{Title}%
+\DTLcheckbibfieldendsperiod{Title}%
+\DTLifbibfieldexists{HowPublished}{\DTLaddperiod}{%
+\DTLifanybibfieldexists{Month,Year}{\DTLaddcomma}{%
+\DTLaddperiod}%
+}%
+\DTLmidsentencefalse}{}%
+\DTLifbibfieldexists{HowPublished}{%
+\DTLstartsentencespace
+\DTLbibfield{HowPublished}%
+\DTLcheckbibfieldendsperiod{HowPublished}%
+\DTLifanybibfieldexists{Month,Year}{\DTLaddcomma}{%
+\DTLaddperiod}}{}%
+\DTLformatdate
+\DTLifanybibfieldexists{Month,Year}{\DTLaddperiod}{}%
+\DTLifbibfieldexists{Note}{%
+\DTLstartsentencespace
+\DTLbibfield{Note}%
+\DTLcheckbibfieldendsperiod{Note}%
+\DTLaddperiod}{}%
+}%
+% \end{macrocode}
+% The format of a PhD thesis.
+% \begin{macrocode}
+\renewcommand*{\DTLformatphdthesis}{%
+\DTLifbibfieldexists{Author}{\DTLformatauthorlist\DTLaddperiod}{}%
+\DTLifbibfieldexists{Title}{%
+\DTLstartsentencespace
+{\em\DTLbibfield{Title}}%
+\DTLcheckbibfieldendsperiod{Title}%
+\DTLaddperiod}{}%
+\DTLifbibfieldexists{Type}{%
+\DTLstartsentencespace
+\DTLbibfield{Type}%
+\DTLcheckbibfieldendsperiod{Type}%
+\DTLifanybibfieldexists{School,Address,Month,Year}{%
+\DTLaddcomma}{\DTLaddperiod}}{}%
+\DTLifbibfieldexists{School}{%
+\DTLstartsentencespace
+\DTLbibfield{School}%
+\DTLcheckbibfieldendsperiod{School}%
+\DTLifanybibfieldexists{Address,Month,Year}{%
+\DTLaddcomma}{\DTLaddperiod}}{}%
+\DTLifbibfieldexists{Address}{%
+\DTLstartsentencespace
+\DTLbibfield{Address}%
+\DTLcheckbibfieldendsperiod{Address}%
+\DTLifanybibfieldexists{Month,Year}{%
+\DTLaddcomma}{\DTLaddperiod}}{}%
+\DTLformatdate
+\DTLifanybibfieldexists{Month,Year}{\DTLaddperiod}{}%
+\DTLifbibfieldexists{Note}{%
+\DTLstartsentencespace
+\DTLbibfield{Note}%
+\DTLcheckbibfieldendsperiod{Note}%
+\DTLaddperiod}{}%
+}%
+% \end{macrocode}
+% The format of a proceedings.
+% \begin{macrocode}
+\renewcommand*{\DTLformatproceedings}{%
+\DTLifbibfieldexists{Editor}{%
+\DTLformateditorlist\DTLaddperiod}{%
+\DTLifbibfieldexists{Organization}{%
+\DTLstartsentencespace
+\DTLbibfield{Organization}%
+\DTLcheckbibfieldendsperiod{Organization}%
+\DTLaddperiod}{}}%
+\DTLifbibfieldexists{Title}{%
+\DTLstartsentencespace
+{\em\DTLbibfield{Title}}%
+\DTLcheckbibfieldendsperiod{Title}%
+\DTLifanybibfieldexists{Volume,Number,Address,Editor,Publisher,%
+Month,Year}{\DTLaddcomma}{\DTLaddperiod}%
+}{}%
+\DTLformatbvolume
+\DTLifbibfieldexists{Volume}{%
+\DTLifanybibfieldexists{Number,Address,Editor,Publisher,%
+Month,Year}{\DTLaddcomma}{\DTLaddperiod}}{}%
+\DTLformatnumberseries
+\DTLifbibfieldexists{Number}{%
+\DTLifanybibfieldexists{Address,Editor,Publisher,%
+Month,Year}{\DTLaddcomma}{\DTLaddperiod}}{}%
+\DTLifbibfieldexists{Address}{%
+\DTLstartsentencespace
+\DTLbibfield{Address}%
+\DTLcheckbibfieldendsperiod{Address}%
+\DTLifanybibfieldexists{Month,Year}{\DTLaddcomma}{\DTLaddperiod}%
+\DTLformatdate
+\DTLifanybibfieldexists{Month,Year}{\DTLaddperiod}{}%
+\DTLifbibfieldexists{Editor}{\DTLifbibfieldexists{Organization}{%
+\DTLstartsentencespace
+\DTLbibfield{Organization}%
+\DTLcheckbibfieldendsperiod{Organization}%
+\DTLifbibfieldexists{Publisher}{%
+\DTLaddcomma}{\DTLaddperiod}}{}}{}%
+\DTLifbibfieldexists{Publisher}{%
+\DTLstartsentencespace
+\DTLbibfield{Publisher}%
+\DTLcheckbibfieldendsperiod{Publisher}%
+\DTLaddperiod
+}{}%
+}{% no address
+\DTLifbibfieldexists{Editor}{%
+\DTLifbibfieldexists{Organization}{%
+\DTLstartsentencespace
+\DTLbibfield{Organization}%
+\DTLcheckbibfieldendsperiod{Organization}%
+\DTLifanybibfieldexists{Publisher,Month,Year}{%
+\DTLaddcomma}{\DTLaddperiod}}{}%
+}{}%
+\DTLifbibfieldexists{Publisher}{%
+\DTLstartsentencespace
+\DTLbibfield{Publisher}%
+\DTLcheckbibfieldendsperiod{Publisher}%
+\DTLifanybibfieldexists{Month,Year}{\DTLaddcomma}{\DTLaddperiod}}{}%
+\DTLformatdate
+\DTLifanybibfieldexists{Month,Year}{\DTLaddperiod}{}%
+}%
+\DTLifbibfieldexists{Note}{%
+\DTLstartsentencespace
+\DTLbibfield{Note}%
+\DTLcheckbibfieldendsperiod{Note}%
+\DTLaddperiod}{}%
+}%
+% \end{macrocode}
+% The format of a technical report.
+% \begin{macrocode}
+\renewcommand*{\DTLformattechreport}{%
+\DTLifbibfieldexists{Author}{\DTLformatauthorlist\DTLaddperiod}{}%
+\DTLifbibfieldexists{Title}{%
+\DTLstartsentencespace
+\DTLbibfield{Title}%
+\DTLcheckbibfieldendsperiod{Title}%
+\DTLaddperiod}{}%
+\DTLifbibfieldexists{Type}{%
+\DTLstartsentencespace
+\DTLbibfield{Type}%
+\DTLcheckbibfieldendsperiod{Type}%
+\DTLifbibfieldexists{Number}{~}{}}{}%
+\DTLifbibfieldexists{Number}{%
+\DTLstartsentencespace
+\DTLbibfield{Number}%
+\DTLcheckbibfieldendsperiod{Number}%
+}{}%
+\DTLifanybibfieldexists{Type,Number}{%
+\DTLifanybibfieldexists{Institution,Address,Month,Year}{\DTLaddcomma
+}{\DTLaddperiod}}{}%
+\DTLifbibfieldexists{Institution}{%
+\DTLstartsentencespace
+\DTLbibfield{Institution}%
+\DTLcheckbibfieldendsperiod{Institution}%
+\DTLifanybibfieldexists{Address,Month,Year}{\DTLaddcomma
+}{\DTLaddperiod}}{}%
+\DTLifbibfieldexists{Address}{%
+\DTLstartsentencespace
+\DTLbibfield{Address}%
+\DTLcheckbibfieldendsperiod{Address}%
+\DTLifanybibfieldexists{Month,Year}{\DTLaddcomma
+}{\DTLaddperiod}}{}%
+\DTLformatdate
+\DTLifanybibfieldexists{Month,Year}{\DTLaddperiod}{}%
+\DTLifbibfieldexists{Note}{%
+\DTLstartsentencespace
+\DTLbibfield{Note}%
+\DTLcheckbibfieldendsperiod{Note}%
+\DTLaddperiod}{}%
+}%
+% \end{macrocode}
+% The format of an unpublished work.
+% \begin{macrocode}
+\renewcommand*{\DTLformatunpublished}{%
+\DTLifbibfieldexists{Author}{\DTLformatauthorlist\DTLaddperiod}{}%
+\DTLifbibfieldexists{Title}{%
+\DTLstartsentencespace
+\DTLbibfield{Title}%
+\DTLcheckbibfieldendsperiod{Title}%
+\DTLaddperiod}{}%
+\DTLifbibfieldexists{Note}{%
+\DTLstartsentencespace
+\DTLbibfield{Note}%
+\DTLcheckbibfieldendsperiod{Note}%
+\DTLifanybibfieldexists{Month,Year}{\DTLaddcomma}{\DTLaddperiod}}{}%
+\DTLformatdate
+\DTLifanybibfieldexists{Month,Year}{\DTLaddperiod}{}%
+}%
+% \end{macrocode}
+% End of `plain' style.
+% \begin{macrocode}
+}
+% \end{macrocode}
+%\end{macro}
+%
+%\begin{macro}{\dtlbst@abbrv}
+% Define `abbrv' style. This is similar to `plain' except that
+% some of the values are abbreviated
+% \begin{macrocode}
+\newcommand{\dtlbst@abbrv}{%
+% \end{macrocode}
+% Base this style on `plain':
+% \begin{macrocode}
+\dtlbst@plain
+% \end{macrocode}
+% Sets the author name format.
+% \begin{macrocode}
+\renewcommand*{\DTLformatauthor}[4]{%
+\DTLformatabbrvforenames{##4}
+\DTLformatvon{##1}%
+\DTLformatsurname{##2}%
+\DTLformatjr{##3}}
+% \end{macrocode}
+% Sets the editor name format.
+% \begin{macrocode}
+\renewcommand*{\DTLformateditor}[4]{%
+\DTLformatabbrvforenames{##4}
+\DTLformatvon{##1}%
+\DTLformatsurname{##2}%
+\DTLformatjr{##3}}
+% \end{macrocode}
+% Sets the monthname format.
+% \begin{macrocode}
+\let\DTLmonthname\dtl@abbrvmonthname
+% \end{macrocode}
+% Sets other predefined names:
+% \begin{macrocode}
+\renewcommand*{\DTLacmcs}{ACM Comput.\ Surv.}
+\renewcommand*{\DTLacta}{Acta Inf.}
+\renewcommand*{\DTLcacm}{Commun.\ ACM}
+\renewcommand*{\DTLibmjrd}{IBM J.\ Res.\ Dev.}
+\renewcommand*{\DTLibmsj}{IBM Syst.~J.}
+\renewcommand*{\DTLieeese}{IEEE Trans. Softw.\ Eng.}
+\renewcommand*{\DTLieeetc}{IEEE Trans.\ Comput.}
+\renewcommand*{\DTLieeetcad}{IEEE Trans.\ Comput.-Aided Design
+Integrated Circuits}
+\renewcommand*{\DTLipl}{Inf.\ Process.\ Lett.}
+\renewcommand*{\DTLjacm}{J.~ACM}
+\renewcommand*{\DTLjcss}{J.~Comput.\ Syst.\ Sci.}
+\renewcommand*{\DTLscp}{Sci.\ Comput.\ Programming}
+\renewcommand*{\DTLsicomp}{SIAM J.~Comput.}
+\renewcommand*{\DTLtocs}{ACM Trans.\ Comput.\ Syst.}
+\renewcommand*{\DTLtods}{ACM Trans.\ Database Syst.}
+\renewcommand*{\DTLtog}{ACM Trans.\ Gr.}
+\renewcommand*{\DTLtoms}{ACM Trans.\ Math. Softw.}
+\renewcommand*{\DTLtoois}{ACM Trans. Office Inf.\ Syst.}
+\renewcommand*{\DTLtoplas}{ACM Trans.\ Prog. Lang.\ Syst.}
+\renewcommand*{\DTLtcs}{Theoretical Comput.\ Sci.}
+% \end{macrocode}
+% End of `abbrv' style.
+% \begin{macrocode}
+}
+% \end{macrocode}
+%\end{macro}
+%
+%\begin{macro}{\dtlbst@alpha}
+% Define `alpha' style. This is similar to `plain' except that
+% the labels are strings rather than numerical.
+% \begin{macrocode}
+\newcommand{\dtlbst@alpha}{%
+% \end{macrocode}
+% Base this style on `plain':
+% \begin{macrocode}
+\dtlbst@plain
+% \end{macrocode}
+% Set how to format the entire bibliography:
+% \begin{macrocode}
+\renewenvironment{DTLthebibliography}[2][\boolean{true}]{%
+\dtl@createalphabiblabels{##1}{##2}%
+\begin{thebibliography}{\@dtl@widestlabel}%
+}{\end{thebibliography}}%
+% \end{macrocode}
+% Set how to start the bibliography entry:
+% \begin{macrocode}
+\renewcommand*{\DTLbibitem}{%
+\expandafter\bibitem\expandafter
+ [\csname dtl@biblabel@\DBIBcitekey\endcsname]{\DBIBcitekey}}%
+% \end{macrocode}
+% \begin{macrocode}
+% \end{macrocode}
+% End of `alpha' style.
+% \begin{macrocode}
+}
+% \end{macrocode}
+%\end{macro}
+%
+%\begin{macro}{dtl@createalphabiblabels}
+%\begin{definition}
+%\cs{dtl@createalphabiblabels}\marg{condition}\marg{db name}
+%\end{definition}
+% Constructs the alpha style bib labels for the given database.
+% (Labels are stored in the control sequence
+%\cs{dtl@biblabel@}\meta{citekey}.) This also sets
+% \cs{@dtl@widestlabel} to the widest label.
+% \begin{macrocode}
+\newcommand*{\dtl@createalphabiblabels}[2]{%
+\dtl@message{Creating bib labels}%
+\begingroup
+\gdef\@dtl@widestlabel{}%
+\dtl@widest=0pt\relax
+\DTLforeachbibentry[#1]{#2}{%
+\dtl@message{\DBIBcitekey}%
+\DTLifbibfieldexists{Author}{%
+ \dtl@listgetalphalabel{\@dtl@thislabel}{\@dtl@key@Author}%
+}{%
+\DTLifbibfieldexists{Editor}{%
+ \dtl@listgetalphalabel{\@dtl@thislabel}{\@dtl@key@Editor}%
+ }{%
+ \DTLifbibfieldexists{Key}{%
+ \expandafter\dtl@get@firstthree\expandafter
+ {\@dtl@key@Key}{\@dtl@thislabel}%
+ }{%
+ \DTLifbibfieldexists{Organization}{%
+ \expandafter\dtl@get@firstthree\expandafter
+ {\@dtl@key@Organization}{\@dtl@thislabel}%
+ }{%
+ \expandafter\dtl@get@firstthree\expandafter
+ {\DBIBentrytype}{\@dtl@thislabel}%
+ }%
+ }}}%
+\DTLifbibfieldexists{Year}{}{\DTLifbibfieldexists{CrossRef}{%
+\DTLgetvalueforkey{\@dtl@key@Year}{Year}{#2}{CiteKey}{%
+\@dtl@key@CrossRef}}{}}%
+\DTLifbibfieldexists{Year}{%
+\expandafter\dtl@get@yearsuffix\expandafter{\@dtl@key@Year}%
+\expandafter\toks@\expandafter{\@dtl@thislabel}%
+\expandafter\@dtl@toks\expandafter{\@dtl@year}%
+\edef\@dtl@thislabel{\the\toks@\the\@dtl@toks}%
+}{}%
+\let\@dtl@s@thislabel=\@dtl@thislabel
+\@onelevel@sanitize\@dtl@s@thislabel
+\@ifundefined{c@biblabel@\@dtl@s@thislabel}{%
+\newcounter{biblabel@\@dtl@s@thislabel}%
+\setcounter{biblabel@\@dtl@s@thislabel}{1}%
+\expandafter\edef\csname @dtl@bibfirst@\@dtl@s@thislabel\endcsname{%
+\DBIBcitekey}%
+\expandafter\global
+\expandafter\let\csname dtl@biblabel@\DBIBcitekey\endcsname=
+ \@dtl@thislabel
+}{%
+\expandafter\ifnum\csname c@biblabel@\@dtl@s@thislabel\endcsname=1\relax
+ \expandafter\let\expandafter\@dtl@tmp
+ \csname @dtl@bibfirst@\@dtl@s@thislabel\endcsname
+ \expandafter\protected@xdef\csname dtl@biblabel@\@dtl@tmp\endcsname{%
+ \@dtl@thislabel a}%
+\fi
+\stepcounter{biblabel@\@dtl@s@thislabel}%
+\expandafter\protected@xdef\csname dtl@biblabel@\DBIBcitekey\endcsname{%
+ \@dtl@thislabel\alph{biblabel@\@dtl@s@thislabel}}%
+}%
+\settowidth{\dtl@tmplength}{%
+ \csname dtl@biblabel@\DBIBcitekey\endcsname}%
+\ifdim\dtl@tmplength>\dtl@widest
+ \dtl@widest=\dtl@tmplength
+ \expandafter\global\expandafter\let\expandafter\@dtl@widestlabel
+ \expandafter=\csname dtl@biblabel@\DBIBcitekey\endcsname
+\fi
+}%
+\endgroup
+}
+% \end{macrocode}
+%\end{macro}
+%
+%\begin{macro}{\dtl@listgetalphalabel}
+% Determine the alpha style label from a list of authors/editors
+% (the first argument must be a control sequence (in which the
+% label is stored), the second argument must be the list of names.)
+% \begin{macrocode}
+\newcommand*{\dtl@listgetalphalabel}[2]{%
+\@dtl@authorcount=0\relax
+\@for\@dtl@author:=#2\do{%
+\advance\@dtl@authorcount by 1\relax}%
+\ifnum\@dtl@authorcount=1\relax
+ \expandafter\dtl@getsinglealphalabel#2{#1}\relax
+\else
+ {%
+ \xdef#1{}%
+ \@dtl@tmpcount=0\relax
+ \def\DTLafterinitials{}\def\DTLbetweeninitials{}%
+ \def\DTLafterinitialbeforehyphen{}\def\DTLinitialhyphen{}%
+ \@for\@dtl@author:=#2\do{%
+ \expandafter\dtl@getauthorinitial\@dtl@author
+ \expandafter\toks@\expandafter{\@dtl@tmp}%
+ \expandafter\@dtl@toks\expandafter{#1}%
+ \xdef#1{\the\@dtl@toks\the\toks@}%
+ \advance\@dtl@tmpcount by 1\relax
+ \ifnum\@dtl@tmpcount>2\relax\@endfortrue\fi
+ }}%
+\fi
+}
+% \end{macrocode}
+%\end{macro}
+% Get author's initial (stores in \cs{@dtl@tmp}):
+% \begin{macrocode}
+\newcommand*{\dtl@getauthorinitial}[4]{%
+\def\@dtl@vonpart{#1}%
+\ifx\@dtl@vonpart\@empty
+ \DTLstoreinitials{#2}{\@dtl@tmp}%
+\else
+ \DTLstoreinitials{#1 #2}{\@dtl@tmp}%
+\fi}
+% \end{macrocode}
+% Get label for single author (last argument is control sequence
+% in which to store the label):
+% \begin{macrocode}
+\newcommand*{\dtl@getsinglealphalabel}[5]{%
+\def\@dtl@vonpart{#1}%
+\ifx\@dtl@vonpart\@empty
+ \DTLifSubString{#2}{-}{%
+ {\def\DTLafterinitials{}\def\DTLbetweeninitials{}%
+ \def\DTLafterinitialbeforehyphen{}%
+ \def\DTLinitialhyphen{}%
+ \DTLstoreinitials{#2}{\@dtl@tmp}\global\let#5=\@dtl@tmp}%
+ }{%
+ \dtl@getfirstthree{#5}#2{}{}{}{}\@nil
+ }
+\else
+ {\def\DTLafterinitials{}\def\DTLbetweeninitials{}%
+ \def\DTLafterinitialbeforehyphen{}%
+ \def\DTLinitialhyphen{}%
+ \DTLstoreinitials{#1 #2}{\@dtl@tmp}\global\let#5=\@dtl@tmp}%
+\fi
+}
+% \end{macrocode}
+%Get first three letters from the given string:
+% \begin{macrocode}
+\def\dtl@getfirstthree#1#2#3#4#5\@nil{%
+ \def#1{#2#3#4}%
+}
+\newcommand*{\dtl@get@firstthree}[2]{%
+\dtl@getfirstthree#2#1{}{}{}{}{}\@nil}
+% \end{macrocode}
+%Get year suffix:
+% \begin{macrocode}
+\newcommand*{\dtl@get@yearsuffix}[1]{%
+\dtl@getyearsuffix#1\@nil\relax\relax}
+
+\def\dtl@getyearsuffix#1#2#3{%
+\def\@dtl@argi{#1}\def\@dtl@argii{#2}%
+\def\@dtl@argiii{#3}%
+\ifx\@dtl@argi\@nnil
+ \def\@dtl@year{}%
+ \let\@dtl@donext=\relax
+\else
+ \ifx\@dtl@argii\@nnil
+ \dtl@ifsingle{#1}{%
+ \def\@dtl@year{#1}%
+ \let\@dtl@donext=\relax
+ }{%
+ \def\@dtl@donext{\dtl@getyearsuffix#1#2#3}%
+ }%
+ \else
+ \ifx\@dtl@argiii\@nnil
+ \dtl@ifsingle{#1}{%
+ \dtl@ifsingle{#2}{%
+ \def\@dtl@year{#1#2}%
+ \let\@dtl@donext=\relax
+ }{%
+ \def\@dtl@donext{\dtl@getyearsuffix#2#3}%
+ }%
+ }{%
+ \def\@dtl@donext{\dtl@getyearsuffix#2#3}%
+ }%
+ \else
+ \def\@dtl@donext{\dtl@getyearsuffix{#2}{#3}}%
+ \fi
+ \fi
+\fi
+\@dtl@donext
+}
+% \end{macrocode}
+%
+%\begin{macro}{\DTLbibliographystyle}
+%\begin{definition}
+%\cs{DTLbibliographystyle}\marg{style}
+%\end{definition}
+% Sets the bibliography style.
+% \begin{macrocode}
+\newcommand*{\DTLbibliographystyle}[1]{%
+\@ifundefined{dtlbst@#1}{\PackageError{databib}{Unknown
+bibliography style `#1'}{}}{\csname dtlbst@#1\endcsname}}
+% \end{macrocode}
+%\end{macro}
+%Set the default bibliography style:
+% \begin{macrocode}
+\DTLbibliographystyle{\dtlbib@style}
+% \end{macrocode}
+%\iffalse
+% \begin{macrocode}
+%</databib.sty>
+% \end{macrocode}
+%\fi
+%\iffalse
+% \begin{macrocode}
+%<*databib.bst>
+% \end{macrocode}
+%\fi
+%\iffalse
+% \begin{macrocode}
+% \begin{macrocode}
+% Bibliography style `databib'
+% This style is provided for use with the databib package.
+
+ENTRY
+ { address
+ author
+ booktitle
+ chapter
+ edition
+ editor
+ howpublished
+ institution
+ journal
+ key
+ month
+ note
+ number
+ organization
+ pages
+ publisher
+ school
+ series
+ title
+ type
+ volume
+ year
+ isbn
+ doi
+ pubmed
+ url
+ abstract
+ }
+ {}
+ { label }
+
+INTEGERS { output.state before.all mid.sentence after.sentence after.block }
+
+FUNCTION {init.state.consts}
+{ #0 'before.all :=
+ #1 'mid.sentence :=
+ #2 'after.sentence :=
+ #3 'after.block :=
+}
+
+STRINGS { s t }
+
+FUNCTION {output.nonnull}
+{ 's :=
+% output.state mid.sentence =
+% { "%" * write$
+% newline$
+% }
+% { output.state after.block =
+% { add.period$ write$
+% newline$
+% }
+ %{
+ output.state before.all =
+ {
+ "%" * write$
+ newline$
+ }
+ { newline$
+ %add.period$ " " * write$
+ }
+ if$
+% }
+ % if$
+ % mid.sentence 'output.state :=
+ % }
+ %if$
+ s
+}
+
+FUNCTION {output}
+{ duplicate$ empty$
+ 'pop$
+ 'output.nonnull
+ if$
+}
+
+FUNCTION {output.check}
+{ 't :=
+ duplicate$ empty$
+ { pop$ "empty " t * " in " * cite$ * warning$ }
+ {
+ output.nonnull
+ }
+ if$
+}
+
+FUNCTION {output.bibitem}
+{ "\DTLnewbibrow" write$
+ newline$
+ "\DTLnewbibitem {CiteKey}{" write$
+ cite$ write$
+ "}%" write$
+ newline$
+ ""
+ before.all 'output.state :=
+}
+
+FUNCTION {fin.entry}
+{ "%" *
+ write$
+ newline$
+}
+
+FUNCTION {new.block}
+{ output.state before.all =
+ 'skip$
+ { after.block 'output.state := }
+ if$
+}
+
+FUNCTION {new.sentence}
+{ output.state after.block =
+ 'skip$
+ { output.state before.all =
+ 'skip$
+ { after.sentence 'output.state := }
+ if$
+ }
+ if$
+}
+
+FUNCTION {not}
+{ { #0 }
+ { #1 }
+ if$
+}
+
+FUNCTION {and}
+{ 'skip$
+ { pop$ #0 }
+ if$
+}
+
+FUNCTION {or}
+{ { pop$ #1 }
+ 'skip$
+ if$
+}
+
+FUNCTION {new.block.checka}
+{ empty$
+ 'skip$
+ 'new.block
+ if$
+}
+
+FUNCTION {new.block.checkb}
+{ empty$
+ swap$ empty$
+ and
+ 'skip$
+ 'new.block
+ if$
+}
+
+FUNCTION {new.sentence.checka}
+{ empty$
+ 'skip$
+ 'new.sentence
+ if$
+}
+
+FUNCTION {new.sentence.checkb}
+{ empty$
+ swap$ empty$
+ and
+ 'skip$
+ 'new.sentence
+ if$
+}
+
+FUNCTION {field.or.null}
+{ duplicate$ empty$
+ { pop$ "" }
+ 'skip$
+ if$
+}
+
+FUNCTION {emphasize}
+{ duplicate$ empty$
+ { pop$ "" }
+ { "{\em " swap$ * "}" * }
+ if$
+}
+
+FUNCTION {group}
+{ duplicate$ empty$
+ { pop$ "" }
+ { "{" swap$ * "}" * }
+ if$
+}
+
+INTEGERS { nameptr namesleft numnames }
+
+FUNCTION {format.names}
+{
+ 's :=
+ #1 'nameptr :=
+ s num.names$ 'numnames :=
+ numnames 'namesleft :=
+ { namesleft #0 > }
+ {
+ %s nameptr "{vv,}{ll,}{jj,}{ff}" format.name$ 't :=
+ "{" *
+ s nameptr "{vv}" format.name$ 't :=
+ t * "}" *
+ "{" *
+ s nameptr "{ll}" format.name$ 't :=
+ t * "}{" *
+ s nameptr "{jj}" format.name$ 't :=
+ t * "}" *
+ "{" *
+ s nameptr "{ff}" format.name$ 't :=
+ t * "}" *
+ s nameptr "" format.name$ 't :=
+ namesleft #1 >
+ { "," * }
+ { }
+ if$
+ nameptr #1 >
+ {
+ t *
+ }
+ 't
+ if$
+ nameptr #1 + 'nameptr :=
+ namesleft #1 - 'namesleft :=
+ }
+ while$
+ "}" *
+}
+
+FUNCTION {format.authors}
+{
+ author empty$
+ { "" }
+ { author
+ "\DTLnewbibitem {Author}{" write$
+ format.names }
+ if$
+}
+
+FUNCTION {format.editors}
+{ editor empty$
+ { "" }
+ { editor
+ "\DTLnewbibitem {Editor}{" write$
+ format.names
+ }
+ if$
+}
+
+FUNCTION {format.title}
+{ title empty$
+ { "" }
+ {
+ "\DTLnewbibitem {Title}"
+ title "t" change.case$ group *
+ }
+ if$
+}
+
+FUNCTION {format.howpublished}
+{ howpublished empty$
+ { "" }
+ {
+ howpublished
+ "\DTLnewbibitem {HowPublished}" swap$ group *
+ }
+ if$
+}
+
+FUNCTION {format.organization}
+{ organization empty$
+ { "" }
+ {
+ organization
+ "\DTLnewbibitem {Organization}" swap$ group *
+ }
+ if$
+}
+
+FUNCTION {format.institution}
+{ institution empty$
+ { "" }
+ {
+ institution
+ "\DTLnewbibitem {Institution}" swap$ group *
+ }
+ if$
+}
+
+FUNCTION {format.key}
+{ key empty$
+ { "" }
+ {
+ key
+ "\DTLnewbibitem {Key}" swap$ group *
+ }
+ if$
+}
+
+FUNCTION {format.note}
+{ note empty$
+ { "" }
+ {
+ note
+ "\DTLnewbibitem {Note}" swap$ group *
+ }
+ if$
+}
+
+FUNCTION {format.isbn}
+{ isbn empty$
+ { "" }
+ {
+ isbn
+ "\DTLnewbibitem {ISBN}" swap$ group *
+ }
+ if$
+}
+
+FUNCTION {format.doi}
+{ doi empty$
+ { "" }
+ {
+ doi
+ "\DTLnewbibitem {DOI}" swap$ group *
+ }
+ if$
+}
+
+FUNCTION {format.pubmed}
+{ pubmed empty$
+ { "" }
+ {
+ pubmed
+ "\DTLnewbibitem {PubMed}" swap$ group *
+ }
+ if$
+}
+
+FUNCTION {format.abstract}
+{ abstract empty$
+ { "" }
+ {
+ abstract
+ "\DTLnewbibitem {Abstract}" swap$ group *
+ }
+ if$
+}
+
+FUNCTION {format.url}
+{ url empty$
+ { "" }
+ {
+ url
+ "\DTLnewbibitem {Url}" swap$ group *
+ }
+ if$
+}
+
+FUNCTION {format.address}
+{ address empty$
+ { "" }
+ {
+ address
+ "\DTLnewbibitem {Address}" swap$ group *
+ }
+ if$
+}
+
+FUNCTION {format.school}
+{ school empty$
+ { "" }
+ {
+ school
+ "\DTLnewbibitem {School}" swap$ group *
+ }
+ if$
+}
+
+FUNCTION {format.publisher}
+{ publisher empty$
+ { "" }
+ {
+ publisher
+ "\DTLnewbibitem {Publisher}" swap$ group *
+ }
+ if$
+}
+
+FUNCTION {n.dashify}
+{ 't :=
+ ""
+ { t empty$ not }
+ { t #1 #1 substring$ "-" =
+ { t #1 #2 substring$ "--" = not
+ { "--" *
+ t #2 global.max$ substring$ 't :=
+ }
+ { { t #1 #1 substring$ "-" = }
+ { "-" *
+ t #2 global.max$ substring$ 't :=
+ }
+ while$
+ }
+ if$
+ }
+ { t #1 #1 substring$ *
+ t #2 global.max$ substring$ 't :=
+ }
+ if$
+ }
+ while$
+}
+
+FUNCTION {format.date}
+{ year empty$
+ { month empty$
+ { "" }
+ { "there's a month but no year in " cite$ * warning$
+ "\DTLnewbibitem {Month}" *
+ month group
+ }
+ if$
+ }
+ { month empty$
+ { }
+ { "\DTLnewbibitem {Month}{" * month * "}" * }
+ if$
+ "\DTLnewbibitem {Year}{" * year * "}"
+ }
+ if$
+}
+
+FUNCTION {format.btitle}
+{ title
+ "\DTLnewbibitem {Title}{" swap$ *
+ "}" *
+}
+
+FUNCTION {tie.or.space.connect}
+{ duplicate$ text.length$ #3 <
+ { "~" }
+ { " " }
+ if$
+ swap$ * *
+}
+
+FUNCTION {either.or.check}
+{ empty$
+ 'pop$
+ { "can't use both " swap$ * " fields in " * cite$ * warning$ }
+ if$
+}
+
+FUNCTION {format.bvolume}
+{ volume empty$
+ { "" }
+ {
+ "\DTLnewbibitem {Volume}{" volume * "}" *
+ series empty$
+ 'skip$
+ {
+ "\DTLnewbibitem {Series}" * series group *
+ }
+ if$
+ "volume and number" number either.or.check
+ }
+ if$
+}
+
+FUNCTION {format.number.series}
+{ volume empty$
+ { number empty$
+ {
+ %series field.or.null group
+ series empty$
+ { "" }
+ { "\DTLnewbibitem {Series}" * series group }
+ if$
+ }
+ {
+ "\DTLnewbibitem {Number}" number group *
+ series empty$
+ { "there's a number but no series in " cite$ * warning$ }
+ { "\DTLnewbibitem {Series}{" * series * "}" * }
+ if$
+ }
+ if$
+ }
+ { "" }
+ if$
+}
+
+FUNCTION {format.edition}
+{ edition empty$
+ { "" }
+ {
+ "\DTLnewbibitem {Edition}"
+ edition "l" change.case$ group *
+ }
+ if$
+}
+
+INTEGERS { multiresult }
+
+FUNCTION {multi.page.check}
+{ 't :=
+ #0 'multiresult :=
+ { multiresult not
+ t empty$ not
+ and
+ }
+ { t #1 #1 substring$
+ duplicate$ "-" =
+ swap$ duplicate$ "," =
+ swap$ "+" =
+ or or
+ { #1 'multiresult := }
+ { t #2 global.max$ substring$ 't := }
+ if$
+ }
+ while$
+ multiresult
+}
+
+FUNCTION {format.pages}
+{ pages empty$
+ { "" }
+ { pages multi.page.check
+ { "\DTLnewbibitem {Pages}" pages n.dashify
+ group * }
+ { "\DTLnewbibitem {Pages}" pages
+ group *}
+ if$
+ }
+ if$
+}
+
+FUNCTION {format.vol.num.pages}
+{
+ volume empty$
+ { "" }
+ {
+ "\DTLnewbibitem {Volume}{" volume * "}" *
+ }
+ if$
+ number empty$
+ 'skip$
+ { "\DTLnewbibitem {Number}{" number * "}\relax " * *
+ volume empty$
+ { "there's a number but no volume in " cite$ * warning$ }
+ 'skip$
+ if$
+ }
+ if$
+ pages empty$
+ 'skip$
+ { duplicate$ empty$
+ { pop$ format.pages }
+ { "\DTLnewbibitem {Pages}" * pages n.dashify group * }
+ if$
+ }
+ if$
+}
+
+FUNCTION {format.chapter.pages}
+{ chapter empty$
+ 'format.pages
+ { type empty$
+ { "\DTLnewbibitem {Type}{chapter}" }
+ { "\DTLnewbibitem {Type}" type "l" change.case$ group *}
+ if$
+ "\DTLnewbibitem {Chapter}{" * chapter * "}" *
+ pages empty$
+ 'skip$
+ { format.pages * }
+ if$
+ }
+ if$
+}
+
+FUNCTION {format.in.ed.booktitle}
+{ booktitle empty$
+ { "" }
+ {
+ "\DTLnewbibitem {BookTitle}" booktitle group *
+ editor empty$
+ {}
+ {
+ "\DTLnewbibitem {Editor}{" *
+ editor format.names *
+ }
+ if$
+ }
+ if$
+}
+
+FUNCTION {empty.misc.check}
+{ author empty$ title empty$ howpublished empty$
+ month empty$ year empty$ note empty$
+ and and and and and
+ { "all relevant fields are empty in " cite$ * warning$ }
+ 'skip$
+ if$
+}
+
+FUNCTION {format.thesis.type}
+{ type empty$
+ 'skip$
+ { pop$
+ type "t" change.case$
+ "\DTLnewbibitem {Type}" swap$ group *
+ }
+ if$
+}
+
+FUNCTION {format.tr.number}
+{
+ type empty$
+ { "\techreportname " }
+ 'type
+ if$
+ number empty$
+ { "t" change.case$ "\DTLnewbibitem {Type}" swap$ group *}
+ { "\DTLnewbibitem {Type}" swap$ group *
+ "\DTLnewbibitem {Number}" *
+ number group * }
+ if$
+}
+
+FUNCTION {format.article.crossref}
+{ key empty$
+ { journal empty$
+ { "need key or journal for " cite$ * " to crossref " * crossref *
+ warning$
+ ""
+ }
+ {
+ "\DTLnewbibitem {Journal}" journal group *
+ }
+ if$
+ }
+ {
+ ""
+ }
+ if$
+ "\DTLnewbibitem {CrossRef}{" * crossref * "}" *
+}
+
+FUNCTION {format.crossref.editor}
+{ format.editors
+% editor #1 "{vv~}{ll}" format.name$
+% editor num.names$ duplicate$
+% #2 >
+% { pop$ " et~al." * }
+% { #2 <
+% 'skip$
+% { editor #2 "{ff }{vv }{ll}{ jj}" format.name$ "others" =
+% { " et~al." * }
+% { " and " * editor #2 "{vv~}{ll}" format.name$ * }
+% if$
+% }
+% if$
+% }
+% if$
+}
+
+FUNCTION {format.book.crossref}
+{ volume empty$
+ { "empty volume in " cite$ * "'s crossref of " * crossref * warning$
+ }
+ {
+ "\DTLnewbibitem {Volume}"
+ volume group *
+ }
+ if$
+ editor empty$
+ editor field.or.null author field.or.null =
+ or
+ { key empty$
+ { series empty$
+ { "need editor, key, or series for " cite$ * " to crossref " *
+ crossref * warning$
+ "" *
+ }
+ {
+ "\DTLnewbibitem {Series}{" * series *
+ "}" *
+ }
+ if$
+ }
+ { ""
+ }
+ if$
+ }
+ {
+ format.crossref.editor *
+ }
+ if$
+ "\DTLnewbibitem {CrossRef}{" * crossref * "}" *
+}
+
+FUNCTION {format.incoll.inproc.crossref}
+{ editor empty$
+ editor field.or.null author field.or.null =
+ or
+ { key empty$
+ { booktitle empty$
+ { "need editor, key, or booktitle for " cite$ * " to crossref " *
+ crossref * warning$
+ ""
+ }
+ { "\DTLnewbibitem {BookTitle}{" booktitle * "}" * }
+ if$
+ }
+ { "" }
+ if$
+ }
+ {
+ "\DTLnewbibitem {Editor}{" *
+ editor format.names
+ }
+ if$
+ "\DTLnewbibitem {CrossRef}{" * crossref * "}" *
+}
+
+FUNCTION {article}
+{ output.bibitem
+ "\DTLnewbibitem {EntryType}{article}%" write$
+ newline$
+ format.authors "author"
+ output.check
+ format.title "title" output.check
+ new.block
+ crossref missing$
+ {
+ "\DTLnewbibitem {Journal}" *
+ journal group "journal" output.check
+ format.vol.num.pages output
+ format.date "year" output.check
+ }
+ { format.article.crossref output.nonnull
+ format.pages output
+ }
+ if$
+ new.block
+ format.key output
+ format.note output
+ format.isbn output
+ format.doi output
+ format.pubmed output
+ format.url output
+ format.abstract output
+ fin.entry
+}
+
+FUNCTION {book}
+{ output.bibitem
+ "\DTLnewbibitem {EntryType}{book}%" write$
+ newline$
+ author empty$
+ { format.editors "author and editor" output.check }
+ { format.authors output.nonnull
+ crossref missing$
+ { "author and editor" editor either.or.check
+ }
+ 'skip$
+ if$
+ }
+ if$
+ new.block
+ format.btitle "title" output.check
+ crossref missing$
+ { format.bvolume output
+ new.block
+ format.number.series output
+ %new.sentence
+ format.publisher "publisher" output.check
+ format.address output
+ }
+ { new.block
+ format.book.crossref output.nonnull
+ }
+ if$
+ format.edition output
+ format.date "year" output.check
+ new.block
+ format.key output
+ format.note output
+ format.isbn output
+ format.doi output
+ format.pubmed output
+ format.url output
+ format.abstract output
+ fin.entry
+}
+
+FUNCTION {booklet}
+{ output.bibitem
+ "\DTLnewbibitem {EntryType}{booklet}%" write$
+ newline$
+ format.authors output
+ new.block
+ format.title "title" output.check
+ howpublished address new.block.checkb
+ format.howpublished output
+ format.address output
+ format.date output
+ new.block
+ format.key output
+ format.note output
+ format.isbn output
+ format.doi output
+ format.pubmed output
+ format.url output
+ format.abstract output
+ fin.entry
+}
+
+FUNCTION {inbook}
+{ output.bibitem
+ "\DTLnewbibitem {EntryType}{inbook}%" write$
+ newline$
+ author empty$
+ { format.editors "author and editor" output.check }
+ { format.authors output.nonnull
+ crossref missing$
+ { "author and editor" editor either.or.check }
+ 'skip$
+ if$
+ }
+ if$
+ new.block
+ format.btitle "title" output.check
+ crossref missing$
+ { format.bvolume output
+ format.chapter.pages "chapter and pages" output.check
+ new.block
+ format.number.series output
+ new.sentence
+ format.publisher "publisher" output.check
+ format.address output
+ }
+ { format.chapter.pages "chapter and pages" output.check
+ new.block
+ format.book.crossref output.nonnull
+ }
+ if$
+ format.edition output
+ format.date "year" output.check
+ new.block
+ format.key output
+ format.note output
+ format.isbn output
+ format.doi output
+ format.pubmed output
+ format.url output
+ format.abstract output
+ fin.entry
+}
+
+FUNCTION {incollection}
+{ output.bibitem
+ "\DTLnewbibitem {EntryType}{incollection}%" write$
+ newline$
+ format.authors "author" output.check
+ format.title "title" output.check
+ crossref missing$
+ { format.in.ed.booktitle "booktitle" output.check
+ format.bvolume output
+ format.number.series output
+ format.chapter.pages output
+ new.sentence
+ format.publisher "publisher" output.check
+ format.address output
+ format.edition output
+ format.date "year" output.check
+ }
+ { format.incoll.inproc.crossref output.nonnull
+ format.chapter.pages output
+ }
+ if$
+ format.key output
+ format.note output
+ format.isbn output
+ format.doi output
+ format.pubmed output
+ format.url output
+ format.abstract output
+ fin.entry
+}
+
+FUNCTION {inproceedings}
+{ output.bibitem
+ "\DTLnewbibitem {EntryType}{inproceedings}%" write$
+ newline$
+ format.authors "author" output.check
+ format.title "title" output.check
+ crossref missing$
+ { format.in.ed.booktitle "booktitle" output.check
+ format.bvolume output
+ format.number.series output
+ format.pages output
+ address empty$
+ { %organization publisher new.sentence.checkb
+ format.organization write$
+ format.publisher output
+ }
+ { format.address write$
+ new.sentence
+ format.organization output
+ format.publisher output
+ }
+ if$
+ format.date "year" output.check
+ }
+ {
+ format.incoll.inproc.crossref output.nonnull
+ format.pages output
+ }
+ if$
+ format.key output
+ format.note output
+ format.isbn output
+ format.doi output
+ format.pubmed output
+ format.url output
+ format.abstract output
+ fin.entry
+}
+
+FUNCTION {conference} { inproceedings }
+
+FUNCTION {manual}
+{ output.bibitem
+ "\DTLnewbibitem {EntryType}{manual}%" write$
+ newline$
+ author empty$
+ { organization empty$
+ 'skip$
+ { format.organization output
+ format.address output
+ }
+ if$
+ }
+ { format.authors output }
+ if$
+ new.block
+ format.btitle "title" output.check
+ author empty$
+ { organization empty$
+ { address new.block.checka
+ address output
+ }
+ 'skip$
+ if$
+ }
+ { %organization address new.block.checkb
+ format.organization output
+ format.address output
+ }
+ if$
+ format.edition output
+ format.date output
+ new.block
+ format.key output
+ format.note output
+ format.isbn output
+ format.doi output
+ format.pubmed output
+ format.url output
+ format.abstract output
+ fin.entry
+}
+
+FUNCTION {mastersthesis}
+{ output.bibitem
+ "\DTLnewbibitem {EntryType}{mastersthesis}%" write$
+ newline$
+ format.authors "author" output.check
+ new.block
+ format.title "title" output.check
+ new.block
+ "\DTLnewbibitem {Type}{\mscthesisname }"
+ format.thesis.type output.nonnull
+ format.school "school" output.check
+ format.address output
+ format.date "year" output.check
+ new.block
+ format.key output
+ format.note output
+ format.isbn output
+ format.doi output
+ format.pubmed output
+ format.url output
+ format.abstract output
+ fin.entry
+}
+
+FUNCTION {misc}
+{ output.bibitem
+ "\DTLnewbibitem {EntryType}{misc}%" write$
+ newline$
+ format.authors output
+ title howpublished new.block.checkb
+ format.title output
+ %howpublished new.block.checka
+ format.howpublished output
+ format.date output
+ new.block
+ format.key output
+ format.note output
+ format.isbn output
+ format.doi output
+ format.pubmed output
+ format.url output
+ format.abstract output
+ fin.entry
+ empty.misc.check
+}
+
+FUNCTION {phdthesis}
+{ output.bibitem
+ "\DTLnewbibitem {EntryType}{phdthesis}%" write$
+ newline$
+ format.authors "author" output.check
+ new.block
+ format.btitle "title" output.check
+ new.block
+ "\DTLnewbibitem {Type}{\phdthesisname }"
+ format.thesis.type output.nonnull
+ format.school "school" output.check
+ format.address output
+ format.date "year" output.check
+ new.block
+ format.key output
+ format.note output
+ format.isbn output
+ format.doi output
+ format.pubmed output
+ format.url output
+ format.abstract output
+ fin.entry
+}
+
+FUNCTION {proceedings}
+{ output.bibitem
+ "\DTLnewbibitem {EntryType}{proceedings}%" write$
+ newline$
+ editor empty$
+ { format.organization output }
+ { format.editors output.nonnull }
+ if$
+ new.block
+ format.btitle "title" output.check
+ format.bvolume output
+ format.number.series output
+ address empty$
+ { editor empty$
+ { publisher new.sentence.checka }
+ { organization publisher new.sentence.checkb
+ format.organization output
+ }
+ if$
+ format.publisher output
+ format.date "year" output.check
+ }
+ { format.address output
+ format.date "year" output.check
+ new.sentence
+ editor empty$
+ 'skip$
+ { format.organization output }
+ if$
+ format.publisher output
+ }
+ if$
+ new.block
+ format.key output
+ format.note output
+ format.isbn output
+ format.doi output
+ format.pubmed output
+ format.url output
+ format.abstract output
+ fin.entry
+}
+
+FUNCTION {techreport}
+{ output.bibitem
+ "\DTLnewbibitem {EntryType}{techreport}%" write$
+ newline$
+ format.authors "author" output.check
+ new.block
+ format.title "title" output.check
+ new.block
+ format.tr.number output.nonnull
+ format.institution "institution" output.check
+ format.address output
+ format.date "year" output.check
+ new.block
+ format.key output
+ format.note output
+ format.isbn output
+ format.doi output
+ format.pubmed output
+ format.url output
+ format.abstract output
+ fin.entry
+}
+
+FUNCTION {unpublished}
+{ output.bibitem
+ "\DTLnewbibitem {EntryType}{unpublished}%" write$
+ newline$
+ format.authors "author" output.check
+ new.block
+ format.title "title" output.check
+ new.block
+ format.key output
+ format.note output
+ format.isbn output
+ format.doi output
+ format.pubmed output
+ format.url output
+ format.abstract output
+ format.date output
+ fin.entry
+}
+
+FUNCTION {default.type} { misc }
+
+MACRO {jan} {"\DTLmonthname{01}"}
+
+MACRO {feb} {"\DTLmonthname{02}"}
+
+MACRO {mar} {"\DTLmonthname{03}"}
+
+MACRO {apr} {"\DTLmonthname{04}"}
+
+MACRO {may} {"\DTLmonthname{05}"}
+
+MACRO {jun} {"\DTLmonthname{06}"}
+
+MACRO {jul} {"\DTLmonthname{07}"}
+
+MACRO {aug} {"\DTLmonthname{08}"}
+
+MACRO {sep} {"\DTLmonthname{09}"}
+
+MACRO {oct} {"\DTLmonthname{10}"}
+
+MACRO {nov} {"\DTLmonthname{11}"}
+
+MACRO {dec} {"\DTLmonthname{12}"}
+
+MACRO {acmcs} {"\DTLacmcs "}
+
+MACRO {acta} {"\DTLacta "}
+
+MACRO {cacm} {"\DTLcacm "}
+
+MACRO {ibmjrd} {"\DTLibmjrd "}
+
+MACRO {ibmsj} {"\DTLibmsj "}
+
+MACRO {ieeese} {"\DTLieeese "}
+
+MACRO {ieeetc} {"\DTLieeetc "}
+
+MACRO {ieeetcad} {"\DTLieeetcad "}
+
+MACRO {ipl} {"\DTLipl "}
+
+MACRO {jacm} {"\DTLjacm "}
+
+MACRO {jcss} {"\DTLjcss "}
+
+MACRO {scp} {"\DTLscp "}
+
+MACRO {sicomp} {"\DTLsicomp "}
+
+MACRO {tocs} {"\DTLtocs "}
+
+MACRO {tods} {"\DTLtods "}
+
+MACRO {tog} {"\DTLtog "}
+
+MACRO {toms} {"\DTLtoms "}
+
+MACRO {toois} {"\DTLtoois "}
+
+MACRO {toplas} {"\DTLtoplas "}
+
+MACRO {tcs} {"\DTLtcs "}
+
+READ
+
+STRINGS { longest.label }
+
+INTEGERS { number.label longest.label.width }
+
+FUNCTION {initialize.longest.label}
+{ "" 'longest.label :=
+ #1 'number.label :=
+ #0 'longest.label.width :=
+}
+
+FUNCTION {longest.label.pass}
+{ number.label int.to.str$ 'label :=
+ number.label #1 + 'number.label :=
+ label width$ longest.label.width >
+ { label 'longest.label :=
+ label width$ 'longest.label.width :=
+ }
+ 'skip$
+ if$
+}
+
+EXECUTE {initialize.longest.label}
+
+ITERATE {longest.label.pass}
+
+FUNCTION {begin.bib}
+{ preamble$ empty$
+ 'skip$
+ { preamble$ write$ newline$ }
+ if$
+}
+
+EXECUTE {begin.bib}
+
+EXECUTE {init.state.consts}
+
+ITERATE {call.type$}
+
+FUNCTION {end.bib}
+{
+}
+
+EXECUTE {end.bib}
+% \end{macrocode}
+% \end{macrocode}
+%\fi
+%\iffalse
+% \begin{macrocode}
+%</databib.bst>
+% \end{macrocode}
+%\fi
%\Finale
\endinput
diff --git a/Master/texmf-dist/source/latex/datatool/datatool.ins b/Master/texmf-dist/source/latex/datatool/datatool.ins
new file mode 100644
index 00000000000..87c233613df
--- /dev/null
+++ b/Master/texmf-dist/source/latex/datatool/datatool.ins
@@ -0,0 +1,40 @@
+% datatool.ins generated using makedtx version 0.94b 2007/8/19 14:27
+\input docstrip
+
+\preamble
+
+ datatool.dtx
+ Copyright 2007 Nicola Talbot
+
+ This work may be distributed and/or modified under the
+ conditions of the LaTeX Project Public License, either version 1.3
+ of this license of (at your option) any later version.
+ The latest version of this license is in
+ http://www.latex-project.org/lppl.txt
+ and version 1.3 or later is part of all distributions of LaTeX
+ version 2005/12/01 or later.
+
+ This work has the LPPL maintenance status `maintained'.
+
+ The Current Maintainer of this work is Nicola Talbot.
+
+ This work consists of the files datatool.dtx and datatool.ins and the derived files datatool.sty, datapie.sty, dataplot.sty, databar.sty, databib.sty, databib.bst.
+
+\endpreamble
+
+\askforoverwritefalse
+
+\generate{\file{datatool.sty}{\usepreamble\defaultpreamble
+\usepostamble\defaultpostamble\from{datatool.dtx}{datatool.sty,package}}
+\file{datapie.sty}{\usepreamble\defaultpreamble
+\usepostamble\defaultpostamble\from{datatool.dtx}{datapie.sty,package}}
+\file{dataplot.sty}{\usepreamble\defaultpreamble
+\usepostamble\defaultpostamble\from{datatool.dtx}{dataplot.sty,package}}
+\file{databar.sty}{\usepreamble\defaultpreamble
+\usepostamble\defaultpostamble\from{datatool.dtx}{databar.sty,package}}
+\file{databib.sty}{\usepreamble\defaultpreamble
+\usepostamble\defaultpostamble\from{datatool.dtx}{databib.sty,package}}
+\file{databib.bst}{\nopreamble\usepreamble\defaultpreamble\nopostamble\from{datatool.dtx}{databib.bst}}
+}
+
+\endbatchfile
diff --git a/Master/texmf-dist/tex/latex/datatool/databar.sty b/Master/texmf-dist/tex/latex/datatool/databar.sty
new file mode 100644
index 00000000000..63b5f505912
--- /dev/null
+++ b/Master/texmf-dist/tex/latex/datatool/databar.sty
@@ -0,0 +1,803 @@
+%%
+%% This is file `databar.sty',
+%% generated with the docstrip utility.
+%%
+%% The original source files were:
+%%
+%% datatool.dtx (with options: `databar.sty,package')
+%%
+%% datatool.dtx
+%% Copyright 2007 Nicola Talbot
+%%
+%% This work may be distributed and/or modified under the
+%% conditions of the LaTeX Project Public License, either version 1.3
+%% of this license of (at your option) any later version.
+%% The latest version of this license is in
+%% http://www.latex-project.org/lppl.txt
+%% and version 1.3 or later is part of all distributions of LaTeX
+%% version 2005/12/01 or later.
+%%
+%% This work has the LPPL maintenance status `maintained'.
+%%
+%% The Current Maintainer of this work is Nicola Talbot.
+%%
+%% This work consists of the files datatool.dtx and datatool.ins and the derived files datatool.sty, datapie.sty, dataplot.sty, databar.sty, databib.sty, databib.bst.
+%%
+%% \CharacterTable
+%% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
+%% Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
+%% Digits \0\1\2\3\4\5\6\7\8\9
+%% Exclamation \! Double quote \" Hash (number) \#
+%% Dollar \$ Percent \% Ampersand \&
+%% Acute accent \' Left paren \( Right paren \)
+%% Asterisk \* Plus \+ Comma \,
+%% Minus \- Point \. Solidus \/
+%% Colon \: Semicolon \; Less than \<
+%% Equals \= Greater than \> Question mark \?
+%% Commercial at \@ Left bracket \[ Backslash \\
+%% Right bracket \] Circumflex \^ Underscore \_
+%% Grave accent \` Left brace \{ Vertical bar \|
+%% Right brace \} Tilde \~}
+\NeedsTeXFormat{LaTeX2e}
+\ProvidesPackage{databar}[2007/08/17 v1.01 (NLCT)]
+\RequirePackage{xkeyval}
+\RequirePackage{dataplot}
+\newif\ifDTLcolorbarchart
+\DTLcolorbarcharttrue
+\DeclareOption{color}{\DTLcolorbarcharttrue}
+\DeclareOption{gray}{\DTLcolorbarchartfalse}
+\newcommand*{\DTLbarXlabelalign}{left,rotate=-90}
+\newcommand*{\DTLbarYticklabelalign}{right}
+\define@boolkey{databar}[DTL]{verticalbars}[true]{%
+\ifDTLverticalbars
+ \def\DTLbarXlabelalign{left,rotate=-90}%
+ \def\DTLbarYticklabelalign{right}
+\else
+ \def\DTLbarXlabelalign{right}%
+ \def\DTLbarYticklabelalign{center}
+\fi}
+\DTLverticalbarstrue
+\DeclareOption{vertical}{\DTLverticalbarstrue
+ \def\DTLbarXlabelalign{left,rotate=-90}%
+ \def\DTLbarYticklabelalign{right}
+}
+\DeclareOption{horizontal}{\DTLverticalbarsfalse
+ \def\DTLbarXlabelalign{right}%
+ \def\DTLbarYticklabelalign{center}
+}
+\ProcessOptions
+\RequirePackage{datatool}
+\RequirePackage{tikz}
+\newlength\DTLbarchartlength
+\DTLbarchartlength=3in
+\newlength\DTLbarwidth
+\DTLbarwidth=1cm
+\newlength\DTLbarlabeloffset
+\setlength\DTLbarlabeloffset{10pt}
+\newcommand*{\DTLBarXAxisStyle}{-}
+\newcommand*{\DTLBarYAxisStyle}{-}
+\newcounter{DTLbarroundvar}
+\setcounter{DTLbarroundvar}{1}
+\newcommand*{\DTLbardisplayYticklabel}[1]{#1}
+\newcommand*{\DTLdisplaylowerbarlabel}[1]{#1}
+\newcommand*{\DTLdisplaylowermultibarlabel}[1]{#1}
+\newcommand*{\DTLdisplayupperbarlabel}[1]{#1}
+\newcommand*{\DTLdisplayuppermultibarlabel}[1]{#1}
+\newcommand*{\DTLbaratbegintikz}{}
+\newcommand*{\DTLbaratendtikz}{}
+\newif\ifDTLbarxaxis
+\newif\ifDTLbaryaxis
+\newif\ifDTLbarytics
+\newcount\@dtl@barcount
+\newcommand*{\DTLsetbarcolor}[2]{%
+\expandafter\def\csname dtlbar@segcol\romannumeral#1\endcsname{#2}%
+}
+\newcommand*{\DTLgetbarcolor}[1]{%
+\csname dtlbar@segcol\romannumeral#1\endcsname}
+\newcommand*{\DTLdobarcolor}[1]{%
+\expandafter\color\expandafter
+{\csname dtlbar@segcol\romannumeral#1\endcsname}}
+\newcommand*{\DTLdocurrentbarcolor}{%
+\ifnum\dtlforeachlevel=0\relax
+ \PackageError{databar}{Can't use
+ \string\DTLdocurrentbarcolor\space outside
+ \string\DTLbarchart}{}%
+\else
+ \expandafter\DTLdobarcolor\expandafter{%
+ \csname c@DTLrow\romannumeral\dtlforeachlevel\endcsname}%
+\fi}
+\newcommand*{\DTLbaroutlinecolor}{black}
+\newlength\DTLbaroutlinewidth
+\DTLbaroutlinewidth=0pt
+\ifDTLcolorbarchart
+ \DTLsetbarcolor{1}{red}
+ \DTLsetbarcolor{2}{green}
+ \DTLsetbarcolor{3}{blue}
+ \DTLsetbarcolor{4}{yellow}
+ \DTLsetbarcolor{5}{magenta}
+ \DTLsetbarcolor{6}{cyan}
+ \DTLsetbarcolor{7}{orange}
+ \DTLsetbarcolor{8}{white}
+\else
+ \DTLsetbarcolor{1}{black!15}
+ \DTLsetbarcolor{2}{black!25}
+ \DTLsetbarcolor{3}{black!35}
+ \DTLsetbarcolor{4}{black!45}
+ \DTLsetbarcolor{5}{black!55}
+ \DTLsetbarcolor{6}{black!65}
+ \DTLsetbarcolor{7}{black!75}
+ \DTLsetbarcolor{8}{black!85}
+\fi
+\define@key{databar}{max}{\def\DTLbarmax{#1}}
+\define@key{databar}{length}{\DTLbarchartlength=#1\relax
+}
+\define@key{databar}{maxdepth}{%
+\ifnum#1>0\relax
+ \PackageError{databar}{depth must be zero or negative}{}%
+\else
+ \def\DTLnegextent{#1}%
+\fi}
+\define@choicekey{databar}{axes}[\var\nr]{both,x,y,none}{%
+\ifcase\nr\relax
+ % both
+ \DTLbarxaxistrue
+ \DTLbaryaxistrue
+ \DTLbaryticstrue
+\or
+ % x only
+ \DTLbarxaxistrue
+ \DTLbaryaxisfalse
+ \DTLbaryticsfalse
+\or
+ % y only
+ \DTLbarxaxisfalse
+ \DTLbaryaxistrue
+ \DTLbaryticstrue
+\or
+ % neither
+ \DTLbarxaxisfalse
+ \DTLbaryaxisfalse
+ \DTLbaryticsfalse
+\fi
+}
+\define@key{databar}{variable}{%
+\def\DTLbarvariable{#1}}
+\define@key{databar}{variables}{%
+\def\dtlbar@variables{#1}}
+\define@key{databar}{barwidth}{\setlength{\DTLbarwidth}{#1}}
+\define@key{databar}{barlabel}{%
+\def\dtl@barlabel{#1}}
+\def\dtl@barlabel{}
+\define@key{databar}{multibarlabels}{%
+\def\dtl@multibarlabels{#1}}
+\def\dtl@multibarlabels{}
+\define@key{databar}{groupgap}{\def\dtlbar@groupgap{#1}}
+\def\dtlbar@groupgap{1}
+\define@key{databar}{upperbarlabel}{%
+\def\dtl@upperbarlabel{#1}}
+\def\dtl@upperbarlabel{}
+\define@key{databar}{uppermultibarlabels}{%
+\def\dtl@uppermultibarlabels{#1}}
+\def\dtl@uppermultibarlabels{}
+\define@key{databar}{yticpoints}{%
+\def\dtlbar@yticlist{#1}\DTLbaryticstrue\DTLbaryaxistrue}
+\let\dtlbar@yticlist=\relax
+\define@key{databar}{yticgap}{%
+\def\dtlbar@yticgap{#1}\DTLbaryticstrue\DTLbaryaxistrue}
+\let\dtlbar@yticgap=\relax
+\define@key{databar}{yticlabels}{%
+\def\dtlbar@yticlabels{#1}\DTLbaryticstrue\DTLbaryaxistrue}
+\let\dtlbar@yticlabels=\relax
+\define@key{databar}{ylabel}{%
+\def\dtlbar@ylabel{#1}}
+\let\dtlbar@ylabel=\relax
+\newcommand*{\DTLbarchart}[4][\boolean{true}]{%
+{\let\DTLbarvariable=\relax
+\let\DTLbarmax=\relax
+\let\DTLnegextent=\relax
+\disable@keys{databar}{variables,multibarlabels,%
+uppermultibarlabels,groupgap}%
+\setkeys{databar}{#2}%
+\ifx\DTLbarvariable\relax
+ \PackageError{databar}{\string\DTLbarchart\space missing variable}{}%
+\else
+ \ifx\DTLbarmax\relax
+ \@sDTLforeach[#1]{#3}{#4}{%
+ \expandafter\DTLconverttodecimal\expandafter
+ {\DTLbarvariable}{\dtl@barvar}%
+ \ifx\DTLbarmax\relax
+ \let\DTLbarmax=\dtl@barvar
+ \else
+ \let\dtl@old=\DTLbarmax
+ \FPmax{\DTLbarmax}{\dtl@old}{\dtl@barvar}%
+ \fi
+ }%
+ \ifx\dtlbar@yticgap\relax
+ \else
+ \let\dtl@thistick=\dtlbar@yticgap%
+ \whiledo{\DTLisFPopenbetween{\dtl@thistick}{0}{\DTLbarmax}}{%
+ \FPadd{\dtl@thistick}{\dtl@thistick}{\dtlbar@yticgap}%
+ }%
+ \let\DTLbarmax=\dtl@thistick
+ \fi
+ \fi
+ \ifx\DTLnegextent\relax
+ \def\DTLnegextent{0}%
+ \@sDTLforeach[#1]{#3}{#4}{%
+ \expandafter\DTLconverttodecimal\expandafter
+ {\DTLbarvariable}{\dtl@barvar}%
+ \let\dtl@old=\DTLnegextent
+ \DTLmin{\DTLnegextent}{\dtl@old}{\dtl@barvar}%
+ }%
+ \ifx\dtlbar@yticgap\relax
+ \else
+ \ifthenelse{\DTLisFPlt{\DTLnegextent}{0}}{%
+ \edef\dtl@thistick{0}%
+ \whiledo{\DTLisFPclosedbetween{\dtl@thistick}{\DTLnegextent}{0}}{%
+ \FPsub{\dtl@thistick}{\dtl@thistick}{\dtlbar@yticgap}%
+ }%
+ \let\DTLnegextent=\dtl@thistick
+ }{}%
+ \fi
+ \fi
+ \@dtl@tmpcount=\DTLbarchartlength
+ \FPsub{\dtl@extent}{\DTLbarmax}{\DTLnegextent}%
+ \FPdiv{\dtl@unit}{\number\@dtl@tmpcount}{\dtl@extent}%
+ \setlength{\dtl@yticlabelwidth}{0pt}%
+ \ifDTLbarytics
+ \ifx\dtlbar@yticlist\relax
+ \ifx\dtlbar@yticgap\relax
+ \dtl@constructticklist\DTLnegextent\DTLbarmax
+ \dtl@unit\dtlbar@yticlist
+ \else
+ \dtl@constructticklistwithgapz
+ \DTLnegextent\DTLbarmax\dtlbar@yticlist\dtlbar@yticgap
+ \fi
+ \fi
+ \ifx\dtlbar@ylabel\relax
+ \else
+ \ifx\dtlbar@yticlabels\relax
+ \@for\dtl@thislabel:=\dtlbar@yticlist\do{%
+ \FPround{\dtl@thislabel}{\dtl@thislabel}
+ {\c@DTLbarroundvar}%
+ \ifDTLverticalbars
+ \settowidth{\dtl@tmplength}{%
+ \DTLbardisplayYticklabel{\dtl@thislabel}}%
+ \else
+ \settoheight{\dtl@tmplength}{%
+ \DTLbardisplayYticklabel{\dtl@thislabel}}%
+ \edef\@dtl@h{\the\dtl@tmplength}%
+ \settodepth{\dtl@tmplength}{%
+ \DTLbardisplayYticklabel{\dtl@thislabel}}%
+ \addtolength{\dtl@tmplength}{\@dtl@h}%
+ \addtolength{\dtl@tmplength}{\baselineskip}%
+ \fi
+ \ifdim\dtl@tmplength>\dtl@yticlabelwidth
+ \setlength{\dtl@yticlabelwidth}{\dtl@tmplength}%
+ \fi
+ }%
+ \else
+ \@for\dtl@thislabel:=\dtlbar@yticlabels\do{%
+ \ifDTLverticalbars
+ \settowidth{\dtl@tmplength}{%
+ \DTLbardisplayYticklabel{\dtl@thislabel}}%
+ \else
+ \settoheight{\dtl@tmplength}{%
+ \DTLbardisplayYticklabel{\dtl@thislabel}}%
+ \edef\@dtl@h{\the\dtl@tmplength}%
+ \settodepth{\dtl@tmplength}{%
+ \DTLbardisplayYticklabel{\dtl@thislabel}}%
+ \addtolength{\dtl@tmplength}{\@dtl@h}%
+ \addtolength{\dtl@tmplength}{\baselineskip}%
+ \fi
+ \ifdim\dtl@tmplength>\dtl@yticlabelwidth
+ \setlength{\dtl@yticlabelwidth}{\dtl@tmplength}%
+ \fi
+ }%
+ \fi
+ \fi
+ \fi
+\edef\DTLbarchartwidth{\expandafter\number\csname dtlrows@#3\endcsname}
+\begin{tikzpicture}
+\ifDTLverticalbars
+ \pgfsetyvec{\pgfpoint{0pt}{\dtl@unit sp}}%
+ \pgfsetxvec{\pgfpoint{\DTLbarwidth}{0pt}}%
+\else
+ \pgfsetxvec{\pgfpoint{\dtl@unit sp}{0pt}}%
+ \pgfsetyvec{\pgfpoint{0pt}{\DTLbarwidth}}%
+\fi
+\DTLbaratbegintikz
+\def\@dtl@start{0}%
+\@sDTLforeach[#1]{#3}{#4}{%
+\expandafter\let\expandafter\@dtl@bar
+ \csname c@DTLrow\romannumeral\dtlforeachlevel\endcsname%
+\expandafter\DTLconverttodecimal\expandafter
+ {\DTLbarvariable}{\dtl@variable}%
+\begin{scope}
+ \DTLdocurrentbarcolor
+ \ifDTLverticalbars
+ \fill (\@dtl@start,0) -- (\@dtl@start,\dtl@variable)
+ -- (\@dtl@bar,\dtl@variable) -- (\@dtl@bar,0) -- cycle;
+ \else
+ \fill (0,\@dtl@start) -- (\dtl@variable,\@dtl@start)
+ -- (\dtl@variable,\@dtl@bar) -- (0,\@dtl@bar) -- cycle;
+ \fi
+\end{scope}
+\begin{scope}
+\ifdim\DTLbaroutlinewidth>0pt
+ \expandafter\color\expandafter{\DTLbaroutlinecolor}
+ \ifDTLverticalbars
+ \draw (\@dtl@start,0) -- (\@dtl@start,\dtl@variable)
+ -- (\@dtl@bar,\dtl@variable) -- (\@dtl@bar,0) -- cycle;
+ \else
+ \draw (0,\@dtl@start) -- (\dtl@variable,\@dtl@start)
+ -- (\dtl@variable,\@dtl@bar) -- (0,\@dtl@bar) -- cycle;
+ \fi
+\fi
+\end{scope}
+\ifDTLverticalbars
+ \edef\dtl@textopt{%
+ at={\noexpand\pgfpointadd
+ {\noexpand\pgfpointxy{\@dtl@start.5}{0}}
+ {\noexpand\pgfpoint{0pt}{-\noexpand\DTLbarlabeloffset}}},
+ \DTLbarXlabelalign
+ }%
+\else
+ \edef\dtl@textopt{%
+ at={\noexpand\pgfpointadd
+ {\noexpand\pgfpointxy{0}{\@dtl@start.5}}
+ {\noexpand\pgfpoint{-\noexpand\DTLbarlabeloffset}{0pt}}},
+ \DTLbarXlabelalign
+ }%
+\fi
+ \expandafter\pgftext\expandafter[\dtl@textopt]{%
+ \DTLdisplaylowerbarlabel{\dtl@barlabel}}
+\ifDTLverticalbars
+ \expandafter\DTLifnumlt\expandafter{\DTLbarvariable}{0}
+ {
+ \edef\dtl@textopt{%
+ at={\noexpand\pgfpointadd
+ {\noexpand\pgfpointxy{\@dtl@start.5}{\dtl@variable}}
+ {\noexpand\pgfpoint{0pt}{-\noexpand\DTLbarlabeloffset}}}
+ }%
+ }{%
+ \edef\dtl@textopt{%
+ at={\noexpand\pgfpointadd
+ {\noexpand\pgfpointxy{\@dtl@start.5}{\dtl@variable}}
+ {\noexpand\pgfpoint{0pt}{\noexpand\DTLbarlabeloffset}}}
+ }%
+ }
+\else
+ \expandafter\DTLifnumlt\expandafter{\DTLbarvariable}{0}
+ {
+ \edef\dtl@textopt{right,
+ at={\noexpand\pgfpointadd
+ {\noexpand\pgfpointxy{\dtl@variable}{\@dtl@start.5}}
+ {\noexpand\pgfpoint{-\noexpand\DTLbarlabeloffset}{0pt}}}
+ }%
+ }{%
+ \edef\dtl@textopt{left,
+ at={\noexpand\pgfpointadd
+ {\noexpand\pgfpointxy{\dtl@variable}{\@dtl@start.5}}
+ {\noexpand\pgfpoint{\noexpand\DTLbarlabeloffset}{0pt}}}
+ }%
+ }
+\fi
+ \expandafter\pgftext\expandafter[\dtl@textopt]{%
+ \DTLdisplayupperbarlabel{\dtl@upperbarlabel}}
+ \edef\@dtl@start{\number\@dtl@bar}%
+}
+\ifDTLbarxaxis
+ \ifDTLverticalbars
+ \expandafter\draw\expandafter[\DTLBarXAxisStyle]
+ (0,0) -- (\DTLbarchartwidth,0);
+ \else
+ \expandafter\draw\expandafter[\DTLBarXAxisStyle]
+ (0,0) -- (0,\DTLbarchartwidth);
+ \fi
+\fi
+\ifDTLbaryaxis
+ \ifDTLverticalbars
+ \expandafter\draw\expandafter[\DTLBarYAxisStyle]
+ (0,\DTLnegextent) -- (0,\DTLbarmax);
+ \else
+ \expandafter\draw\expandafter[\DTLBarYAxisStyle]
+ (\DTLnegextent,0) -- (\DTLbarmax,0);
+ \fi
+\fi
+\ifx\dtlbar@yticlist\relax
+\else
+ \@for\dtl@thistick:=\dtlbar@yticlist\do{%
+ \ifDTLverticalbars
+ \pgfpathmoveto{\pgfpointxy{0}{\dtl@thistick}}
+ \pgfpathlineto{
+ \pgfpointadd{\pgfpointxy{0}{\dtl@thistick}}
+ {\pgfpoint{-\DTLticklength}{0pt}}}
+ \else
+ \pgfpathmoveto{\pgfpointxy{\dtl@thistick}{0}}
+ \pgfpathlineto{
+ \pgfpointadd{\pgfpointxy{\dtl@thistick}{0}}
+ {\pgfpoint{0pt}{-\DTLticklength}}}
+ \fi
+ \pgfusepath{stroke}
+ \ifx\dtlbar@yticlabels\relax
+ \FPround{\dtl@thislabel}{\dtl@thistick}
+ {\c@DTLbarroundvar}%
+ \else
+ \dtl@chopfirst\dtlbar@yticlabels\dtl@thislabel\dtl@rest
+ \let\dtlbar@yticlabels=\dtl@rest
+ \fi
+ \ifDTLverticalbars
+ \edef\dtl@textopt{\DTLbarYticklabelalign,%
+ at={\noexpand\pgfpointadd
+ {\noexpand\pgfpointxy{0}{\dtl@thistick}}
+ {\noexpand\pgfpoint{-\noexpand\DTLticklabeloffset}{0pt}},
+ }}%
+ \else
+ \edef\dtl@textopt{\DTLbarYticklabelalign,
+ at={\noexpand\pgfpointadd
+ {\noexpand\pgfpointxy{\dtl@thistick}{0}}
+ {\noexpand\pgfpoint{0pt}{-\noexpand\DTLticklabeloffset}}
+ }}%
+ \fi
+ \expandafter\pgftext\expandafter[\dtl@textopt]{%
+ \DTLbardisplayYticklabel{\dtl@thislabel}}
+ }%
+\fi
+\ifx\dtlbar@ylabel\relax
+\else
+ \addtolength{\dtl@yticlabelwidth}{\baselineskip}%
+ \setlength{\dtl@tmplength}{0.5\DTLbarchartlength}
+ \ifDTLverticalbars
+ \pgftext[bottom,center,at={\pgfpointadd
+ {\pgfpointxy{0}{\DTLnegextent}}%
+ {\pgfpoint{-\dtl@yticlabelwidth}{\dtl@tmplength}}},
+ rotate=90]{%
+ \dtlbar@ylabel}
+ \else
+ \pgftext[bottom,center,at={\pgfpointadd
+ {\pgfpointxy{\DTLnegextent}{0}}%
+ {\pgfpoint{\dtl@tmplength}{-\dtl@yticlabelwidth}}}]{%
+ \dtlbar@ylabel}
+ \fi
+\fi
+\DTLbaratendtikz
+\end{tikzpicture}
+\fi
+}}
+\newcommand*{\DTLmultibarchart}[4][\boolean{true}]{%
+{\let\dtlbar@variables=\relax
+\let\DTLbarmax=\relax
+\let\DTLnegextent=\relax
+\disable@keys{databar}{variable,upperbarlabel}%
+\setkeys{databar}{#2}%
+\ifx\dtlbar@variables\relax
+ \PackageError{databar}{\string\DTLmultibarchart\space missing variables setting}{}%
+\else
+ \ifx\DTLbarmax\relax
+ \@sDTLforeach[#1]{#3}{#4}{%
+ \@for\DTLbarvariable:=\dtlbar@variables\do{%
+ \expandafter\DTLconverttodecimal\expandafter
+ {\DTLbarvariable}{\dtl@barvar}%
+ \ifx\DTLbarmax\relax
+ \let\DTLbarmax=\dtl@barvar
+ \else
+ \let\dtl@old=\DTLbarmax
+ \FPmax{\DTLbarmax}{\dtl@old}{\dtl@barvar}%
+ \fi
+ }%
+ }%
+ \ifx\dtlbar@yticgap\relax
+ \else
+ \let\dtl@thistick=\dtlbar@yticgap%
+ \whiledo{\DTLisFPopenbetween{\dtl@thistick}{0}{\DTLbarmax}}{%
+ \FPadd{\dtl@thistick}{\dtl@thistick}{\dtlbar@yticgap}%
+ }%
+ \let\DTLbarmax=\dtl@thistick
+ \fi
+ \fi
+ \ifx\DTLnegextent\relax
+ \def\DTLnegextent{0}%
+ \@sDTLforeach[#1]{#3}{#4}{%
+ \@for\DTLbarvariable:=\dtlbar@variables\do{%
+ \expandafter\DTLconverttodecimal\expandafter
+ {\DTLbarvariable}{\dtl@barvar}%
+ \let\dtl@old=\DTLnegextent
+ \DTLmin{\DTLnegextent}{\dtl@old}{\dtl@barvar}%
+ }%
+ }%
+ \ifx\dtlbar@yticgap\relax
+ \else
+ \ifthenelse{\DTLisFPlt{\DTLnegextent}{0}}{%
+ \edef\dtl@thistick{0}%
+ \whiledo{\DTLisFPclosedbetween{\dtl@thistick}{\DTLnegextent}{0}}{%
+ \FPsub{\dtl@thistick}{\dtl@thistick}{\dtlbar@yticgap}%
+ }%
+ \let\DTLnegextent=\dtl@thistick
+ }{}%
+ \fi
+ \fi
+ \@dtl@tmpcount=\DTLbarchartlength
+ \FPsub{\dtl@extent}{\DTLbarmax}{\DTLnegextent}%
+ \FPdiv{\dtl@unit}{\number\@dtl@tmpcount}{\dtl@extent}%
+ \setlength{\dtl@yticlabelwidth}{0pt}%
+ \ifDTLbarytics
+ \ifx\dtlbar@yticlist\relax
+ \ifx\dtlbar@yticgap\relax
+ \dtl@constructticklist\DTLnegextent\DTLbarmax
+ \dtl@unit\dtlbar@yticlist
+ \else
+ \dtl@constructticklistwithgapz
+ \DTLnegextent\DTLbarmax\dtlbar@yticlist\dtlbar@yticgap
+ \fi
+ \fi
+ \ifx\dtlbar@ylabel\relax
+ \else
+ \ifx\dtlbar@yticlabels\relax
+ \@for\dtl@thislabel:=\dtlbar@yticlist\do{%
+ \FPround{\dtl@thislabel}{\dtl@thislabel}
+ {\c@DTLbarroundvar}%
+ \ifDTLverticalbars
+ \settowidth{\dtl@tmplength}{%
+ \DTLbardisplayYticklabel{\dtl@thislabel}}%
+ \else
+ \settoheight{\dtl@tmplength}{%
+ \DTLbardisplayYticklabel{\dtl@thislabel}}%
+ \edef\@dtl@h{\the\dtl@tmplength}%
+ \settodepth{\dtl@tmplength}{%
+ \DTLbardisplayYticklabel{\dtl@thislabel}}%
+ \addtolength{\dtl@tmplength}{\@dtl@h}%
+ \addtolength{\dtl@tmplength}{\baselineskip}%
+ \fi
+ \ifdim\dtl@tmplength>\dtl@yticlabelwidth
+ \setlength{\dtl@yticlabelwidth}{\dtl@tmplength}%
+ \fi
+ }%
+ \else
+ \@for\dtl@thislabel:=\dtlbar@yticlabels\do{%
+ \ifDTLverticalbars
+ \settowidth{\dtl@tmplength}{%
+ \DTLbardisplayYticklabel{\dtl@thislabel}}%
+ \else
+ \settoheight{\dtl@tmplength}{%
+ \DTLbardisplayYticklabel{\dtl@thislabel}}%
+ \edef\@dtl@h{\the\dtl@tmplength}%
+ \settodepth{\dtl@tmplength}{%
+ \DTLbardisplayYticklabel{\dtl@thislabel}}%
+ \addtolength{\dtl@tmplength}{\@dtl@h}%
+ \addtolength{\dtl@tmplength}{\baselineskip}%
+ \fi
+ \ifdim\dtl@tmplength>\dtl@yticlabelwidth
+ \setlength{\dtl@yticlabelwidth}{\dtl@tmplength}%
+ \fi
+ }%
+ \fi
+ \fi
+ \fi
+\dtl@xticlabelheight=0pt\relax
+\@dtl@tmpcount=0\relax
+\@for\dtl@thislabel:=\dtl@multibarlabels\do{%
+ \advance\@dtl@tmpcount by 1\relax
+ \settoheight{\dtl@tmplength}{\tikz\expandafter\pgftext\expandafter
+ [\DTLbarXlabelalign]{\DTLdisplaylowerbarlabel{\dtl@thislabel}};}%
+ \edef\@dtl@h{\the\dtl@tmplength}%
+ \settodepth{\dtl@tmplength}{\tikz\expandafter\pgftext\expandafter
+ [\DTLbarXlabelalign]{\DTLdisplaylowerbarlabel{\dtl@thislabel}};}%
+ \addtolength{\dtl@tmplength}{\@dtl@h}%
+ \addtolength{\dtl@tmplength}{\baselineskip}%
+ \ifdim\dtl@tmplength>\dtl@xticlabelheight
+ \setlength{\dtl@xticlabelheight}{\dtl@tmplength}%
+ \fi
+}
+\@dtl@tmpcount=0\relax
+\@for\dtl@this:=\dtlbar@variables\do{%
+ \advance\@dtl@tmpcount by 1\relax
+}%
+\edef\DTLbargroupwidth{\number\@dtl@tmpcount}%
+\edef\dtl@n{\expandafter\number\csname dtlrows@#3\endcsname}
+\FPmul{\dtl@tmpi}{\dtl@n}{\DTLbargroupwidth}
+\FPsub{\dtl@tmpii}{\dtl@n}{1}%
+\FPmul{\dtl@tmpii}{\dtl@tmpii}{\dtlbar@groupgap}%
+\FPadd{\DTLbarchartwidth}{\dtl@tmpi}{\dtl@tmpii}
+\begin{tikzpicture}
+\ifDTLverticalbars
+ \pgfsetyvec{\pgfpoint{0pt}{\dtl@unit sp}}%
+ \pgfsetxvec{\pgfpoint{\DTLbarwidth}{0pt}}%
+\else
+ \pgfsetxvec{\pgfpoint{\dtl@unit sp}{0pt}}%
+ \pgfsetyvec{\pgfpoint{0pt}{\DTLbarwidth}}%
+\fi
+\DTLbaratbegintikz
+\def\@dtl@start{0}%
+\@sDTLforeach[#1]{#3}{#4}{%
+\@dtl@barcount = 1\relax
+\let\dtl@multibar@labels=\dtl@multibarlabels
+\let\dtl@uppermultibar@labels=\dtl@uppermultibarlabels
+\FPmul{\dtl@multimidpt}{\DTLbargroupwidth}{0.5}%
+\FPadd{\dtl@multimidpt}{\dtl@multimidpt}{\@dtl@start}%
+\@for\DTLbarvariable:=\dtlbar@variables\do{%
+\FPadd{\@dtl@endpt}{\@dtl@start}{1}%
+\expandafter\DTLconverttodecimal\expandafter
+ {\DTLbarvariable}{\dtl@variable}%
+\dtl@chopfirst\dtl@multibar@labels\dtl@thisbarlabel\dtl@rest
+\let\dtl@multibar@labels=\dtl@rest
+\dtl@chopfirst\dtl@uppermultibar@labels\dtl@thisupperbarlabel\dtl@rest
+\let\dtl@uppermultibar@labels=\dtl@rest
+\begin{scope}
+ \expandafter\color\expandafter{\DTLgetbarcolor{\@dtl@barcount}}%
+ \ifDTLverticalbars
+ \fill (\@dtl@start,0) -- (\@dtl@start,\dtl@variable)
+ -- (\@dtl@endpt,\dtl@variable) -- (\@dtl@endpt,0) -- cycle;
+ \else
+ \fill (0,\@dtl@start) -- (\dtl@variable,\@dtl@start)
+ -- (\dtl@variable,\@dtl@endpt) -- (0,\@dtl@endpt) -- cycle;
+ \fi
+\end{scope}
+\begin{scope}
+\ifdim\DTLbaroutlinewidth>0pt
+ \expandafter\color\expandafter{\DTLbaroutlinecolor}
+ \ifDTLverticalbars
+ \draw (\@dtl@start,0) -- (\@dtl@start,\dtl@variable)
+ -- (\@dtl@endpt,\dtl@variable) -- (\@dtl@endpt,0) -- cycle;
+ \else
+ \draw (0,\@dtl@start) -- (\dtl@variable,\@dtl@start)
+ -- (\dtl@variable,\@dtl@endpt) -- (0,\@dtl@endpt) -- cycle;
+ \fi
+\fi
+\end{scope}
+\FPadd{\@dtl@midpt}{\@dtl@start}{0.5}%
+\ifDTLverticalbars
+ \edef\dtl@textopt{%
+ at={\noexpand\pgfpointadd
+ {\noexpand\pgfpointxy{\@dtl@midpt}{0}}
+ {\noexpand\pgfpoint{0pt}{-\noexpand\DTLbarlabeloffset}}},
+ \DTLbarXlabelalign
+ }%
+\else
+ \edef\dtl@textopt{%
+ at={\noexpand\pgfpointadd
+ {\noexpand\pgfpointxy{0}{\@dtl@midpt}}
+ {\noexpand\pgfpoint{-\noexpand\DTLbarlabeloffset}{0pt}}},
+ \DTLbarXlabelalign
+ }%
+\fi
+ \expandafter\pgftext\expandafter[\dtl@textopt]{%
+ \DTLdisplaylowermultibarlabel{\dtl@thisbarlabel}}
+\ifDTLverticalbars
+ \expandafter\DTLifnumlt\expandafter{\DTLbarvariable}{0}
+ {
+ \edef\dtl@textopt{%
+ at={\noexpand\pgfpointadd
+ {\noexpand\pgfpointxy{\@dtl@midpt}{\dtl@variable}}
+ {\noexpand\pgfpoint{0pt}{-\noexpand\DTLbarlabeloffset}}}
+ }%
+ }{%
+ \edef\dtl@textopt{%
+ at={\noexpand\pgfpointadd
+ {\noexpand\pgfpointxy{\@dtl@midpt}{\dtl@variable}}
+ {\noexpand\pgfpoint{0pt}{\noexpand\DTLbarlabeloffset}}}
+ }%
+ }
+\else
+ \expandafter\DTLifnumlt\expandafter{\DTLbarvariable}{0}
+ {
+ \edef\dtl@textopt{right,
+ at={\noexpand\pgfpointadd
+ {\noexpand\pgfpointxy{\dtl@variable}{\@dtl@midpt}}
+ {\noexpand\pgfpoint{-\noexpand\DTLbarlabeloffset}{0pt}}}
+ }%
+ }{%
+ \edef\dtl@textopt{left,
+ at={\noexpand\pgfpointadd
+ {\noexpand\pgfpointxy{\dtl@variable}{\@dtl@midpt}}
+ {\noexpand\pgfpoint{\noexpand\DTLbarlabeloffset}{0pt}}}
+ }%
+ }
+\fi
+ \expandafter\pgftext\expandafter[\dtl@textopt]{%
+ \DTLdisplayuppermultibarlabel{\dtl@thisupperbarlabel}}
+ \FPadd{\@dtl@start}{\@dtl@start}{1}%
+ \advance\@dtl@barcount by 1\relax
+}%
+\setlength{\dtl@tmplength}{\DTLbarlabeloffset}%
+\addtolength{\dtl@tmplength}{\dtl@xticlabelheight}%
+\ifDTLverticalbars
+ \edef\dtl@textopt{%
+ at={\noexpand\pgfpointadd
+ {\noexpand\pgfpointxy{\dtl@multimidpt}{0}}
+ {\noexpand\pgfpoint{0pt}{-\noexpand\dtl@tmplength}}},
+ \DTLbarXlabelalign
+ }%
+\else
+ \edef\dtl@textopt{%
+ at={\noexpand\pgfpointadd
+ {\noexpand\pgfpointxy{0}{\dtl@multimidpt}}
+ {\noexpand\pgfpoint{-\noexpand\dtl@tmplength}{0pt}}},
+ \DTLbarXlabelalign
+ }%
+\fi
+ \expandafter\pgftext\expandafter[\dtl@textopt]{%
+ \DTLdisplaylowerbarlabel{\dtl@barlabel}}
+ \FPadd{\@dtl@start}{\@dtl@start}{\dtlbar@groupgap}%
+}
+\ifDTLbarxaxis
+ \ifDTLverticalbars
+ \expandafter\draw\expandafter[\DTLBarXAxisStyle]
+ (0,0) -- (\DTLbarchartwidth,0);
+ \else
+ \expandafter\draw\expandafter[\DTLBarXAxisStyle]
+ (0,0) -- (0,\DTLbarchartwidth);
+ \fi
+\fi
+\ifDTLbaryaxis
+ \ifDTLverticalbars
+ \expandafter\draw\expandafter[\DTLBarYAxisStyle]
+ (0,\DTLnegextent) -- (0,\DTLbarmax);
+ \else
+ \expandafter\draw\expandafter[\DTLBarYAxisStyle]
+ (\DTLnegextent,0) -- (\DTLbarmax,0);
+ \fi
+\fi
+\ifx\dtlbar@yticlist\relax
+\else
+ \@for\dtl@thistick:=\dtlbar@yticlist\do{%
+ \ifDTLverticalbars
+ \pgfpathmoveto{\pgfpointxy{0}{\dtl@thistick}}
+ \pgfpathlineto{
+ \pgfpointadd{\pgfpointxy{0}{\dtl@thistick}}
+ {\pgfpoint{-\DTLticklength}{0pt}}}
+ \else
+ \pgfpathmoveto{\pgfpointxy{\dtl@thistick}{0}}
+ \pgfpathlineto{
+ \pgfpointadd{\pgfpointxy{\dtl@thistick}{0}}
+ {\pgfpoint{0pt}{-\DTLticklength}}}
+ \fi
+ \pgfusepath{stroke}
+ \ifx\dtlbar@yticlabels\relax
+ \FPround{\dtl@thislabel}{\dtl@thistick}
+ {\c@DTLbarroundvar}%
+ \else
+ \dtl@chopfirst\dtlbar@yticlabels\dtl@thislabel\dtl@rest
+ \let\dtlbar@yticlabels=\dtl@rest
+ \fi
+ \ifDTLverticalbars
+ \edef\dtl@textopt{\DTLbarYticklabelalign,%
+ at={\noexpand\pgfpointadd
+ {\noexpand\pgfpointxy{0}{\dtl@thistick}}
+ {\noexpand\pgfpoint{-\noexpand\DTLticklabeloffset}{0pt}},
+ }}%
+ \else
+ \edef\dtl@textopt{\DTLbarYticklabelalign,
+ at={\noexpand\pgfpointadd
+ {\noexpand\pgfpointxy{\dtl@thistick}{0}}
+ {\noexpand\pgfpoint{0pt}{-\noexpand\DTLticklabeloffset}}
+ }}%
+ \fi
+ \expandafter\pgftext\expandafter[\dtl@textopt]{%
+ \DTLbardisplayYticklabel{\dtl@thislabel}}
+ }%
+\fi
+\ifx\dtlbar@ylabel\relax
+\else
+ \addtolength{\dtl@yticlabelwidth}{\baselineskip}%
+ \setlength{\dtl@tmplength}{0.5\DTLbarchartlength}
+ \ifDTLverticalbars
+ \pgftext[bottom,center,at={\pgfpointadd
+ {\pgfpointxy{0}{\DTLnegextent}}%
+ {\pgfpoint{-\dtl@yticlabelwidth}{\dtl@tmplength}}},
+ rotate=90]{%
+ \dtlbar@ylabel}
+ \else
+ \pgftext[bottom,center,at={\pgfpointadd
+ {\pgfpointxy{\DTLnegextent}{0}}%
+ {\pgfpoint{\dtl@tmplength}{-\dtl@yticlabelwidth}}}]{%
+ \dtlbar@ylabel}
+ \fi
+\fi
+\DTLbaratendtikz
+\end{tikzpicture}
+\fi
+}}
+\endinput
+%%
+%% End of file `databar.sty'.
diff --git a/Master/texmf-dist/tex/latex/datatool/databib.sty b/Master/texmf-dist/tex/latex/datatool/databib.sty
new file mode 100644
index 00000000000..2b168d64dd4
--- /dev/null
+++ b/Master/texmf-dist/tex/latex/datatool/databib.sty
@@ -0,0 +1,1529 @@
+%%
+%% This is file `databib.sty',
+%% generated with the docstrip utility.
+%%
+%% The original source files were:
+%%
+%% datatool.dtx (with options: `databib.sty,package')
+%%
+%% datatool.dtx
+%% Copyright 2007 Nicola Talbot
+%%
+%% This work may be distributed and/or modified under the
+%% conditions of the LaTeX Project Public License, either version 1.3
+%% of this license of (at your option) any later version.
+%% The latest version of this license is in
+%% http://www.latex-project.org/lppl.txt
+%% and version 1.3 or later is part of all distributions of LaTeX
+%% version 2005/12/01 or later.
+%%
+%% This work has the LPPL maintenance status `maintained'.
+%%
+%% The Current Maintainer of this work is Nicola Talbot.
+%%
+%% This work consists of the files datatool.dtx and datatool.ins and the derived files datatool.sty, datapie.sty, dataplot.sty, databar.sty, databib.sty, databib.bst.
+%%
+%% \CharacterTable
+%% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
+%% Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
+%% Digits \0\1\2\3\4\5\6\7\8\9
+%% Exclamation \! Double quote \" Hash (number) \#
+%% Dollar \$ Percent \% Ampersand \&
+%% Acute accent \' Left paren \( Right paren \)
+%% Asterisk \* Plus \+ Comma \,
+%% Minus \- Point \. Solidus \/
+%% Colon \: Semicolon \; Less than \<
+%% Equals \= Greater than \> Question mark \?
+%% Commercial at \@ Left bracket \[ Backslash \\
+%% Right bracket \] Circumflex \^ Underscore \_
+%% Grave accent \` Left brace \{ Vertical bar \|
+%% Right brace \} Tilde \~}
+\NeedsTeXFormat{LaTeX2e}
+\ProvidesPackage{databib}[2007/08/17 v1.0 (NLCT)]
+\RequirePackage{datatool}
+\newcommand*{\dtlbib@style}{plain}
+\define@choicekey{databib.sty}{style}{plain,abbrv,alpha}{%
+\def\dtlbib@style{#1}}
+\ProcessOptionsX
+\newcommand*{\DTLloadbbl}[3][\jobname.bbl]{%
+\bibliographystyle{databib}%
+\if@filesw
+ \immediate\write\@auxout{\string\bibdata{#3}}%
+\fi
+\DTLnewdb{#2}%
+\edef\DTLBIBdbname{#2}%
+\@input@{#1}}
+\newcommand*{\DTLnewbibrow}{\DTLnewrow{\DTLBIBdbname}}
+\newcommand*{\DTLnewbibitem}[2]{%
+\DTLnewdbentry{\DTLBIBdbname}{#1}{#2}}
+\providecommand*{\andname}{and}
+\providecommand*{\ofname}{of}
+\providecommand*{\inname}{in}
+\providecommand*{\etalname}{et al.}
+\providecommand*{\editorname}{editor}
+\providecommand*{\editorsname}{editors}
+\providecommand*{\volumename}{volume}
+\providecommand*{\numbername}{number}
+\providecommand*{\pagesname}{pages}
+\providecommand*{\pagename}{page}
+\providecommand*{\editionname}{edition}
+\providecommand*{\techreportname}{Technical report}
+\providecommand*{\mscthesisname}{Master's thesis}
+\providecommand*{\phdthesisname}{PhD thesis}
+\newcommand*{\DTLbibliography}[2][\boolean{true}]{%
+\begin{DTLthebibliography}[#1]{#2}%
+\DTLforeachbibentry[#1]{#2}{%
+\DTLbibitem \DTLformatbibentry \DTLendbibitem
+}%
+\end{DTLthebibliography}%
+}
+\newcommand*{\DTLformatbibentry}{%
+\@ifundefined{DTLformat\DBIBentrytype}{%
+\PackageError{databib}{Don't know how to format bibliography entries
+of type `\DBIBentrytype'}{}}{%
+\dtl@message{[\DBIBcitekey]}%
+\DTLstartsentencefalse\DTLmidsentencefalse\DTLperiodfalse
+\csname DTLformat\DBIBentrytype\endcsname}%
+}
+\newcommand*{\DTLendbibitem}{}
+\newlength\dtl@widest
+\newcommand*{\DTLcomputewidestbibentry}[4]{%
+\dtl@widest=0pt\relax
+\let#4=\@empty
+\DTLforeachbibentry[#1]{#2}{%
+\settowidth{\dtl@tmplength}{#3}%
+\ifdim\dtl@tmplength>\dtl@widest\relax
+ \dtl@widest=\dtl@tmplength
+ \protected@edef#4{#3}%
+\fi
+}%
+}
+\newcommand*{\DTLforeachbibentry}{%
+\@ifstar\@DTLforeachbibentry\@DTLforeachbibentry}
+\newcommand*{\@DTLforeachbibentry}[3][\boolean{true}]{%
+\edef\DBIBname{#2}\setcounter{DTLbibrow}{0}%
+\@DTLforeach{#2}{\DBIBcitekey=CiteKey,\DBIBentrytype
+=EntryType}{\dtl@gathervalues{#2}{\@dtl@currentrow}%
+\ifthenelse{#1}{\refstepcounter{DTLbibrow}#3}{}}}
+\newcommand*{\@sDTLforeachbibentry}[3][\boolean{true}]{%
+\edef\DBIBname{#2}\setcounter{DTLbibrow}{0}%
+\@sDTLforeach{#2}{\DBIBcitekey=CiteKey,\DBIBentrytype
+=EntryType}{\dtl@gathervalues{#2}{\@dtl@currentrow}%
+\ifthenelse{#1}{\refstepcounter{DTLbibrow}#3}{}}}
+\newcounter{DTLbibrow}
+\def\theHDTLbibrow{\theHDTLrow.bib.\arabic{DTLbibrow}}%
+\newcommand*{\DTLbibfield}[1]{\csname @dtl@key@#1\endcsname}
+\newcommand*{\DTLifbibfieldexists}[3]{%
+\@ifundefined{@dtl@key@#1}{#3}{%
+\expandafter\DTLifnull\csname @dtl@key@#1\endcsname
+{#3}{#2}}}
+\newcommand*{\DTLifanybibfieldexists}[3]{%
+\@for\dtl@thisfield:=#1\do{%
+\@ifundefined{@dtl@key@\dtl@thisfield}{}{%
+\expandafter\DTLifnull\csname @dtl@key@\dtl@thisfield\endcsname
+{}{%
+\@endfortrue}}}%
+\if@endfor
+ #2%
+\else
+ #3%
+\fi
+\@endforfalse
+}
+\newif\ifDTLperiod
+\newcommand*{\DTLcheckendsperiod}[1]{%
+\dtl@checkendsperiod#1\@nil\relax}
+\def\dtl@checkendsperiod#1#2{%
+\def\@dtl@argi{#1}\def\@dtl@argii{#2}%
+\def\@dtl@period{.}%
+\ifx\@dtl@argi\@nnil
+ \global\DTLperiodfalse
+ \let\@dtl@donext=\relax
+\else
+ \ifx\@dtl@argii\@nnil
+ \ifx\@dtl@argi\@dtl@period
+ \global\DTLperiodtrue
+ \else
+ \global\DTLperiodfalse
+ \fi
+ \let\@dtl@donext=\@gobble
+ \else
+ \let\@dtl@donext=\dtl@checkendsperiod
+ \fi
+\fi
+\@dtl@donext{#2}%
+}
+\newcommand*{\DTLcheckbibfieldendsperiod}[1]{%
+\protected@edef\@dtl@tmp{\DTLbibfield{#1}}%
+\expandafter\DTLcheckendsperiod\expandafter{\@dtl@tmp}}
+\newif\ifDTLmidsentence
+\newif\ifDTLstartsentence
+\newcommand*{\DTLaddperiod}{\DTLmidsentencefalse\DTLperiodfalse
+\DTLstartsentencetrue
+\ifDTLperiod\else.\fi}
+\newcommand*{\DTLaddcomma}{, \DTLmidsentencetrue
+\DTLperiodfalse\DTLstartsentencefalse}
+\newcommand*{\DTLstartsentencespace}{%
+\ifDTLstartsentence\spacefactor=\sfcode`\.\relax\space
+\fi\DTLstartsentencefalse}
+\newcommand*{\DTLtwoand}{\ \andname\ }
+\newcommand*{\DTLandlast}{, \andname\ }
+\newcommand*{\DTLandnotlast}{, }
+\newcount\@dtl@authorcount
+\newcounter{DTLmaxauthors}
+\setcounter{DTLmaxauthors}{10}
+\newcommand*{\DTLformatauthorlist}{%
+\DTLifbibfieldexists{Author}{%
+\DTLstartsentencespace
+\@dtl@authorcount=0\relax
+\@for\@dtl@author:=\@dtl@key@Author\do{%
+\advance\@dtl@authorcount by 1\relax}%
+\@dtl@tmpcount=0\relax
+\ifnum\@dtl@authorcount>\c@DTLmaxauthors
+{%
+ \@for\@dtl@author:=\@dtl@key@Author\do{%
+ \advance\@dtl@tmpcount by 1\relax
+ \ifnum\@dtl@tmpcount=1\relax
+ \expandafter\DTLformatauthor\@dtl@author
+ \else
+ \ifnum\@dtl@tmpcount>\c@DTLmaxauthors
+ \DTLandnotlast \etalname
+ \expandafter\DTLcheckendsperiod\expandafter{\etalname}%
+ \@endfortrue
+ \else
+ \DTLandnotlast \expandafter\DTLformatauthor\@dtl@author
+ \fi
+ \fi
+ }%
+}%
+\else
+ \@for\@dtl@author:=\@dtl@key@Author\do{%
+ \advance\@dtl@tmpcount by 1\relax
+ \ifnum\@dtl@tmpcount=1\relax
+ \expandafter\DTLformatauthor\@dtl@author
+ \else
+ \ifnum\@dtl@tmpcount=\@dtl@authorcount
+ \ifnum\@dtl@authorcount=2\relax
+ \DTLtwoand
+ \else
+ \DTLandlast
+ \fi
+ \expandafter\DTLformatauthor\@dtl@author
+ \else
+ \DTLandnotlast \expandafter\DTLformatauthor\@dtl@author
+ \fi
+ \fi
+ }%
+\fi
+}{}%
+}
+\newcounter{DTLmaxeditors}
+\setcounter{DTLmaxeditors}{10}
+\newcommand*{\DTLformateditorlist}{%
+\DTLifbibfieldexists{Editor}{%
+\DTLstartsentencespace
+\@dtl@authorcount=0\relax
+\@for\@dtl@author:=\@dtl@key@Editor\do{%
+\advance\@dtl@authorcount by 1\relax}%
+\@dtl@tmpcount=0\relax
+\ifnum\@dtl@authorcount>\c@DTLmaxeditors
+{%
+ \@for\@dtl@author:=\@dtl@key@Editor\do{%
+ \advance\@dtl@tmpcount by 1\relax
+ \ifnum\@dtl@tmpcount=1\relax
+ \expandafter\DTLformateditor\@dtl@author
+ \else
+ \ifnum\@dtl@tmpcount>\c@DTLmaxeditors
+ \DTLandnotlast \etalname
+ \expandafter\DTLcheckendsperiod\expandafter{\etalname}%
+ \@endfortrue
+ \else
+ \DTLandnotlast \expandafter\DTLformateditor\@dtl@author
+ \fi
+ \fi
+ }%
+}%
+\else
+\@for\@dtl@author:=\@dtl@key@Editor\do{%
+ \advance\@dtl@tmpcount by 1\relax
+ \ifnum\@dtl@tmpcount=1\relax
+ \expandafter\DTLformateditor\@dtl@author
+ \else
+ \ifnum\@dtl@tmpcount=\@dtl@authorcount
+ \ifnum\@dtl@authorcount=2\relax
+ \DTLtwoand
+ \else
+ \DTLandlast
+ \fi
+ \expandafter\DTLformateditor\@dtl@author
+ \else
+ \DTLandnotlast \expandafter\DTLformateditor\@dtl@author
+ \fi
+ \fi
+ }%
+\fi
+,
+\ifnum\@dtl@authorcount=1\relax
+ \editorname
+ \expandafter\DTLcheckendsperiod\expandafter{\editorname}%
+\else
+ \editorsname
+ \expandafter\DTLcheckendsperiod\expandafter{\editorsname}%
+\fi
+}{}%
+}
+\newcommand*{\DTLformatsurnameonly}[4]{%
+\DTLstartsentencespace
+\def\@dtl@tmp{#1}%
+\ifx\@dtl@tmp\@empty\else#1~\fi
+#2%
+\def\@dtl@tmp{#3}%
+\ifx\@dtl@tmp\@empty
+ \DTLcheckendsperiod{#2}%
+\else
+ , #3%
+ \DTLcheckendsperiod{#3}%
+\fi
+}
+\newcommand*{\DTLformatforenames}[1]{%
+\DTLstartsentencespace
+#1%
+\DTLcheckendsperiod{#1}}
+\newcommand*{\DTLformatabbrvforenames}[1]{%
+\DTLstartsentencespace
+\DTLstoreinitials{#1}{\@dtl@tmp}\@dtl@tmp
+\expandafter\DTLcheckendsperiod\expandafter{\@dtl@tmp}}
+\newcommand*{\DTLformatvon}[1]{%
+\DTLstartsentencespace
+\def\@dtl@tmp{#1}%
+\ifx\@dtl@tmp\@empty
+\else
+ #1~%
+\fi
+}
+\newcommand*{\DTLformatsurname}[1]{%
+\DTLstartsentencespace
+#1\DTLcheckendsperiod{#1}}
+\newcommand*{\DTLformatjr}[1]{%
+\DTLstartsentencespace
+\def\@dtl@tmp{#1}%
+\ifx\@dtl@tmp\@empty
+\else
+ , #1\DTLcheckendsperiod{#1}%
+\fi
+}
+\newcommand*{\DTLformatcrossrefeditor}{%
+\DTLifbibfieldexists{Editor}{%
+\DTLstartsentencespace
+\@dtl@authorcount=0\relax
+\@for\@dtl@author:=\@dtl@key@Editor\do{%
+\advance\@dtl@authorcount by 1\relax}%
+{\@dtl@tmpcount=0\relax
+\@for\@dtl@author:=\@dtl@key@Editor\do{%
+\ifnum\@dtl@authorcount=1\relax
+ \expandafter\DTLformatsurnameonly\@dtl@author
+\else
+ \advance\@dtl@tmpcount by 1\relax
+ \ifnum\@dtl@tmpcount=1\relax
+ \expandafter\DTLformatsurnameonly\@dtl@author
+ \else
+ \ifnum\@dtl@authorcount=2\relax
+ \ \andname\ \expandafter\DTLformatsurnameonly\@dtl@author
+ \else
+ \ \etalname
+ \expandafter\DTLcheckendsperiod\expandafter{\etalname}
+ \fi
+ \@endfortrue
+ \fi
+\fi
+}}%
+}{}%
+}
+\newcommand*{\DTLformatvolnumpages}{%
+\DTLifbibfieldexists{Volume}{%
+\DTLstartsentencespace
+\DTLbibfield{Volume}\DTLperiodfalse}{}%
+\DTLifbibfieldexists{Number}{%
+\DTLstartsentencespace
+(\DTLbibfield{Number})\DTLperiodfalse}{}%
+\DTLifbibfieldexists{Pages}{%
+\DTLifanybibfieldexists{Volume,Number}{:}{%
+\DTLstartsentencespace
+\protected@edef\@dtl@pages{0\DTLbibfield{Pages}}%
+\DTLifnumerical{\@dtl@pages}{\pagename}{\pagesname}~}%
+\DTLbibfield{Pages}\DTLperiodfalse}{}%
+}
+\newcommand*{\DTLformatbvolume}{%
+\DTLifbibfieldexists{Volume}{%
+\ifDTLmidsentence
+ \volumename
+\else
+ \DTLstartsentencespace
+ \expandafter\MakeUppercase\volumename
+\fi
+~\DTLbibfield{Volume}%
+\DTLifbibfieldexists{Series}{\ \ofname\
+{\em\DTLbibfield{Series}}\DTLcheckbibfieldendsperiod{Series}}{%
+\DTLcheckbibfieldendsperiod{Volume}}%
+}{}}
+\newcommand*{\DTLformatchapterpages}{%
+\DTLifbibfieldexists{Chapter}{%
+\DTLifbibfieldexists{Type}{%
+\DTLstartsentencespace
+\DTLbibfield{Type}}{%
+\DTLstartsentencespace
+\chaptername}~\DTLbibfield{Chapter}%
+\DTLifbibfieldexists{Pages}{\DTLaddcomma}{%
+\DTLcheckbibfieldendsperiod{Chapter}}}{}%
+\DTLstartsentencespace
+\DTLformatpages}
+\newcommand*{\DTLformatpages}{%
+\DTLifbibfieldexists{Pages}{%
+\DTLstartsentencespace
+\protected@edef\@dtl@pages{0\DTLbibfield{Pages}}%
+\DTLifnumerical{\@dtl@pages}{\pagename}{\pagesname}~%
+\DTLbibfield{Pages}\DTLcheckbibfieldendsperiod{Pages}}{}%
+}
+\newcommand*{\DTLformatnumberseries}{%
+\DTLifbibfieldexists{Volume}{}{%
+\DTLifbibfieldexists{Number}{%
+\ifDTLmidsentence
+ \numbername
+\else
+ \DTLstartsentencespace
+ \expandafter\MakeUppercase\numbername
+\fi~\DTLbibfield{Number}%
+\DTLifbibfieldexists{Series}{\ \inname\ \DTLbibfield{Series}%
+\DTLcheckbibfieldendsperiod{Series}}{%
+\DTLcheckbibfieldendsperiod{Number}}%
+}{%
+\DTLifbibfieldexists{Series}{%
+\DTLstartsentencespace
+\DTLbibfield{Series}%
+\DTLcheckbibfieldendsperiod{Series}}{}}%
+}%
+}
+\newcommand*{\DTLformatbookcrossref}{%
+\DTLifbibfieldexists{Volume}{%
+\ifDTLmidsentence
+ \volumename
+\else
+ \DTLstartsentencespace
+ \expandafter\MakeUppercase\volumename
+\fi
+~\DTLbibfield{Volume}\ \ofname\
+}{%
+\ifDTLmidsentence
+ \inname
+\else
+ \DTLstartsentencespace
+ \expandafter\MakeUppercase\inname
+\fi\ }%
+\DTLifbibfieldexists{Editor}{\DTLformatcrossrefeditor}{%
+\DTLifbibfieldexists{Key}{%
+\DTLbibfield{Key}}{%
+\DTLifbibfieldexists{Series}{%
+{\em\DTLbibfield{Series}}}{}%
+}%
+}%
+\edef\@dtl@tmp{\DTLbibfield{CrossRef}}%
+~\cite{\@dtl@tmp}%
+}
+\newcommand*{\DTLformatincollproccrossref}{%
+\DTLifbibfieldexists{Editor}{%
+\ifDTLmidsentence
+ \inname
+\else
+ \DTLstartsentencespace
+ \expandafter\MakeUppercase\inname
+\fi\
+\DTLformatcrossrefeditor
+}{%
+\DTLifbibfieldexists{Key}{%
+\ifDTLmidsentence
+ \inname
+\else
+ \DTLstartsentencespace
+ \expandafter\MakeUppercase\inname
+\fi\ \DTLbibfield{Key}%
+}{%
+\DTLifbibfieldexists{BookTitle}{%
+\ifDTLmidsentence
+ \inname
+\else
+ \DTLstartsentencespace
+ \expandafter\MakeUppercase\inname
+\fi\ {\em\DTLbibfield{BookTitle}}}{}%
+}}%
+\edef\@dtl@tmp{\DTLbibfield{CrossRef}}%
+~\cite{\@dtl@tmp}%
+}
+\newcommand*{\DTLformatinedbooktitle}{%
+\DTLifbibfieldexists{BookTitle}{%
+\ifDTLmidsentence
+ \inname
+\else
+ \DTLstartsentencespace
+ \expandafter\MakeUppercase\inname
+\fi\
+\DTLifbibfieldexists{Editor}{%
+\DTLformateditorlist\DTLaddcomma {\em\DTLbibfield{BookTitle}}%
+\DTLcheckbibfieldendsperiod{BookTitle}%
+}{{\em\DTLbibfield{BookTitle}}%
+\DTLcheckbibfieldendsperiod{BookTitle}%
+}}{}}
+\newcommand*{\DTLformatdate}{%
+\DTLifbibfieldexists{Year}{%
+\DTLifbibfieldexists{Month}{%
+\protected@edef\@dtl@tmp{\DTLbibfield{Month}}%
+\ifDTLmidsentence
+ \@dtl@tmp
+\else
+ \DTLstartsentencespace
+ \expandafter\MakeUppercase\@dtl@tmp
+\fi\
+\DTLmidsentencefalse}{}%
+\DTLstartsentencespace
+\DTLbibfield{Year}}{%
+\DTLifbibfieldexists{Month}{%
+\protected@edef\@dtl@tmp{\DTLbibfield{Month}}%
+\ifDTLmidsentence
+ \@dtl@tmp
+\else
+ \DTLstartsentencespace
+ \expandafter\MakeUppercase\@dtl@tmp
+\fi
+\DTLcheckbibfieldendsperiod{Month}%
+}{}}}
+\newcommand*{\DTLformatarticlecrossref}{%
+\DTLifbibfieldexists{Key}{%
+\ifDTLmidsentence
+ \inname
+\else
+ \DTLstartsentencespace
+ \expandafter\MakeUppercase\inname
+\fi
+\ {\em\DTLbibfield{Key}}}{%
+\DTLifbibfieldexists{Journal}{%
+\ifDTLmidsentence
+ \inname
+\else
+ \DTLstartsentencespace
+ \expandafter\MakeUppercase\inname
+\fi
+\ {\em\DTLbibfield{Journal}}}{}}%
+\edef\@dtl@tmp{\DTLbibfield{CrossRef}}%
+~\cite{\@dtl@tmp}%
+}
+\newcommand*{\DTLbibfieldexists}[1]{%
+\TE@throw\noexpand\dtl@testbibfieldexists{#1}%
+\noexpand\if@dtl@condition}
+\newcommand*{\dtl@testbibfieldexists}[1]{%
+\DTLifbibfieldexists{#1}{\@dtl@conditiontrue}{\@dtl@conditionfalse}}
+\newcommand*{\DTLbibfieldiseq}[2]{%
+\TE@throw\noexpand\dtl@testbibfieldiseq{#1}{#2}%
+\noexpand\if@dtl@condition}
+\newcommand*{\dtl@testbibfieldiseq}[2]{%
+\DTLifbibfieldexists{#1}{%
+\expandafter\let\expandafter\@dtl@tmp\expandafter
+ =\csname @dtl@key@#1\endcsname
+\expandafter\toks@\expandafter{\@dtl@tmp}%
+\@dtl@toks{#2}%
+\edef\@dtl@docompare{\noexpand\dtlcompare{\noexpand\@dtl@tmpcount}%
+{\the\toks@}{\the\@dtl@toks}}%
+\@dtl@docompare
+\ifnum\@dtl@tmpcount=0\relax
+ \@dtl@conditiontrue
+\else
+ \@dtl@conditionfalse
+\fi
+}{%
+\@dtl@conditionfalse}%
+}
+\newcommand*{\DTLbibfieldislt}[2]{%
+\TE@throw\noexpand\dtl@testbibfieldislt{#1}{#2}%
+\noexpand\if@dtl@condition}
+\newcommand*{\dtl@testbibfieldislt}[2]{%
+\DTLifbibfieldexists{#1}{%
+\expandafter\let\expandafter\@dtl@tmp\expandafter
+ =\csname @dtl@key@#1\endcsname
+\expandafter\toks@\expandafter{\@dtl@tmp}%
+\@dtl@toks{#2}%
+\edef\@dtl@docompare{\noexpand\dtlcompare{\noexpand\@dtl@tmpcount}%
+{\the\toks@}{\the\@dtl@toks}}%
+\@dtl@docompare
+\ifnum\@dtl@tmpcount=-1\relax
+ \@dtl@conditiontrue
+\else
+ \@dtl@conditionfalse
+\fi
+}{%
+\@dtl@conditionfalse}%
+}
+\newcommand*{\DTLbibfieldisle}[2]{%
+\TE@throw\noexpand\dtl@testbibfieldisle{#1}{#2}%
+\noexpand\if@dtl@condition}
+\newcommand*{\dtl@testbibfieldisle}[2]{%
+\DTLifbibfieldexists{#1}{%
+\expandafter\let\expandafter\@dtl@tmp\expandafter
+ =\csname @dtl@key@#1\endcsname
+\expandafter\toks@\expandafter{\@dtl@tmp}%
+\@dtl@toks{#2}%
+\edef\@dtl@docompare{\noexpand\dtlcompare{\noexpand\@dtl@tmpcount}%
+{\the\toks@}{\the\@dtl@toks}}%
+\@dtl@docompare
+\ifnum\@dtl@tmpcount<1\relax
+ \@dtl@conditiontrue
+\else
+ \@dtl@conditionfalse
+\fi
+}{%
+\@dtl@conditionfalse}%
+}
+\newcommand*{\DTLbibfieldisgt}[2]{%
+\TE@throw\noexpand\dtl@testbibfieldisgt{#1}{#2}%
+\noexpand\if@dtl@condition}
+\newcommand*{\dtl@testbibfieldisgt}[2]{%
+\DTLifbibfieldexists{#1}{%
+\expandafter\let\expandafter\@dtl@tmp\expandafter
+ =\csname @dtl@key@#1\endcsname
+\expandafter\toks@\expandafter{\@dtl@tmp}%
+\@dtl@toks{#2}%
+\edef\@dtl@docompare{\noexpand\dtlcompare{\noexpand\@dtl@tmpcount}%
+{\the\toks@}{\the\@dtl@toks}}%
+\@dtl@docompare
+\ifnum\@dtl@tmpcount=1\relax
+ \@dtl@conditiontrue
+\else
+ \@dtl@conditionfalse
+\fi
+}{%
+\@dtl@conditionfalse}%
+}
+\newcommand*{\DTLbibfieldisge}[2]{%
+\TE@throw\noexpand\dtl@testbibfieldisge{#1}{#2}%
+\noexpand\if@dtl@condition}
+\newcommand*{\dtl@testbibfieldisge}[2]{%
+\DTLifbibfieldexists{#1}{%
+\expandafter\let\expandafter\@dtl@tmp\expandafter
+ =\csname @dtl@key@#1\endcsname
+\expandafter\toks@\expandafter{\@dtl@tmp}%
+\@dtl@toks{#2}%
+\edef\@dtl@docompare{\noexpand\dtlcompare{\noexpand\@dtl@tmpcount}%
+{\the\toks@}{\the\@dtl@toks}}%
+\@dtl@docompare
+\ifnum\@dtl@tmpcount>-1\relax
+ \@dtl@conditiontrue
+\else
+ \@dtl@conditionfalse
+\fi
+}{%
+\@dtl@conditionfalse}%
+}
+\newcommand*{\DTLbibfieldcontains}[2]{%
+\TE@throw\noexpand\dtl@testbibfieldcontains{#1}{#2}%
+\noexpand\if@dtl@condition}
+\newcommand*{\dtl@testbibfieldcontains}[2]{%
+\DTLifbibfieldexists{#1}{%
+\expandafter\let\expandafter\@dtl@tmp\expandafter
+ =\csname @dtl@key@#1\endcsname
+\expandafter\dtl@testifsubstring\expandafter{\@dtl@tmp}{#2}%
+}{\@dtl@conditionfalse}}
+\newenvironment{DTLthebibliography}[2][\boolean{true}]{%
+\@dtl@tmpcount=0\relax
+\@sDTLforeach[#1]{#2}{}{\advance\@dtl@tmpcount by 1\relax}%
+\begin{thebibliography}{\number\@dtl@tmpcount}
+}{\end{thebibliography}}
+\newcommand*{\DTLmonthname}[1]{%
+\dtl@monthname{#1}}
+\newcommand*{\dtl@monthname}[1]{%
+\ifcase#1%
+\or January%
+\or February%
+\or March%
+\or April%
+\or May%
+\or June%
+\or July%
+\or August%
+\or September%
+\or October%
+\or November%
+\or December%
+\fi}
+\newcommand*{\dtl@abbrvmonthname}[1]{%
+\ifcase#1%
+\or Jan.%
+\or Feb.%
+\or Mar.%
+\or Apr.%
+\or May%
+\or June%
+\or July%
+\or Aug.%
+\or Sept.%
+\or Oct.%
+\or Nov.%
+\or Dec.%
+\fi}
+\newcommand*{\DTLbibitem}{\bibitem{\DBIBcitekey}}
+\newcommand*{\DTLformatauthor}[4]{%
+\DTLformatforenames{#4}
+\DTLformatvon{#1}%
+\DTLformatsurname{#2}%
+\DTLformatjr{#3}}
+\newcommand*{\DTLformateditor}[4]{%
+\DTLformatforenames{#4}
+\DTLformatvon{#1}%
+\DTLformatsurname{#2}%
+\DTLformatjr{#3}}
+\newcommand*{\DTLformatedition}[1]{#1 \editionname}
+\newcommand{\DTLformatarticle}{}
+\newcommand{\DTLformatbook}{}
+\newcommand{\DTLformatbooklet}{}
+\newcommand{\DTLformatinbook}{}
+\newcommand{\DTLformatincollection}{}
+\newcommand{\DTLformatinproceedings}{}
+\newcommand{\DTLformatmanual}{}
+\newcommand{\DTLformatmastersthesis}{}
+\newcommand{\DTLformatmisc}{}
+\newcommand{\DTLformatphdthesis}{}
+\newcommand{\DTLformatproceedings}{}
+\newcommand{\DTLformattechreport}{}
+\newcommand{\DTLformatunpublished}{}
+\newcommand*{\DTLacmcs}{ACM Computing Surveys}
+\newcommand*{\DTLacta}{Acta Informatica}
+\newcommand*{\DTLcacm}{Communications of the ACM}
+\newcommand*{\DTLibmjrd}{IBM Journal of Research and Development}
+\newcommand*{\DTLibmsj}{IBM Systems Journal}
+\newcommand*{\DTLieeese}{IEEE Transactions on Software Engineering}
+\newcommand*{\DTLieeetc}{IEEE Transactions on Computers}
+\newcommand*{\DTLieeetcad}{IEEE Transactions on Computer-Aided Design
+of Integrated Circuits}
+\newcommand*{\DTLipl}{Information Processing Letters}
+\newcommand*{\DTLjacm}{Journal of the ACM}
+\newcommand*{\DTLjcss}{Journal of Computer and System Sciences}
+\newcommand*{\DTLscp}{Science of Computer Programming}
+\newcommand*{\DTLsicomp}{SIAM Journal on Computing}
+\newcommand*{\DTLtocs}{ACM Transactions on Computer Systems}
+\newcommand*{\DTLtods}{ACM Transactions on Database Systems}
+\newcommand*{\DTLtog}{ACM Transactions on Graphics}
+\newcommand*{\DTLtoms}{ACM Transactions on Mathematical Software}
+\newcommand*{\DTLtoois}{ACM Transactions on Office Information
+Systems}
+\newcommand*{\DTLtoplas}{ACM Transactions on Programming Languages
+and Systems}
+\newcommand*{\DTLtcs}{Theoretical Computer Science}
+\newcommand{\dtlbst@plain}{%
+\renewenvironment{DTLthebibliography}[2][\boolean{true}]{%
+\@dtl@tmpcount=0\relax
+\@sDTLforeach[##1]{##2}{}{\advance\@dtl@tmpcount by 1\relax}%
+\begin{thebibliography}{\number\@dtl@tmpcount}%
+}{\end{thebibliography}}%
+\renewcommand*{\DTLbibitem}{\bibitem{\DBIBcitekey}}%
+\renewcommand*{\DTLformatauthor}[4]{%
+\DTLformatforenames{##4}
+\DTLformatvon{##1}%
+\DTLformatsurname{##2}%
+\DTLformatjr{##3}}
+\renewcommand*{\DTLformateditor}[4]{%
+\DTLformatforenames{##4}
+\DTLformatvon{##1}%
+\DTLformatsurname{##2}%
+\DTLformatjr{##3}}
+\renewcommand*{\DTLformatedition}[1]{##1 \editionname}%
+\let\DTLmonthname\dtl@monthname
+\renewcommand*{\DTLacmcs}{ACM Computing Surveys}
+\renewcommand*{\DTLacta}{Acta Informatica}
+\renewcommand*{\DTLcacm}{Communications of the ACM}
+\renewcommand*{\DTLibmjrd}{IBM Journal of Research and Development}
+\renewcommand*{\DTLibmsj}{IBM Systems Journal}
+\renewcommand*{\DTLieeese}{IEEE Transactions on Software Engineering}
+\renewcommand*{\DTLieeetc}{IEEE Transactions on Computers}
+\renewcommand*{\DTLieeetcad}{IEEE Transactions on Computer-Aided Design
+of Integrated Circuits}
+\renewcommand*{\DTLipl}{Information Processing Letters}
+\renewcommand*{\DTLjacm}{Journal of the ACM}
+\renewcommand*{\DTLjcss}{Journal of Computer and System Sciences}
+\renewcommand*{\DTLscp}{Science of Computer Programming}
+\renewcommand*{\DTLsicomp}{SIAM Journal on Computing}
+\renewcommand*{\DTLtocs}{ACM Transactions on Computer Systems}
+\renewcommand*{\DTLtods}{ACM Transactions on Database Systems}
+\renewcommand*{\DTLtog}{ACM Transactions on Graphics}
+\renewcommand*{\DTLtoms}{ACM Transactions on Mathematical Software}
+\renewcommand*{\DTLtoois}{ACM Transactions on Office Information
+Systems}
+\renewcommand*{\DTLtoplas}{ACM Transactions on Programming Languages
+and Systems}
+\renewcommand*{\DTLtcs}{Theoretical Computer Science}
+\renewcommand*{\DTLformatarticle}{%
+\DTLformatauthorlist
+\DTLifbibfieldexists{Author}{\DTLaddperiod}{}%
+\DTLifbibfieldexists{Title}{%
+\DTLstartsentencespace\DTLbibfield{Title}%
+\DTLcheckbibfieldendsperiod{Title}%
+\DTLaddperiod}{}%
+\DTLifbibfieldexists{CrossRef}{%
+\DTLformatarticlecrossref
+\DTLifbibfieldexists{Pages}{\DTLaddcomma}{}%
+\DTLformatpages
+\DTLaddperiod
+}{% no cross ref field
+\DTLifbibfieldexists{Journal}{\DTLstartsentencespace
+{\em\DTLbibfield{Journal}}%
+\DTLcheckbibfieldendsperiod{Journal}%
+\DTLifanybibfieldexists{Number,Volume,Pages,Month,Year}{%
+\DTLaddcomma}{\DTLaddperiod}}{}%
+\DTLformatvolnumpages
+\DTLifanybibfieldexists{Volume,Number,Pages}{%
+\DTLifanybibfieldexists{Year,Month}{\DTLaddcomma}{%
+\DTLaddperiod}%
+\DTLmidsentencefalse}{}%
+\DTLformatdate
+\DTLifanybibfieldexists{Year,Month}{\DTLaddperiod}{}%
+}%
+\DTLifbibfieldexists{Note}{\DTLstartsentencespace\DTLbibfield{Note}%
+\DTLcheckbibfieldendsperiod{Note}%
+\DTLaddperiod}{}%
+}
+\renewcommand*{\DTLformatbook}{%
+\DTLifbibfieldexists{Author}{%
+\DTLformatauthorlist\DTLaddperiod
+}{\DTLformateditorlist\DTLifbibfieldexists{Editor}{%
+\DTLaddperiod}{}}%
+\DTLifbibfieldexists{Title}{\DTLstartsentencespace
+{\em\DTLbibfield{Title}}%
+\DTLcheckbibfieldendsperiod{Title}}{}%
+\DTLifbibfieldexists{CrossRef}{%
+\DTLifbibfieldexists{Title}{\DTLaddperiod}{}%
+\DTLformatbookcrossref
+\DTLifanybibfieldexists{Edition,Month,Year}{\DTLaddcomma
+}{\DTLaddperiod}%
+}{% no cross ref field
+\DTLifbibfieldexists{Title}{%
+\DTLifbibfieldexists{Volume}{\DTLaddcomma}{\DTLaddperiod}}{}%
+\DTLformatbvolume
+\DTLformatnumberseries
+\DTLifanybibfieldexists{Number,Series,Volume}{\DTLaddperiod}{}%
+\DTLifbibfieldexists{Publisher}{\DTLstartsentencespace
+\DTLbibfield{Publisher}%
+\DTLcheckbibfieldendsperiod{Publisher}%
+\DTLifbibfieldexists{Address}{\DTLaddcomma}{%
+\DTLifanybibfieldexists{Month,Year}{\DTLaddcomma
+}{\DTLaddperiod}%
+}}{}%
+\DTLifbibfieldexists{Address}{\DTLstartsentencespace
+\DTLbibfield{Address}%
+\DTLcheckbibfieldendsperiod{Address}%
+\DTLifanybibfieldexists{Month,Year}{\DTLaddcomma}{\DTLaddperiod}}{}%
+}%
+\DTLifbibfieldexists{Edition}{%
+\protected@edef\@dtl@tmp{\DTLformatedition{\DTLbibfield{Edition}}}%
+\ifDTLmidsentence
+ \@dtl@tmp
+\else
+ \DTLstartsentencespace\expandafter\MakeUppercase\@dtl@tmp
+\fi
+\expandafter\DTLcheckendsperiod\expandafter{\@dtl@tmp}%
+\DTLifanybibfieldexists{Month,Year}{\DTLaddcomma}{\DTLaddperiod}%
+}{}%
+\DTLformatdate
+\DTLifanybibfieldexists{Year,Month}{\DTLaddperiod}{}%
+\DTLifbibfieldexists{Note}{\DTLstartsentencespace
+\DTLbibfield{Note}%
+\DTLcheckbibfieldendsperiod{Note}%
+\DTLaddperiod}{}%
+}%
+\renewcommand*{\DTLformatbooklet}{%
+\DTLifbibfieldexists{Author}{%
+\DTLformatauthorlist\DTLaddperiod}{}%
+\DTLifbibfieldexists{Title}{\DTLstartsentencespace
+\DTLbibfield{Title}%
+\DTLcheckbibfieldendsperiod{Title}%
+\DTLaddperiod}{}%
+\DTLifbibfieldexists{HowPublished}{%
+\DTLstartsentencespace\DTLbibfield{HowPublished}%
+\DTLcheckbibfieldendsperiod{HowPublished}%
+\DTLifanybibfieldexists{Address,Month,Year}{\DTLaddcomma
+}{\DTLaddperiod}}{}%
+\DTLifbibfieldexists{Address}{\DTLstartsentencespace
+\DTLbibfield{Address}%
+\DTLcheckbibfieldendsperiod{Address}%
+\DTLifanybibfieldexists{Month,Year}{\DTLaddcomma}{\DTLaddperiod}}{}%
+\DTLformatdate
+\DTLifanybibfieldexists{Year,Month}{\DTLaddperiod}{}%
+\DTLifbibfieldexists{Note}{\DTLstartsentencespace\DTLbibfield{Note}%
+\DTLcheckbibfieldendsperiod{Note}%
+\DTLaddperiod}{}%
+}%
+\renewcommand*{\DTLformatinbook}{%
+\DTLifbibfieldexists{Author}{%
+\DTLformatauthorlist\DTLaddperiod}{%
+\DTLifbibfieldexists{Editor}{\DTLformateditorlist\DTLaddperiod}{}}%
+\DTLifbibfieldexists{Title}{%
+\DTLstartsentencespace
+{\em\DTLbibfield{Title}}%
+\DTLcheckbibfieldendsperiod{Title}%
+}{}%
+\DTLifbibfieldexists{CrossRef}{%
+\DTLifbibfieldexists{Title}{%
+\DTLifbibfieldexists{Chapter}{\DTLaddcomma}{\DTLaddperiod}}{}%
+\DTLformatchapterpages
+\DTLifanybibfieldexists{Chapter,Pages}{\DTLaddperiod}{}%
+\DTLformatbookcrossref
+}{% no cross ref
+\DTLifbibfieldexists{Title}{%
+\DTLifanybibfieldexists{Chapter,Volume}{\DTLaddcomma
+}{\DTLaddperiod}}{}%
+\DTLformatbvolume
+\DTLifanybibfieldexists{Volume,Series}{%
+\DTLifanybibfieldexists{Chapter,Pages}{%
+\DTLaddcomma}{\DTLaddperiod}}{}%
+\DTLformatchapterpages
+\DTLifanybibfieldexists{Chapter,Pages}{\DTLaddperiod}{}%
+\DTLifbibfieldexists{Publisher}{%
+\DTLstartsentencespace
+\DTLbibfield{Publisher}%
+\DTLcheckbibfieldendsperiod{Publisher}%
+\DTLifbibfieldexists{Address}{\DTLaddcomma}{}}{}%
+\DTLifbibfieldexists{Address}{%
+\DTLstartsentencespace
+\DTLbibfield{Address}%
+\DTLcheckbibfieldendsperiod{Address}}{}%
+}%
+\DTLifanybibfieldexists{Edition,Month,Year}{\DTLaddcomma
+}{\DTLaddperiod}%
+\DTLifbibfieldexists{Edition}{%
+\protected@edef\@dtl@tmp{\DTLformatedition{\DTLbibfield{Edition}}}%
+\ifDTLmidsentence
+ \@dtl@tmp
+\else
+ \DTLstartsentencespace
+ \expandafter\MakeUppercase\@dtl@tmp
+\fi
+\expandafter\DTLcheckendsperiod\expandafter{\@dtl@tmp}%
+\DTLifanybibfieldexists{Month,Year}{\DTLaddcomma
+}{\DTLaddperiod}%
+}{}%
+\DTLformatdate
+\DTLifanybibfieldexists{Month,Year}{\DTLaddperiod}{}%
+\DTLifbibfieldexists{Note}{%
+\DTLstartsentencespace
+\DTLbibfield{Note}%
+\DTLcheckbibfieldendsperiod{Note}%
+\DTLaddperiod}{}%
+}%
+\renewcommand*{\DTLformatincollection}{%
+\DTLifbibfieldexists{Author}{\DTLformatauthorlist\DTLaddperiod}{}%
+\DTLifbibfieldexists{Title}{%
+\DTLstartsentencespace
+\DTLbibfield{Title}%
+\DTLcheckbibfieldendsperiod{Title}%
+\DTLaddperiod}{}%
+\DTLifbibfieldexists{CrossRef}{%
+\DTLformatincollproccrossref
+\DTLifanybibfieldexists{Chapter,Pages}{\DTLaddcomma}{}%
+\DTLformatchapterpages\DTLaddperiod
+}{% no cross ref entry
+\DTLformatinedbooktitle
+\DTLifbibfieldexists{BookTitle}{%
+\DTLifanybibfieldexists{Volume,Series,Chapter,Pages,Number}{%
+\DTLaddcomma}{\DTLaddperiod}}{}%
+\DTLformatbvolume
+\DTLifbibfieldexists{Volume}{%
+\DTLifanybibfieldexists{Number,Series,Chapter,Pages}{%
+\DTLaddcomma}{\DTLaddperiod}}{}%
+\DTLformatnumberseries
+\DTLifanybibfieldexists{Number,Series}{%
+\DTLifanybibfieldexists{Chapter,Pages}{\DTLaddcomma
+}{\DTLaddperiod}}{}%
+\DTLformatchapterpages
+\DTLifanybibfieldexists{Chapter,Pages}{\DTLaddperiod}{}%
+\DTLifbibfieldexists{Publisher}{%
+\DTLstartsentencespace
+\DTLbibfield{Publisher}%
+\DTLcheckbibfieldendsperiod{Publisher}%
+\DTLifanybibfieldexists{Address,Edition,Month,Year}{%
+\DTLaddcomma}{\DTLaddperiod}}{}%
+\DTLifbibfieldexists{Address}{%
+\DTLstartsentencespace
+\DTLbibfield{Address}%
+\DTLcheckbibfieldendsperiod{Address}%
+\DTLifanybibfieldexists{Edition,Month,Year}{%
+\DTLaddcomma}{\DTLaddperiod}}{}%
+\DTLifbibfieldexists{Edition}{%
+\protected@edef\@dtl@tmp{\DTLformatedition{\DTLbibfield{Edition}}}%
+\ifDTLmidsentence
+ \@dtl@tmp
+\else
+ \DTLstartsentencespace
+ \expandafter\MakeUppercase\@dtl@tmp
+\fi
+\expandafter\DTLcheckendsperiod\expandafter{\@dtl@tmp}%
+\DTLifanybibfieldexists{Month,Year}{\DTLaddcomma
+}{\DTLaddperiod}%
+}{}%
+\DTLformatdate
+\DTLifanybibfieldexists{Month,Year}{\DTLaddperiod}{}%
+}%
+\DTLifbibfieldexists{Note}{%
+\DTLstartsentencespace
+\DTLbibfield{Note}%
+\DTLcheckbibfieldendsperiod{Note}%
+\DTLaddperiod}{}%
+}%
+\renewcommand*{\DTLformatinproceedings}{%
+\DTLifbibfieldexists{Author}{\DTLformatauthorlist
+\DTLaddperiod}{}%
+\DTLifbibfieldexists{Title}{%
+\DTLstartsentencespace
+\DTLbibfield{Title}%
+\DTLcheckbibfieldendsperiod{Title}%
+\DTLaddperiod}{}%
+\DTLifbibfieldexists{CrossRef}{%
+\DTLformatincollproccrossref
+\DTLifbibfieldexists{Pages}{\DTLaddcomma}{%
+\DTLaddperiod}%
+\DTLformatpages
+\DTLifbibfieldexists{Pages}{\DTLaddperiod}{}%
+}{% no cross ref
+\DTLformatinedbooktitle
+\DTLifbibfieldexists{BookTitle}{%
+\DTLifanybibfieldexists{Volume,Series,Pages,Number,Address,%
+Month,Year}{%
+\DTLaddcomma}{\DTLaddperiod}}{}%
+\DTLformatbvolume
+\DTLifbibfieldexists{Volume}{%
+\DTLifanybibfieldexists{Number,Series,Pages,Address,Month,Year}{%
+\DTLaddcomma}{\DTLaddperiod}}{}%
+\DTLformatnumberseries
+\DTLifanybibfieldexists{Number,Series}{%
+\DTLifanybibfieldexists{Pages,Address,Month,Year}{%
+\DTLaddcomma}{\DTLaddperiod}}{}%
+\DTLformatpages
+\DTLifbibfieldexists{Pages}{%
+\DTLifanybibfieldexists{Address,Month,Year}{%
+\DTLaddcomma}{\DTLaddperiod}}{}%
+\DTLifbibfieldexists{Address}{%
+\DTLstartsentencespace
+\DTLbibfield{Address}%
+\DTLcheckbibfieldendsperiod{Address}%
+\DTLifanybibfieldexists{Month,Year}{\DTLaddcomma}{%
+\DTLaddperiod}%
+\DTLformatdate
+\DTLifanybibfieldexists{Month,Year}{\DTLaddperiod}{}%
+\DTLifbibfieldexists{Organization}{%
+\DTLstartsentencespace
+\DTLbibfield{Organization}%
+\DTLcheckbibfieldendsperiod{Organization}%
+\DTLifbibfieldexists{Publisher}{\DTLaddcomma}{%
+\DTLaddperiod}}{}%
+\DTLifbibfieldexists{Publisher}{%
+\DTLstartsentencespace
+\DTLbibfield{Publisher}%
+\DTLcheckbibfieldendsperiod{Publisher}%
+\DTLaddperiod}{}%
+}{%
+\DTLifanybibfieldexists{Publisher,Organization}{%
+\DTLaddperiod}{}%
+\DTLifbibfieldexists{Organization}{%
+\DTLstartsentencespace
+\DTLbibfield{Organization}%
+\DTLcheckbibfieldendsperiod{Organization}%
+\DTLifanybibfieldexists{Publisher,Month,Year}{%
+\DTLaddcomma}{}}{}%
+\DTLifbibfieldexists{Publisher}{%
+\DTLstartsentencespace
+\DTLbibfield{Publisher}%
+\DTLcheckbibfieldendsperiod{Publisher}%
+\DTLifanybibfieldexists{Month,Year}{\DTLaddcomma}{%
+\DTLaddperiod}}{}%
+\DTLformatdate
+\DTLifanybibfieldexists{Month,Year}{\DTLaddperiod}{}%
+}%
+}%
+\DTLifbibfieldexists{Note}{%
+\DTLstartsentencespace
+\DTLbibfield{Note}%
+\DTLcheckbibfieldendsperiod{Note}%
+\DTLaddperiod}{}%
+}%
+\renewcommand*{\DTLformatmanual}{%
+\DTLifbibfieldexists{Author}{\DTLformatauthorlist
+\DTLaddperiod}{%
+\DTLifbibfieldexists{Organization}{%
+\DTLstartsentencespace
+\DTLbibfield{Organization}%
+\DTLcheckbibfieldendsperiod{Organization}%
+\DTLifbibfieldexists{Address}{\DTLaddcomma \DTLbibfield{Address}%
+\DTLcheckbibfieldendsperiod{Address}%
+}{}%
+\DTLaddperiod}{}%
+}%
+\DTLifbibfieldexists{Title}{%
+\DTLstartsentencespace
+{\em\DTLbibfield{Title}}%
+\DTLcheckbibfieldendsperiod{Title}%
+\DTLifbibfieldexists{Author}{%
+\DTLifanybibfieldexists{Organization,Address}{%
+\DTLaddperiod}{\DTLaddcomma}}{%
+\DTLifanybibfieldexists{Organization,Address,Edition,Month,Year}{%
+\DTLaddcomma}{\DTLaddperiod}}}{}%
+\DTLifbibfieldexists{Author}{%
+\DTLifbibfieldexists{Organization}{%
+\DTLstartsentencespace
+\DTLbibfield{Organization}%
+\DTLcheckbibfieldendsperiod{Organization}%
+\DTLifanybibfieldexists{Address,Edition,Month,Year}{%
+\DTLaddcomma}{\DTLaddperiod}}{}%
+\DTLifbibfieldexists{Address}{%
+\DTLstartsentencespace
+\DTLbibfield{Address}%
+\DTLcheckbibfieldendsperiod{Address}%
+\DTLifanybibfieldexists{Edition,Month,Year}{%
+\DTLaddcomma}{\DTLaddperiod}}{}%
+}{%
+\DTLifbibfieldexists{Organization}{}{%
+\DTLifbibfieldexists{Address}{%
+\DTLstartsentencespace
+\DTLbibfield{Address}%
+\DTLcheckbibfieldendsperiod{Address}%
+\DTLifanybibfieldexists{Edition,Month,Year}{\DTLaddcomma}{%
+\DTLaddperiod}}{}}%
+}%
+\DTLifbibfieldexists{Edition}{%
+\protected@edef\@dtl@tmp{\DTLformatedition{\DTLbibfield{Edition}}}%
+\ifDTLmidsentence
+ \@dtl@tmp
+\else
+ \DTLstartsentencespace
+ \expandafter\MakeUppercase\@dtl@tmp
+\fi
+\expandafter\DTLcheckendsperiod\expandafter{\@dtl@tmp}%
+\DTLifanybibfieldexists{Month,Year}{\DTLaddcomma}{%
+\DTLaddperiod}}{}%
+\DTLformatdate
+\DTLifanybibfieldexists{Month,Year}{\DTLaddperiod}{}%
+\DTLifbibfieldexists{Note}{%
+\DTLstartsentencespace
+\DTLbibfield{Note}%
+\DTLcheckbibfieldendsperiod{Note}%
+\DTLaddperiod}{}%
+}%
+\renewcommand*{\DTLformatmastersthesis}{%
+\DTLifbibfieldexists{Author}{\DTLformatauthorlist\DTLaddperiod}{}%
+\DTLifbibfieldexists{Title}{%
+\DTLstartsentencespace
+\DTLbibfield{Title}%
+\DTLcheckbibfieldendsperiod{Title}%
+\DTLaddperiod}{}%
+\DTLifbibfieldexists{Type}{%
+\DTLstartsentencespace
+\DTLbibfield{Type}%
+\DTLcheckbibfieldendsperiod{Type}%
+\DTLifanybibfieldexists{School,Address,Month,Year}{%
+\DTLaddcomma}{\DTLaddperiod}}{}%
+\DTLifbibfieldexists{School}{%
+\DTLstartsentencespace
+\DTLbibfield{School}%
+\DTLcheckbibfieldendsperiod{School}%
+\DTLifanybibfieldexists{Address,Month,Year}{%
+\DTLaddcomma}{\DTLaddperiod}}{}%
+\DTLifbibfieldexists{Address}{%
+\DTLstartsentencespace
+\DTLbibfield{Address}%
+\DTLcheckbibfieldendsperiod{Address}%
+\DTLifanybibfieldexists{Month,Year}{%
+\DTLaddcomma}{\DTLaddperiod}}{}%
+\DTLformatdate
+\DTLifanybibfieldexists{Month,Year}{\DTLaddperiod}{}%
+\DTLifbibfieldexists{Note}{%
+\DTLstartsentencespace
+\DTLbibfield{Note}%
+\DTLcheckbibfieldendsperiod{Note}%
+\DTLaddperiod}{}%
+}%
+\renewcommand*{\DTLformatmisc}{%
+\DTLifbibfieldexists{Author}{\DTLformatauthorlist\DTLaddperiod}{}%
+\DTLifbibfieldexists{Title}{%
+\DTLstartsentencespace
+\DTLbibfield{Title}%
+\DTLcheckbibfieldendsperiod{Title}%
+\DTLifbibfieldexists{HowPublished}{\DTLaddperiod}{%
+\DTLifanybibfieldexists{Month,Year}{\DTLaddcomma}{%
+\DTLaddperiod}%
+}%
+\DTLmidsentencefalse}{}%
+\DTLifbibfieldexists{HowPublished}{%
+\DTLstartsentencespace
+\DTLbibfield{HowPublished}%
+\DTLcheckbibfieldendsperiod{HowPublished}%
+\DTLifanybibfieldexists{Month,Year}{\DTLaddcomma}{%
+\DTLaddperiod}}{}%
+\DTLformatdate
+\DTLifanybibfieldexists{Month,Year}{\DTLaddperiod}{}%
+\DTLifbibfieldexists{Note}{%
+\DTLstartsentencespace
+\DTLbibfield{Note}%
+\DTLcheckbibfieldendsperiod{Note}%
+\DTLaddperiod}{}%
+}%
+\renewcommand*{\DTLformatphdthesis}{%
+\DTLifbibfieldexists{Author}{\DTLformatauthorlist\DTLaddperiod}{}%
+\DTLifbibfieldexists{Title}{%
+\DTLstartsentencespace
+{\em\DTLbibfield{Title}}%
+\DTLcheckbibfieldendsperiod{Title}%
+\DTLaddperiod}{}%
+\DTLifbibfieldexists{Type}{%
+\DTLstartsentencespace
+\DTLbibfield{Type}%
+\DTLcheckbibfieldendsperiod{Type}%
+\DTLifanybibfieldexists{School,Address,Month,Year}{%
+\DTLaddcomma}{\DTLaddperiod}}{}%
+\DTLifbibfieldexists{School}{%
+\DTLstartsentencespace
+\DTLbibfield{School}%
+\DTLcheckbibfieldendsperiod{School}%
+\DTLifanybibfieldexists{Address,Month,Year}{%
+\DTLaddcomma}{\DTLaddperiod}}{}%
+\DTLifbibfieldexists{Address}{%
+\DTLstartsentencespace
+\DTLbibfield{Address}%
+\DTLcheckbibfieldendsperiod{Address}%
+\DTLifanybibfieldexists{Month,Year}{%
+\DTLaddcomma}{\DTLaddperiod}}{}%
+\DTLformatdate
+\DTLifanybibfieldexists{Month,Year}{\DTLaddperiod}{}%
+\DTLifbibfieldexists{Note}{%
+\DTLstartsentencespace
+\DTLbibfield{Note}%
+\DTLcheckbibfieldendsperiod{Note}%
+\DTLaddperiod}{}%
+}%
+\renewcommand*{\DTLformatproceedings}{%
+\DTLifbibfieldexists{Editor}{%
+\DTLformateditorlist\DTLaddperiod}{%
+\DTLifbibfieldexists{Organization}{%
+\DTLstartsentencespace
+\DTLbibfield{Organization}%
+\DTLcheckbibfieldendsperiod{Organization}%
+\DTLaddperiod}{}}%
+\DTLifbibfieldexists{Title}{%
+\DTLstartsentencespace
+{\em\DTLbibfield{Title}}%
+\DTLcheckbibfieldendsperiod{Title}%
+\DTLifanybibfieldexists{Volume,Number,Address,Editor,Publisher,%
+Month,Year}{\DTLaddcomma}{\DTLaddperiod}%
+}{}%
+\DTLformatbvolume
+\DTLifbibfieldexists{Volume}{%
+\DTLifanybibfieldexists{Number,Address,Editor,Publisher,%
+Month,Year}{\DTLaddcomma}{\DTLaddperiod}}{}%
+\DTLformatnumberseries
+\DTLifbibfieldexists{Number}{%
+\DTLifanybibfieldexists{Address,Editor,Publisher,%
+Month,Year}{\DTLaddcomma}{\DTLaddperiod}}{}%
+\DTLifbibfieldexists{Address}{%
+\DTLstartsentencespace
+\DTLbibfield{Address}%
+\DTLcheckbibfieldendsperiod{Address}%
+\DTLifanybibfieldexists{Month,Year}{\DTLaddcomma}{\DTLaddperiod}%
+\DTLformatdate
+\DTLifanybibfieldexists{Month,Year}{\DTLaddperiod}{}%
+\DTLifbibfieldexists{Editor}{\DTLifbibfieldexists{Organization}{%
+\DTLstartsentencespace
+\DTLbibfield{Organization}%
+\DTLcheckbibfieldendsperiod{Organization}%
+\DTLifbibfieldexists{Publisher}{%
+\DTLaddcomma}{\DTLaddperiod}}{}}{}%
+\DTLifbibfieldexists{Publisher}{%
+\DTLstartsentencespace
+\DTLbibfield{Publisher}%
+\DTLcheckbibfieldendsperiod{Publisher}%
+\DTLaddperiod
+}{}%
+}{% no address
+\DTLifbibfieldexists{Editor}{%
+\DTLifbibfieldexists{Organization}{%
+\DTLstartsentencespace
+\DTLbibfield{Organization}%
+\DTLcheckbibfieldendsperiod{Organization}%
+\DTLifanybibfieldexists{Publisher,Month,Year}{%
+\DTLaddcomma}{\DTLaddperiod}}{}%
+}{}%
+\DTLifbibfieldexists{Publisher}{%
+\DTLstartsentencespace
+\DTLbibfield{Publisher}%
+\DTLcheckbibfieldendsperiod{Publisher}%
+\DTLifanybibfieldexists{Month,Year}{\DTLaddcomma}{\DTLaddperiod}}{}%
+\DTLformatdate
+\DTLifanybibfieldexists{Month,Year}{\DTLaddperiod}{}%
+}%
+\DTLifbibfieldexists{Note}{%
+\DTLstartsentencespace
+\DTLbibfield{Note}%
+\DTLcheckbibfieldendsperiod{Note}%
+\DTLaddperiod}{}%
+}%
+\renewcommand*{\DTLformattechreport}{%
+\DTLifbibfieldexists{Author}{\DTLformatauthorlist\DTLaddperiod}{}%
+\DTLifbibfieldexists{Title}{%
+\DTLstartsentencespace
+\DTLbibfield{Title}%
+\DTLcheckbibfieldendsperiod{Title}%
+\DTLaddperiod}{}%
+\DTLifbibfieldexists{Type}{%
+\DTLstartsentencespace
+\DTLbibfield{Type}%
+\DTLcheckbibfieldendsperiod{Type}%
+\DTLifbibfieldexists{Number}{~}{}}{}%
+\DTLifbibfieldexists{Number}{%
+\DTLstartsentencespace
+\DTLbibfield{Number}%
+\DTLcheckbibfieldendsperiod{Number}%
+}{}%
+\DTLifanybibfieldexists{Type,Number}{%
+\DTLifanybibfieldexists{Institution,Address,Month,Year}{\DTLaddcomma
+}{\DTLaddperiod}}{}%
+\DTLifbibfieldexists{Institution}{%
+\DTLstartsentencespace
+\DTLbibfield{Institution}%
+\DTLcheckbibfieldendsperiod{Institution}%
+\DTLifanybibfieldexists{Address,Month,Year}{\DTLaddcomma
+}{\DTLaddperiod}}{}%
+\DTLifbibfieldexists{Address}{%
+\DTLstartsentencespace
+\DTLbibfield{Address}%
+\DTLcheckbibfieldendsperiod{Address}%
+\DTLifanybibfieldexists{Month,Year}{\DTLaddcomma
+}{\DTLaddperiod}}{}%
+\DTLformatdate
+\DTLifanybibfieldexists{Month,Year}{\DTLaddperiod}{}%
+\DTLifbibfieldexists{Note}{%
+\DTLstartsentencespace
+\DTLbibfield{Note}%
+\DTLcheckbibfieldendsperiod{Note}%
+\DTLaddperiod}{}%
+}%
+\renewcommand*{\DTLformatunpublished}{%
+\DTLifbibfieldexists{Author}{\DTLformatauthorlist\DTLaddperiod}{}%
+\DTLifbibfieldexists{Title}{%
+\DTLstartsentencespace
+\DTLbibfield{Title}%
+\DTLcheckbibfieldendsperiod{Title}%
+\DTLaddperiod}{}%
+\DTLifbibfieldexists{Note}{%
+\DTLstartsentencespace
+\DTLbibfield{Note}%
+\DTLcheckbibfieldendsperiod{Note}%
+\DTLifanybibfieldexists{Month,Year}{\DTLaddcomma}{\DTLaddperiod}}{}%
+\DTLformatdate
+\DTLifanybibfieldexists{Month,Year}{\DTLaddperiod}{}%
+}%
+}
+\newcommand{\dtlbst@abbrv}{%
+\dtlbst@plain
+\renewcommand*{\DTLformatauthor}[4]{%
+\DTLformatabbrvforenames{##4}
+\DTLformatvon{##1}%
+\DTLformatsurname{##2}%
+\DTLformatjr{##3}}
+\renewcommand*{\DTLformateditor}[4]{%
+\DTLformatabbrvforenames{##4}
+\DTLformatvon{##1}%
+\DTLformatsurname{##2}%
+\DTLformatjr{##3}}
+\let\DTLmonthname\dtl@abbrvmonthname
+\renewcommand*{\DTLacmcs}{ACM Comput.\ Surv.}
+\renewcommand*{\DTLacta}{Acta Inf.}
+\renewcommand*{\DTLcacm}{Commun.\ ACM}
+\renewcommand*{\DTLibmjrd}{IBM J.\ Res.\ Dev.}
+\renewcommand*{\DTLibmsj}{IBM Syst.~J.}
+\renewcommand*{\DTLieeese}{IEEE Trans. Softw.\ Eng.}
+\renewcommand*{\DTLieeetc}{IEEE Trans.\ Comput.}
+\renewcommand*{\DTLieeetcad}{IEEE Trans.\ Comput.-Aided Design
+Integrated Circuits}
+\renewcommand*{\DTLipl}{Inf.\ Process.\ Lett.}
+\renewcommand*{\DTLjacm}{J.~ACM}
+\renewcommand*{\DTLjcss}{J.~Comput.\ Syst.\ Sci.}
+\renewcommand*{\DTLscp}{Sci.\ Comput.\ Programming}
+\renewcommand*{\DTLsicomp}{SIAM J.~Comput.}
+\renewcommand*{\DTLtocs}{ACM Trans.\ Comput.\ Syst.}
+\renewcommand*{\DTLtods}{ACM Trans.\ Database Syst.}
+\renewcommand*{\DTLtog}{ACM Trans.\ Gr.}
+\renewcommand*{\DTLtoms}{ACM Trans.\ Math. Softw.}
+\renewcommand*{\DTLtoois}{ACM Trans. Office Inf.\ Syst.}
+\renewcommand*{\DTLtoplas}{ACM Trans.\ Prog. Lang.\ Syst.}
+\renewcommand*{\DTLtcs}{Theoretical Comput.\ Sci.}
+}
+\newcommand{\dtlbst@alpha}{%
+\dtlbst@plain
+\renewenvironment{DTLthebibliography}[2][\boolean{true}]{%
+\dtl@createalphabiblabels{##1}{##2}%
+\begin{thebibliography}{\@dtl@widestlabel}%
+}{\end{thebibliography}}%
+\renewcommand*{\DTLbibitem}{%
+\expandafter\bibitem\expandafter
+ [\csname dtl@biblabel@\DBIBcitekey\endcsname]{\DBIBcitekey}}%
+}
+\newcommand*{\dtl@createalphabiblabels}[2]{%
+\dtl@message{Creating bib labels}%
+\begingroup
+\gdef\@dtl@widestlabel{}%
+\dtl@widest=0pt\relax
+\DTLforeachbibentry[#1]{#2}{%
+\dtl@message{\DBIBcitekey}%
+\DTLifbibfieldexists{Author}{%
+ \dtl@listgetalphalabel{\@dtl@thislabel}{\@dtl@key@Author}%
+}{%
+\DTLifbibfieldexists{Editor}{%
+ \dtl@listgetalphalabel{\@dtl@thislabel}{\@dtl@key@Editor}%
+ }{%
+ \DTLifbibfieldexists{Key}{%
+ \expandafter\dtl@get@firstthree\expandafter
+ {\@dtl@key@Key}{\@dtl@thislabel}%
+ }{%
+ \DTLifbibfieldexists{Organization}{%
+ \expandafter\dtl@get@firstthree\expandafter
+ {\@dtl@key@Organization}{\@dtl@thislabel}%
+ }{%
+ \expandafter\dtl@get@firstthree\expandafter
+ {\DBIBentrytype}{\@dtl@thislabel}%
+ }%
+ }}}%
+\DTLifbibfieldexists{Year}{}{\DTLifbibfieldexists{CrossRef}{%
+\DTLgetvalueforkey{\@dtl@key@Year}{Year}{#2}{CiteKey}{%
+\@dtl@key@CrossRef}}{}}%
+\DTLifbibfieldexists{Year}{%
+\expandafter\dtl@get@yearsuffix\expandafter{\@dtl@key@Year}%
+\expandafter\toks@\expandafter{\@dtl@thislabel}%
+\expandafter\@dtl@toks\expandafter{\@dtl@year}%
+\edef\@dtl@thislabel{\the\toks@\the\@dtl@toks}%
+}{}%
+\let\@dtl@s@thislabel=\@dtl@thislabel
+\@onelevel@sanitize\@dtl@s@thislabel
+\@ifundefined{c@biblabel@\@dtl@s@thislabel}{%
+\newcounter{biblabel@\@dtl@s@thislabel}%
+\setcounter{biblabel@\@dtl@s@thislabel}{1}%
+\expandafter\edef\csname @dtl@bibfirst@\@dtl@s@thislabel\endcsname{%
+\DBIBcitekey}%
+\expandafter\global
+\expandafter\let\csname dtl@biblabel@\DBIBcitekey\endcsname=
+ \@dtl@thislabel
+}{%
+\expandafter\ifnum\csname c@biblabel@\@dtl@s@thislabel\endcsname=1\relax
+ \expandafter\let\expandafter\@dtl@tmp
+ \csname @dtl@bibfirst@\@dtl@s@thislabel\endcsname
+ \expandafter\protected@xdef\csname dtl@biblabel@\@dtl@tmp\endcsname{%
+ \@dtl@thislabel a}%
+\fi
+\stepcounter{biblabel@\@dtl@s@thislabel}%
+\expandafter\protected@xdef\csname dtl@biblabel@\DBIBcitekey\endcsname{%
+ \@dtl@thislabel\alph{biblabel@\@dtl@s@thislabel}}%
+}%
+\settowidth{\dtl@tmplength}{%
+ \csname dtl@biblabel@\DBIBcitekey\endcsname}%
+\ifdim\dtl@tmplength>\dtl@widest
+ \dtl@widest=\dtl@tmplength
+ \expandafter\global\expandafter\let\expandafter\@dtl@widestlabel
+ \expandafter=\csname dtl@biblabel@\DBIBcitekey\endcsname
+\fi
+}%
+\endgroup
+}
+\newcommand*{\dtl@listgetalphalabel}[2]{%
+\@dtl@authorcount=0\relax
+\@for\@dtl@author:=#2\do{%
+\advance\@dtl@authorcount by 1\relax}%
+\ifnum\@dtl@authorcount=1\relax
+ \expandafter\dtl@getsinglealphalabel#2{#1}\relax
+\else
+ {%
+ \xdef#1{}%
+ \@dtl@tmpcount=0\relax
+ \def\DTLafterinitials{}\def\DTLbetweeninitials{}%
+ \def\DTLafterinitialbeforehyphen{}\def\DTLinitialhyphen{}%
+ \@for\@dtl@author:=#2\do{%
+ \expandafter\dtl@getauthorinitial\@dtl@author
+ \expandafter\toks@\expandafter{\@dtl@tmp}%
+ \expandafter\@dtl@toks\expandafter{#1}%
+ \xdef#1{\the\@dtl@toks\the\toks@}%
+ \advance\@dtl@tmpcount by 1\relax
+ \ifnum\@dtl@tmpcount>2\relax\@endfortrue\fi
+ }}%
+\fi
+}
+\newcommand*{\dtl@getauthorinitial}[4]{%
+\def\@dtl@vonpart{#1}%
+\ifx\@dtl@vonpart\@empty
+ \DTLstoreinitials{#2}{\@dtl@tmp}%
+\else
+ \DTLstoreinitials{#1 #2}{\@dtl@tmp}%
+\fi}
+\newcommand*{\dtl@getsinglealphalabel}[5]{%
+\def\@dtl@vonpart{#1}%
+\ifx\@dtl@vonpart\@empty
+ \DTLifSubString{#2}{-}{%
+ {\def\DTLafterinitials{}\def\DTLbetweeninitials{}%
+ \def\DTLafterinitialbeforehyphen{}%
+ \def\DTLinitialhyphen{}%
+ \DTLstoreinitials{#2}{\@dtl@tmp}\global\let#5=\@dtl@tmp}%
+ }{%
+ \dtl@getfirstthree{#5}#2{}{}{}{}\@nil
+ }
+\else
+ {\def\DTLafterinitials{}\def\DTLbetweeninitials{}%
+ \def\DTLafterinitialbeforehyphen{}%
+ \def\DTLinitialhyphen{}%
+ \DTLstoreinitials{#1 #2}{\@dtl@tmp}\global\let#5=\@dtl@tmp}%
+\fi
+}
+\def\dtl@getfirstthree#1#2#3#4#5\@nil{%
+ \def#1{#2#3#4}%
+}
+\newcommand*{\dtl@get@firstthree}[2]{%
+\dtl@getfirstthree#2#1{}{}{}{}{}\@nil}
+\newcommand*{\dtl@get@yearsuffix}[1]{%
+\dtl@getyearsuffix#1\@nil\relax\relax}
+
+\def\dtl@getyearsuffix#1#2#3{%
+\def\@dtl@argi{#1}\def\@dtl@argii{#2}%
+\def\@dtl@argiii{#3}%
+\ifx\@dtl@argi\@nnil
+ \def\@dtl@year{}%
+ \let\@dtl@donext=\relax
+\else
+ \ifx\@dtl@argii\@nnil
+ \dtl@ifsingle{#1}{%
+ \def\@dtl@year{#1}%
+ \let\@dtl@donext=\relax
+ }{%
+ \def\@dtl@donext{\dtl@getyearsuffix#1#2#3}%
+ }%
+ \else
+ \ifx\@dtl@argiii\@nnil
+ \dtl@ifsingle{#1}{%
+ \dtl@ifsingle{#2}{%
+ \def\@dtl@year{#1#2}%
+ \let\@dtl@donext=\relax
+ }{%
+ \def\@dtl@donext{\dtl@getyearsuffix#2#3}%
+ }%
+ }{%
+ \def\@dtl@donext{\dtl@getyearsuffix#2#3}%
+ }%
+ \else
+ \def\@dtl@donext{\dtl@getyearsuffix{#2}{#3}}%
+ \fi
+ \fi
+\fi
+\@dtl@donext
+}
+\newcommand*{\DTLbibliographystyle}[1]{%
+\@ifundefined{dtlbst@#1}{\PackageError{databib}{Unknown
+bibliography style `#1'}{}}{\csname dtlbst@#1\endcsname}}
+\DTLbibliographystyle{\dtlbib@style}
+\endinput
+%%
+%% End of file `databib.sty'.
diff --git a/Master/texmf-dist/tex/latex/datatool/datapie.sty b/Master/texmf-dist/tex/latex/datatool/datapie.sty
new file mode 100644
index 00000000000..418f8a045a2
--- /dev/null
+++ b/Master/texmf-dist/tex/latex/datatool/datapie.sty
@@ -0,0 +1,351 @@
+%%
+%% This is file `datapie.sty',
+%% generated with the docstrip utility.
+%%
+%% The original source files were:
+%%
+%% datatool.dtx (with options: `datapie.sty,package')
+%%
+%% datatool.dtx
+%% Copyright 2007 Nicola Talbot
+%%
+%% This work may be distributed and/or modified under the
+%% conditions of the LaTeX Project Public License, either version 1.3
+%% of this license of (at your option) any later version.
+%% The latest version of this license is in
+%% http://www.latex-project.org/lppl.txt
+%% and version 1.3 or later is part of all distributions of LaTeX
+%% version 2005/12/01 or later.
+%%
+%% This work has the LPPL maintenance status `maintained'.
+%%
+%% The Current Maintainer of this work is Nicola Talbot.
+%%
+%% This work consists of the files datatool.dtx and datatool.ins and the derived files datatool.sty, datapie.sty, dataplot.sty, databar.sty, databib.sty, databib.bst.
+%%
+%% \CharacterTable
+%% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
+%% Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
+%% Digits \0\1\2\3\4\5\6\7\8\9
+%% Exclamation \! Double quote \" Hash (number) \#
+%% Dollar \$ Percent \% Ampersand \&
+%% Acute accent \' Left paren \( Right paren \)
+%% Asterisk \* Plus \+ Comma \,
+%% Minus \- Point \. Solidus \/
+%% Colon \: Semicolon \; Less than \<
+%% Equals \= Greater than \> Question mark \?
+%% Commercial at \@ Left bracket \[ Backslash \\
+%% Right bracket \] Circumflex \^ Underscore \_
+%% Grave accent \` Left brace \{ Vertical bar \|
+%% Right brace \} Tilde \~}
+\NeedsTeXFormat{LaTeX2e}
+\ProvidesPackage{datapie}[2007/08/17 v1.01 (NLCT)]
+\RequirePackage{xkeyval}
+\newif\ifDTLcolorpiechart
+\DTLcolorpiecharttrue
+\DeclareOption{color}{\DTLcolorpiecharttrue}
+\DeclareOption{gray}{\DTLcolorpiechartfalse}
+\define@boolkey{datapie}[DTL]{rotateinner}[true]{}
+\define@boolkey{datapie}[DTL]{rotateouter}[true]{}
+\DTLrotateinnerfalse
+\DTLrotateouterfalse
+\DeclareOption{rotateinner}{\DTLrotateinnertrue}
+\DeclareOption{norotateinner}{\DTLrotateinnerfalse}
+\DeclareOption{rotateouter}{\DTLrotateoutertrue}
+\DeclareOption{norotateouter}{\DTLrotateouterfalse}
+\ProcessOptions
+\RequirePackage{datatool}
+\RequirePackage{tikz}
+\newlength\DTLradius
+\DTLradius=2cm
+\newcommand*{\DTLinnerratio}{0.5}
+\newcommand*{\DTLouterratio}{1.25}
+\newcommand*\DTLcutawayratio{0.2}
+\newcommand*{\DTLstartangle}{0}
+\newlength\dtl@inneroffset
+\dtl@inneroffset=\DTLinnerratio\DTLradius
+\newlength\dtl@outeroffset
+\dtl@outeroffset=\DTLouterratio\DTLradius
+\newlength\dtl@cutawayoffset
+\dtl@cutawayoffset=\DTLcutawayratio\DTLradius
+\newcommand*{\dtl@piecutaways}{}
+\def\dtl@innerlabel{\DTLpievariable}%
+\def\dtl@outerlabel{}%
+\newcounter{DTLpieroundvar}
+\setcounter{DTLpieroundvar}{1}
+\newcommand*{\DTLdisplayinnerlabel}[1]{#1}
+\newcommand*{\DTLdisplayouterlabel}[1]{#1}
+\newcommand*{\DTLpiepercent}{%
+\ifnum\dtlforeachlevel=0\relax
+ \PackageError{datapie}{Can't use
+ \string\DTLpiepercent\space outside
+ \string\DTLpiechart}{}%
+\else
+ \csname dtl@piepercent@\romannumeral\@dtl@seg\endcsname
+\fi}
+\newcommand*{\DTLpieatbegintikz}{}
+\newcommand*{\DTLpieatendtikz}{}
+\newcommand*{\DTLsetpiesegmentcolor}[2]{%
+\expandafter\def\csname dtlpie@segcol\romannumeral#1\endcsname{#2}%
+}
+\newcommand*{\DTLgetpiesegmentcolor}[1]{%
+\csname dtlpie@segcol\romannumeral#1\endcsname}
+\newcommand*{\DTLdopiesegmentcolor}[1]{%
+\expandafter\color\expandafter
+{\csname dtlpie@segcol\romannumeral#1\endcsname}}
+\newcommand*{\DTLdocurrentpiesegmentcolor}{%
+\ifnum\dtlforeachlevel=0\relax
+ \PackageError{datapie}{Can't use
+ \string\DTLdocurrentpiesegmentcolor\space outside
+ \string\DTLpiechart}{}%
+\else
+ \expandafter\DTLdopiesegmentcolor\expandafter{%
+ \csname c@DTLrow\romannumeral\dtlforeachlevel\endcsname}%
+\fi}
+\newcommand*{\DTLpieoutlinecolor}{black}
+\newlength\DTLpieoutlinewidth
+\DTLpieoutlinewidth=0pt
+\ifDTLcolorpiechart
+ \DTLsetpiesegmentcolor{1}{red}
+ \DTLsetpiesegmentcolor{2}{green}
+ \DTLsetpiesegmentcolor{3}{blue}
+ \DTLsetpiesegmentcolor{4}{yellow}
+ \DTLsetpiesegmentcolor{5}{magenta}
+ \DTLsetpiesegmentcolor{6}{cyan}
+ \DTLsetpiesegmentcolor{7}{orange}
+ \DTLsetpiesegmentcolor{8}{white}
+\else
+ \DTLsetpiesegmentcolor{1}{black!15}
+ \DTLsetpiesegmentcolor{2}{black!25}
+ \DTLsetpiesegmentcolor{3}{black!35}
+ \DTLsetpiesegmentcolor{4}{black!45}
+ \DTLsetpiesegmentcolor{5}{black!55}
+ \DTLsetpiesegmentcolor{6}{black!65}
+ \DTLsetpiesegmentcolor{7}{black!75}
+ \DTLsetpiesegmentcolor{8}{black!85}
+\fi
+\define@key{datapie}{start}{\def\DTLstartangle{#1}}
+\define@key{datapie}{radius}{\DTLradius=#1\relax
+\dtl@inneroffset=\DTLinnerratio\DTLradius
+\dtl@outeroffset=\DTLouterratio\DTLradius
+\dtl@cutawayoffset=\DTLcutawayratio\DTLradius}
+\define@key{datapie}{innerratio}{%
+\def\DTLinnerratio{#1}%
+\dtl@inneroffset=\DTLinnerratio\DTLradius}
+\define@key{datapie}{outerratio}{%
+\def\DTLouterratio{#1}%
+\dtl@outeroffset=\DTLouterratio\DTLradius}
+\define@key{datapie}{cutawayratio}{%
+\def\DTLcutawayratio{#1}%
+\dtl@cutawayoffset=\DTLcutawayratio\DTLradius}
+\define@key{datapie}{inneroffset}{%
+\dtl@inneroffset=#1}
+\define@key{datapie}{outeroffset}{%
+\dtl@outeroffset=#1}
+\define@key{datapie}{cutawayoffset}{%
+\dtl@cutawayoffset=#1}
+\define@key{datapie}{cutaway}{%
+\renewcommand*{\dtl@piecutaways}{#1}}
+\define@key{datapie}{variable}{%
+\def\DTLpievariable{#1}}
+\define@key{datapie}{innerlabel}{%
+\def\dtl@innerlabel{#1}}
+\define@key{datapie}{outerlabel}{%
+\def\dtl@outerlabel{#1}}
+\newcommand*{\DTLpiechart}[4][\boolean{true}]{%
+{\let\DTLpievariable=\relax
+\setkeys{datapie}{#2}%
+\ifx\DTLpievariable\relax
+ \PackageError{datapie}{\string\DTLpiechart\space missing variable}{}%
+\else
+\def\dtl@total{0}%
+\@sDTLforeach[#1]{#3}{#4}{%
+\let\dtl@oldtotal=\dtl@total
+\expandafter\DTLconverttodecimal\expandafter
+ {\DTLpievariable}{\dtl@variable}%
+\FPadd{\dtl@total}{\dtl@variable}{\dtl@total}%
+}%
+\expandafter\DTLconverttodecimal\expandafter
+ {\DTLstartangle}{\@dtl@start}%
+\@sDTLforeach[#1]{#3}{#4}{%
+\expandafter\DTLconverttodecimal\expandafter
+ {\DTLpievariable}{\dtl@variable}%
+\dtl@computeangles{%
+\csname c@DTLrow\romannumeral\dtlforeachlevel\endcsname}{%
+\dtl@variable}%
+\expandafter\@dtl@seg\expandafter=
+\csname c@DTLrow\romannumeral\dtlforeachlevel\endcsname%
+\FPmul{\dtl@tmp}{\dtl@variable}{100}%
+\let\dtl@old=\dtl@tmp
+\FPdiv{\dtl@tmp}{\dtl@old}{\dtl@total}%
+\expandafter\FPround
+\csname dtl@piepercent@\romannumeral\@dtl@seg\endcsname\dtl@tmp
+\c@DTLpieroundvar
+}%
+\@for\dtl@row:=\dtl@piecutaways\do{%
+\expandafter\@dtl@set@off\dtl@row-\relax
+}%
+\let\dtl@start=\DTLstartangle
+\begin{tikzpicture}
+\DTLpieatbegintikz
+\@sDTLforeach[#1]{#3}{#4}{%
+\expandafter\@dtl@seg\expandafter=
+\csname c@DTLrow\romannumeral\dtlforeachlevel\endcsname%
+\edef\dtl@start{\csname dtl@sang@\romannumeral\@dtl@seg\endcsname}%
+\edef\dtl@extent{\csname dtl@angle@\romannumeral\@dtl@seg\endcsname}%
+\FPadd{\dtl@endangle}{\dtl@start}{\dtl@extent}%
+\edef\dtl@angle{\csname dtl@cut@angle@\romannumeral\@dtl@seg\endcsname}%
+\let\dtl@old=\dtl@angle
+\dtl@truncatedecimal\dtl@angle
+\ifnum\dtl@angle>180
+ \FPsub{\dtl@angle}{\dtl@old}{360}%
+ \dtl@truncatedecimal\dtl@angle
+\fi
+\edef\dtl@cutlen{%
+\csname dtl@cut@len@\romannumeral\@dtl@seg\endcsname}
+\edef\@dtl@shift{(\dtl@angle:\dtl@cutlen)}%
+\FPmul{\dtl@angle}{\dtl@extent}{0.5}%
+\FPadd{\dtl@midangle}{\dtl@angle}{\dtl@start}%
+\begin{scope}[shift={\@dtl@shift}]%
+\dtl@truncatedecimal\dtl@start
+\dtl@truncatedecimal\dtl@endangle
+\fill[color=\DTLgetpiesegmentcolor\@dtl@seg] (0,0) --
+(\dtl@start:\DTLradius)
+arc (\dtl@start:\dtl@endangle:\DTLradius) -- cycle;
+\ifdim\DTLpieoutlinewidth>0pt\relax
+\draw[color=\DTLpieoutlinecolor,line width=\DTLpieoutlinewidth]
+(0,0) -- (\dtl@start:\DTLradius)
+arc (\dtl@start:\dtl@endangle:\DTLradius) -- cycle;
+\fi
+\dtl@truncatedecimal\dtl@midangle
+\ifDTLrotateinner
+\ifthenelse{\(\dtl@midangle > 90 \and \dtl@midangle < 270\)
+\TE@or \dtl@midangle < -90}{%
+ \FPsub{\dtl@labelangle}{\dtl@midangle}{180}%
+ \dtl@truncatedecimal\dtl@labelangle
+ \edef\dtl@innernodeopt{anchor=east,rotate=\dtl@labelangle}%
+}{%
+ \edef\dtl@innernodeopt{anchor=west,rotate=\dtl@midangle}%
+}%
+\else
+ \edef\dtl@innernodeopt{anchor=center}%
+\fi
+\ifDTLrotateouter
+\ifthenelse{\(\dtl@midangle > 90 \and \dtl@midangle < 270\)
+\TE@or \dtl@midangle < -90}{%
+ \FPsub{\dtl@labelangle}{\dtl@midangle}{180}%
+ \dtl@truncatedecimal\dtl@labelangle
+ \edef\dtl@outernodeopt{anchor=east,rotate=\dtl@labelangle}%
+}{%
+ \edef\dtl@outernodeopt{anchor=west,rotate=\dtl@midangle}%
+}%
+\else
+ \ifthenelse{\(\dtl@midangle<45\and\dtl@midangle>-45\)
+ \TE@or \dtl@midangle=45
+ \TE@or \dtl@midangle>315}{%
+ % east quadrant
+ \edef\dtl@outernodeopt{anchor=west}%
+ }{%
+ \ifthenelse{\(\dtl@midangle<135\and\dtl@midangle>45\)
+ \TE@or \dtl@midangle=135}{%
+ % north quadrant
+ \edef\dtl@outernodeopt{anchor=south}%
+ }{%
+ \ifthenelse{\(\dtl@midangle<225\and\dtl@midangle>135\)
+ \TE@or \dtl@midangle=225
+ \TE@or \dtl@midangle=-135
+ \TE@or \dtl@midangle<-135}{%
+ % west quadrant
+ \edef\dtl@outernodeopt{anchor=east}%
+ }{%
+ \edef\dtl@outernodeopt{anchor=north}%
+ }%
+ }
+ }
+\fi
+\edef\@dtl@dolabel{%
+\noexpand\draw (\dtl@midangle:\the\dtl@inneroffset)
+node[\dtl@innernodeopt]{%
+\noexpand\DTLdisplayinnerlabel{\noexpand\dtl@innerlabel}};}%
+\@dtl@dolabel
+\edef\@dtl@dolabel{%
+\noexpand\draw (\dtl@midangle:\the\dtl@outeroffset)
+node[\dtl@outernodeopt]{%
+\noexpand\DTLdisplayouterlabel{\noexpand\dtl@outerlabel}};}%
+\@dtl@dolabel
+\end{scope}
+}%
+\DTLpieatendtikz
+\end{tikzpicture}
+\fi
+}}
+\newcommand*{\dtl@computeangles}[2]{%
+\FPifgt{\@dtl@start}{180}%
+ \let\dtl@old=\@dtl@start
+ \FPsub{\@dtl@start}{\dtl@old}{360}%
+\fi
+\FPiflt{\@dtl@start}{-180}%
+ \let\dtl@old=\@dtl@start
+ \FPadd{\@dtl@start}{\dtl@old}{360}%
+\fi
+\expandafter\edef\csname dtl@sang@\romannumeral#1\endcsname{%
+\@dtl@start}%
+\FPmul{\dtl@angle}{360}{#2}%
+\let\dtl@old=\dtl@angle
+\FPdiv{\dtl@angle}{\dtl@old}{\dtl@total}%
+\expandafter\let\csname dtl@angle@\romannumeral#1\endcsname=\dtl@angle
+\let\dtl@old=\@dtl@start
+\FPadd{\@dtl@start}{\dtl@old}{\dtl@angle}%
+\expandafter\def\csname dtl@cut@angle@\romannumeral#1\endcsname{0}%
+\expandafter\def\csname dtl@cut@len@\romannumeral#1\endcsname{0cm}%
+}
+\def\@dtl@set@off#1-#2\relax{%
+\ifthenelse{\equal{#2}{}}{%
+\@@dtl@set@off{#1}}{%
+\@@dtl@set@offr#1-#2\relax}%
+}
+\newcommand*{\@@dtl@set@off}[1]{%
+\edef\dtl@old{\csname dtl@angle@\romannumeral#1\endcsname}%
+\FPmul{\dtl@angle}{\dtl@old}{0.5}%
+\let\dtl@old=\dtl@angle
+\edef\dtl@sang{\csname dtl@sang@\romannumeral#1\endcsname}%
+\FPadd{\dtl@angle}{\dtl@old}{\dtl@sang}%
+\expandafter\edef\csname dtl@cut@angle@\romannumeral#1\endcsname{%
+\dtl@angle}%
+\expandafter\edef\csname dtl@cut@len@\romannumeral#1\endcsname{%
+ \the\dtl@cutawayoffset}
+}
+\newcount\@dtl@seg
+\def\@@dtl@set@offr#1-#2-\relax{%
+\ifnum#1>#2\relax
+ \PackageError{datapie}{Segment ranges must go in ascending order}{%
+Try #2-#1 instead of #1-#2}%
+\else
+ \def\dtl@angle{0}%
+ \@dtl@seg=#1\relax
+ \whiledo{\not\(\@dtl@seg > #2\)}{%
+ \let\dtl@old=\dtl@angle
+ \edef\dtl@segang{\csname dtl@angle@\romannumeral\@dtl@seg\endcsname}%
+ \FPadd{\dtl@angle}{\dtl@old}{\dtl@segang}%
+ \advance\@dtl@seg by 1\relax
+ }%
+ \let\dtl@old=\dtl@angle
+ \FPmul{\dtl@angle}{\dtl@old}{0.5}%
+ \edef\dtl@sang{\csname dtl@sang@\romannumeral#1\endcsname}%
+ \let\dtl@old=\dtl@angle
+ \FPadd{\dtl@angle}{\dtl@old}{\dtl@sang}%
+ \@dtl@seg=#1\relax
+ \whiledo{\not\(\@dtl@seg > #2\)}{%
+ \expandafter
+ \let\csname dtl@cut@angle@\romannumeral\@dtl@seg\endcsname
+ =\dtl@angle
+ \expandafter
+ \edef\csname dtl@cut@len@\romannumeral\@dtl@seg\endcsname{%
+ \the\dtl@cutawayoffset}
+ \advance\@dtl@seg by 1\relax
+ }%
+\fi
+}
+\endinput
+%%
+%% End of file `datapie.sty'.
diff --git a/Master/texmf-dist/tex/latex/datatool/dataplot.sty b/Master/texmf-dist/tex/latex/datatool/dataplot.sty
new file mode 100644
index 00000000000..83eaef56ebb
--- /dev/null
+++ b/Master/texmf-dist/tex/latex/datatool/dataplot.sty
@@ -0,0 +1,917 @@
+%%
+%% This is file `dataplot.sty',
+%% generated with the docstrip utility.
+%%
+%% The original source files were:
+%%
+%% datatool.dtx (with options: `dataplot.sty,package')
+%%
+%% datatool.dtx
+%% Copyright 2007 Nicola Talbot
+%%
+%% This work may be distributed and/or modified under the
+%% conditions of the LaTeX Project Public License, either version 1.3
+%% of this license of (at your option) any later version.
+%% The latest version of this license is in
+%% http://www.latex-project.org/lppl.txt
+%% and version 1.3 or later is part of all distributions of LaTeX
+%% version 2005/12/01 or later.
+%%
+%% This work has the LPPL maintenance status `maintained'.
+%%
+%% The Current Maintainer of this work is Nicola Talbot.
+%%
+%% This work consists of the files datatool.dtx and datatool.ins and the derived files datatool.sty, datapie.sty, dataplot.sty, databar.sty, databib.sty, databib.bst.
+%%
+%% \CharacterTable
+%% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
+%% Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
+%% Digits \0\1\2\3\4\5\6\7\8\9
+%% Exclamation \! Double quote \" Hash (number) \#
+%% Dollar \$ Percent \% Ampersand \&
+%% Acute accent \' Left paren \( Right paren \)
+%% Asterisk \* Plus \+ Comma \,
+%% Minus \- Point \. Solidus \/
+%% Colon \: Semicolon \; Less than \<
+%% Equals \= Greater than \> Question mark \?
+%% Commercial at \@ Left bracket \[ Backslash \\
+%% Right bracket \] Circumflex \^ Underscore \_
+%% Grave accent \` Left brace \{ Vertical bar \|
+%% Right brace \} Tilde \~}
+\NeedsTeXFormat{LaTeX2e}
+\ProvidesPackage{dataplot}[2007/08/17 v1.01 (NLCT)]
+\RequirePackage{xkeyval}
+\RequirePackage{tikz}
+\RequirePackage{datatool}
+\usetikzlibrary{plotmarks}
+\usetikzlibrary{plothandlers}
+\newcommand*{\DTLplotstream}[4][\boolean{true}]{%
+\@sDTLforeach[#1]{#2}{\dtl@x=#3,\dtl@y=#4}{%
+\DTLconverttodecimal{\dtl@x}{\dtl@decx}%
+\DTLconverttodecimal{\dtl@y}{\dtl@decy}%
+\pgfplotstreampoint{\pgfpointxy{\dtl@decx}{\dtl@decy}}}}
+\newcommand*{\DTLplotmarks}{%
+\pgfuseplotmark{o},%
+\pgfuseplotmark{x},%
+\pgfuseplotmark{+},%
+\pgfuseplotmark{square},%
+\pgfuseplotmark{triangle},%
+\pgfuseplotmark{diamond},%
+\pgfuseplotmark{pentagon},%
+\pgfuseplotmark{asterisk},%
+\pgfuseplotmark{star}}
+\newcommand*{\DTLplotmarkcolors}{%
+red,%
+green,%
+blue,%
+yellow,%
+magenta,%
+cyan,%
+orange,%
+black,%
+gray}
+\newcommand*{\DTLplotlines}{%
+\pgfsetdash{}{{0pt}},% solid line
+\pgfsetdash{{10pt}{5pt}}{0pt},%
+\pgfsetdash{{5pt}{5pt}}{0pt},%
+\pgfsetdash{{1pt}{5pt}}{0pt},%
+\pgfsetdash{{5pt}{5pt}{1pt}{5pt}}{0pt},%
+\pgfsetdash{{1pt}{3pt}}{0pt},%
+}
+\newcommand*{\DTLplotlinecolors}{%
+red,%
+green,%
+blue,%
+yellow,%
+magenta,%
+cyan,%
+orange,%
+black,%
+gray}
+\newlength\DTLplotwidth
+\setlength\DTLplotwidth{4in}
+\newlength\DTLplotheight
+\setlength\DTLplotheight{4in}
+\newlength\DTLticklength
+\setlength\DTLticklength{5pt}
+\newlength\DTLminorticklength
+\setlength\DTLminorticklength{2pt}
+\newlength\DTLticklabeloffset
+\setlength\DTLticklabeloffset{8pt}
+\newlength\dtl@xticlabelheight
+\newlength\dtl@yticlabelwidth
+\newlength\DTLmintickgap
+\setlength\DTLmintickgap{20pt}
+\newlength\DTLminminortickgap
+\setlength\DTLminminortickgap{5pt}
+\newcounter{DTLplotroundXvar}
+\setcounter{DTLplotroundXvar}{2}
+\newcounter{DTLplotroundYvar}
+\setcounter{DTLplotroundYvar}{2}
+\newif\ifDTLxaxis
+\DTLxaxistrue
+\newcommand*{\DTLXAxisStyle}{-}
+\newif\ifDTLyaxis
+\DTLyaxistrue
+\newcommand*{\DTLYAxisStyle}{-}
+\newcommand*{\DTLmajorgridstyle}{color=gray,-}
+\newcommand*{\DTLminorgridstyle}{color=gray,loosely dotted}
+\newif\ifDTLxticsin
+\DTLxticsintrue
+\newif\ifDTLyticsin
+\DTLyticsintrue
+\newcount\dtl@legendsetting
+\newlength\DTLlegendxoffset
+\setlength\DTLlegendxoffset{10pt}
+\newlength\DTLlegendyoffset
+\setlength\DTLlegendyoffset{10pt}
+\newcommand*{\DTLformatlegend}[1]{%
+\setlength{\fboxrule}{1.1pt}%
+\fcolorbox{black}{white}{#1}}
+\newif\ifDTLshowmarkers
+\DTLshowmarkerstrue
+\newif\ifDTLshowlines
+\DTLshowlinesfalse
+\newcommand*{\DTLplotatbegintikz}{}
+\newcommand*{\DTLplotatendtikz}{}
+\define@key{dataplot}{x}{%
+\def\dtl@xkey{#1}}
+\define@key{dataplot}{y}{%
+\def\dtl@ykey{#1}}
+\define@key{dataplot}{markcolors}{%
+\def\DTLplotmarkcolors{#1}}
+\define@key{dataplot}{linecolors}{%
+\def\DTLplotlinecolors{#1}}
+\define@key{dataplot}{colors}{%
+\def\DTLplotmarkcolors{#1}%
+\def\DTLplotlinecolors{#1}}
+\define@key{dataplot}{marks}{%
+\def\DTLplotmarks{#1}}
+\define@key{dataplot}{lines}{%
+\def\DTLplotlines{#1}}
+\define@key{dataplot}{width}{%
+\setlength\DTLplotwidth{#1}}
+\define@key{dataplot}{height}{%
+\setlength\DTLplotheight{#1}}
+\define@choicekey{dataplot}{style}[\val\nr]{both,lines,markers}{%
+\ifcase\nr\relax
+ \DTLshowlinestrue
+ \DTLshowmarkerstrue
+\or
+ \DTLshowlinestrue
+ \DTLshowmarkersfalse
+\or
+ \DTLshowmarkerstrue
+ \DTLshowlinesfalse
+\fi}
+\define@choicekey{dataplot}{axes}[\val\nr]{both,x,y,none}[both]{%
+\ifcase\nr\relax
+ % both
+ \DTLxaxistrue
+ \DTLxticstrue
+ \DTLyaxistrue
+ \DTLyticstrue
+\or % x
+ \DTLxaxistrue
+ \DTLxticstrue
+ \DTLyaxisfalse
+ \DTLyticsfalse
+\or % y
+ \DTLxaxisfalse
+ \DTLxticsfalse
+ \DTLyaxistrue
+ \DTLyticstrue
+\or % none
+ \DTLxaxisfalse
+ \DTLxticsfalse
+ \DTLyaxisfalse
+ \DTLyticsfalse
+\fi
+}
+\define@boolkey{dataplot}[DTL]{box}[true]{}
+\DTLboxfalse
+\define@boolkey{dataplot}[DTL]{xtics}[true]{}
+\DTLxticstrue
+\define@boolkey{dataplot}[DTL]{ytics}[true]{}
+\DTLyticstrue
+\define@boolkey{dataplot}[DTL]{xminortics}[true]{%
+\ifDTLxminortics \DTLxticstrue\fi}
+\DTLxminorticsfalse
+\define@boolkey{dataplot}[DTL]{yminortics}[true]{%
+\ifDTLyminortics \DTLyticstrue\fi}
+\DTLyminorticsfalse
+\define@boolkey{dataplot}[DTL]{grid}[true]{}
+\define@choicekey{dataplot}{xticdir}[\val\nr]{in,out}{%
+\ifcase\nr\relax
+ \DTLxticsintrue
+\or
+ \DTLxticsinfalse
+\fi
+}
+\define@choicekey{dataplot}{yticdir}[\val\nr]{in,out}{%
+\ifcase\nr\relax
+ \DTLyticsintrue
+\or
+ \DTLyticsinfalse
+\fi
+}
+\define@choicekey{dataplot}{ticdir}[\val\nr]{in,out}{%
+\ifcase\nr\relax
+ \DTLxticsintrue
+ \DTLyticsintrue
+\or
+ \DTLxticsinfalse
+ \DTLyticsinfalse
+\fi
+}
+\define@key{dataplot}{bounds}{%
+\def\dtl@bounds{#1}}
+\let\dtl@bounds=\relax
+\define@key{dataplot}{minx}{%
+\def\dtl@minx{#1}}
+\let\dtl@minx=\relax
+\define@key{dataplot}{maxx}{%
+\def\dtl@maxx{#1}}
+\let\dtl@maxx=\relax
+\define@key{dataplot}{miny}{%
+\def\dtl@miny{#1}}
+\let\dtl@miny=\relax
+\define@key{dataplot}{maxy}{%
+\def\dtl@maxy{#1}}
+\let\dtl@maxy=\relax
+\define@key{dataplot}{xticpoints}{%
+\def\dtl@xticlist{#1}\DTLxticstrue\DTLxaxistrue}
+\let\dtl@xticlist=\relax
+\define@key{dataplot}{yticpoints}{%
+\def\dtl@yticlist{#1}\DTLyticstrue\DTLyaxistrue}
+\let\dtl@yticlist=\relax
+\define@key{dataplot}{xticgap}{\def\dtl@xticgap{#1}%
+\DTLxticstrue\DTLxaxistrue}
+\let\dtl@xticgap=\relax
+\define@key{dataplot}{yticgap}{\def\dtl@yticgap{#1}%
+\DTLyticstrue\DTLyaxistrue}
+\let\dtl@yticgap=\relax
+\define@key{dataplot}{xticlabels}{%
+\def\dtl@xticlabels{#1}\DTLxticstrue\DTLxaxistrue}
+\let\dtl@xticlabels=\relax
+\define@key{dataplot}{yticlabels}{%
+\def\dtl@yticlabels{#1}\DTLyticstrue\DTLyaxistrue}
+\let\dtl@yticlabels=\relax
+\define@key{dataplot}{xlabel}{%
+\def\dtl@xlabel{#1}}
+\let\dtl@xlabel=\relax
+\define@key{dataplot}{ylabel}{%
+\def\dtl@ylabel{#1}}
+\let\dtl@ylabel=\relax
+\define@choicekey{dataplot}{legend}[\val\nr]{none,north,northeast,%
+east,southeast,south,southwest,west,northwest}[northeast]{%
+\dtl@legendsetting=\nr\relax
+}
+\define@key{dataplot}{legendlabels}{\def\dtl@legendlabels{#1}}
+\newcommand*{\DTLplot}[3][\boolean{true}]{{%
+\let\dtl@xkey=\relax
+\let\dtl@ykey=\relax
+\let\dtl@legendlabels=\relax
+\setkeys{dataplot}{#3}%
+\let\dtl@plotmarklist=\DTLplotmarks
+\let\dtl@plotlinelist=\DTLplotlines
+\let\dtl@plotmarkcolorlist=\DTLplotmarkcolors
+\let\dtl@plotlinecolorlist=\DTLplotlinecolors
+\def\dtl@legend{}%
+\ifx\dtl@legendlabels\relax
+ \edef\dtl@legendlabels{#2}%
+\fi
+\ifx\dtl@xkey\relax
+ \PackageError{dataplot}{Missing x setting for
+ \string\DTLplot}{}%
+\else
+ \ifx\dtl@ykey\relax
+ \PackageError{dataplot}{Missing y setting for
+ \string\DTLplot}{}%
+ \else
+ \ifx\dtl@bounds\relax
+ \DTLcomputebounds[#1]{#2}{\dtl@xkey}{\dtl@ykey}
+ {\DTLminX}{\DTLminY}{\DTLmaxX}{\DTLmaxY}%
+ \ifx\dtl@minx\relax
+ \else
+ \let\DTLminX=\dtl@minx
+ \fi
+ \ifx\dtl@maxx\relax
+ \else
+ \let\DTLmaxX=\dtl@maxx
+ \fi
+ \ifx\dtl@miny\relax
+ \else
+ \let\DTLminY=\dtl@miny
+ \fi
+ \ifx\dtl@maxy\relax
+ \else
+ \let\DTLmaxY=\dtl@maxy
+ \fi
+ \else
+ \expandafter\dtl@getbounds\dtl@bounds\@nil
+ \fi
+ \@dtl@tmpcount=\DTLplotwidth
+ \FPsub{\dtl@dx}{\DTLmaxX}{\DTLminX}%
+ \FPdiv{\dtl@unit@x}{\number\@dtl@tmpcount}{\dtl@dx}%
+ \@dtl@tmpcount=\DTLplotheight
+ \FPsub{\dtl@dy}{\DTLmaxY}{\DTLminY}%
+ \FPdiv{\dtl@unit@y}{\number\@dtl@tmpcount}{\dtl@dy}%
+ \ifDTLxtics
+ \ifx\dtl@xticlist\relax
+ \ifx\dtl@xticgap\relax
+ \dtl@constructticklist\DTLminX\DTLmaxX
+ \dtl@unit@x\dtl@xticlist
+ \else
+ \DTLifFPopenbetween{0}{\DTLminX}{\DTLmaxX}{%
+ \dtl@constructticklistwithgapz
+ \DTLminX\DTLmaxX\dtl@xticlist\dtl@xticgap}{%
+ \dtl@constructticklistwithgap
+ \DTLminX\DTLmaxX\dtl@xticlist\dtl@xticgap}%
+ \fi
+ \fi
+ \let\dtl@xminorticlist\@empty
+ \ifDTLxminortics
+ \let\dtl@prevtick=\relax
+ \@for\dtl@nexttick:=\dtl@xticlist\do{%
+ \ifx\dtl@prevtick\relax
+ \else
+ \dtl@constructminorticklist
+ \dtl@prevtick\dtl@nexttick\dtl@unit@x\dtl@xminorticlist
+ \fi
+ \let\dtl@prevtick=\dtl@nexttick
+ }%
+ \fi
+ \ifx\dtl@xticlabels\relax
+ \settoheight{\dtl@xticlabelheight}{\dtl@xticlist}%
+ \else
+ \settoheight{\dtl@xticlabelheight}{\dtl@xticlabels}%
+ \fi
+ \else
+ \setlength{\dtl@xticlabelheight}{0pt}%
+ \fi
+ \setlength{\dtl@yticlabelwidth}{0pt}%
+ \ifDTLytics
+ \ifx\dtl@yticlist\relax
+ \ifx\dtl@yticgap\relax
+ \dtl@constructticklist\DTLminY\DTLmaxY
+ \dtl@unit@y\dtl@yticlist
+ \else
+ \DTLifFPopenbetween{0}{\DTLminY}{\DTLmaxY}{%
+ \dtl@constructticklistwithgapz
+ \DTLminY\DTLmaxY\dtl@yticlist\dtl@yticgap}{%
+ \dtl@constructticklistwithgap
+ \DTLminY\DTLmaxY\dtl@yticlist\dtl@yticgap}%
+ \fi
+ \fi
+ \let\dtl@yminorticlist\@empty
+ \ifDTLyminortics
+ \let\dtl@prevtick=\relax
+ \@for\dtl@nexttick:=\dtl@yticlist\do{%
+ \ifx\dtl@prevtick\relax
+ \else
+ \dtl@constructminorticklist
+ \dtl@prevtick\dtl@nexttick\dtl@unit@y\dtl@yminorticlist
+ \fi
+ \let\dtl@prevtick=\dtl@nexttick
+ }%
+ \fi
+ \ifx\dtl@ylabel\relax
+ \else
+ \ifx\dtl@yticlabels\relax
+ \@for\dtl@thislabel:=\dtl@yticlist\do{%
+ \FPround{\dtl@thislabel}{\dtl@thislabel}
+ {\c@DTLplotroundYvar}%
+ \settowidth{\dtl@tmplength}{\dtl@thislabel}%
+ \ifdim\dtl@tmplength>\dtl@yticlabelwidth
+ \setlength{\dtl@yticlabelwidth}{\dtl@tmplength}%
+ \fi
+ }%
+ \else
+ \@for\dtl@thislabel:=\dtl@yticlabels\do{%
+ \settowidth{\dtl@tmplength}{\dtl@thislabel}%
+ \ifdim\dtl@tmplength>\dtl@yticlabelwidth
+ \setlength{\dtl@yticlabelwidth}{\dtl@tmplength}%
+ \fi
+ }%
+ \fi
+ \fi
+ \begin{tikzpicture}
+ \pgfsetxvec{\pgfpoint{\dtl@unit@x sp}{0pt}}%
+ \pgfsetyvec{\pgfpoint{0pt}{\dtl@unit@y sp}}%
+ \DTLplotatbegintikz
+ \ifDTLbox
+ \draw (\DTLminX,\DTLminY) -- (\DTLmaxX,\DTLminY) --
+ (\DTLmaxX,\DTLmaxY) -- (\DTLminX,\DTLmaxY) --
+ cycle;
+ \else
+ \ifDTLxaxis
+ \expandafter\draw\expandafter[\DTLXAxisStyle]
+ (\DTLminX,\DTLminY) -- (\DTLmaxX,\DTLminY);
+ \fi
+ \ifDTLyaxis
+ \expandafter\draw\expandafter[\DTLYAxisStyle]
+ (\DTLminX,\DTLminY) -- (\DTLminX,\DTLmaxY);
+ \fi
+ \fi
+ \ifDTLgrid
+ \ifDTLxminortics
+ \@for\dtl@thistick:=\dtl@xminorticlist\do{%
+ \expandafter\draw\expandafter[\DTLminorgridstyle]
+ (\dtl@thistick,\DTLminY) -- (\dtl@thistick,\DTLmaxY);
+ }%
+ \fi
+ \ifDTLyminortics
+ \@for\dtl@thistick:=\dtl@yminorticlist\do{%
+ \expandafter\draw\expandafter[\DTLminorgridstyle]
+ (\DTLminX,\dtl@thistick) -- (\DTLmaxX,\dtl@thistick);
+ }%
+ \fi
+ \@for\dtl@thistick:=\dtl@xticlist\do{%
+ \expandafter\draw\expandafter[\DTLmajorgridstyle]
+ (\dtl@thistick,\DTLminY) -- (\dtl@thistick,\DTLmaxY);
+ }%
+ \@for\dtl@thistick:=\dtl@yticlist\do{%
+ \expandafter\draw\expandafter[\DTLmajorgridstyle]
+ (\DTLminX,\dtl@thistick) -- (\DTLmaxX,\dtl@thistick);
+ }%
+ \fi
+ \ifDTLxtics
+ \addtolength\dtl@xticlabelheight{\DTLticklabeloffset}%
+ \@for\dtl@thistick:=\dtl@xticlist\do{%
+ \pgfpathmoveto{\pgfpointxy{\dtl@thistick}{\DTLminY}}
+ \ifDTLxticsin
+ \pgfpathlineto{
+ \pgfpointadd{\pgfpointxy{\dtl@thistick}{\DTLminY}}
+ {\pgfpoint{0pt}{\DTLticklength}}}
+ \else
+ \pgfpathlineto{
+ \pgfpointadd{\pgfpointxy{\dtl@thistick}{\DTLminY}}
+ {\pgfpoint{0pt}{-\DTLticklength}}}
+ \fi
+ \ifDTLbox
+ \pgfpathmoveto{\pgfpointxy{\dtl@thistick}{\DTLmaxY}}
+ \ifDTLxticsin
+ \pgfpathlineto{
+ \pgfpointadd{\pgfpointxy{\dtl@thistick}{\DTLmaxY}}
+ {\pgfpoint{0pt}{-\DTLticklength}}}
+ \else
+ \pgfpathlineto{
+ \pgfpointadd{\pgfpointxy{\dtl@thistick}{\DTLmaxY}}
+ {\pgfpoint{0pt}{\DTLticklength}}}
+ \fi
+ \fi
+ \pgfusepath{stroke}%
+ \ifx\dtl@xticlabels\relax
+ \FPround{\dtl@thislabel}{\dtl@thistick}
+ {\c@DTLplotroundXvar}%
+ \else
+ \dtl@chopfirst\dtl@xticlabels\dtl@thislabel\dtl@rest
+ \let\dtl@xticlabels=\dtl@rest
+ \fi
+ \pgftext[base,center,at={\pgfpointadd
+ {\pgfpointxy{\dtl@thistick}{\DTLminY}}
+ {\pgfpoint{0pt}{-\dtl@xticlabelheight}}}]
+ {\dtl@thislabel}
+ }%
+ \fi
+ \ifx\dtl@xlabel\relax
+ \else
+ \addtolength{\dtl@xticlabelheight}{\baselineskip}%
+ \setlength{\dtl@tmplength}{0.5\DTLplotwidth}
+ \pgftext[base,center,at={\pgfpointadd
+ {\pgfpointxy{\DTLminX}{\DTLminY}}%
+ {\pgfpoint{\dtl@tmplength}{-\dtl@xticlabelheight}}}]{%
+ \dtl@xlabel}
+ \fi
+ \ifDTLxminortics
+ \@for\dtl@thistick:=\dtl@xminorticlist\do{%
+ \pgfpathmoveto{\pgfpointxy{\dtl@thistick}{\DTLminY}}
+ \ifDTLxticsin
+ \pgfpathlineto{
+ \pgfpointadd{\pgfpointxy{\dtl@thistick}{\DTLminY}}
+ {\pgfpoint{0pt}{\DTLminorticklength}}}
+ \else
+ \pgfpathlineto{
+ \pgfpointadd{\pgfpointxy{\dtl@thistick}{\DTLminY}}
+ {\pgfpoint{0pt}{-\DTLminorticklength}}}
+ \fi
+ \ifDTLbox
+ \pgfpathmoveto{\pgfpointxy{\dtl@thistick}{\DTLmaxY}}
+ \ifDTLxticsin
+ \pgfpathlineto{
+ \pgfpointadd{\pgfpointxy{\dtl@thistick}{\DTLmaxY}}
+ {\pgfpoint{0pt}{-\DTLminorticklength}}}
+ \else
+ \pgfpathlineto{
+ \pgfpointadd{\pgfpointxy{\dtl@thistick}{\DTLmaxY}}
+ {\pgfpoint{0pt}{\DTLminorticklength}}}
+ \fi
+ \fi
+ }%
+ \fi
+ \ifDTLytics
+ \@for\dtl@thistick:=\dtl@yticlist\do{%
+ \pgfpathmoveto{\pgfpointxy{\DTLminX}{\dtl@thistick}}
+ \ifDTLyticsin
+ \pgfpathlineto{
+ \pgfpointadd{\pgfpointxy{\DTLminX}{\dtl@thistick}}
+ {\pgfpoint{\DTLticklength}{0pt}}}
+ \else
+ \pgfpathlineto{
+ \pgfpointadd{\pgfpointxy{\DTLminX}{\dtl@thistick}}
+ {\pgfpoint{-\DTLticklength}{0pt}}}
+ \fi
+ \ifDTLbox
+ \pgfpathmoveto{\pgfpointxy{\DTLmaxX}{\dtl@thistick}}
+ \ifDTLyticsin
+ \pgfpathlineto{
+ \pgfpointadd{\pgfpointxy{\DTLmaxX}{\dtl@thistick}}
+ {\pgfpoint{-\DTLticklength}{0pt}}}
+ \else
+ \pgfpathlineto{
+ \pgfpointadd{\pgfpointxy{\DTLmaxX}{\dtl@thistick}}
+ {\pgfpoint{\DTLticklength}{0pt}}}
+ \fi
+ \fi
+ \pgfusepath{stroke}
+ \ifx\dtl@yticlabels\relax
+ \FPround{\dtl@thislabel}{\dtl@thistick}
+ {\c@DTLplotroundYvar}%
+ \else
+ \dtl@chopfirst\dtl@yticlabels\dtl@thislabel\dtl@rest
+ \let\dtl@yticlabels=\dtl@rest
+ \fi
+ \pgftext[right,at={\pgfpointadd
+ {\pgfpointxy{\DTLminX}{\dtl@thistick}}
+ {\pgfpoint{-\DTLticklabeloffset}{0pt}}}]
+ {\dtl@thislabel}
+ }%
+ \fi
+ \ifx\dtl@ylabel\relax
+ \else
+ \addtolength{\dtl@yticlabelwidth}{\baselineskip}%
+ \setlength{\dtl@tmplength}{0.5\DTLplotheight}
+ \pgftext[bottom,center,at={\pgfpointadd
+ {\pgfpointxy{\DTLminX}{\DTLminY}}%
+ {\pgfpoint{-\dtl@yticlabelwidth}{\dtl@tmplength}}},
+ rotate=90]{%
+ \dtl@ylabel}
+ \fi
+ \ifDTLyminortics
+ \@for\dtl@thistick:=\dtl@yminorticlist\do{%
+ \pgfpathmoveto{\pgfpointxy{\DTLminX}{\dtl@thistick}}
+ \ifDTLyticsin
+ \pgfpathlineto{
+ \pgfpointadd{\pgfpointxy{\DTLminX}{\dtl@thistick}}
+ {\pgfpoint{\DTLminorticklength}{0pt}}}
+ \else
+ \pgfpathlineto{
+ \pgfpointadd{\pgfpointxy{\DTLminX}{\dtl@thistick}}
+ {\pgfpoint{-\DTLminorticklength}{0pt}}}
+ \fi
+ \ifDTLbox
+ \pgfpathmoveto{\pgfpointxy{\DTLmaxX}{\dtl@thistick}}
+ \ifDTLyticsin
+ \pgfpathlineto{
+ \pgfpointadd{\pgfpointxy{\DTLmaxX}{\dtl@thistick}}
+ {\pgfpoint{-\DTLminorticklength}{0pt}}}
+ \else
+ \pgfpathlineto{
+ \pgfpointadd{\pgfpointxy{\DTLmaxX}{\dtl@thistick}}
+ {\pgfpoint{\DTLminorticklength}{0pt}}}
+ \fi
+ \fi
+ \pgfusepath{stroke}
+ }%
+ \fi
+ \@for\dtl@thisdb:=#2\do{%
+ \ifx\dtl@plotmarkcolorlist\@empty
+ \let\dtl@plotmarkcolorlist=\DTLplotmarkcolors
+ \fi
+ \dtl@chopfirst\dtl@plotmarkcolorlist\dtl@thisplotmarkcolor
+ \dtl@remainder
+ \let\dtl@plotmarkcolorlist=\dtl@remainder
+ \ifDTLshowmarkers
+ \ifx\dtl@plotmarklist\@empty
+ \let\dtl@plotmarklist=\DTLplotmarks
+ \fi
+ \dtl@chopfirst\dtl@plotmarklist\dtl@thisplotmark
+ \dtl@remainder
+ \let\dtl@plotmarklist=\dtl@remainder
+ \ifx\dtl@thisplotmark\relax
+ \let\dtl@mark=\relax
+ \else
+ \expandafter\toks@\expandafter{\dtl@thisplotmark}%
+ \ifx\dtl@thisplotmarkcolor\@empty
+ \edef\dtl@mark{\the\toks@}%
+ \else
+ \edef\dtl@mark{%
+ \noexpand\color{\dtl@thisplotmarkcolor}%
+ \the\toks@}%
+ \fi
+ \fi
+ \else
+ \let\dtl@mark=\relax
+ \fi
+ \ifx\dtl@plotlinecolorlist\@empty
+ \let\dtl@plotlinecolorlist=\DTLplotlinecolors
+ \fi
+ \dtl@chopfirst\dtl@plotlinecolorlist\dtl@thisplotlinecolor
+ \dtl@remainder
+ \let\dtl@plotlinecolorlist=\dtl@remainder
+ \ifDTLshowlines
+ \ifx\dtl@plotlinelist\@empty
+ \let\dtl@plotlinelist=\DTLplotlines
+ \fi
+ \dtl@chopfirst\dtl@plotlinelist\dtl@thisplotline
+ \dtl@remainder
+ \let\dtl@plotlinelist=\dtl@remainder
+ \expandafter\ifx\dtl@thisplotline\relax
+ \let\dtl@linestyle=\relax
+ \else
+ \expandafter\toks@\expandafter{\dtl@thisplotline}%
+ \ifx\dtl@thisplotlinecolor\@empty
+ \edef\dtl@linestyle{\the\toks@}%
+ \else
+ \edef\dtl@linestyle{%
+ \noexpand\color{\dtl@thisplotlinecolor}%
+ \the\toks@}%
+ \fi
+ \fi
+ \else
+ \let\dtl@linestyle=\relax
+ \fi
+ \ifnum\dtl@legendsetting>0\relax
+ \dtl@chopfirst\dtl@legendlabels\dtl@thislabel\dtl@rest
+ \let\dtl@legendlabels=\dtl@rest
+ \expandafter\toks@\expandafter{\dtl@mark}%
+ \expandafter\@dtl@toks\expandafter{\dtl@linestyle}%
+ \edef\dtl@addtolegend{\noexpand\DTLaddtoplotlegend
+ {\the\toks@}{\the\@dtl@toks}{\dtl@thislabel}}%
+ \dtl@addtolegend
+ \fi
+ \def\dtl@stream{\pgfplotstreamstart}%
+ \@sDTLforeach[#1]{\dtl@thisdb}{\dtl@x=\dtl@xkey,%
+ \dtl@y=\dtl@ykey}{%
+ \DTLconverttodecimal{\dtl@x}{\dtl@decx}%
+ \DTLconverttodecimal{\dtl@y}{\dtl@decy}%
+ \ifthenelse{%
+ \DTLisclosedbetween{\dtl@x}{\DTLminX}{\DTLmaxX}%
+ \and
+ \DTLisclosedbetween{\dtl@y}{\DTLminY}{\DTLmaxY}%
+ }{%
+ \expandafter\toks@\expandafter{\dtl@stream}%
+ \edef\dtl@stream{\the\toks@
+ \noexpand\pgfplotstreampoint
+ {\noexpand\pgfpointxy{\dtl@decx}{\dtl@decy}}}%
+ }{}%
+ }%
+ \expandafter\toks@\expandafter{\dtl@stream}%
+ \edef\dtl@stream{\the\toks@\noexpand\pgfplotstreamend}%
+ \ifx\dtl@linestyle\relax
+ \else
+ \begin{scope}
+ \dtl@linestyle
+ \pgfplothandlerlineto
+ \dtl@stream
+ \pgfusepath{stroke}
+ \end{scope}
+ \fi
+ \ifx\dtl@mark\relax
+ \else
+ \begin{scope}
+ \pgfplothandlermark{\dtl@mark}%
+ \dtl@stream
+ \pgfusepath{stroke}
+ \end{scope}
+ \fi
+ }%
+ \ifcase\dtl@legendsetting
+ % none
+ \or % north
+ \pgftext[top,center,at={\pgfpointadd
+ {\pgfpointxy{\DTLminX}{\DTLmaxY}}
+ {\pgfpoint{0.5\DTLplotwidth}{-\DTLlegendyoffset}}}]
+ {\DTLformatlegend
+ {\begin{tabular}{cl}\dtl@legend\end{tabular}}}
+ \or % north east
+ \pgftext[top,right,at={\pgfpointadd
+ {\pgfpointxy{\DTLmaxX}{\DTLmaxY}}
+ {\pgfpoint{-\DTLlegendxoffset}{-\DTLlegendyoffset}}}]
+ {\DTLformatlegend
+ {\begin{tabular}{cl}\dtl@legend\end{tabular}}}
+ \or % east
+ \pgftext[center,right,at={\pgfpointadd
+ {\pgfpointxy{\DTLmaxX}{\DTLminY}}
+ {\pgfpoint{-\DTLlegendxoffset}{0.5\DTLplotheight}}}]
+ {\DTLformatlegend
+ {\begin{tabular}{cl}\dtl@legend\end{tabular}}}
+ \or % south east
+ \pgftext[bottom,right,at={\pgfpointadd
+ {\pgfpointxy{\DTLmaxX}{\DTLminY}}
+ {\pgfpoint{-\DTLlegendxoffset}{\DTLlegendyoffset}}}]
+ {\DTLformatlegend
+ {\begin{tabular}{cl}\dtl@legend\end{tabular}}}
+ \or % south
+ \pgftext[center,bottom,at={\pgfpointadd
+ {\pgfpointxy{\DTLminX}{\DTLminY}}
+ {\pgfpoint{0.5\DTLplotwidth}{\DTLlegendyoffset}}}]
+ {\DTLformatlegend
+ {\begin{tabular}{cl}\dtl@legend\end{tabular}}}
+ \or % south west
+ \pgftext[bottom,left,at={\pgfpointadd
+ {\pgfpointxy{\DTLminX}{\DTLminY}}
+ {\pgfpoint{\DTLlegendxoffset}{\DTLlegendyoffset}}}]
+ {\DTLformatlegend
+ {\begin{tabular}{cl}\dtl@legend\end{tabular}}}
+ \or % west
+ \pgftext[center,left,at={\pgfpointadd
+ {\pgfpointxy{\DTLminX}{\DTLminY}}
+ {\pgfpoint{\DTLlegendxoffset}{0.5\DTLplotheight}}}]
+ {\DTLformatlegend
+ {\begin{tabular}{cl}\dtl@legend\end{tabular}}}
+ \or % north west
+ \pgftext[top,left,at={\pgfpointadd
+ {\pgfpointxy{\DTLminX}{\DTLmaxY}}
+ {\pgfpoint{\DTLlegendxoffset}{-\DTLlegendyoffset}}}]
+ {\DTLformatlegend
+ {\begin{tabular}{cl}\dtl@legend\end{tabular}}}
+ \fi
+ \DTLplotatendtikz
+ \end{tikzpicture}
+ \fi
+ \fi
+\fi
+}}
+\def\dtl@getbounds#1,#2,#3,#4\@nil{%
+\def\DTLminX{#1}%
+\def\DTLminY{#2}%
+\def\DTLmaxX{#3}%
+\def\DTLmaxY{#4}%
+\FPifgt{\DTLminX}{\DTLmaxX}
+ \PackageError{dataplot}{Min X > Max X in bounds #1,#2,#3,#4}{%
+ The bounds must be specified as minX,minY,maxX,maxY}%
+\fi
+\FPifgt{\DTLminY}{\DTLmaxY}
+ \PackageError{dataplot}{Min Y > Max Y in bounds #1,#2,#3,#4}{%
+ The bounds must be specified as minX,minY,maxX,maxY}%
+\fi
+}
+\newcommand*{\dtl@constructticklist}[4]{%
+\DTLifFPopenbetween{0}{#1}{#2}{%
+ \FPsub{\@dtl@width}{0}{#1}%
+ \FPmul{\@dtl@width}{\@dtl@width}{#3}%
+ \FPdiv{\@dtl@neggap}{\@dtl@width}{10}%
+ \setlength\dtl@tmplength{\@dtl@neggap sp}%
+ \ifdim\dtl@tmplength<\DTLmintickgap
+ \FPdiv{\@dtl@neggap}{\@dtl@width}{4}%
+ \setlength\dtl@tmplength{\@dtl@neggap sp}%
+ \ifdim\dtl@tmplength<\DTLmintickgap
+ \FPdiv{\@dtl@neggap}{\@dtl@width}{2}%
+ \setlength\dtl@tmplength{\@dtl@neggap sp}%
+ \ifdim\dtl@tmplength<\DTLmintickgap
+ \let\@dtl@neggap=\@dtl@width
+ \fi
+ \fi
+ \fi
+ \FPmul{\@dtl@width}{#2}{#3}%
+ \FPdiv{\@dtl@posgap}{\@dtl@width}{10}%
+ \setlength\dtl@tmplength{\@dtl@posgap sp}%
+ \ifdim\dtl@tmplength<\DTLmintickgap
+ \FPdiv{\@dtl@posgap}{\@dtl@width}{4}%
+ \setlength\dtl@tmplength{\@dtl@posgap sp}%
+ \ifdim\dtl@tmplength<\DTLmintickgap
+ \FPdiv{\@dtl@posgap}{\@dtl@width}{2}%
+ \setlength\dtl@tmplength{\@dtl@posgap sp}%
+ \ifdim\dtl@tmplength<\DTLmintickgap
+ \let\@dtl@posgap=\@dtl@width
+ \fi
+ \fi
+ \fi
+ \FPmax{\@dtl@gap}{\@dtl@neggap}{\@dtl@posgap}%
+ \FPdiv{\@dtl@gap}{\@dtl@gap}{#3}%
+ \dtl@constructticklistwithgapz{#1}{#2}{#4}{\@dtl@gap}%
+}{%
+ \FPsub{\@dtl@width}{#2}{#1}%
+ \FPmul{\@dtl@width}{\@dtl@width}{#3}%
+ \FPdiv{\@dtl@gap}{\@dtl@width}{10}%
+ \setlength\dtl@tmplength{\@dtl@gap sp}%
+ \ifdim\dtl@tmplength<\DTLmintickgap
+ \FPdiv{\@dtl@gap}{\@dtl@width}{4}%
+ \setlength\dtl@tmplength{\@dtl@gap sp}%
+ \ifdim\dtl@tmplength<\DTLmintickgap
+ \FPdiv{\@dtl@gap}{\@dtl@width}{2}%
+ \setlength\dtl@tmplength{\@dtl@gap sp}%
+ \ifdim\dtl@tmplength<\DTLmintickgap
+ \let\@dtl@gap=\@dtl@width
+ \fi
+ \fi
+ \fi
+ \FPdiv{\@dtl@gap}{\@dtl@gap}{#3}%
+ \dtl@constructticklistwithgap{#1}{#2}{#4}{\@dtl@gap}%
+}%
+}
+\newcommand*{\dtl@constructticklistwithgap}[4]{%
+\edef\@dtl@thistick{#1}%
+\edef#3{#1}%
+\FPadd{\@dtl@thistick}{\@dtl@thistick}{#4}%
+\whiledo{\DTLisFPopenbetween{\@dtl@thistick}{#1}{#2}}{%
+ \expandafter\toks@\expandafter{\@dtl@thistick}%
+ \edef#3{#3,\the\toks@}%
+ \FPadd{\@dtl@thistick}{\@dtl@thistick}{#4}%
+}%
+\expandafter\toks@\expandafter{#2}%
+\edef#3{#3,\the\toks@}%
+}
+\newcommand*{\dtl@constructticklistwithgapz}[4]{%
+\edef\@dtl@thistick{0}%
+\edef#3{0}%
+\FPadd{\@dtl@thistick}{\@dtl@thistick}{#4}%
+\whiledo{\DTLisFPopenbetween{\@dtl@thistick}{0}{#2}}{%
+ \expandafter\toks@\expandafter{\@dtl@thistick}%
+ \edef#3{#3,\the\toks@}%
+ \FPadd{\@dtl@thistick}{\@dtl@thistick}{#4}%
+}%
+\expandafter\toks@\expandafter{#2}%
+\edef#3{#3,\the\toks@}%
+\FPifeq{#1}{0}%
+\else
+\edef\@dtl@thistick{0}%
+ \FPsub{\@dtl@thistick}{\@dtl@thistick}{#4}%
+ \whiledo{\DTLisFPopenbetween{\@dtl@thistick}{#1}{0}}{%
+ \expandafter\toks@\expandafter{\@dtl@thistick}%
+ \edef#3{\the\toks@,#3}%
+ \FPsub{\@dtl@thistick}{\@dtl@thistick}{#4}%
+ }%
+ \expandafter\toks@\expandafter{#1}%
+ \edef#3{\the\toks@,#3}%
+\fi
+}
+\newcommand*{\dtl@constructminorticklist}[4]{%
+ \FPsub{\@dtl@width}{#2}{#1}%
+ \FPmul{\@dtl@width}{\@dtl@width}{#3}%
+ \FPdiv{\@dtl@gap}{\@dtl@width}{10}%
+ \setlength\dtl@tmplength{\@dtl@gap sp}%
+ \ifdim\dtl@tmplength<\DTLminminortickgap
+ \FPdiv{\@dtl@gap}{\@dtl@width}{4}%
+ \setlength\dtl@tmplength{\@dtl@gap sp}%
+ \ifdim\dtl@tmplength<\DTLminminortickgap
+ \FPdiv{\@dtl@gap}{\@dtl@width}{2}%
+ \setlength\dtl@tmplength{\@dtl@gap sp}%
+ \ifdim\dtl@tmplength<\DTLminminortickgap
+ \let\@dtl@gap=\@dtl@width
+ \fi
+ \fi
+ \fi
+ \FPdiv{\@dtl@gap}{\@dtl@gap}{#3}%
+ \dtl@constructticklistwithgapex{#1}{#2}{\dtl@tmp}{\@dtl@gap}%
+ \ifx#4\@empty
+ \let#4=\dtl@tmp
+ \else
+ \expandafter\toks@\expandafter{#4}%
+ \edef#4{#4,\dtl@tmp}%
+ \fi
+}
+\newcommand*{\dtl@constructticklistwithgapex}[4]{%
+\edef\@dtl@thistick{#1}%
+\let#3=\@empty
+\FPadd{\@dtl@thistick}{\@dtl@thistick}{#4}%
+\whiledo{\DTLisFPopenbetween{\@dtl@thistick}{#1}{#2}}{%
+ \expandafter\toks@\expandafter{\@dtl@thistick}%
+ \ifx#3\@empty
+ \edef#3{\the\toks@}%
+ \else
+ \edef#3{#3,\the\toks@}%
+ \fi
+ \FPadd{\@dtl@thistick}{\@dtl@thistick}{#4}%
+}%
+}
+\newcommand*{\DTLaddtoplotlegend}[3]{%
+\def\dtl@legendline{}%
+\ifx\relax#2\relax
+\else
+ \toks@{#2%
+ \pgfpathmoveto{\pgfpoint{-10pt}{0pt}}%
+ \pgfpathlineto{\pgfpoint{10pt}{0pt}}%
+ \pgfusepath{stroke}}%
+ \edef\dtl@legendline{\the\toks@}%
+\fi
+\ifx\relax#1\relax
+\else
+ \toks@{#1}%
+ \expandafter\@dtl@toks\expandafter{\dtl@legendline}%
+ \edef\dtl@legendline{\the\@dtl@toks\the\toks@}%
+\fi
+\expandafter\toks@\expandafter{\dtl@legendline}%
+\ifx\dtl@legend\@empty
+ \edef\dtl@legend{\noexpand\tikz\the\toks@; \noexpand& #3}%
+\else
+ \expandafter\@dtl@toks\expandafter{\dtl@legend}%
+ \edef\dtl@legend{\the\@dtl@toks\noexpand\\%
+ \noexpand\tikz\the\toks@; \noexpand& #3}%
+\fi
+}
+\endinput
+%%
+%% End of file `dataplot.sty'.
diff --git a/Master/texmf-dist/tex/latex/datatool/datatool.sty b/Master/texmf-dist/tex/latex/datatool/datatool.sty
new file mode 100644
index 00000000000..099417295be
--- /dev/null
+++ b/Master/texmf-dist/tex/latex/datatool/datatool.sty
@@ -0,0 +1,3318 @@
+%%
+%% This is file `datatool.sty',
+%% generated with the docstrip utility.
+%%
+%% The original source files were:
+%%
+%% datatool.dtx (with options: `datatool.sty,package')
+%%
+%% datatool.dtx
+%% Copyright 2007 Nicola Talbot
+%%
+%% This work may be distributed and/or modified under the
+%% conditions of the LaTeX Project Public License, either version 1.3
+%% of this license of (at your option) any later version.
+%% The latest version of this license is in
+%% http://www.latex-project.org/lppl.txt
+%% and version 1.3 or later is part of all distributions of LaTeX
+%% version 2005/12/01 or later.
+%%
+%% This work has the LPPL maintenance status `maintained'.
+%%
+%% The Current Maintainer of this work is Nicola Talbot.
+%%
+%% This work consists of the files datatool.dtx and datatool.ins and the derived files datatool.sty, datapie.sty, dataplot.sty, databar.sty, databib.sty, databib.bst.
+%%
+%% \CharacterTable
+%% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
+%% Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
+%% Digits \0\1\2\3\4\5\6\7\8\9
+%% Exclamation \! Double quote \" Hash (number) \#
+%% Dollar \$ Percent \% Ampersand \&
+%% Acute accent \' Left paren \( Right paren \)
+%% Asterisk \* Plus \+ Comma \,
+%% Minus \- Point \. Solidus \/
+%% Colon \: Semicolon \; Less than \<
+%% Equals \= Greater than \> Question mark \?
+%% Commercial at \@ Left bracket \[ Backslash \\
+%% Right bracket \] Circumflex \^ Underscore \_
+%% Grave accent \` Left brace \{ Vertical bar \|
+%% Right brace \} Tilde \~}
+\NeedsTeXFormat{LaTeX2e}
+\ProvidesPackage{datatool}[2007/08/17 v1.01 (NLCT)]
+\RequirePackage{xkeyval}
+\RequirePackage{ifthen}
+\RequirePackage{xfor}
+\RequirePackage{fp}
+\RequirePackage{substr}
+\newcommand*{\@dtl@separator}{,}
+\newcommand*{\DTLsetseparator}[1]{%
+\renewcommand*{\@dtl@separator}{#1}%
+\@dtl@construct@lopoffs
+}
+\begingroup
+\catcode`\ 12
+\gdef\DTLsettabseparator{%
+ \catcode`\ 12
+ \DTLsetseparator{ }%
+}
+\endgroup
+\begingroup
+\catcode`\"12\relax
+\gdef\@dtl@delimiter{"}
+\endgroup
+\newcommand*\DTLsetdelimiter[1]{%
+\renewcommand*{\@dtl@delimiter}{#1}%
+\@dtl@construct@lopoffs}
+\edef\@dtl@construct@lopoff#1#2{%
+\noexpand\long\noexpand\def\noexpand\@dtl@lopoff#1##1##2\noexpand
+\to##3##4{%
+\noexpand\ifx#2##1\noexpand\relax
+\noexpand\@dtl@qlopoff#1##1##2\noexpand\to##3##4\relax
+\noexpand\else
+\noexpand\@dtl@lop@ff#1##1##2\noexpand\to##3##4\relax
+\noexpand\fi
+}}
+\edef\@dtl@construct@qlopoff#1#2{%
+\noexpand\long\noexpand\def\noexpand\@dtl@qlopoff#1#2##1#2#1##2\noexpand
+\to##3##4{%
+\noexpand\def##4{##1}\noexpand\def##3{#1##2}%
+}}
+\edef\@dtl@construct@lop@ff#1{%
+\noexpand\long\noexpand\def\noexpand\@dtl@lop@ff#1##1#1##2\noexpand
+\to##3##4{%
+\noexpand\def##4{##1}\noexpand\def##3{#1##2}%
+}}
+\newcommand{\@dtl@construct@lopoffs}{%
+\edef\@dtl@chars{{\@dtl@separator}{\@dtl@delimiter}}%
+\expandafter\@dtl@construct@lopoff\@dtl@chars
+\expandafter\@dtl@construct@qlopoff\@dtl@chars
+\expandafter\@dtl@construct@lop@ff\expandafter{\@dtl@separator}%
+}
+\newcommand*{\@dtl@decimal}{.}
+\newcommand*{\@dtl@numbergroupchar}{,}
+\newcommand*{\DTLsetnumberchars}[2]{%
+\renewcommand*{\@dtl@numbergroupchar}{#1}%
+\renewcommand*{\@dtl@decimal}{#2}%
+\@dtl@construct@getnums
+\@dtl@construct@stripnumgrpchar{#1}}
+\edef\@dtl@construct@getintfrac#1{%
+\noexpand\def\noexpand\@dtl@getintfrac##1#1##2\noexpand\relax{%
+\noexpand\@dtl@get@intpart{##1}%
+\noexpand\def\noexpand\@dtl@fracpart{##2}%
+\noexpand\ifx\noexpand\@empty\noexpand\@dtl@fracpart
+ \noexpand\def\noexpand\@dtl@fracpart{0}%
+\noexpand\else
+ \noexpand\@dtl@getfracpart##2\noexpand\relax
+ \noexpand\@dtl@choptrailingzeroes{\noexpand\@dtl@fracpart}%
+\noexpand\fi
+}%
+\noexpand\def\noexpand\@dtl@getfracpart##1#1\noexpand\relax{%
+\noexpand\def\noexpand\@dtl@fracpart{##1}%
+}%
+\noexpand\def\noexpand\DTLconverttodecimal##1##2{%
+\noexpand\dtl@ifsingle{##1}%
+{\noexpand\expandafter\noexpand\toks@\noexpand\expandafter{##1}%
+\noexpand\edef\noexpand\@dtl@tmp{\noexpand\the\noexpand\toks@}}%
+{\noexpand\def\noexpand\@dtl@tmp{##1}}%
+ \noexpand\@dtl@standardize@currency\noexpand\@dtl@tmp
+ \noexpand\ifx\noexpand\@dtl@org@currency\noexpand\@empty
+ \noexpand\else
+ \noexpand\let\noexpand\@dtl@currency\noexpand\@dtl@org@currency
+ \noexpand\fi
+\noexpand\expandafter
+\noexpand\@dtl@getintfrac\noexpand\@dtl@tmp#1\noexpand\relax
+\noexpand\edef##2{\noexpand\@dtl@intpart.\noexpand\@dtl@fracpart}}%
+}
+\newcommand*{\@dtl@construct@getnums}{%
+\expandafter\@dtl@construct@getintfrac\expandafter{\@dtl@decimal}}
+\newcommand*{\@dtl@get@intpart}[1]{%
+\@dtl@tmpcount=1\relax
+\def\@dtl@intpart{#1}%
+\ifx\@dtl@intpart\@empty
+ \def\@dtl@intpart{0}%
+\else
+ \def\@dtl@intpart{}%
+ \@dtl@get@int@part#1.\relax%
+\fi
+\ifnum\@dtl@tmpcount<0\relax
+ \edef\@dtl@intpart{-\@dtl@intpart}%
+\fi
+\@dtl@strip@numgrpchar{\@dtl@intpart}%
+}
+\def\@dtl@get@int@part#1#2\relax{%
+\def\@dtl@argi{#1}%
+\def\@dtl@argii{#2}%
+\ifx\protect#1\relax%
+ \let\@dtl@get@nextintpart=\@dtl@get@int@part
+\else
+ \expandafter\ifx\@dtl@argi\$%
+ \let\@dtl@get@nextintpart=\@dtl@get@int@part
+ \else
+ \ifx-#1%
+ \multiply\@dtl@tmpcount by -1\relax
+ \let\@dtl@get@nextintpart=\@dtl@get@int@part
+ \else
+ \if\@dtl@argi+%
+ \let\@dtl@get@nextintpart=\@dtl@get@int@part
+ \else
+ \def\@dtl@intpart{#1}%
+ \ifx.\@dtl@argii
+ \let\@dtl@get@nextintpart=\@gobble
+ \else
+ \let\@dtl@get@nextintpart=\@dtl@get@next@intpart
+ \fi
+ \fi
+ \fi
+ \fi
+\fi
+\@dtl@get@nextintpart#2\relax
+}
+\def\@dtl@get@next@intpart#1.\relax{%
+\edef\@dtl@intpart{\@dtl@intpart#1}%
+}
+\newcommand*{\@dtl@choptrailingzeroes}[1]{%
+\def\@dtl@tmpcpz{}%
+\expandafter\@dtl@chop@trailingzeroes#1\@nil%
+\let#1=\@dtl@tmpcpz
+}
+\def\@dtl@chop@trailingzeroes#1#2\@nil{%
+\FPifeq{#2}{0}%
+ \edef\@dtl@tmpcpz{\@dtl@tmpcpz#1}%
+ \let\@dtl@chopzeroesnext=\@dtl@gobbletonil
+\else
+ \edef\@dtl@tmpcpz{\@dtl@tmpcpz#1}%
+ \let\@dtl@chopzeroesnext=\@dtl@chop@trailingzeroes
+\fi
+\@dtl@chopzeroesnext#2\@nil
+}
+\def\@dtl@gobbletonil#1\@nil{}
+\newcommand*{\dtl@truncatedecimal}[1]{%
+\expandafter\@dtl@truncatedecimal#1.\@nil#1}
+\def\@dtl@truncatedecimal#1.#2\@nil#3{%
+\def#3{#1}}
+\newcommand*{\@dtl@strip@numgrpchar}[1]{%
+\def\@dtl@stripped{}%
+\edef\@dtl@do@stripnumgrpchar{%
+\noexpand\@@dtl@strip@numgrpchar#1\@dtl@numbergroupchar
+\noexpand\relax}%
+\@dtl@do@stripnumgrpchar
+\let#1=\@dtl@stripped
+}
+\edef\@dtl@construct@stripnumgrpchar#1{%
+\noexpand\def\noexpand\@@dtl@strip@numgrpchar##1#1##2\noexpand\relax{%
+\noexpand\expandafter\noexpand\toks@\noexpand\expandafter
+{\noexpand\@dtl@stripped}%
+\noexpand\edef\noexpand\@dtl@stripped{\noexpand\the\noexpand\toks@
+##1}%
+\noexpand\def\noexpand\@dtl@tmp{##2}%
+\noexpand\ifx\noexpand\@dtl@tmp\noexpand\@empty
+ \noexpand\let\noexpand\@dtl@next=\noexpand\relax
+\noexpand\else
+ \noexpand\let\noexpand\@dtl@next=\noexpand\@@dtl@strip@numgrpchar
+\noexpand\fi
+\noexpand\@dtl@next##2\noexpand\relax
+}%
+}
+\newcommand*{\DTLdecimaltolocale}[2]{%
+\edef\@dtl@tmpdtl{#1}%
+\expandafter\@dtl@decimaltolocale\@dtl@tmpdtl.\relax
+\FPifeq{\@dtl@fracpart}{0}%
+ \edef#2{\@dtl@intpart}%
+\else
+ \edef#2{\@dtl@intpart\@dtl@decimal\@dtl@fracpart}%
+\fi
+}
+\def\@dtl@decimaltolocale#1.#2\relax{%
+\@dtl@decimaltolocaleint{#1}%
+\def\@dtl@fracpart{#2}%
+\ifx\@dtl@fracpart\@empty
+ \def\@dtl@fracpart{0}%
+\else
+ \@dtl@decimaltolocalefrac#2\relax
+\fi
+}
+\def\@dtl@decimaltolocaleint#1{%
+\@dtl@tmpcount=0\relax
+\@dtl@countdigits#1.\relax
+\@dtl@numgrpsepcount=\@dtl@tmpcount\relax
+\divide\@dtl@numgrpsepcount by 3\relax
+\multiply\@dtl@numgrpsepcount by 3\relax
+\advance\@dtl@numgrpsepcount by -\@dtl@tmpcount\relax
+\ifnum\@dtl@numgrpsepcount<0\relax
+ \advance\@dtl@numgrpsepcount by 3\relax
+\fi
+\def\@dtl@intpart{}%
+\@dtl@decimal@to@localeint#1.\relax
+}
+\def\@dtl@countdigits#1#2\relax{%
+\advance\@dtl@tmpcount by 1\relax
+\ifx.#2\relax
+ \let\@dtl@countnext=\@gobble
+\else
+ \let\@dtl@countnext=\@dtl@countdigits
+\fi
+\@dtl@countnext#2\relax
+}
+\def\@dtl@decimal@to@localeint#1#2\relax{%
+\advance\@dtl@numgrpsepcount by 1\relax
+\ifx.#2\relax
+ \edef\@dtl@intpart{\@dtl@intpart#1}%
+ \let\@dtl@localeintnext=\@gobble
+\else
+ \ifnum\@dtl@numgrpsepcount=3\relax
+ \edef\@dtl@intpart{\@dtl@intpart#1\@dtl@numbergroupchar}%
+ \@dtl@numgrpsepcount=0\relax
+ \else
+ \ifnum\@dtl@numgrpsepcount>3\relax
+ \@dtl@numgrpsepcount=0\relax
+ \fi
+ \edef\@dtl@intpart{\@dtl@intpart#1}%
+ \fi
+ \let\@dtl@localeintnext=\@dtl@decimal@to@localeint
+\fi
+\@dtl@localeintnext#2\relax
+}
+\def\@dtl@decimaltolocalefrac#1.\relax{%
+\def\@dtl@fracpart{#1}%
+\@dtl@choptrailingzeroes{\@dtl@fracpart}%
+}
+\newcommand*{\DTLdecimaltocurrency}[2]{%
+\edef\@dtl@tmpdtl{#1}%
+\expandafter\@dtl@decimaltolocale\@dtl@tmpdtl.\relax
+\dtl@truncatedecimal\@dtl@tmpdtl
+\@dtl@tmpcount=\@dtl@tmpdtl\relax
+\expandafter\@dtl@toks\expandafter{\@dtl@currency}%
+\FPifeq{\@dtl@fracpart}{0}%
+ \ifnum\@dtl@tmpcount<0\relax
+ \@dtl@tmpcount = -\@dtl@tmpcount\relax
+ \edef#2{-\the\@dtl@toks\the\@dtl@tmpcount\@dtl@decimal00}%
+ \else
+ \edef#2{\the\@dtl@toks\@dtl@intpart\@dtl@decimal00}%
+ \fi
+\else
+ \ifnum\@dtl@tmpcount<0\relax
+ \@dtl@tmpcount = -\@dtl@tmpcount\relax
+ \ifnum\@dtl@fracpart<10\relax
+ \edef#2{-\the\@dtl@toks\number\@dtl@tmpcount
+ \@dtl@decimal\@dtl@fracpart0}%
+ \else
+ \edef#2{-\the\@dtl@toks\number\@dtl@tmpcount
+ \@dtl@decimal\@dtl@fracpart}%
+ \fi
+ \else
+ \ifnum\@dtl@fracpart<10\relax
+ \edef#2{\the\@dtl@toks\@dtl@intpart\@dtl@decimal\@dtl@fracpart0}%
+ \else
+ \edef#2{\the\@dtl@toks\@dtl@intpart\@dtl@decimal\@dtl@fracpart}%
+ \fi
+ \fi
+\fi
+}
+\@dtl@construct@lopoffs
+\@dtl@construct@getnums
+\expandafter\@dtl@construct@stripnumgrpchar\expandafter
+{\@dtl@numbergroupchar}
+\define@key{datatool.sty}{separator}{%
+\DTLsetseparator{#1}}
+\define@key{datatool.sty}{delimiter}{%
+\DTLsetdelimiter{#1}}
+\define@boolkey{datatool.sty}[dtl]{verbose}[true]{%
+\ifdtlverbose \FPmessagestrue\else \FPmessagesfalse\fi}
+\newcommand*{\dtl@message}[1]{%
+\ifdtlverbose\typeout{#1}\fi}
+\ProcessOptionsX
+\DeclareRobustCommand\DTLpar{\@par}
+\newcount\@dtl@datatype
+\newcount\@dtl@tmpcount
+\newlength\dtl@tmplength
+\newcount\@dtl@numgrpsepcount
+\newcommand{\@dtl@checknumerical}[1]{%
+\@dtl@numgrpsepfalse
+\def\@dtl@tmp{#1}%
+\ifx\@empty#1\@empty
+ \@dtl@datatype=0\relax
+\else
+ \dtl@ifsingle{#1}%
+ {\expandafter\toks@\expandafter{#1}%
+ \edef\@dtl@tmp{\the\toks@}}%
+ {\def\@dtl@tmp{#1}}%
+ \@dtl@tmpcount=0\relax
+ \@dtl@datatype=0\relax
+ \@dtl@numgrpsepcount=2\relax
+ \@dtl@standardize@currency\@dtl@tmp
+ \ifx\@dtl@org@currency\@empty
+ \else
+ \let\@dtl@currency\@dtl@org@currency
+ \fi
+ \expandafter\@dtl@checknumericalstart\@dtl@tmp\@nil\@nil
+\fi
+\ifnum\@dtl@numgrpsepcount>-1\relax
+ \if@dtl@numgrpsep
+ \ifnum\@dtl@numgrpsepcount=3\relax
+ \else
+ \@dtl@datatype=0\relax
+ \fi
+ \fi
+\fi
+}
+\def\@dtl@checknumericalstart#1#2\@nil\@nil{%
+\ifx#1\protect
+ \@dtl@checknumericalstart#2\@nil\@nil\relax
+\else
+ \ifx-#1\relax
+ \def\@dtl@tmp{#2}%
+ \ifx\@empty\@dtl@tmp
+ \@dtl@datatype=0\relax
+ \else
+ \ifnum\@dtl@datatype=0\relax
+ \@dtl@datatype=1\relax
+ \fi
+ \@dtl@checknumericalstart#2\@nil\@nil\relax
+ \fi
+ \else
+ \ifx+#1\relax
+ \def\@dtl@tmp{#2}%
+ \ifx\@empty\@dtl@tmp
+ \@dtl@datatype=0\relax
+ \else
+ \ifnum\@dtl@datatype=0\relax
+ \@dtl@datatype=1\relax
+ \fi
+ \@dtl@checknumericalstart#2\@nil\@nil\relax
+ \fi
+ \else
+ \def\@dtl@tmp{#1}%
+ \ifx#1\$\relax
+ \@dtl@datatype=3\relax
+ \@dtl@checknumericalstart#2\@nil\@nil\relax
+ \else
+ \ifx\@empty\@dtl@tmp
+ \@dtl@datatype=0\relax
+ \else
+ \ifnum\@dtl@datatype=0\relax
+ \@dtl@datatype=1\relax
+ \fi
+ \@dtl@checknumericalloop#1#2\@nil\@nil\relax
+ \fi
+ \fi
+ \fi
+ \fi
+\fi
+}
+\newif\if@dtl@numgrpsep
+\newcommand*{\@dtl@ifDigitOrDecimalSep}[3]{%
+\ifx0#1\relax
+ #2%
+\else
+ \ifx1#1\relax
+ #2%
+ \else
+ \ifx2#1\relax
+ #2%
+ \else
+ \ifx3#1\relax
+ #2%
+ \else
+ \ifx4#1\relax
+ #2%
+ \else
+ \ifx5#1\relax
+ #2%
+ \else
+ \ifx6#1\relax
+ #2%
+ \else
+ \ifx7#1\relax
+ #2%
+ \else
+ \ifx8#1\relax
+ #2%
+ \else
+ \ifx9#1\relax
+ #2%
+ \else
+ \expandafter\ifx\@dtl@decimal#1\relax
+ #2%
+ \else
+ #3%
+ \fi
+ \fi
+ \fi
+ \fi
+ \fi
+ \fi
+ \fi
+ \fi
+ \fi
+ \fi
+\fi
+}
+\def\@dtl@checknumericalloop#1#2\@nil{%
+\def\@dtl@tmp{#1}%
+\ifx\@nnil\@dtl@tmp\relax
+ \let\@dtl@chcknumnext=\@dtl@checknumericalnoop%
+\else
+ \@dtl@ifDigitOrDecimalSep{#1}{%
+ \let\@dtl@chcknumnext=\@dtl@checknumericalloop%
+ \expandafter\ifx\@dtl@decimal#1\relax
+ \if@dtl@numgrpsep
+ \ifnum\@dtl@numgrpsepcount=3\relax
+ \@dtl@numgrpsepcount=-1\relax
+ \else
+ \@dtl@datatype=0\relax
+ \let\@dtl@chcknumnext=\@dtl@checknumericalnoop
+ \fi
+ \else
+ \@dtl@numgrpsepcount=-1\relax
+ \fi
+ \else
+ \ifnum\@dtl@numgrpsepcount=-1\relax
+ \else
+ \advance\@dtl@numgrpsepcount by 1\relax
+ \fi
+ \fi
+}{%
+\ifx\@dtl@numbergroupchar\@dtl@tmp\relax
+ \@dtl@numgrpseptrue
+ \ifnum\@dtl@numgrpsepcount<3\relax
+ \@dtl@datatype=0\relax
+ \let\@dtl@chcknumnext=\@dtl@checknumericalnoop
+ \else
+ \@dtl@numgrpsepcount=0\relax
+ \fi
+\else
+ \@dtl@datatype=0\relax
+ \let\@dtl@chcknumnext=\@dtl@checknumericalnoop
+\fi
+}%
+ \ifx\@dtl@decimal\@dtl@tmp\relax
+ \ifnum\@dtl@datatype<3\relax
+ \@dtl@datatype=2\relax
+ \fi
+ \advance\@dtl@tmpcount by 1\relax
+ \ifnum\@dtl@tmpcount>1\relax
+ \@dtl@datatype=0\relax
+ \let\@dtl@chcknumnext=\@dtl@checknumericalnoop%
+ \fi
+ \fi
+\fi
+\@dtl@chcknumnext#2\@nil
+}
+\def\@dtl@checknumericalnoop#1\@nil#2{}
+\newcommand{\DTLifnumerical}[3]{%
+\@dtl@checknumerical{#1}%
+\ifnum\@dtl@datatype=0\relax#3\else#2\fi
+}
+\newcommand{\DTLifreal}[3]{%
+\@dtl@checknumerical{#1}%
+\ifnum\@dtl@datatype=2\relax #2\else #3\fi
+}
+\newcommand{\DTLifint}[3]{%
+\@dtl@checknumerical{#1}%
+\ifnum\@dtl@datatype=1\relax #2\else #3\fi
+}
+\newcommand{\DTLifstring}[3]{%
+\@dtl@checknumerical{#1}%
+\ifnum\@dtl@datatype=0\relax #2\else #3\fi
+}
+\newcommand{\DTLifcurrency}[3]{%
+\@dtl@checknumerical{#1}%
+\ifnum\@dtl@datatype=3\relax #2\else #3\fi
+}
+\newcommand*{\DTLifcurrencyunit}[4]{%
+\@dtl@checknumerical{#1}%
+\ifnum\@dtl@datatype=3\relax
+ \ifthenelse{\equal{\@dtl@org@currency}{#2}}{#3}{#4}%
+\else
+ #4%
+\fi
+}
+\newcommand{\DTLifcasedatatype}[5]{%
+\@dtl@checknumerical{#1}%
+\ifcase\@dtl@datatype
+ #2% string
+\or
+ #3% integer
+\or
+ #4% number
+\or
+ #5% currency
+\fi
+}
+\newcommand*{\dtl@testbothnumerical}[2]{%
+\dtl@ifsingle{#1}{%
+ \edef\@dtl@tmp{#1}}{%
+ \def\@dtl@tmp{#1}}%
+\expandafter\@dtl@checknumerical\expandafter{\@dtl@tmp}%
+\edef\@dtl@firsttype{\number\@dtl@datatype}%
+\dtl@ifsingle{#2}{%
+ \edef\@dtl@tmp{#2}}{%
+ \def\@dtl@tmp{#2}}%
+\expandafter\@dtl@checknumerical\expandafter{\@dtl@tmp}%
+\multiply\@dtl@datatype by \@dtl@firsttype\relax
+\ifnum\@dtl@datatype>0\relax
+ \@dtl@conditiontrue
+\else
+ \@dtl@conditionfalse
+\fi
+}
+\newcommand*{\DTLifnumlt}[4]{%
+ \DTLconverttodecimal{#1}{\@dtl@numi}%
+ \DTLconverttodecimal{#2}{\@dtl@numii}%
+ \FPiflt{\@dtl@numi}{\@dtl@numii}%
+ #3%
+ \else
+ #4%
+ \fi
+}
+\newcommand*{\dtlcompare}[3]{%
+\dtl@subnobrsp{#2}{\@dtl@argA}%
+\dtl@subnobrsp{#3}{\@dtl@argB}%
+\ifx\@dtl@argA\@empty
+ \ifx\@dtl@argB\@empty
+ #1=0\relax
+ \else
+ #1=-1\relax
+ \fi
+\else
+ \ifx\@dtl@argB\@empty
+ #1=1\relax
+ \else
+ \DTLsubstituteall{\@dtl@argA}{ }{\space }%
+ \DTLsubstituteall{\@dtl@argB}{ }{\space }%
+ \expandafter\dtl@getfirst\@dtl@argA\end
+ \let\dtl@firstA=\dtl@first
+ \let\dtl@restA=\dtl@rest
+ \expandafter\dtl@getfirst\@dtl@argB\end
+ \let\dtl@firstB=\dtl@first
+ \let\dtl@restB=\dtl@rest
+ \expandafter\dtl@ifsingle\expandafter{\dtl@firstA}{%
+ \expandafter\dtl@ifsingle\expandafter{\dtl@firstB}{%
+ \expandafter\dtl@setcharcode\expandafter{\dtl@firstA}{\dtl@codeA}%
+ \expandafter\dtl@setcharcode\expandafter{\dtl@firstB}{\dtl@codeB}%
+ \ifnum\dtl@codeA=-1\relax
+ \ifnum\dtl@codeB=-1\relax
+ \protected@edef\dtl@donext{%
+ \noexpand\dtlcompare{\noexpand#1}{\dtl@restA}{\dtl@restB}}%
+ \dtl@donext
+ \else
+ \protected@edef\dtl@donext{%
+ \noexpand\dtlcompare
+ {\noexpand#1}{\dtl@restA}{\dtl@firstB\dtl@restB}}%
+ \dtl@donext
+ \fi
+ \else
+ \ifnum\dtl@codeB=-1\relax
+ \protected@edef\dtl@donext{%
+ \noexpand\dtlcompare
+ {\noexpand#1}{\dtl@firstA\dtl@restA}{\dtl@restB}}%
+ \dtl@donext
+ \else
+ \ifnum\dtl@codeA<\dtl@codeB
+ #1=-1\relax
+ \else
+ \ifnum\dtl@codeA>\dtl@codeB
+ #1=1\relax
+ \else
+ \ifx\dtl@restA\@empty
+ \ifx\dtl@restB\@empty
+ #1=0\relax
+ \else
+ #1=-1\relax
+ \fi
+ \else
+ \ifx\restB\@empty
+ #1=1\relax
+ \else
+ \protected@edef\dtl@donext{%
+ \noexpand\dtlcompare
+ {\noexpand#1}{\dtl@restA}{\dtl@restB}}%
+ \dtl@donext
+ \fi
+ \fi
+ \fi
+ \fi
+ \fi
+ \fi
+ }{%
+ \protected@edef\dtl@donext{%
+ \noexpand\dtlcompare
+ {\noexpand#1}{\dtl@firstA\dtl@restA}{\dtl@firstB\dtl@restB}}%
+ \dtl@donext
+ }}{%
+ \protected@edef\dtl@donext{%
+ \noexpand\dtlcompare
+ {\noexpand#1}{\dtl@firstA\dtl@restA}{\dtl@firstB\dtl@restB}}%
+ \dtl@donext
+ }%
+ \fi
+\fi
+}
+\def\dtl@getfirst#1#2\end{%
+\def\dtl@first{#1}%
+\ifx\dtl@first\@empty
+ \def\dtl@rest{#2}%
+\else
+ \dtl@ifsingle{#1}{\def\dtl@rest{#2}}{\dtl@getfirst#1#2\end}%
+\fi
+}
+\newcount\dtl@codeA
+\newcount\dtl@codeB
+\newcommand*{\dtl@setcharcode}[2]{%
+\def\@dtl@tmp{#1}%
+\ifx\@dtl@tmp\@empty
+ #2=-1\relax
+\else
+ \ifx#1\space\relax
+ #2=`\ \relax
+ \else
+ \ifx#1~\relax
+ #2=`\ \relax
+ \else
+ \ifcat\noexpand#1\relax%
+ #2=-1\relax
+ \else
+ #2=`#1\relax
+ \fi
+ \fi
+ \fi
+\fi
+}
+\newcommand*{\dtl@setlccharcode}[2]{%
+\def\@dtl@tmp{#1}%
+\ifx\@dtl@tmp\@empty
+ #2=-1\relax
+\else
+ \ifx#1\space\relax
+ #2=`\ \relax
+ \else
+ \ifx#1~\relax
+ #2=`\ \relax
+ \else
+ \ifcat\noexpand#1\relax%
+ #2=-1\relax
+ \else
+ #2=\lccode`#1\relax
+ \fi
+ \fi
+ \fi
+\fi
+}
+\newcommand*{\dtlicompare}[3]{%
+\dtl@subnobrsp{#2}{\@dtl@argA}%
+\dtl@subnobrsp{#3}{\@dtl@argB}%
+\ifx\@dtl@argA\@empty
+ \ifx\@dtl@argB\@empty
+ #1=0\relax
+ \else
+ #1=-1\relax
+ \fi
+\else
+ \ifx\@dtl@argB\@empty
+ #1=1\relax
+ \else
+ \DTLsubstituteall{\@dtl@argA}{ }{\space }%
+ \DTLsubstituteall{\@dtl@argB}{ }{\space }%
+ \expandafter\dtl@getfirst\@dtl@argA\end
+ \let\dtl@firstA=\dtl@first
+ \let\dtl@restA=\dtl@rest
+ \expandafter\dtl@getfirst\@dtl@argB\end
+ \let\dtl@firstB=\dtl@first
+ \let\dtl@restB=\dtl@rest
+ \expandafter\dtl@ifsingle\expandafter{\dtl@firstA}{%
+ \expandafter\dtl@ifsingle\expandafter{\dtl@firstB}{%
+ \expandafter\dtl@setlccharcode\expandafter{\dtl@firstA}{\dtl@codeA}%
+ \expandafter\dtl@setlccharcode\expandafter{\dtl@firstB}{\dtl@codeB}%
+ \ifnum\dtl@codeA=-1\relax
+ \ifnum\dtl@codeB=-1\relax
+ \protected@edef\dtl@donext{%
+ \noexpand\dtlicompare{\noexpand#1}{\dtl@restA}{\dtl@restB}}%
+ \dtl@donext
+ \else
+ \protected@edef\dtl@donext{%
+ \noexpand\dtlicompare
+ {\noexpand#1}{\dtl@restA}{\dtl@firstB\dtl@restB}}%
+ \dtl@donext
+ \fi
+ \else
+ \ifnum\dtl@codeB=-1\relax
+ \protected@edef\dtl@donext{%
+ \noexpand\dtlicompare
+ {\noexpand#1}{\dtl@firstA\dtl@restA}{\dtl@restB}}%
+ \dtl@donext
+ \else
+ \ifnum\dtl@codeA<\dtl@codeB
+ #1=-1\relax
+ \else
+ \ifnum\dtl@codeA>\dtl@codeB
+ #1=1\relax
+ \else
+ \ifx\dtl@restA\@empty
+ \ifx\dtl@restB\@empty
+ #1=0\relax
+ \else
+ #1=-1\relax
+ \fi
+ \else
+ \ifx\restB\@empty
+ #1=1\relax
+ \else
+ \protected@edef\dtl@donext{%
+ \noexpand\dtlicompare
+ {\noexpand#1}{\dtl@restA}{\dtl@restB}}%
+ \dtl@donext
+ \fi
+ \fi
+ \fi
+ \fi
+ \fi
+ \fi
+ }{%
+ \protected@edef\dtl@donext{%
+ \noexpand\dtlicompare
+ {\noexpand#1}{\dtl@firstA\dtl@restA}{\dtl@firstB\dtl@restB}}%
+ \dtl@donext
+ }}{%
+ \protected@edef\dtl@donext{%
+ \noexpand\dtlicompare
+ {\noexpand#1}{\dtl@firstA\dtl@restA}{\dtl@firstB\dtl@restB}}%
+ \dtl@donext
+ }%
+ \fi
+\fi
+}
+\newcommand*{\DTLifstringlt}{\@ifstar\@sDTLifstringlt\@DTLifstringlt}
+\newcommand*{\@DTLifstringlt}[4]{%
+\protected@edef\@dtl@tmpcmp{%
+ \noexpand\dtlcompare{\noexpand\@dtl@tmpcount}{#1}{#2}}%
+\@dtl@tmpcmp
+\ifnum\@dtl@tmpcount<0\relax
+ #3%
+\else
+ #4%
+\fi
+}
+\newcommand*{\@sDTLifstringlt}[4]{%
+\protected@edef\@dtl@tmpcmp{%
+ \noexpand\dtlicompare{\noexpand\@dtl@tmpcount}{#1}{#2}}%
+\@dtl@tmpcmp
+\ifnum\@dtl@tmpcount<0\relax
+ #3%
+\else
+ #4%
+\fi
+}
+\newcommand*{\DTLiflt}{\@ifstar\@sDTLiflt\@DTLiflt}
+\newcommand*{\@DTLiflt}[4]{%
+\dtl@testbothnumerical{#1}{#2}%
+\if@dtl@condition
+ \DTLifnumlt{#1}{#2}{#3}{#4}%
+\else
+ \@DTLifstringlt{#1}{#2}{#3}{#4}%
+\fi
+}
+\newcommand*{\@sDTLiflt}[4]{%
+\dtl@testbothnumerical{#1}{#2}%
+\if@dtl@condition
+ \DTLifnumlt{#1}{#2}{#3}{#4}%
+\else
+ \@sDTLifstringlt{#1}{#2}{#3}{#4}%
+\fi
+}
+\newcommand*{\DTLifnumgt}[4]{%
+ \DTLconverttodecimal{#1}{\@dtl@numi}%
+ \DTLconverttodecimal{#2}{\@dtl@numii}%
+ \FPifgt{\@dtl@numi}{\@dtl@numii}%
+ #3%
+ \else
+ #4%
+ \fi
+}
+\newcommand*{\DTLifstringgt}{\@ifstar\@sDTLifstringgt\@DTLifstringgt}
+\newcommand*{\@DTLifstringgt}[4]{%
+\protected@edef\@dtl@tmpcmp{%
+ \noexpand\dtlcompare{\noexpand\@dtl@tmpcount}{#1}{#2}}%
+\@dtl@tmpcmp
+\ifnum\@dtl@tmpcount>0\relax
+ #3%
+\else
+ #4%
+\fi
+}
+\newcommand*{\@sDTLifstringgt}[4]{%
+\protected@edef\@dtl@tmpcmp{%
+ \noexpand\dtlicompare{\noexpand\@dtl@tmpcount}{#1}{#2}}%
+\@dtl@tmpcmp
+\ifnum\@dtl@tmpcount>0\relax
+ #3%
+\else
+ #4%
+\fi
+}
+\newcommand*{\DTLifgt}{\@ifstar\@sDTLifgt\@DTLifgt}
+\newcommand*{\@DTLifgt}[4]{%
+\dtl@testbothnumerical{#1}{#2}%
+\if@dtl@condition
+ \DTLifnumgt{#1}{#2}{#3}{#4}%
+\else
+ \@DTLifstringgt{#1}{#2}{#3}{#4}%
+\fi
+}
+\newcommand*{\@sDTLifgt}[4]{%
+\dtl@testbothnumerical{#1}{#2}%
+\if@dtl@condition
+ \DTLifnumgt{#1}{#2}{#3}{#4}%
+\else
+ \@sDTLifstringgt{#1}{#2}{#3}{#4}%
+\fi
+}
+\newcommand*{\DTLifnumeq}[4]{%
+ \DTLconverttodecimal{#1}{\@dtl@numi}%
+ \DTLconverttodecimal{#2}{\@dtl@numii}%
+ \FPifeq{\@dtl@numi}{\@dtl@numii}%
+ #3%
+ \else
+ #4%
+ \fi
+}
+\newcommand*{\DTLifstringeq}{\@ifstar\@sDTLifstringeq\@DTLifstringeq}
+\newcommand*{\@DTLifstringeq}[4]{%
+\protected@edef\@dtl@tmpcmp{%
+ \noexpand\dtlcompare{\noexpand\@dtl@tmpcount}{#1}{#2}}%
+\@dtl@tmpcmp
+\ifnum\@dtl@tmpcount=0\relax
+ #3%
+\else
+ #4%
+\fi
+}
+\newcommand*{\@sDTLifstringeq}[4]{%
+\protected@edef\@dtl@tmpcmp{%
+ \noexpand\dtlicompare{\noexpand\@dtl@tmpcount}{#1}{#2}}%
+\@dtl@tmpcmp
+\ifnum\@dtl@tmpcount=0\relax
+ #3%
+\else
+ #4%
+\fi
+}
+\newcommand*{\DTLifeq}{\@ifstar\@sDTLifeq\@DTLifeq}
+\newcommand*{\@DTLifeq}[4]{%
+\dtl@testbothnumerical{#1}{#2}%
+\if@dtl@condition
+ \DTLifnumeq{#1}{#2}{#3}{#4}%
+\else
+ \@DTLifstringeq{#1}{#2}{#3}{#4}%
+\fi
+}
+\newcommand*{\@sDTLifeq}[4]{%
+\dtl@testbothnumerical{#1}{#2}%
+\if@dtl@condition
+ \DTLifnumeq{#1}{#2}{#3}{#4}%
+\else
+ \@sDTLifstringeq{#1}{#2}{#3}{#4}%
+\fi
+}
+\newcommand*{\DTLifSubString}[4]{%
+\protected@edef\@dtl@tmp{\noexpand\dtl@testifsubstring
+{#1}{#2}}%
+\@dtl@tmp
+\if@dtl@condition
+ #3%
+\else
+ #4%
+\fi
+}
+\newcommand*{\dtl@testifsubstring}[2]{%
+\dtl@subnobrsp{#1}{\@dtl@argA}%
+\dtl@subnobrsp{#2}{\@dtl@argB}%
+\ifx\@dtl@argB\@empty
+ \@dtl@conditiontrue
+\else
+ \ifx\@dtl@argA\@empty
+ \@dtl@conditionfalse
+ \else
+ \dtl@teststartswith{#1}{#2}%
+ \if@dtl@condition
+ \else
+ \DTLsubstituteall{\@dtl@argA}{ }{\space }%
+ \expandafter\dtl@getfirst\@dtl@argA\end
+ \expandafter\dtl@ifsingle\expandafter{\dtl@first}{%
+ \expandafter\dtl@testifsubstring\expandafter{\dtl@rest}{#2}%
+ }{%
+ \protected@edef\@dtl@donext{\noexpand\dtl@testifsubstring
+ {\dtl@first\dtl@rest}{\@dtl@argB}}%
+ \@dtl@donext
+ }%
+ \fi
+ \fi
+\fi
+}
+\newcommand*{\DTLifStartsWith}[4]{%
+\@dtl@conditionfalse
+\protected@edef\@dtl@tmp{\noexpand\dtl@teststartswith{#1}{#2}}%
+\@dtl@tmp
+\if@dtl@condition
+ #3%
+\else
+ #4%
+\fi
+}
+\newcommand*{\dtl@teststartswith}[2]{%
+\dtl@subnobrsp{#1}{\@dtl@argA}%
+\dtl@subnobrsp{#2}{\@dtl@argB}%
+\ifx\@dtl@argA\@empty
+ \ifx\@dtl@argB\@empty
+ \@dtl@conditiontrue
+ \else
+ \@dtl@conditionfalse
+ \fi
+\else
+ \ifx\@dtl@argB\@empty
+ \@dtl@conditiontrue
+ \else
+ \DTLsubstituteall{\@dtl@argA}{ }{\space }%
+ \DTLsubstituteall{\@dtl@argB}{ }{\space }%
+ \expandafter\dtl@getfirst\@dtl@argA\end
+ \let\dtl@firstA=\dtl@first
+ \let\dtl@restA=\dtl@rest
+ \expandafter\dtl@getfirst\@dtl@argB\end
+ \let\dtl@firstB=\dtl@first
+ \let\dtl@restB=\dtl@rest
+ \expandafter\dtl@ifsingle\expandafter{\dtl@firstA}{%
+ \expandafter\dtl@ifsingle\expandafter{\dtl@firstB}{%
+ \expandafter\dtl@setcharcode\expandafter{\dtl@firstA}{\dtl@codeA}%
+ \expandafter\dtl@setcharcode\expandafter{\dtl@firstB}{\dtl@codeB}%
+ \ifnum\dtl@codeA=-1\relax
+ \ifnum\dtl@codeB=-1\relax
+ \protected@edef\dtl@donext{%
+ \noexpand\dtl@teststartswith{\dtl@restA}{\dtl@restB}}%
+ \dtl@donext
+ \else
+ \protected@edef\dtl@donext{%
+ \noexpand\dtl@teststartswith
+ {\dtl@restA}{\dtl@firstB\dtl@restB}}%
+ \dtl@donext
+ \fi
+ \else
+ \ifnum\dtl@codeB=-1\relax
+ \protected@edef\dtl@donext{%
+ \noexpand\dtl@teststartswith
+ {\dtl@firstA\dtl@restA}{\dtl@restB}}%
+ \dtl@donext
+ \else
+ \ifnum\dtl@codeA=\dtl@codeB
+ \protected@edef\dtl@donext{%
+ \noexpand\dtl@teststartswith{\dtl@restA}{\dtl@restB}}%
+ \dtl@donext
+ \else
+ \@dtl@conditionfalse
+ \fi
+ \fi
+ \fi
+ }{%
+ \protected@edef\dtl@donext{%
+ \noexpand\dtl@teststartswith
+ {\dtl@firstA\dtl@restA}{\dtl@firstB\dtl@restB}}%
+ \dtl@donext
+ }}{%
+ \protected@edef\dtl@donext{%
+ \noexpand\dtl@teststartswith
+ {\dtl@firstA\dtl@restA}{\dtl@firstB\dtl@restB}}%
+ }%
+ \fi
+\fi
+}
+\newcommand*{\DTLifnumclosedbetween}[5]{%
+\DTLconverttodecimal{#1}{\@dtl@numi}%
+\DTLconverttodecimal{#2}{\@dtl@numii}%
+\DTLconverttodecimal{#3}{\@dtl@numiii}%
+\DTLifFPclosedbetween{\@dtl@numi}{\@dtl@numii}{\@dtl@numiii}{#4}{#5}%
+}
+\newcommand*{\DTLifstringclosedbetween}{%
+\@ifstar\@sDTLifstringclosedbetween\@DTLifstringclosedbetween}
+\newcommand*{\@DTLifstringclosedbetween}[5]{%
+\protected@edef\@dtl@tmpcmp{%
+ \noexpand\dtlcompare{\noexpand\@dtl@tmpcount}{#1}{#2}}%
+\@dtl@tmpcmp
+\let\@dtl@dovalue\relax
+\ifnum\@dtl@tmpcount<0\relax
+ \def\@dtl@dovalue{#5}%
+\fi
+\ifx\@dtl@dovalue\relax
+ \protected@edef\@dtl@tmpcmp{%
+ \noexpand\dtlcompare{\noexpand\@dtl@tmpcount}{#1}{#3}}%
+ \@dtl@tmpcmp
+ \ifnum\@dtl@tmpcount>0\relax
+ \def\@dtl@dovalue{#5}%
+ \else
+ \def\@dtl@dovalue{#4}%
+ \fi
+\fi
+\@dtl@dovalue
+}
+\newcommand*{\@sDTLifstringclosedbetween}[5]{%
+\protected@edef\@dtl@tmpcmp{%
+ \noexpand\dtlicompare{\noexpand\@dtl@tmpcount}{#1}{#2}}%
+\@dtl@tmpcmp
+\let\@dtl@dovalue\relax
+\ifnum\@dtl@tmpcount<0\relax
+ \def\@dtl@dovalue{#5}%
+\fi
+\ifx\@dtl@dovalue\relax
+ \protected@edef\@dtl@tmpcmp{%
+ \noexpand\dtlicompare{\noexpand\@dtl@tmpcount}{#1}{#3}}%
+ \@dtl@tmpcmp
+ \ifnum\@dtl@tmpcount>0\relax
+ \def\@dtl@dovalue{#5}%
+ \else
+ \def\@dtl@dovalue{#4}%
+ \fi
+\fi
+\@dtl@dovalue
+}
+\newcommand*{\DTLifclosedbetween}{%
+\@ifstar\@sDTLifclosedbetween\@DTLifclosedbetween}
+\newcommand*{\@DTLifclosedbetween}[5]{%
+\dtl@testbothnumerical{#2}{#3}%
+\if@dtl@condition
+ \dtl@ifsingle{#1}{%
+ \edef\@dtl@tmp{#1}}{%
+ \def\@dtl@tmp{#1}}%
+ \expandafter\@dtl@checknumerical\expandafter{\@dtl@tmp}%
+ \ifnum\@dtl@datatype>0\relax
+ \DTLifnumclosedbetween{#1}{#2}{#3}{#4}{#5}%
+ \else
+ \@DTLifstringclosedbetween{#1}{#2}{#3}{#4}{#5}%
+ \fi
+\else
+ \@DTLifstringclosedbetween{#1}{#2}{#3}{#4}{#5}%
+\fi
+}
+\newcommand*{\@sDTLifclosedbetween}[5]{%
+\dtl@testbothnumerical{#2}{#3}%
+\if@dtl@condition
+ \dtl@ifsingle{#1}{%
+ \edef\@dtl@tmp{#1}}{%
+ \def\@dtl@tmp{#1}}%
+ \expandafter\@dtl@checknumerical\expandafter{\@dtl@tmp}%
+ \ifnum\@dtl@datatype>0\relax
+ \DTLifnumclosedbetween{#1}{#2}{#3}{#4}{#5}%
+ \else
+ \@sDTLifstringclosedbetween{#1}{#2}{#3}{#4}{#5}%
+ \fi
+\else
+ \@sDTLifstringclosedbetween{#1}{#2}{#3}{#4}{#5}%
+\fi
+}
+\newcommand*{\DTLifnumopenbetween}[5]{%
+\DTLconverttodecimal{#1}{\@dtl@numi}%
+\DTLconverttodecimal{#2}{\@dtl@numii}%
+\DTLconverttodecimal{#3}{\@dtl@numiii}%
+\DTLifFPopenbetween{\@dtl@numi}{\@dtl@numii}{\@dtl@numiii}{#4}{#5}%
+}
+\newcommand*{\DTLifstringopenbetween}{%
+\@ifstar\@sDTLifstringopenbetween\@DTLifstringopenbetween}
+\newcommand*{\@DTLifstringopenbetween}[5]{%
+\protected@edef\@dtl@tmpcmp{%
+ \noexpand\dtlcompare{\noexpand\@dtl@tmpcount}{#1}{#2}}%
+\@dtl@tmpcmp
+\let\@dtl@dovalue\relax
+\ifnum\@dtl@tmpcount>0\relax
+\else
+ \def\@dtl@dovalue{#5}%
+\fi
+\ifx\@dtl@dovalue\relax
+ \protected@edef\@dtl@tmpcmp{%
+ \noexpand\dtlcompare{\noexpand\@dtl@tmpcount}{#1}{#3}}%
+ \@dtl@tmpcmp
+ \ifnum\@dtl@tmpcount<0\relax
+ \def\@dtl@dovalue{#4}%
+ \else
+ \def\@dtl@dovalue{#5}%
+ \fi
+\fi
+\@dtl@dovalue
+}
+\newcommand*{\@sDTLifstringopenbetween}[5]{%
+\protected@edef\@dtl@tmpcmp{%
+ \noexpand\dtlicompare{\noexpand\@dtl@tmpcount}{#1}{#2}}%
+\@dtl@tmpcmp
+\let\@dtl@dovalue\relax
+\ifnum\@dtl@tmpcount>0\relax
+\else
+ \def\@dtl@dovalue{#5}%
+\fi
+\ifx\@dtl@dovalue\relax
+ \protected@edef\@dtl@tmpcmp{%
+ \noexpand\dtlicompare{\noexpand\@dtl@tmpcount}{#1}{#3}}%
+ \@dtl@tmpcmp
+ \ifnum\@dtl@tmpcount<0\relax
+ \def\@dtl@dovalue{#4}%
+ \else
+ \def\@dtl@dovalue{#5}%
+ \fi
+\fi
+\@dtl@dovalue
+}
+\newcommand*{\DTLifopenbetween}{%
+\@ifstar\@sDTLifopenbetween\@DTLifopenbetween}
+\newcommand*{\@DTLifopenbetween}[5]{%
+\dtl@testbothnumerical{#2}{#3}%
+\if@dtl@condition
+ \dtl@ifsingle{#1}{%
+ \edef\@dtl@tmp{#1}}{%
+ \def\@dtl@tmp{#1}}%
+ \expandafter\@dtl@checknumerical\expandafter{\@dtl@tmp}%
+ \ifnum\@dtl@datatype>0\relax
+ \DTLifnumopenbetween{#1}{#2}{#3}{#4}{#5}%
+ \else
+ \@DTLifstringopenbetween{#1}{#2}{#3}{#4}{#5}%
+ \fi
+\else
+ \@DTLifstringopenbetween{#1}{#2}{#3}{#4}{#5}%
+\fi
+}
+\newcommand*{\@sDTLifopenbetween}[5]{%
+\dtl@testbothnumerical{#2}{#3}%
+\if@dtl@condition
+ \dtl@ifsingle{#1}{%
+ \edef\@dtl@tmp{#1}}{%
+ \def\@dtl@tmp{#1}}%
+ \expandafter\@dtl@checknumerical\expandafter{\@dtl@tmp}%
+ \ifnum\@dtl@datatype>0\relax
+ \DTLifnumopenbetween{#1}{#2}{#3}{#4}{#5}%
+ \else
+ \@sDTLifstringopenbetween{#1}{#2}{#3}{#4}{#5}%
+ \fi
+\else
+ \@sDTLifstringopenbetween{#1}{#2}{#3}{#4}{#5}%
+\fi
+}
+\newcommand*{\DTLifFPopenbetween}[5]{%
+ \let\@dtl@dovalue\relax
+ \FPifgt{#1}{#2}%
+ \else
+ \def\@dtl@dovalue{#5}%
+ \fi
+ \FPiflt{#1}{#3}%
+ \ifx\@dtl@dovalue\relax
+ \def\@dtl@dovalue{#4}%
+ \fi
+ \else
+ \def\@dtl@dovalue{#5}%
+ \fi
+\@dtl@dovalue
+}
+\newcommand*{\DTLifFPclosedbetween}[5]{%
+ \let\@dtl@dovalue\relax
+ \FPifgt{#1}{#3}%
+ \def\@dtl@dovalue{#5}%
+ \fi
+ \FPiflt{#1}{#2}%
+ \ifx\@dtl@dovalue\relax
+ \def\@dtl@dovalue{#5}%
+ \fi
+ \else
+ \def\@dtl@dovalue{#4}%
+ \fi
+\@dtl@dovalue
+}
+\newcommand{\DTLiffirstrow}[2]{%
+\ifnum\dtlforeachlevel=0\relax
+ \PackageError{datatool}{\string\DTLiffirstrow\space can only
+ be used inside \string\DTLforeach}{}%
+\else
+\expandafter\ifnum\csname c@DTLrow\romannumeral
+\dtlforeachlevel\endcsname
+=1\relax#1\else#2\fi
+\fi}
+\newcommand{\DTLiflastrow}[2]{%
+\ifnum\dtlforeachlevel=0\relax
+ \PackageError{datatool}{\string\DTLiflastrow\space can only
+ be used inside \string\DTLforeach}{}%
+\else
+\ifx\@dtl@nextrow\@nnil
+#1\else #2\fi
+\fi
+}
+\newcommand{\DTLifoddrow}[2]{%
+\ifnum\dtlforeachlevel=0\relax
+ \PackageError{datatool}{\string\DTLifoddrow\space can only
+ be used inside \string\DTLforeach}{}%
+\else
+\expandafter\ifodd\csname c@DTLrow\romannumeral
+\dtlforeachlevel\endcsname
+#1\else #2\fi
+\fi
+}
+\newif\if@dtl@condition
+\newcommand*{\dtl@testlt}[2]{%
+\DTLiflt{#1}{#2}{\@dtl@conditiontrue}{\@dtl@conditionfalse}}
+\newcommand*{\DTLislt}[2]{%
+\TE@throw\noexpand\dtl@testlt{#1}{#2}\noexpand\if@dtl@condition}
+\newcommand*{\dtl@testiclt}[2]{%
+\@sDTLiflt{#1}{#2}{\@dtl@conditiontrue}{\@dtl@conditionfalse}}
+\newcommand*{\DTLisilt}[2]{%
+\TE@throw\noexpand\dtl@testiclt{#1}{#2}\noexpand\if@dtl@condition}
+\newcommand*{\dtl@testgt}[2]{%
+\DTLifgt{#1}{#2}{\@dtl@conditiontrue}{\@dtl@conditionfalse}}
+\newcommand*{\DTLisgt}[2]{%
+\TE@throw\noexpand\dtl@testgt{#1}{#2}\noexpand\if@dtl@condition}
+\newcommand*{\dtl@testicgt}[2]{%
+\@sDTLifgt{#1}{#2}{\@dtl@conditiontrue}{\@dtl@conditionfalse}}
+\newcommand*{\DTLisigt}[2]{%
+\TE@throw\noexpand\dtl@testicgt{#1}{#2}\noexpand\if@dtl@condition}
+\newcommand*{\dtl@testeq}[2]{%
+\DTLifeq{#1}{#2}{\@dtl@conditiontrue}{\@dtl@conditionfalse}}
+\newcommand*{\DTLiseq}[2]{%
+\TE@throw\noexpand\dtl@testeq{#1}{#2}\noexpand\if@dtl@condition}
+\newcommand*{\dtl@testiceq}[2]{%
+\@sDTLifeq{#1}{#2}{\@dtl@conditiontrue}{\@dtl@conditionfalse}}
+\newcommand*{\DTLisieq}[2]{%
+\TE@throw\noexpand\dtl@testiceq{#1}{#2}\noexpand\if@dtl@condition}
+\newcommand*{\DTLisSubString}[2]{%
+\TE@throw\noexpand\dtl@testifsubstring{#1}{#2}%
+\noexpand\if@dtl@condition}
+\newcommand*{\DTLisPrefix}[2]{%
+\TE@throw\noexpand\dtl@teststartswith{#1}{#2}%
+\noexpand\if@dtl@condition}
+\newcommand*{\dtl@testclosedbetween}[3]{%
+\DTLifclosedbetween{#1}{#2}{#3}{\@dtl@conditiontrue}{\@dtl@conditionfalse}}
+\newcommand*{\DTLisclosedbetween}[3]{%
+\TE@throw\noexpand\dtl@testclosedbetween{#1}{#2}{#3}%
+\noexpand\if@dtl@condition}
+\newcommand*{\dtl@testiclosedbetween}[3]{%
+\@sDTLifclosedbetween{#1}{#2}{#3}{\@dtl@conditiontrue}{\@dtl@conditionfalse}}
+\newcommand*{\DTLisiclosedbetween}[3]{%
+\TE@throw\noexpand\dtl@testiclosedbetween{#1}{#2}{#3}%
+\noexpand\if@dtl@condition}
+\newcommand*{\dtl@testopenbetween}[3]{%
+\DTLifopenbetween{#1}{#2}{#3}{\@dtl@conditiontrue
+}{\@dtl@conditionfalse}}
+\newcommand*{\DTLisopenbetween}[3]{%
+\TE@throw\noexpand\dtl@testopenbetween{#1}{#2}{#3}%
+\noexpand\if@dtl@condition}
+\newcommand*{\dtl@testiopenbetween}[3]{%
+\@sDTLifopenbetween{#1}{#2}{#3}{\@dtl@conditiontrue
+}{\@dtl@conditionfalse}}
+\newcommand*{\DTLisiopenbetween}[3]{%
+\TE@throw\noexpand\dtl@testiopenbetween{#1}{#2}{#3}%
+\noexpand\if@dtl@condition}
+\newcommand*{\dtl@testFPclosedbetween}[3]{%
+\DTLifFPclosedbetween{#1}{#2}{#3}%
+{\@dtl@conditiontrue}{\@dtl@conditionfalse}}
+\newcommand*{\DTLisFPclosedbetween}[3]{%
+\TE@throw\noexpand\dtl@testFPclosedbetween{#1}{#2}{#3}%
+\noexpand\if@dtl@condition}
+\newcommand*{\dtl@testFPopenbetween}[3]{%
+\DTLifFPopenbetween{#1}{#2}{#3}{\@dtl@conditiontrue}{\@dtl@conditionfalse}}
+\newcommand*{\DTLisFPopenbetween}[3]{%
+\TE@throw\noexpand\dtl@testFPopenbetween{#1}{#2}{#3}%
+\noexpand\if@dtl@condition}
+\newcommand*{\dtl@testFPislt}[2]{%
+\FPiflt{#1}{#2}\@dtl@conditiontrue\else\@dtl@conditionfalse\fi}
+\newcommand*{\DTLisFPlt}[2]{%
+\TE@throw\noexpand\dtl@testFPislt{#1}{#2}%
+\noexpand\if@dtl@condition}
+\newcommand*{\dtl@testFPisgt}[2]{%
+\FPifgt{#1}{#2}\@dtl@conditiontrue\else\@dtl@conditionfalse\fi}
+\newcommand*{\DTLisFPgt}[2]{%
+\TE@throw\noexpand\dtl@testFPisgt{#1}{#2}%
+\noexpand\if@dtl@condition}
+\newcommand*{\dtl@testFPiseq}[2]{%
+\FPifeq{#1}{#2}\@dtl@conditiontrue\else\@dtl@conditionfalse\fi}
+\newcommand*{\DTLisFPeq}[2]{%
+\TE@throw\noexpand\dtl@testFPiseq{#1}{#2}%
+\noexpand\if@dtl@condition}
+\newcommand*{\dtl@testFPislteq}[2]{%
+\FPiflt{#1}{#2}\@dtl@conditiontrue\else\@dtl@conditionfalse\fi
+\if@dtl@condition
+\else
+ \dtl@testFPiseq{#1}{#2}%
+\fi
+}
+\newcommand*{\DTLisFPlteq}[2]{%
+\TE@throw\noexpand\dtl@testFPislteq{#1}{#2}%
+\noexpand\if@dtl@condition}
+\newcommand*{\dtl@testFPisgteq}[2]{%
+\FPifgt{#1}{#2}\@dtl@conditiontrue\else\@dtl@conditionfalse\fi
+\if@dtl@condition
+\else
+ \dtl@testFPiseq{#1}{#2}%
+\fi
+}
+\newcommand*{\DTLisFPgteq}[2]{%
+\TE@throw\noexpand\dtl@testFPisgteq{#1}{#2}%
+\noexpand\if@dtl@condition}
+\newcommand*{\dtl@teststring}[1]{%
+\DTLifstring{#1}{\@dtl@conditiontrue}{\@dtl@conditionfalse}}
+\newcommand*{\DTLisstring}[1]{%
+\TE@throw\noexpand\dtl@teststring{#1}\noexpand\if@dtl@condition}
+\newcommand*{\dtl@testnumerical}[1]{%
+\DTLifnumerical{#1}{\@dtl@conditiontrue}{\@dtl@conditionfalse}%
+}
+\newcommand*{\DTLisnumerical}[1]{%
+\TE@throw\noexpand\dtl@testnumerical{#1}\noexpand\if@dtl@condition}
+\newcommand*{\dtl@testint}[1]{%
+\DTLifint{#1}{\@dtl@conditiontrue}{\@dtl@conditionfalse}}
+\newcommand*{\DTLisint}[1]{%
+\TE@throw\noexpand\dtl@testint{#1}\noexpand\if@dtl@condition}
+\newcommand*{\dtl@testreal}[1]{%
+\DTLifreal{#1}{\@dtl@conditiontrue}{\@dtl@conditionfalse}}
+\newcommand*{\DTLisreal}[1]{%
+\TE@throw\noexpand\dtl@testreal{#1}\noexpand\if@dtl@condition}
+\newcommand*{\dtl@testcurrency}[1]{%
+\DTLifcurrency{#1}{\@dtl@conditiontrue}{\@dtl@conditionfalse}}
+\newcommand*{\DTLiscurrency}[1]{%
+\TE@throw\noexpand\dtl@testcurrency{#1}\noexpand\if@dtl@condition}
+\newcommand*{\dtl@testcurrencyunit}[2]{%
+\DTLifcurrencyunit{#1}{#2}{\@dtl@conditiontrue}{\@dtl@conditionfalse}}
+\newcommand*{\DTLiscurrencyunit}[2]{%
+\TE@throw\noexpand\dtl@testcurrencyunit{#1}{#2}%
+\noexpand\if@dtl@condition}
+\newcommand*{\DTLnewdb}[1]{%
+\DTLifdbexists{#1}{%
+\PackageError{datatool}{Database `#1' already exists}{}}{%
+\dtl@message{Creating database `#1'}%
+\expandafter\gdef\csname dtldb@#1\endcsname{}%
+\expandafter\gdef\csname dtlkeys@#1\endcsname{}%
+\expandafter\global\expandafter\newcount\csname dtlrows@#1\endcsname}}
+\newcommand*{\DTLrowcount}[1]{%
+\expandafter\number\csname dtlrows@#1\endcsname}
+\newcommand{\DTLifdbempty}[3]{%
+\DTLifdbexists{#1}{%
+\expandafter\ifx\csname dtldb@#1\endcsname\@empty
+ #2%
+\else
+ #3%
+\fi}{%
+\PackageError{Database `#1' doesn't exist}{}{}}}
+\newcommand*{\DTLnewrow}[1]{%
+\DTLifdbempty{#1}{%
+ \expandafter\gdef\csname dtldb@#1\endcsname{{}}%
+ \expandafter\global\expandafter\advance
+ \csname dtlrows@#1\endcsname by 1\relax
+ \dtl@message{New row added to database `#1'}%
+}{%
+ \expandafter\let\expandafter\@dtl@olddb\csname dtldb@#1\endcsname%
+ \expandafter\toks@\expandafter{\@dtl@olddb,{}}%
+ \expandafter\xdef\csname dtldb@#1\endcsname{\the\toks@}%
+ \expandafter\global\expandafter\advance
+ \csname dtlrows@#1\endcsname by 1\relax
+ \dtl@message{New row added to database `#1'}%
+}}
+\newcommand{\DTLnewdbentry}[3]{%
+\@dtl@toks{#3}%
+\edef\@dtl@dbvalue{\the\@dtl@toks}%
+\edef\@dtl@dbid{#2}%
+\edef\@dtl@dbentry{{\@dtl@dbid}{\the\@dtl@toks}}%
+\DTLifdbempty{#1}{\DTLnewrow{#1}}{}%
+\expandafter\dtl@choplast\expandafter{%
+\csname dtldb@#1\endcsname}{\@dtl@dbrest}{\@dtl@dblastrow}%
+\dtl@ifrowcontains{#2}{\@dtl@dblastrow}{%
+\PackageError{datatool}{Can't add entry with ID `#2' to current
+row of database `#1'}{There is already an entry with this ID on
+the current row}}{%
+\expandafter\@dtl@toks\expandafter{\@dtl@dbentry}%
+\ifthenelse{\equal{}{\@dtl@dblastrow}}{%
+ \edef\@dtl@dblastrow{\the\@dtl@toks}%
+}{%
+ \expandafter\toks@\expandafter{\@dtl@dblastrow}%
+ \edef\@dtl@dblastrow{\the\toks@,\the\@dtl@toks}%
+}%
+\expandafter\@dtl@toks\expandafter{\@dtl@dblastrow}%
+\ifthenelse{\equal{}{\@dtl@dbrest}}{%
+ \expandafter\long\expandafter\xdef\csname dtldb@#1\endcsname{%
+ {\the\@dtl@toks}}%
+}{%
+ \expandafter\toks@\expandafter{\@dtl@dbrest}%
+ \expandafter\long\expandafter\xdef\csname dtldb@#1\endcsname{%
+ \the\toks@,{\the\@dtl@toks}}%
+}%
+\@dtl@setidtype{#1}{#2}{#3}%
+\expandafter\@dtl@setkeys\expandafter{#2}{#1}%
+}%
+\dtl@message{Added #2\space -> #3\space to database `#1'}%
+}
+\newcommand{\@dtl@setidtype}[3]{%
+\@dtl@checknumerical{#3}%
+\def\@dtl@value{#3}%
+\@ifundefined{@dtl@idtype@#1@#2}{%
+\ifx\@dtl@value\@empty
+ \expandafter\gdef\csname @dtl@idtype@#1@#2\endcsname{}%
+\else
+ \expandafter\xdef\csname @dtl@idtype@#1@#2\endcsname{%
+ \the\@dtl@datatype}%
+\fi
+}{%
+\ifx\@dtl@value\@empty
+\else
+ \expandafter\ifx\csname @dtl@idtype@#1@#2\endcsname\@empty
+ \expandafter\xdef\csname @dtl@idtype@#1@#2\endcsname{%
+ \the\@dtl@datatype}%
+ \else
+ \expandafter\@dtl@tmpcount\expandafter=
+ \csname @dtl@idtype@#1@#2\endcsname\relax
+ \ifcase\@dtl@tmpcount
+ \or
+ \expandafter\xdef\csname @dtl@idtype@#1@#2\endcsname{%
+ \the\@dtl@datatype}%
+ \or
+ \ifnum\@dtl@datatype=0\relax
+ \expandafter\gdef\csname @dtl@idtype@#1@#2\endcsname{0}%
+ \else
+ \ifnum\@dtl@datatype=3\relax
+ \expandafter\gdef\csname @dtl@idtype@#1@#2\endcsname{3}%
+ \else
+ \expandafter\gdef\csname @dtl@idtype@#1@#2\endcsname{2}%
+ \fi
+ \fi
+ \or
+ \ifnum\@dtl@datatype=0\relax
+ \expandafter\gdef\csname @dtl@idtype@#1@#2\endcsname{0}%
+ \else
+ \expandafter\gdef\csname @dtl@idtype@#1@#2\endcsname{3}%
+ \fi
+ \fi
+ \fi
+\fi
+}%
+}
+\newcommand*{\@dtl@setkeys}[2]{%
+\edef\@dtl@tmp{\csname dtlkeys@#2\endcsname}%
+\expandafter\@dtl@toks\expandafter{\@dtl@tmp}%
+\expandafter\ifx\csname dtlkeys@#2\endcsname\@empty
+ \expandafter\gdef\csname dtlkeys@#2\endcsname{#1}%
+\else
+ \@for\dtl@key:=\@dtl@tmp\do{%
+ \ifthenelse{\equal{\dtl@key}{#1}}{\@endfortrue}{}%
+ }%
+ \if@endfor
+ \else
+ \expandafter\xdef\csname dtlkeys@#2\endcsname{\the\@dtl@toks,#1}%
+ \fi
+\fi
+}
+\newcommand*{\@dtl@getidtype}[2]{%
+\csname @dtl@idtype@#1@#2\endcsname}
+\newcommand{\DTLifdbexists}[3]{%
+\@ifundefined{dtldb@#1}{#3}{#2}}
+\newcommand{\dtl@ifrowcontains}[4]{%
+\@for\@dtl@element:=#2\do{%
+\dtl@getentryid{\@dtl@element}{\@dtl@entryid}%
+\ifthenelse{\equal{#1}{\@dtl@entryid}}{\@endfortrue}{}%
+}%
+\if@endfor #3\else #4\fi
+}
+\newcommand*{\dtl@getentryid}[2]{\expandafter\@dtl@getentryid#1#2}
+\long\def\@dtl@getentryid#1#2#3{\def#3{#1}}
+\newcommand*{\dtl@getentryvalue}[2]{%
+\expandafter\@dtl@getentryvalue#1#2}
+\long\def\@dtl@getentryvalue#1#2#3{\gdef#3{#2}}
+\global\newcount\dtlforeachlevel
+\newcounter{DTLrowi}
+\newcounter{DTLrowii}
+\newcounter{DTLrowiii}
+\newcounter{DTLrow}
+\def\theHDTLrow{\arabic{DTLrow}}
+\def\theHDTLrowi{\theHDTLrow.\arabic{DTLrowi}}
+\def\theHDTLrowii{\theHDTLrowi.\arabic{DTLrowii}}
+\def\theHDTLrowiii{\theHDTLrowii.\arabic{DTLrowiii}}
+\newcommand*{\DTLsavelastrowcount}[1]{%
+\ifnum\dtlforeachlevel>2\relax
+ \def#1{0}%
+\else
+ \ifnum\dtlforeachlevel<0\relax
+ \def#1{0}%
+ \else
+ \@dtl@tmpcount=\dtlforeachlevel
+ \advance\@dtl@tmpcount by 1\relax
+ \edef#1{\expandafter\number
+ \csname c@DTLrow\romannumeral\@dtl@tmpcount\endcsname}%
+ \fi
+\fi}
+\newcommand*{\DTLforeach}{\@ifstar\@sDTLforeach\@DTLforeach}
+\newcommand{\@DTLforeach}[4][\boolean{true}]{%
+\DTLifdbexists{#2}{%
+\refstepcounter{DTLrow}%
+\global\c@DTLrow=\c@DTLrow
+\gdef\@dtl@dbname{#2}%
+\global\advance\dtlforeachlevel by 1\relax
+\ifnum\dtlforeachlevel>3\relax
+ \PackageError{datatool}{\string\DTLforeach\space nested too
+deeply}{}%
+\else
+ \expandafter\global
+ \csname c@DTLrow\romannumeral\dtlforeachlevel\endcsname = 0\relax
+ \expandafter\global\expandafter\let
+ \csname @dtl@foreachrows@\romannumeral\dtlforeachlevel\endcsname
+ =\@empty
+ \expandafter\global\expandafter\let
+ \csname @dtl@dbname@\romannumeral\dtlforeachlevel\endcsname
+ =\@dtl@dbname
+ \expandafter\let\expandafter\@dtl@db\csname dtldb@#2\endcsname%
+ \@for\@dtl@currentrow:=\@dtl@db\do{%
+ \expandafter\global\expandafter
+ \let\csname @dtl@thiscurrentrow@\romannumeral\dtlforeachlevel
+ \endcsname=\@dtl@currentrow
+ \global\let\@dtl@nextrow\@xfor@nextelement
+ \ifx\relax#3\relax
+ \else
+ \@dtl@assign{#3}%
+ \fi
+ \ifthenelse{#1}{%
+ \refstepcounter{DTLrow\romannumeral\dtlforeachlevel}%
+ \expandafter\edef\expandafter\DTLcurrentindex\expandafter
+ {\arabic{DTLrow\romannumeral\dtlforeachlevel}}%
+ #4%
+ }{}%
+ \expandafter\let\expandafter\@dtl@thiscurrentrow
+ \csname @dtl@thiscurrentrow@\romannumeral\dtlforeachlevel\endcsname
+ \ifx\@dtl@thiscurrentrow\@empty
+ \else
+ \expandafter\@dtl@toks\expandafter{\@dtl@thiscurrentrow}%
+ \expandafter
+ \ifx
+ \csname @dtl@foreachrows@\romannumeral\dtlforeachlevel\endcsname
+ \@empty
+ \expandafter
+ \xdef\csname @dtl@foreachrows@\romannumeral\dtlforeachlevel\endcsname{%
+ {\the\@dtl@toks}}%
+ \else
+ \expandafter\let\expandafter\@dtl@foreachrows\expandafter
+ =\csname @dtl@foreachrows@\romannumeral\dtlforeachlevel\endcsname
+ \expandafter\toks@\expandafter{\@dtl@foreachrows}%
+ \expandafter
+ \xdef\csname @dtl@foreachrows@\romannumeral\dtlforeachlevel\endcsname{%
+ \the\toks@,{\the\@dtl@toks}}%
+ \fi
+ \fi
+\@endforfalse
+}%
+\expandafter\let\expandafter\@dtl@foreachrows\expandafter
+ =\csname @dtl@foreachrows@\romannumeral\dtlforeachlevel\endcsname
+\expandafter\global
+ \expandafter\let\csname dtldb@#2\endcsname=\@dtl@foreachrows
+\fi
+\global\advance\dtlforeachlevel by -1\relax
+}{%
+\PackageError{datatool}{Database `#2' doesn't exist}{}}%
+}
+\newcommand{\@sDTLforeach}[4][\boolean{true}]{%
+\DTLifdbexists{#2}{%
+\refstepcounter{DTLrow}%
+\global\c@DTLrow=\c@DTLrow
+\gdef\@dtl@dbname{#2}%
+\global\advance\dtlforeachlevel by 1\relax
+\ifnum\dtlforeachlevel>3\relax
+ \PackageError{datatool}{\string\DTLforeach\space nested too
+deeply}{}%
+\else
+ \expandafter\global
+ \csname c@DTLrow\romannumeral\dtlforeachlevel\endcsname = 0\relax
+ \expandafter\global\expandafter\let
+ \csname @dtl@dbname@\romannumeral\dtlforeachlevel\endcsname
+ =\@nnil
+ \expandafter\let\expandafter\@dtl@db\csname dtldb@#2\endcsname%
+ \@for\@dtl@currentrow:=\@dtl@db\do{%
+ \expandafter\global\expandafter
+ \let\csname @dtl@thiscurrentrow@\romannumeral\dtlforeachlevel
+ \endcsname=\@dtl@currentrow
+ \global\let\@dtl@nextrow\@xfor@nextelement
+ \ifx\relax#3\relax
+ \else
+ \@dtl@assign{#3}%
+ \fi
+ \ifthenelse{#1}{%
+ \refstepcounter{DTLrow\romannumeral\dtlforeachlevel}%
+ \expandafter\edef\expandafter\DTLcurrentindex\expandafter
+ {\arabic{DTLrow\romannumeral\dtlforeachlevel}}%
+ #4%
+ }{}%
+\@endforfalse
+}%
+\fi
+\global\advance\dtlforeachlevel by -1\relax
+}{%
+\PackageError{datatool}{Database `#2' doesn't exist}{}}%
+}
+\newcommand*{\DTLappendtorow}[2]{%
+\ifnum\dtlforeachlevel=0\relax
+ \PackageError{datatool}{\string\DTLappendtorow\space can only
+ be used inside \string\DTLforeach}{}%
+\else
+ \expandafter\let\expandafter\@dtl@thisdb
+ \csname @dtl@dbname@\romannumeral\dtlforeachlevel\endcsname
+ \ifx\@dtl@thisdb\@nnil
+ \PackageError{datatool}{\string\DTLappendtorow\space can't
+ be used inside \string\DTLforeach*}{The starred version of
+ \string\DTLforeach\space is read only}%
+ \else
+ \expandafter\@dtl@toks\expandafter{#2}%
+ \edef\@dtl@dbvalue{\the\@dtl@toks}%
+ \edef\@dtl@dbid{#1}%
+ \edef\@dtl@dbentry{{\@dtl@dbid}{\the\@dtl@toks}}%
+ \expandafter\let\expandafter\@dtl@thisrow
+ \csname @dtl@thiscurrentrow@\romannumeral\dtlforeachlevel\endcsname
+ \dtl@ifrowcontains{#1}{\@dtl@thisrow}{%
+ \PackageError{datatool}{Can't add entry with ID `#1' to current
+ row of database `\@dtl@thisdb'}{There is already an entry with
+ this ID on the current row}}{%
+ \expandafter\@dtl@toks\expandafter{\@dtl@dbentry}%
+ \ifx\@dtl@thisrow\@empty
+ \expandafter
+ \xdef\csname @dtl@thiscurrentrow@\romannumeral\dtlforeachlevel\endcsname{%
+ \the\@dtl@toks}%
+ \else
+ \expandafter\toks@\expandafter{\@dtl@thisrow}%
+ \expandafter
+ \xdef\csname @dtl@thiscurrentrow@\romannumeral\dtlforeachlevel\endcsname{%
+ \the\toks@,\the\@dtl@toks}%
+ \fi
+ }
+ \@dtl@setidtype{\@dtl@thisdb}{#1}{#2}%
+ \expandafter\@dtl@setkeys\expandafter{#1}{\@dtl@thisdb}%
+ \fi
+\fi
+}
+\newcommand*{\DTLremoveentryfromrow}[1]{%
+\ifnum\dtlforeachlevel=0\relax
+ \PackageError{datatool}{\string\DTLremoveentryfromrow\space can only
+ be used inside \string\DTLforeach}{}%
+\else
+ \expandafter\let\expandafter\@dtl@thisdb
+ \csname @dtl@dbname@\romannumeral\dtlforeachlevel\endcsname
+ \ifx\@dtl@thisdb\@nnil
+ \PackageError{datatool}{\string\DTLremoveentryfromrow\space can't
+ be used inside \string\DTLforeach*}{The starred version of
+ \string\DTLforeach\space is read only}%
+ \else
+ \expandafter\let\expandafter\@dtl@thisrow
+ \csname @dtl@thiscurrentrow@\romannumeral\dtlforeachlevel\endcsname
+ \dtl@ifrowcontains{#1}{\@dtl@thisrow}{%
+ \let\@dtl@pre=\@empty
+ \@for\dtl@thisentry:=\@dtl@thisrow\do{%
+ \dtl@getentryid\dtl@thisentry\@dtl@id
+ \ifthenelse{\equal{\@dtl@id}{#1}}{%
+ }{%
+ \expandafter\@dtl@toks\expandafter{\dtl@thisentry}%
+ \ifx\@dtl@pre\@empty
+ \edef\@dtl@pre{{\the\@dtl@toks}}%
+ \else
+ \expandafter\toks@\expandafter{\@dtl@pre}%
+ \edef\@dtl@pre{\the\toks@,{\the\@dtl@toks}}%
+ \fi
+ }
+ }%
+ \expandafter\let
+ \csname @dtl@thiscurrentrow@\romannumeral\dtlforeachlevel\endcsname
+ =\@dtl@pre
+ }{%
+ \PackageError{datatool}{Can't remove entry given by key `#1'
+ from current row in database `\@dtl@thisdb', no such entry}{}%
+ }%
+ \fi
+\fi
+}
+\newcommand*{\DTLreplaceentryforrow}[2]{%
+\ifnum\dtlforeachlevel=0\relax
+ \PackageError{datatool}{\string\DTLreplaceentryforrow\space can only
+ be used inside \string\DTLforeach}{}%
+\else
+ \expandafter\let\expandafter\@dtl@thisdb
+ \csname @dtl@dbname@\romannumeral\dtlforeachlevel\endcsname
+ \ifx\@dtl@thisdb\@nnil
+ \PackageError{datatool}{\string\DTLreplaceentryforrow\space can't
+ be used inside \string\DTLforeach*}{The starred version of
+ \string\DTLforeach\space is read only}%
+ \else
+ \expandafter\@dtl@toks\expandafter{#2}%
+ \edef\@dtl@dbvalue{\the\@dtl@toks}%
+ \edef\@dtl@dbid{#1}%
+ \edef\dtl@newentry{{\@dtl@dbid}{\the\@dtl@toks}}%
+ \expandafter\let\expandafter\@dtl@thisrow
+ \csname @dtl@thiscurrentrow@\romannumeral\dtlforeachlevel\endcsname
+ \dtl@ifrowcontains{#1}{\@dtl@thisrow}{%
+ \let\@dtl@pre=\@empty
+ \@for\dtl@thisentry:=\@dtl@thisrow\do{%
+ \dtl@getentryid\dtl@thisentry\@dtl@id
+ \ifthenelse{\equal{\@dtl@id}{#1}}{%
+ \expandafter\@dtl@toks\expandafter{\dtl@newentry}%
+ }{%
+ \expandafter\@dtl@toks\expandafter{\dtl@thisentry}%
+ }
+ \ifx\@dtl@pre\@empty
+ \edef\@dtl@pre{{\the\@dtl@toks}}%
+ \else
+ \expandafter\toks@\expandafter{\@dtl@pre}%
+ \edef\@dtl@pre{\the\toks@,{\the\@dtl@toks}}%
+ \fi
+ }%
+ \expandafter\let
+ \csname @dtl@thiscurrentrow@\romannumeral\dtlforeachlevel\endcsname
+ =\@dtl@pre
+ }{%
+ \PackageError{datatool}{Can't remove entry given by key `#1'
+ from current row in database `\@dtl@thisdb', no such entry}{}%
+ }%
+ \fi
+\fi
+}
+\newcommand*{\DTLremovecurrentrow}{%
+\ifnum\dtlforeachlevel=0\relax
+ \PackageError{datatool}{\string\DTLremovecurrentrow\space can only
+ be used inside \string\DTLforeach}{}%
+\else
+ \expandafter\ifx
+ \csname @dtl@dbname@\romannumeral\dtlforeachlevel\endcsname\@nnil
+ \PackageError{datatool}{\string\DTLremovecurrentrow\space can't
+ be used inside \string\DTLforeach*}{The starred version of
+ \string\DTLforeach\space is read only}%
+ \else
+ \expandafter\let
+ \csname @dtl@thiscurrentrow@\romannumeral\dtlforeachlevel\endcsname
+ =\@empty
+ \fi
+\fi
+}
+\newcommand*{\DTLforeachkeyinrow}[2]{%
+\ifnum\dtlforeachlevel=0\relax
+ \PackageError{datatool}{\string\DTLforeachkeyinrow\space can only
+ be used inside \string\DTLforeach}{}%
+\else
+ \expandafter\let\expandafter\@dtl@thisrow
+ \csname @dtl@thiscurrentrow@\romannumeral\dtlforeachlevel\endcsname
+ \@for\dtl@thisentry:=\@dtl@thisrow\do{%
+ \dtl@getentryvalue\dtl@thisentry{#1}%
+ #2%
+ }%
+\fi
+}
+\newcommand{\DTLaddentryforrow}[5]{%
+\gdef\@dtl@dbname{#1}%
+\DTLifdbexists{#1}{%
+ \expandafter\@dtl@toks\expandafter{#5}%
+ \edef\@dtl@dbvalue{\the\@dtl@toks}%
+ \edef\@dtl@dbid{#4}%
+ \edef\@dtl@dbentry{{\@dtl@dbid}{\the\@dtl@toks}}%
+ \expandafter
+ \let\expandafter\@dtl@db\csname dtldb@\@dtl@dbname\endcsname%
+ \let\@dtl@prerow=\@empty
+ \@for\@dtl@currentrow:=\@dtl@db\do{%
+ \@dtl@assign{#2}%
+ \ifthenelse{#3}{%
+ \expandafter\@dtl@toks\expandafter{\@dtl@dbentry}%
+ \ifx\@dtl@currentrow\@empty
+ \edef\@dtl@currentrow{{\the\@dtl@toks}}%
+ \else
+ \expandafter\toks@\expandafter{\@dtl@currentrow}%
+ \edef\@dtl@currentrow{\the\toks@,{\the\@dtl@toks}}%
+ \fi
+ \@endfortrue
+ }{%
+ }%
+ \expandafter\@dtl@toks\expandafter{\@dtl@currentrow}%
+ \ifx\@dtl@prerow\@empty
+ \edef\@dtl@prerow{{\the\@dtl@toks}}%
+ \else
+ \expandafter\toks@\expandafter{\@dtl@prerow}%
+ \edef\@dtl@prerow{\the\toks@,{\the\@dtl@toks}}%
+ \fi
+}%
+\if@endfor
+ \expandafter\@dtl@toks\expandafter{\@forremainder}%
+ \expandafter\toks@\expandafter{\@dtl@prerow}%
+ \edef\@dtl@prerow{\the\toks@,{\the\@dtl@toks}}%
+ \expandafter\global\expandafter
+ \let\csname dtldb@\@dtl@dbname\endcsname=\@dtl@prerow
+\else
+ \PackageError{datatool}{Unable to add `#5' for key `#4' - condition
+ not met for any row in database `#1'}{}%
+\fi
+\@endforfalse
+}{%
+\PackageError{datatool}{Database `#1' doesn't exist}{}}%
+}
+\newcommand*{\@dtl@assign}[2][\@dtl@currentrow]{%
+\@dtl@assigncmd#2,\relax\@@{#1}%
+}
+\def\@dtl@assigncmd#1=#2,#3\@@#4{%
+\@for\@dtl@entry:=#4\do{%
+\dtl@getentryid\@dtl@entry\@dtl@id
+\ifthenelse{\equal{\@dtl@id}{#2}}{%
+\dtl@getentryvalue\@dtl@entry#1%
+\@endfortrue}{}%
+}%
+\if@endfor
+\else
+ \@dtl@setnull{#1}{#2}%
+\fi
+\@endforfalse
+\ifx\relax#3%
+ \let\@dtl@next=\@dtl@assigncmdnoop
+\else
+ \let\@dtl@next=\@dtl@assigncmd
+\fi
+\@dtl@next#3\@@{#4}%
+}
+\def\@dtl@assigncmdnoop#1\@@#2{}
+\newcommand*{\@dtl@setnull}[2]{%
+\@ifundefined{@dtl@idtype@\@dtl@dbname @#2}{%
+\global\let#1=\DTLstringnull}{%
+\edef\@dtl@tmp{0\@dtl@getidtype{\@dtl@dbname}{#2}}%
+\expandafter\ifnum\@dtl@tmp=0\relax
+ \global\let#1=\DTLstringnull
+\else
+ \global\let#1=\DTLnumbernull
+\fi
+}}
+\newcommand*{\DTLstringnull}{NULL}
+\newcommand*{\DTLnumbernull}{0}
+\newcommand*{\DTLifnull}[3]{%
+\ifx\DTLstringnull#1\relax
+ #2%
+\else
+ \ifx\DTLnumbernull#1\relax
+ #2%
+ \else
+ #3%
+ \fi
+\fi}
+\newcommand{\dtl@gathervalues}[3][key]{%
+\expandafter\let\expandafter\@dtl@tmp\expandafter
+ =\csname dtlkeys@#2\endcsname%
+\def\@dtl@list{}%
+\@for\dtl@key:=\@dtl@tmp\do{%
+ \expandafter\@dtl@setnull\expandafter{%
+ \csname @dtl@#1@\dtl@key\endcsname}{\dtl@key}%
+ \@for\dtl@thiselement:=#3\do{%
+ \dtl@getentryid\dtl@thiselement\@dtl@id
+ \ifthenelse{\equal{\@dtl@id}{\dtl@key}}{%
+ \dtl@getentryvalue\dtl@thiselement\@dtl@value%
+ \expandafter\toks@\expandafter{\@dtl@value}%
+ \expandafter\edef\csname @dtl@#1@\dtl@key\endcsname{%
+ \the\toks@}%
+ \@endfortrue}{}%
+ }%
+\@endforfalse
+}%
+}
+\newcommand*{\DTLsumforkeys}[4][\boolean{true}\and
+\DTLisnumerical{\DTLthisval}]{%
+\def#4{0}%
+\@for\@dtl@dbname:=#2\do{%
+ \DTLifdbexists{\@dtl@dbname}{%
+ \expandafter
+ \let\expandafter\@dtl@db\csname dtldb@\@dtl@dbname\endcsname%
+ \@for\@dtl@currentrow:=\@dtl@db\do{%
+ \dtl@gathervalues{\@dtl@dbname}{\@dtl@currentrow}%
+ \@for\@dtl@key:=#3\do{%
+ \protected@edef\DTLthisval{%
+ \csname @dtl@key@\@dtl@key\endcsname}%
+ \ifthenelse{#1}{\DTLadd{#4}{#4}{\DTLthisval}}{}%
+ }}%
+ }{\PackageError{datatool}{Database `\@dtl@dbname' doesn't exist}{}%
+ }%
+}%
+}
+\newcommand*{\DTLmeanforkeys}[4][\boolean{true}\and
+\DTLisnumerical{\DTLthisval}]{%
+\def#4{0}%
+\def\dtl@n{0}%
+\@for\@dtl@dbname:=#2\do{%
+\DTLifdbexists{\@dtl@dbname}{%
+ \expandafter
+ \let\expandafter\@dtl@db\csname dtldb@\@dtl@dbname\endcsname%
+ \@for\@dtl@currentrow:=\@dtl@db\do{%
+ \dtl@gathervalues{\@dtl@dbname}{\@dtl@currentrow}%
+ \@for\@dtl@key:=#3\do{%
+ \protected@edef\DTLthisval{%
+ \csname @dtl@key@\@dtl@key\endcsname}%
+ \ifthenelse{#1}{%
+ \DTLadd{#4}{#4}{\DTLthisval}%
+ \DTLadd{\dtl@n}{\dtl@n}{1}%
+ }{}%
+ }}%
+}{\PackageError{datatool}{Database `\@dtl@dbname' doesn't exist}{}}}%
+\ifnum\dtl@n=0\relax
+ \PackageError{datatool}{Can't compute mean, no data!}{}%
+\else
+ \DTLdiv{#4}{#4}{\dtl@n}%
+\fi
+}
+\newcommand*{\DTLvarianceforkeys}[4][\boolean{true}\and
+\DTLisnumerical{\DTLthisval}]{%
+\DTLmeanforkeys[#1]{#2}{#3}{\dtl@mean}%
+\def#4{0}%
+\@for\@dtl@dbname:=#2\do{%
+ \DTLifdbexists{\@dtl@dbname}{%
+ \expandafter
+ \let\expandafter\@dtl@db\csname dtldb@\@dtl@dbname\endcsname
+ \@for\@dtl@currentrow:=\@dtl@db\do{%
+ \dtl@gathervalues{\@dtl@dbname}{\@dtl@currentrow}%
+ \@for\@dtl@key:=#3\do{%
+ \protected@edef\DTLthisval{%
+ \csname @dtl@key@\@dtl@key\endcsname}%
+ \ifthenelse{#1}{%
+ \DTLsub{\dtl@diff}{\DTLthisval}{\dtl@mean}%
+ \DTLmul{\dtl@diff}{\dtl@diff}{\dtl@diff}%
+ \DTLadd{#4}{#4}{\dtl@diff}%
+ }{}%
+ }}%
+ }{\PackageError{datatool}{Database `\@dtl@dbname' doesn't exist}{}%
+ }%
+}%
+\ifnum\dtl@n=0\relax
+ \PackageError{datatool}{Can't compute variance, no data!}{}%
+\else
+ \DTLdiv{#4}{#4}{\dtl@n}%
+\fi
+}
+\newcommand*{\DTLsdforkeys}[4][\boolean{true}\and
+\DTLisnumerical{\DTLthisval}]{%
+\DTLvarianceforkeys[#1]{#2}{#3}{#4}%
+\DTLsqrt{#4}{#4}%
+}
+\newcommand*{\DTLminforkeys}[4][\boolean{true}\and
+\DTLisnumerical{\DTLthisval}]{%
+\def#4{}%
+\@for\@dtl@dbname:=#2\do{%
+\DTLifdbexists{\@dtl@dbname}{%
+ \expandafter
+ \let\expandafter\@dtl@db\csname dtldb@\@dtl@dbname\endcsname%
+ \@for\@dtl@currentrow:=\@dtl@db\do{%
+ \dtl@gathervalues{\@dtl@dbname}{\@dtl@currentrow}%
+ \@for\@dtl@key:=#3\do{%
+ \protected@edef\DTLthisval{%
+ \csname @dtl@key@\@dtl@key\endcsname}%
+ \ifthenelse{#1}{%
+ \ifx#4\@empty
+ \let#4=\DTLthisval
+ \else
+ \DTLmin{#4}{#4}{\DTLthisval}%
+ \fi
+ }{}%
+}}%
+ }{\PackageError{datatool}{Database `\@dtl@dbname' doesn't exist}{}%
+ }%
+}}
+\newcommand*{\DTLmaxforkeys}[4][\boolean{true}\and
+\DTLisnumerical{\DTLthisval}]{%
+\def#4{}%
+\@for\@dtl@dbname:=#2\do{%
+\DTLifdbexists{\@dtl@dbname}{%
+ \expandafter
+ \let\expandafter\@dtl@db\csname dtldb@\@dtl@dbname\endcsname%
+ \@for\@dtl@currentrow:=\@dtl@db\do{%
+ \dtl@gathervalues{\@dtl@dbname}{\@dtl@currentrow}%
+ \@for\@dtl@key:=#3\do{%
+ \protected@edef\DTLthisval{%
+ \csname @dtl@key@\@dtl@key\endcsname}%
+ \ifthenelse{#1}{%
+ \ifx#4\@empty
+ \let#4=\DTLthisval
+ \else
+ \DTLmax{#4}{#4}{\DTLthisval}%
+ \fi
+ }{}%
+}}%
+ }{\PackageError{datatool}{Database `\@dtl@dbname' doesn't exist}{}%
+ }%
+}}
+\newcommand*{\DTLcomputebounds}[8][\boolean{true}]{%
+\let#5=\relax
+\let#6=\relax
+\let#7=\relax
+\let#8=\relax
+\@for\dtl@thisdb:=#2\do{%
+ \@sDTLforeach[#1]{\dtl@thisdb}{\DTLthisX=#3,\DTLthisY=#4}{%
+ \DTLconverttodecimal{\DTLthisX}{\dtl@decx}%
+ \DTLconverttodecimal{\DTLthisY}{\dtl@decy}%
+ \ifx#5\relax
+ \let#5=\dtl@decx
+ \let#6=\dtl@decy
+ \let#7=\dtl@decx
+ \let#8=\dtl@decy
+ \else
+ \FPmin{#5}{#5}{\dtl@decx}%
+ \FPmin{#6}{#6}{\dtl@decy}%
+ \FPmax{#7}{#7}{\dtl@decx}%
+ \FPmax{#8}{#8}{\dtl@decy}%
+ \fi
+ }%
+}%
+}
+\newcommand*{\DTLgetvalueforkey}[5]{%
+{%
+\global\let#1=\DTLstringnull
+\@sDTLforeach{#3}{\dtl@valueA=#2,\dtl@refvalue=#4}{%
+\DTLifnull{\dtl@refvalue}{}{%
+\ifthenelse{\equal{\dtl@refvalue}{#5}}{%
+\global\let#1=\dtl@valueA
+\@endfortrue
+}{}}}%
+}}
+\newcommand*{\DTLgetrowforkey}[4]{%
+{%
+\global\let#1=\@empty
+\@sDTLforeach{#2}{\dtl@refvalue=#3}{%
+\DTLifnull{\dtl@refvalue}{}{%
+\ifthenelse{\equal{\dtl@refvalue}{#4}}{%
+\expandafter\global\expandafter\let\expandafter#1
+ \csname @dtl@thiscurrentrow@\romannumeral\dtlforeachlevel\endcsname
+\@endfortrue
+}{}}}%
+}}
+\newcommand*{\DTLsort}{\@ifstar\@sDTLsort\@DTLsort}
+\newcommand*{\@DTLsort}[3][]{%
+\edef\@dtl@replacementkeys{#1}%
+\edef\@dtl@sortorder{#2}%
+\edef\@dtl@dbname{#3}%
+\let\@dtl@comparecs=\dtlcompare
+\expandafter\let\expandafter\@dtl@list\csname dtldb@#3\endcsname
+\dtl@sortlist{\@dtl@list}{\@dtl@sortcriteria}%
+\expandafter\global\expandafter
+ \let\csname dtldb@#3\endcsname=\@dtl@list}
+\newcommand*{\@sDTLsort}[3][]{%
+\edef\@dtl@replacementkeys{#1}%
+\edef\@dtl@sortorder{#2}%
+\edef\@dtl@dbname{#3}%
+\let\@dtl@comparecs=\dtlicompare
+\expandafter\let\expandafter\@dtl@list\csname dtldb@#3\endcsname
+\dtl@sortlist{\@dtl@list}{\@dtl@sortcriteria}%
+\expandafter\global\expandafter
+ \let\csname dtldb@#3\endcsname=\@dtl@list}
+\newcommand{\@dtl@sortcriteria}[2]{%
+\@for\@dtl@level:=\@dtl@sortorder\do{%
+ \expandafter\@dtl@getsortdirection\@dtl@level=\relax%
+ \@ifundefined{@dtl@idtype@\@dtl@dbname @\@dtl@key}{%
+ \ifx\@dtl@replacementkeys\@empty
+ \PackageError{datatool}{Unknown key `\@dtl@key' for database
+ `\@dtl@dbname'}{}%
+ \else
+ \dtl@gathervalues[keya]{\@dtl@dbname}{#1}%
+ \dtl@gathervalues[keyb]{\@dtl@dbname}{#2}%
+ \@ifundefined{@dtl@keya@\@dtl@key}{%
+ \@dtl@setnull{\@dtl@tmpa}{\@dtl@key}%
+ }{%
+ \expandafter\let\expandafter\@dtl@tmpa\expandafter
+ =\csname @dtl@keya@\@dtl@key\endcsname}%
+ \@ifundefined{@dtl@keyb@\@dtl@key}{%
+ \@dtl@setnull{\@dtl@tmpb}{\@dtl@key}%
+ }{%
+ \expandafter\let\expandafter\@dtl@tmpb\expandafter
+ =\csname @dtl@keyb@\@dtl@key\endcsname}%
+ \let\@dtl@keya=\@dtl@key
+ \let\@dtl@keyb=\@dtl@key
+ \DTLifnull{\@dtl@tmpa}{%
+ % find first non null key in list of replacement keys
+ \@for\@dtl@keya:=\@dtl@replacementkeys\do{%
+ \@ifundefined{@dtl@keya@\@dtl@keya}{}{%
+ \expandafter\let\expandafter\@dtl@tmpa\expandafter
+ =\csname @dtl@keya@\@dtl@keya\endcsname
+ \DTLifnull{\@dtl@tmpa}{}{\@endfortrue}}%
+ }%
+ \if@endfor \else\let\@dtl@keya=\@dtl@key \fi
+ \@endforfalse
+ }{}%
+ \DTLifnull{\@dtl@tmpb}{%
+ % find first non null key in list of replacement keys
+ \@for\@dtl@keyb:=\@dtl@replacementkeys\do{%
+ \@ifundefined{@dtl@keyb@\@dtl@keyb}{}{%
+ \expandafter\let\expandafter\@dtl@tmpb\expandafter
+ =\csname @dtl@keyb@\@dtl@keyb\endcsname
+ \DTLifnull{\@dtl@tmpb}{}{\@endfortrue}}%
+ }%
+ \if@endfor \else\let\@dtl@keyb=\@dtl@key \fi
+ \@endforfalse
+ }{}%
+ \@ifundefined{@dtl@idtype@\@dtl@dbname @\@dtl@keya}{%
+ \@ifundefined{@dtl@idtype@\@dtl@dbname @\@dtl@keyb}{%
+ \dtl@sortresult=0\relax}{\dtl@sortresult=-1\relax}%
+ }{%
+ \@ifundefined{@dtl@idtype@\@dtl@dbname @\@dtl@keyb}{%
+ \dtl@sortresult=1\relax}{%
+ \dtl@compare@{\@dtl@keya}{\@dtl@keyb}{#1}{#2}%
+ }%
+ }%
+ \fi
+ }{%
+ \ifx\@dtl@replacementkeys\@empty
+ \dtl@compare{\@dtl@key}{#1}{#2}%
+ \else
+ \dtl@gathervalues[keya]{\@dtl@dbname}{#1}%
+ \dtl@gathervalues[keyb]{\@dtl@dbname}{#2}%
+ \@ifundefined{@dtl@keya@\@dtl@key}{%
+ \@dtl@setnull{\@dtl@tmpa}{\@dtl@key}%
+ }{%
+ \expandafter\let\expandafter\@dtl@tmpa\expandafter
+ =\csname @dtl@keya@\@dtl@key\endcsname}%
+ \@ifundefined{@dtl@keyb@\@dtl@key}{%
+ \@dtl@setnull{\@dtl@tmpb}{\@dtl@key}%
+ }{%
+ \expandafter\let\expandafter\@dtl@tmpb\expandafter
+ =\csname @dtl@keyb@\@dtl@key\endcsname}%
+ \let\@dtl@keya=\@dtl@key
+ \let\@dtl@keyb=\@dtl@key
+ \DTLifnull{\@dtl@tmpa}{%
+ % find first non null key in list of replacement keys
+ \@for\@dtl@keya:=\@dtl@replacementkeys\do{%
+ \@ifundefined{@dtl@keya@\@dtl@keya}{}{%
+ \expandafter\let\expandafter\@dtl@tmpa\expandafter
+ =\csname @dtl@keya@\@dtl@keya\endcsname
+ \DTLifnull{\@dtl@tmpa}{}{\@endfortrue}}%
+ }%
+ \if@endfor \else\let\@dtl@keya=\@dtl@key \fi
+ \@endforfalse
+ }{}%
+ \DTLifnull{\@dtl@tmpb}{%
+ % find first non null key in list of replacement keys
+ \@for\@dtl@keyb:=\@dtl@replacementkeys\do{%
+ \@ifundefined{@dtl@keyb@\@dtl@keyb}{}{%
+ \expandafter\let\expandafter\@dtl@tmpb\expandafter
+ =\csname @dtl@keyb@\@dtl@keyb\endcsname
+ \DTLifnull{\@dtl@tmpb}{}{\@endfortrue}}%
+ }%
+ \if@endfor \else\let\@dtl@keyb=\@dtl@key \fi
+ \@endforfalse
+ }{}%
+ \dtl@compare@{\@dtl@keya}{\@dtl@keyb}{#1}{#2}%
+ \fi
+ \multiply\dtl@sortresult by \@dtl@sortdirection\relax
+ \ifnum\dtl@sortresult=0\relax
+ \else
+ \@endfortrue
+ \fi
+ }%
+}%
+}
+\def\@dtl@getsortdirection#1=#2\relax{%
+\def\@dtl@key{#1}%
+\def\@dtl@sortdirection{#2}%
+\ifx\@dtl@sortdirection\@empty
+ \def\@dtl@sortdirection{-1}%
+\else
+ \@dtl@get@sortdirection#2%
+ \ifthenelse{\equal{\@dtl@sortdirection}{ascending}}{%
+ \def\@dtl@sortdirection{-1}}{%
+ \ifthenelse{\equal{\@dtl@sortdirection}{descending}}{%
+ \def\@dtl@sortdirection{1}}{%
+ \PackageError{datatool}{Invalid sort direction
+ `\@dtl@sortdirection'}{%
+ The sort direction can only be one of `ascending' or
+ `descending'}\def\@dtl@sortdirection{-1}}}%
+\fi
+}
+\def\@dtl@get@sortdirection#1={\def\@dtl@sortdirection{#1}}
+\newtoks\@dtl@toksA\newtoks\@dtl@toksB
+\newcommand{\dtl@compare}[3]{%
+\dtl@gathervalues{\@dtl@dbname}{#2}%
+\expandafter\let\expandafter\@dtl@tmp\expandafter
+ =\csname @dtl@key@#1\endcsname
+\expandafter\@dtl@toksA\expandafter{\@dtl@tmp}%
+\edef\@dtl@a{\the\@dtl@toksA}%
+\dtl@gathervalues{\@dtl@dbname}{#3}%
+\expandafter\let\expandafter\@dtl@tmp\expandafter
+ =\csname @dtl@key@#1\endcsname
+\expandafter\@dtl@toksB\expandafter{\@dtl@tmp}%
+\edef\@dtl@b{\the\@dtl@toksB}%
+\expandafter\@dtl@datatype\expandafter=
+ \csname @dtl@idtype@\@dtl@dbname @#1\endcsname\relax
+\ifnum\@dtl@datatype=0\relax
+ \edef\@dtl@tmpcmp{%
+ \noexpand\@dtl@comparecs{\noexpand\dtl@sortresult}%
+ {\the\@dtl@toksA}{\the\@dtl@toksB}}%
+ \@dtl@tmpcmp
+\else
+ \DTLifnumlt{\@dtl@a}{\@dtl@b}{\dtl@sortresult=-1\relax}{%
+ \DTLifnumgt{\@dtl@a}{\@dtl@b}{\dtl@sortresult=1\relax}{%
+ \dtl@sortresult=0\relax}}%
+\fi
+\ifdtlverbose
+\@onelevel@sanitize\@dtl@a
+\@onelevel@sanitize\@dtl@b
+\fi
+\dtl@message{`\@dtl@a' <=> `\@dtl@b' = \number\dtl@sortresult}%
+}
+\newcommand{\dtl@compare@}[4]{%
+\dtl@gathervalues{\@dtl@dbname}{#3}%
+\expandafter\let\expandafter\@dtl@tmp\expandafter
+ =\csname @dtl@key@#1\endcsname
+\expandafter\@dtl@toksA\expandafter{\@dtl@tmp}%
+\edef\@dtl@a{\the\@dtl@toksA}%
+\dtl@gathervalues{\@dtl@dbname}{#4}%
+\expandafter\let\expandafter\@dtl@tmp\expandafter
+ =\csname @dtl@key@#2\endcsname
+\expandafter\@dtl@toksB\expandafter{\@dtl@tmp}%
+\edef\@dtl@b{\the\@dtl@toksB}%
+\expandafter\@dtl@tmpcount\expandafter=
+ \csname @dtl@idtype@\@dtl@dbname @#1\endcsname\relax
+\expandafter\@dtl@datatype\expandafter=
+ \csname @dtl@idtype@\@dtl@dbname @#2\endcsname\relax
+\multiply\@dtl@datatype by \@dtl@tmpcount\relax
+\ifnum\@dtl@datatype=0\relax
+ \edef\@dtl@tmpcmp{%
+ \noexpand\@dtl@comparecs{\noexpand\dtl@sortresult}%
+ {\the\@dtl@toksA}{\the\@dtl@toksB}}%
+ \@dtl@tmpcmp
+\else
+ \DTLifnumlt{\@dtl@a}{\@dtl@b}{\dtl@sortresult=-1\relax}{%
+ \DTLifnumgt{\@dtl@a}{\@dtl@b}{\dtl@sortresult=1\relax}{%
+ \dtl@sortresult=0\relax}}%
+\fi
+\ifdtlverbose
+\@onelevel@sanitize\@dtl@a
+\@onelevel@sanitize\@dtl@b
+\fi
+\dtl@message{`\@dtl@a' <=> `\@dtl@b' = \number\dtl@sortresult}%
+}
+\newcommand*{\dtl@choplast}[3]{%
+\let#2\@empty
+\let#3\@empty
+\@for\@dtl@element:=#1\do{%
+\ifx#3\@empty
+\else
+ \ifx#2\@empty
+ \expandafter\toks@\expandafter{#3}%
+ \edef#2{{\the\toks@}}%
+ \else
+ \expandafter\toks@\expandafter{#3}%
+ \expandafter\@dtl@toks\expandafter{#2}%
+ \edef#2{\the\@dtl@toks,{\the\toks@}}%
+ \fi
+\fi
+\let#3=\@dtl@element%
+}%
+}
+\newcommand*{\dtl@chopfirst}[3]{%
+\let#2=\@empty
+\let#3=\@empty
+\@for\@dtl@element:=#1\do{%
+ \let#2=\@dtl@element
+ \@endfortrue
+}%
+\if@endfor
+ \let#3=\@forremainder
+\fi
+\@endforfalse
+}
+\newcommand{\dtl@sortlist}[2]{%
+\def\@dtl@sortedlist{}%
+\@for\@dtl@currentrow:=#1\do{%
+\expandafter\dtl@insertinto\expandafter
+ {\@dtl@currentrow}{\@dtl@sortedlist}{#2}%
+\@endforfalse}%
+\let#1=\@dtl@sortedlist
+}
+\newtoks\@dtl@toks
+\newcommand{\dtl@insertinto}[3]{%
+\def\@dtl@newsortedlist{}%
+\@dtl@insertdonefalse
+\@for\dtl@srtelement:=#2\do{%
+\if@dtl@insertdone
+ \expandafter\toks@\expandafter{\dtl@srtelement}%
+ \edef\@dtl@newstuff{{\the\toks@}}%
+\else
+ \expandafter#3\expandafter{\dtl@srtelement}{#1}%
+ \ifnum\dtl@sortresult<0\relax
+ \expandafter\toks@\expandafter{\dtl@srtelement}%
+ \@dtl@toks{#1}%
+ \edef\@dtl@newstuff{{\the\@dtl@toks},{\the\toks@}}%
+ \@dtl@insertdonetrue
+ \else
+ \expandafter\toks@\expandafter{\dtl@srtelement}%
+ \edef\@dtl@newstuff{{\the\toks@}}%
+ \fi
+\fi
+\ifx\@dtl@newsortedlist\@empty
+ \expandafter\toks@\expandafter{\@dtl@newstuff}%
+ \edef\@dtl@newsortedlist{\the\toks@}%
+\else
+ \expandafter\toks@\expandafter{\@dtl@newsortedlist}%
+ \expandafter\@dtl@toks\expandafter{\@dtl@newstuff}%
+ \edef\@dtl@newsortedlist{\the\toks@,\the\@dtl@toks}%
+\fi
+\@endforfalse
+}%
+ \ifx\@dtl@newsortedlist\@empty
+ \@dtl@toks{#1}%
+ \edef\@dtl@newsortedlist{{\the\@dtl@toks}}%
+ \else
+ \if@dtl@insertdone
+ \else
+ \expandafter\toks@\expandafter{\@dtl@newsortedlist}%
+ \@dtl@toks{#1}%
+ \edef\@dtl@newsortedlist{\the\toks@,{\the\@dtl@toks}}%
+ \fi
+ \fi
+\global\let#2=\@dtl@newsortedlist
+}
+\newif\if@dtl@insertdone
+\newcount\dtl@sortresult
+\newcommand*{\DTLadd}[3]{%
+\DTLconverttodecimal{#2}{\@dtl@numi}%
+\DTLconverttodecimal{#3}{\@dtl@numii}%
+\FPadd{\@dtl@tmp}{\@dtl@numi}{\@dtl@numii}%
+\ifx\@dtl@replaced\@empty
+ \DTLdecimaltolocale{\@dtl@tmp}{#1}%
+\else
+ \DTLdecimaltocurrency{\@dtl@tmp}{#1}%
+\fi
+}
+\newcommand*{\DTLgadd}[3]{%
+\DTLadd{\@dtl@tmpii}{#2}{#3}%
+\global\let#1=\@dtl@tmpii
+}
+\newcommand*{\DTLaddall}[2]{%
+\def\@dtl@sum{0}%
+\@for\dtl@thisval:=#2\do{%
+ \DTLconverttodecimal{\dtl@thisval}{\@dtl@num}%
+ \FPadd{\@dtl@sum}{\@dtl@sum}{\@dtl@num}%
+}%
+\ifx\@dtl@replaced\@empty
+ \DTLdecimaltolocale{\@dtl@sum}{#1}%
+\else
+ \DTLdecimaltocurrency{\@dtl@sum}{#1}%
+\fi
+}
+\newcommand*{\DTLgaddall}[2]{%
+\DTLaddall{\@dtl@tmpi}{#2}%
+\global\let#1=\@dtl@tmpi
+}
+\newcommand*{\DTLsub}[3]{%
+\DTLconverttodecimal{#2}{\@dtl@numi}%
+\DTLconverttodecimal{#3}{\@dtl@numii}%
+\FPsub{\@dtl@tmp}{\@dtl@numi}{\@dtl@numii}%
+\ifx\@dtl@replaced\@empty
+ \DTLdecimaltolocale{\@dtl@tmp}{#1}%
+\else
+ \DTLdecimaltocurrency{\@dtl@tmp}{#1}%
+\fi
+}
+\newcommand*{\DTLgsub}[3]{%
+\DTLsub{\@dtl@tmpii}{#2}{#3}%
+\global\let#1=\@dtl@tmpii
+}
+\newcommand*{\DTLmul}[3]{%
+\let\@dtl@thisreplaced=\@empty
+\DTLconverttodecimal{#2}{\@dtl@numi}%
+\ifx\@dtl@replaced\@empty
+\else
+ \let\@dtl@thisreplaced=\@dtl@replaced
+\fi
+\DTLconverttodecimal{#3}{\@dtl@numii}%
+\ifx\@dtl@replaced\@empty
+\else
+ \let\@dtl@thisreplaced=\@dtl@replaced
+\fi
+\FPmul{\@dtl@tmp}{\@dtl@numi}{\@dtl@numii}%
+\ifx\@dtl@thisreplaced\@empty
+ \DTLdecimaltolocale{\@dtl@tmp}{#1}%
+\else
+ \DTLdecimaltocurrency{\@dtl@tmp}{#1}%
+\fi
+}
+\newcommand*{\DTLgmul}[3]{%
+\DTLmul{\@dtl@tmpii}{#2}{#3}%
+\global\let#1=\@dtl@tmpii
+}
+\newcommand*{\DTLdiv}[3]{%
+\let\@dtl@thisreplaced=\@empty
+\DTLconverttodecimal{#2}{\@dtl@numi}%
+\ifx\@dtl@replaced\@empty
+\else
+ \let\@dtl@thisreplaced=\@dtl@replaced
+\fi
+\DTLconverttodecimal{#3}{\@dtl@numii}%
+\FPdiv{\@dtl@tmp}{\@dtl@numi}{\@dtl@numii}%
+\ifx\@dtl@thisreplaced\@empty
+ \DTLdecimaltolocale{\@dtl@tmp}{#1}%
+\else
+ \ifx\@dtl@thisreplaced\@dtl@replaced
+ \DTLdecimaltolocale{\@dtl@tmp}{#1}%
+ \else
+ \DTLdecimaltocurrency{\@dtl@tmp}{#1}%
+ \fi
+\fi
+}
+\newcommand*{\DTLgdiv}[3]{%
+\DTLdiv{\@dtl@tmpii}{#2}{#3}%
+\global\let#1=\@dtl@tmpii
+}
+\newcommand*{\DTLabs}[2]{%
+\DTLconverttodecimal{#2}{\@dtl@numi}%
+\FPabs{\@dtl@tmp}{\@dtl@numi}%
+\ifx\@dtl@replaced\@empty
+ \DTLdecimaltolocale{\@dtl@tmp}{#1}%
+\else
+ \DTLdecimaltocurrency{\@dtl@tmp}{#1}%
+\fi
+}
+\newcommand*{\DTLgabs}[2]{%
+\DTLabs{\@dtl@tmpii}{#2}%
+\global\let#1=\@dtl@tmpii
+}
+\newcommand*{\DTLneg}[2]{%
+\DTLconverttodecimal{#2}{\@dtl@numi}%
+\FPneg{\@dtl@tmp}{\@dtl@numi}%
+\ifx\@dtl@replaced\@empty
+ \DTLdecimaltolocale{\@dtl@tmp}{#1}%
+\else
+ \DTLdecimaltocurrency{\@dtl@tmp}{#1}%
+\fi
+}
+\newcommand*{\DTLgneg}[2]{%
+\DTLneg{\@dtl@tmpii}{#2}%
+\global\let#1=\@dtl@tmpii
+}
+\newcommand*{\DTLsqrt}[2]{%
+\DTLconverttodecimal{#2}{\@dtl@numi}%
+\FProot{\@dtl@tmpi}{\@dtl@numi}{2}%
+\ifx\@dtl@replaced\@empty
+ \DTLdecimaltolocale{\@dtl@tmpi}{#1}%
+\else
+ \DTLdecimaltocurrency{\@dtl@tmpi}{#1}%
+\fi
+}
+\newcommand*{\DTLgsqrt}[2]{%
+\DTLsqrt{\@dtl@tmpii}{#2}%
+\global\let#1=\@dtl@tmpii
+}
+\newcommand*{\DTLmin}[3]{%
+\DTLconverttodecimal{#2}{\@dtl@numi}%
+\DTLconverttodecimal{#3}{\@dtl@numii}%
+\FPiflt{\@dtl@numi}{\@dtl@numii}%
+ \dtl@ifsingle{#2}{%
+ \let#1=#2}{%
+ \def#1{#2}}%
+\else
+ \dtl@ifsingle{#3}{%
+ \let#1=#3}{%
+ \def#1{#3}}%
+\fi
+}
+\newcommand*{\DTLgmin}[3]{%
+\DTLmin{\@dtl@tmpii}{#2}{#3}%
+\global\let#1=\@dtl@tmpii
+}
+\newcommand*{\DTLminall}[2]{%
+\let\@dtl@min=\@empty
+\@for\dtl@thisval:=#2\do{%
+ \DTLconverttodecimal{\dtl@thisval}{\@dtl@num}%
+ \ifx\@dtl@min\@empty
+ \let\@dtl@min=\@dtl@num
+ \else
+ \FPmin{\@dtl@min}{\@dtl@min}{\@dtl@num}%
+ \fi
+}%
+\ifx\@dtl@replaced\@empty
+ \DTLdecimaltolocale{\@dtl@min}{#1}%
+\else
+ \DTLdecimaltocurrency{\@dtl@min}{#1}%
+\fi
+}
+\newcommand*{\DTLgminall}[2]{%
+\DTLminall{\@dtl@tmpi}{#2}%
+\global\let#1=\@dtl@tmpi
+}
+\newcommand*{\DTLmax}[3]{%
+\DTLconverttodecimal{#2}{\@dtl@numi}%
+\DTLconverttodecimal{#3}{\@dtl@numii}%
+\FPmax{\@dtl@tmp}{\@dtl@numi}{\@dtl@numii}%
+\FPifgt{\@dtl@numi}{\@dtl@numii}%
+ \dtl@ifsingle{#2}{%
+ \let#1=#2}{%
+ \def#1{#2}}%
+\else
+ \dtl@ifsingle{#3}{%
+ \let#1=#3}{%
+ \def#1{#3}}%
+\fi
+}
+\newcommand*{\DTLgmax}[3]{%
+\DTLmax{\@dtl@tmpii}{#2}{#3}%
+\global\let#1=\@dtl@tmpii
+}
+\newcommand*{\DTLmaxall}[2]{%
+\let\@dtl@max=\@empty
+\@for\dtl@thisval:=#2\do{%
+ \DTLconverttodecimal{\dtl@thisval}{\@dtl@num}%
+ \ifx\@dtl@max\@empty
+ \let\@dtl@max\@dtl@num
+ \else
+ \FPmax{\@dtl@max}{\@dtl@max}{\@dtl@num}%
+ \fi
+}%
+\ifx\@dtl@replaced\@empty
+ \DTLdecimaltolocale{\@dtl@max}{#1}%
+\else
+ \DTLdecimaltocurrency{\@dtl@max}{#1}%
+\fi
+}
+\newcommand*{\DTLgmaxall}[2]{%
+\DTLmaxall{\@dtl@tmpi}{#2}%
+\global\let#1=\@dtl@tmpi
+}
+\newcommand*{\DTLmeanforall}[2]{%
+\def\@dtl@mean{0}%
+\def\@dtl@n{0}%
+\@for\dtl@thisval:=#2\do{%
+ \DTLconverttodecimal{\dtl@thisval}{\@dtl@num}%
+ \FPadd{\@dtl@mean}{\@dtl@mean}{\@dtl@num}%
+ \FPadd{\@dtl@n}{\@dtl@n}{1}%
+}%
+\FPdiv{\@dtl@mean}{\@dtl@mean}{\@dtl@n}%
+\ifx\@dtl@replaced\@empty
+ \DTLdecimaltolocale{\@dtl@mean}{#1}%
+\else
+ \DTLdecimaltocurrency{\@dtl@mean}{#1}%
+\fi
+}
+\newcommand*{\DTLgmeanforall}[2]{%
+\DTLmeanforall{\@dtl@tmpi}{#2}%
+\global\let#1=\@dtl@tmpi
+}
+\newcommand*{\DTLvarianceforall}[2]{%
+\def\@dtl@mean{0}%
+\def\@dtl@n{0}%
+\let\@dtl@decvals=\@empty
+\@for\dtl@thisval:=#2\do{%
+ \DTLconverttodecimal{\dtl@thisval}{\@dtl@num}%
+ \ifx\@dtl@decvals\@empty
+ \let\@dtl@decvals=\@dtl@num
+ \else
+ \expandafter\toks@\expandafter{\@dtl@decvals}%
+ \edef\@dtl@decvals{\the\toks@,\@dtl@num}%
+ \fi
+ \FPadd{\@dtl@mean}{\@dtl@mean}{\@dtl@num}%
+ \FPadd{\@dtl@n}{\@dtl@n}{1}%
+}%
+\FPdiv{\@dtl@mean}{\@dtl@mean}{\@dtl@n}%
+\def\@dtl@var{0}%
+\@for\@dtl@num:=\@dtl@decvals\do{%
+ \FPsub{\@dtl@diff}{\@dtl@num}{\@dtl@mean}%
+ \FPmul{\@dtl@diff}{\@dtl@diff}{\@dtl@diff}%
+ \FPadd{\@dtl@var}{\@dtl@var}{\@dtl@diff}%
+}%
+\FPdiv{\@dtl@var}{\@dtl@var}{\@dtl@n}%
+\ifx\@dtl@replaced\@empty
+ \DTLdecimaltolocale{\@dtl@var}{#1}%
+\else
+ \DTLdecimaltocurrency{\@dtl@var}{#1}%
+\fi
+}
+\newcommand*{\DTLgvarianceforall}[2]{%
+\DTLvarianceforall{\@dtl@tmpi}{#2}%
+\global\let#1=\@dtl@tmpi
+}
+\newcommand*{\DTLsdforall}[2]{%
+\def\@dtl@mean{0}%
+\def\@dtl@n{0}%
+\let\@dtl@decvals=\@empty
+\@for\dtl@thisval:=#2\do{%
+ \DTLconverttodecimal{\dtl@thisval}{\@dtl@num}%
+ \ifx\@dtl@decvals\@empty
+ \let\@dtl@decvals=\@dtl@num
+ \else
+ \expandafter\toks@\expandafter{\@dtl@decvals}%
+ \edef\@dtl@decvals{\the\toks@,\@dtl@num}%
+ \fi
+ \FPadd{\@dtl@mean}{\@dtl@mean}{\@dtl@num}%
+ \FPadd{\@dtl@n}{\@dtl@n}{1}%
+}%
+\FPdiv{\@dtl@mean}{\@dtl@mean}{\@dtl@n}%
+\def\@dtl@sd{0}%
+\@for\@dtl@num:=\@dtl@decvals\do{%
+ \FPsub{\@dtl@diff}{\@dtl@num}{\@dtl@mean}%
+ \FPmul{\@dtl@diff}{\@dtl@diff}{\@dtl@diff}%
+ \FPadd{\@dtl@sd}{\@dtl@sd}{\@dtl@diff}%
+}%
+\FPdiv{\@dtl@sd}{\@dtl@sd}{\@dtl@n}%
+\FProot{\@dtl@sd}{\@dtl@sd}{2}%
+\ifx\@dtl@replaced\@empty
+ \DTLdecimaltolocale{\@dtl@sd}{#1}%
+\else
+ \DTLdecimaltocurrency{\@dtl@sd}{#1}%
+\fi
+}
+\newcommand*{\DTLgsdforall}[2]{%
+\DTLsdforall{\@dtl@tmpi}{#2}%
+\global\let#1=\@dtl@tmpi
+}
+\newcommand*{\DTLround}[3]{%
+\DTLconverttodecimal{#2}{\@dtl@numi}%
+\FPround{\@dtl@tmp}{\@dtl@numi}{#3}%
+\ifx\@dtl@replaced\@empty
+ \DTLdecimaltolocale{\@dtl@tmp}{#1}%
+\else
+ \DTLdecimaltocurrency{\@dtl@tmp}{#1}%
+\fi
+}
+\newcommand*{\DTLground}[3]{%
+\DTLround{\@dtl@tmpii}{#2}{#3}%
+\global\let#1=\@dtl@tmpii
+}
+\newcommand*{\DTLtrunc}[3]{%
+\DTLconverttodecimal{#2}{\@dtl@numi}%
+\FPtrunc{\@dtl@tmp}{\@dtl@numi}{#3}%
+\ifx\@dtl@replaced\@empty
+ \DTLdecimaltolocale{\@dtl@tmp}{#1}%
+\else
+ \DTLdecimaltocurrency{\@dtl@tmp}{#1}%
+\fi
+}
+\newcommand*{\DTLgtrunc}[3]{%
+\DTLtrunc{\@dtl@tmpii}{#2}{#3}%
+\global\let#1=\@dtl@tmpii
+}
+\newcommand*{\DTLclip}[2]{%
+\DTLconverttodecimal{#2}{\@dtl@numi}%
+\FPclip{\@dtl@tmp}{\@dtl@numi}%
+\ifx\@dtl@replaced\@empty
+ \DTLdecimaltolocale{\@dtl@tmp}{#1}%
+\else
+ \DTLdecimaltocurrency{\@dtl@tmp}{#1}%
+\fi
+}
+\newcommand*{\DTLgclip}[3]{%
+\DTLclip{\@dtl@tmpii}{#2}%
+\global\let#1=\@dtl@tmpii
+}
+\newcommand*\DTLinitials[1]{%
+\def\dtl@initialscmd{}%
+\dtl@subnobrsp{#1}{\dtl@string}%
+\DTLsubstituteall{\dtl@string}{~}{ }%
+\DTLsubstituteall{\dtl@string}{\ }{ }%
+\DTLsubstituteall{\dtl@string}{\space}{ }%
+\expandafter\dtl@initials\dtl@string{} \@nil%
+\dtl@initialscmd}%
+\edef\dtl@construct@subnobrsp{%
+\noexpand\def\noexpand\@dtl@subnobrsp##1\noexpand\protect
+\expandafter\noexpand\csname nobreakspace \endcsname ##2{%
+\noexpand\toks@{##1}%
+\noexpand\expandafter\noexpand\@dtl@toks\noexpand\expandafter{%
+\noexpand\@dtl@string}%
+\noexpand\edef\noexpand\@dtl@string{\noexpand\the\noexpand\@dtl@toks
+\noexpand\the\noexpand\toks@}%
+\noexpand\def\noexpand\@dtl@tmp{##2}%
+\noexpand\ifx\noexpand\@dtl@tmp\noexpand\@nnil
+ \noexpand\let\noexpand\@dtl@subnobrspnext=\noexpand\relax
+\noexpand\else
+ \noexpand\toks@{ }%
+ \noexpand\expandafter\noexpand\@dtl@toks\noexpand\expandafter{%
+ \noexpand\@dtl@string}%
+ \noexpand\edef\noexpand\@dtl@string{\noexpand\the\noexpand\@dtl@toks
+ \noexpand\the\noexpand\toks@}%
+ \noexpand\let\noexpand\@dtl@subnobrspnext=\noexpand\@dtl@subnobrsp
+\noexpand\fi
+\noexpand\@dtl@subnobrspnext
+}%
+\noexpand\def\noexpand\dtl@subnobrsp##1##2{%
+\noexpand\def\noexpand\@dtl@string{}%
+\noexpand\@dtl@subnobrsp ##1\noexpand\protect\expandafter\noexpand
+\csname nobreakspace \endcsname \noexpand\@nil
+\noexpand\let##2=\noexpand\@dtl@string
+}}
+\dtl@construct@subnobrsp
+\newcommand*{\DTLstoreinitials}[2]{%
+\def\dtl@initialscmd{}%
+\dtl@subnobrsp{#1}{\dtl@string}%
+\DTLsubstituteall{\dtl@string}{~}{ }%
+\DTLsubstituteall{\dtl@string}{\ }{ }%
+\DTLsubstituteall{\dtl@string}{\space}{ }%
+\expandafter\dtl@initials\dtl@string{} \@nil
+\let#2=\dtl@initialscmd
+}
+\def\dtl@initials#1#2 #3{%
+\dtl@ifsingle{#1}{%
+\ifcat\noexpand#1\relax\relax
+ \def\@dtl@donextinitials{\@dtl@initials#2 {#3}}%
+\else
+ \def\@dtl@donextinitials{\@dtl@initials#1#2 {#3}}%
+\fi
+}{%
+ \def\@dtl@donextinitials{\@dtl@initials{#1}#2 {#3}}%
+}%
+\@dtl@donextinitials
+}
+\def\@dtl@initials#1#2 #3{%
+\dtl@initialshyphen#2-{}\dtl@endhyp
+\expandafter\@dtl@toks\expandafter{\dtl@initialscmd}%
+\toks@{#1}%
+\ifx\dtl@inithyphen\@empty
+\else
+ \edef\dtl@initialscmd{\the\@dtl@toks\the\toks@}%
+ \expandafter\@dtl@toks\expandafter{\dtl@initialscmd}%
+ \expandafter\toks@\expandafter{\dtl@inithyphen}%
+\fi
+\def\dtl@tmp{#3}%
+\ifx\@nnil\dtl@tmp
+ \edef\dtl@initialscmd{\the\@dtl@toks\the\toks@\DTLafterinitials}%
+ \let\dtl@initialsnext=\@gobble
+\else
+ \edef\dtl@initialscmd{\the\@dtl@toks\the\toks@\DTLbetweeninitials}%
+ \let\dtl@initialsnext=\dtl@initials
+\fi
+\dtl@initialsnext{#3}}
+\def\dtl@initialshyphen#1-#2#3\dtl@endhyp{%
+\def\dtl@inithyphen{#2}%
+\ifx\dtl@inithyphen\@empty
+\else
+ \edef\dtl@inithyphen{%
+ \DTLafterinitialbeforehyphen\DTLinitialhyphen#2}%
+\fi
+}
+\newcommand*{\DTLafterinitials}{.}
+\newcommand*{\DTLbetweeninitials}{.}
+\newcommand*{\DTLafterinitialbeforehyphen}{.}
+\newcommand*{\DTLinitialhyphen}{-}
+\newcommand*{\DTLifAllUpperCase}[3]{%
+\protected@edef\dtl@tuc{#1}%
+\expandafter\dtl@testifuppercase\dtl@tuc\@nil\relax
+\if@dtl@condition#2\else#3\fi
+}
+\def\dtl@testifuppercase#1#2{%
+\def\dtl@argi{#1}%
+\def\dtl@argii{#2}%
+\def\dtl@tc@rest{}%
+\ifx\dtl@argi\@nnil
+ \let\dtl@testifuppernext=\@nnil
+\else
+ \ifx#1\protect
+ \let\dtl@testifuppernext=\dtl@testifuppercase
+ \else
+ \ifx\uppercase#1\relax
+ \@dtl@conditiontrue
+ \def\dtl@tc@rest{}%
+ \let\dtl@testifuppernext=\relax
+ \else
+ \edef\dtl@tc@arg{\string#1}%
+ \expandafter\dtl@test@ifuppercase\dtl@tc@arg\end
+ \ifx\dtl@argii\@nnil
+ \let\dtl@testifuppernext=\@dtl@gobbletonil
+ \fi
+ \fi
+ \fi
+\fi
+\ifx\dtl@testifuppernext\relax
+ \edef\dtl@dotestifuppernext{%
+ \noexpand\dtl@testifuppercase}%
+\else
+ \ifx\dtl@testifuppernext\@nnil
+ \edef\dtl@dotestifuppernext{#2}%
+ \else
+ \expandafter\toks@\expandafter{\dtl@tc@rest}%
+ \@dtl@toks{#2}%
+ \edef\dtl@dotestifuppernext{%
+ \noexpand\dtl@testifuppernext\the\toks@\the\@dtl@toks}%
+ \fi
+\fi
+\dtl@dotestifuppernext
+}
+\def\dtl@test@ifuppercase#1#2\end{%
+\def\dtl@tc@rest{#2}%
+\IfSubStringInString{\string\MakeUppercase}{#1#2}{%
+ \@dtl@conditiontrue
+ \def\dtl@tc@rest{}%
+ \let\dtl@testifuppernext=\relax
+}{%
+ \IfSubStringInString{\string\MakeTextUppercase}{#1#2}{%
+ \@dtl@conditiontrue
+ \def\dtl@tc@rest{}%
+ \let\dtl@testifuppernext=\relax
+ }{%
+ \edef\dtl@uccode{\the\uccode`#1}%
+ \edef\dtl@code{\number`#1}%
+ \ifnum\dtl@code=\dtl@uccode\relax
+ \@dtl@conditiontrue
+ \let\dtl@testifuppernext=\dtl@testifuppercase
+ \else
+ \ifnum\dtl@uccode=0\relax
+ \@dtl@conditiontrue
+ \let\dtl@testifuppernext=\dtl@testifuppercase
+ \else
+ \@dtl@conditionfalse
+ \let\dtl@testifuppernext=\@dtl@gobbletonil
+ \fi
+ \fi
+}}}
+\newcommand*{\DTLifAllLowerCase}[3]{%
+\protected@edef\dtl@tlc{#1}%
+\expandafter\dtl@testiflowercase\dtl@tlc\@nil\relax
+\if@dtl@condition#2\else#3\fi
+}
+\def\dtl@testiflowercase#1#2{%
+\def\dtl@argi{#1}%
+\def\dtl@argii{#2}%
+\ifx\dtl@argi\@nnil
+ \let\dtl@testiflowernext=\@nnil
+\else
+ \ifx#1\protect
+ \let\dtl@testiflowernext=\dtl@testiflowercase
+ \else
+ \ifx\lowercase#1\relax
+ \@dtl@conditiontrue
+ \def\dtl@tc@rest{}%
+ \let\dtl@testiflowernext=\relax
+ \else
+ \edef\dtl@tc@arg{\string#1}%
+ \expandafter\dtl@test@iflowercase\dtl@tc@arg\end
+ \ifx\dtl@argii\@nnil
+ \let\dtl@testiflowernext=\@dtl@gobbletonil
+ \fi
+ \fi
+ \fi
+\fi
+\ifx\dtl@testiflowernext\relax
+ \edef\dtl@dotestiflowernext{%
+ \noexpand\dtl@testiflowercase}%
+\else
+ \ifx\dtl@testiflowernext\@nnil
+ \edef\dtl@dotestiflowernext{#2}%
+ \else
+ \expandafter\toks@\expandafter{\dtl@tc@rest}%
+ \@dtl@toks{#2}%
+ \edef\dtl@dotestiflowernext{%
+ \noexpand\dtl@testiflowernext\the\toks@\the\@dtl@toks}%
+ \fi
+\fi
+\dtl@dotestiflowernext
+}
+\def\dtl@test@iflowercase#1#2\end{%
+\def\dtl@tc@rest{#2}%
+\IfSubStringInString{\string\MakeLowercase}{#1#2}{%
+ \@dtl@conditiontrue
+ \def\dtl@tc@rest{}%
+ \let\dtl@testiflowernext=\relax
+}{%
+ \IfSubStringInString{\string\MakeTextLowercase}{#1#2}{%
+ \@dtl@conditiontrue
+ \def\dtl@tc@rest{}%
+ \let\dtl@testiflowernext=\relax
+ }{%
+ \edef\dtl@lccode{\the\lccode`#1}%
+ \edef\dtl@code{\number`#1}%
+ \ifnum\dtl@code=\dtl@lccode\relax
+ \@dtl@conditiontrue
+ \let\dtl@testiflowernext=\dtl@testiflowercase
+ \else
+ \ifnum\dtl@lccode=0\relax
+ \@dtl@conditiontrue
+ \let\dtl@testiflowernext=\dtl@testiflowercase
+ \else
+ \@dtl@conditionfalse
+ \let\dtl@testiflowernext=\@dtl@gobbletonil
+ \fi
+ \fi
+}}}
+\newwrite\@dtl@write
+\newcommand*{\DTLsavedb}[2]{%
+\DTLifdbexists{#1}{%
+\openout\@dtl@write=#2%
+\edef\@dtl@keys{\csname dtlkeys@#1\endcsname}%
+\def\@dtl@header{}%
+\@for\@dtl@key:=\@dtl@keys\do{%
+\expandafter\@dtl@toks\expandafter{\@dtl@header}%
+\ifx\@dtl@header\@empty
+ \IfSubStringInString{\@dtl@separator}{\@dtl@key}{%
+ \protected@edef\@dtl@header{%
+ \@dtl@delimiter\@dtl@key\@dtl@delimiter}%
+ }{%
+ \protected@edef\@dtl@header{\@dtl@key}%
+ }%
+\else
+ \IfSubStringInString{\@dtl@separator}{\@dtl@key}{%
+ \protected@edef\@dtl@header{\the\@dtl@toks\@dtl@separator
+ \@dtl@delimiter\@dtl@key\@dtl@delimiter}%
+ }{%
+ \protected@edef\@dtl@header{\the\@dtl@toks\@dtl@separator
+ \@dtl@key}%
+ }%
+\fi
+}%
+\protected@write\@dtl@write{}{\@dtl@header}%
+\expandafter\let\expandafter\@dtl@db\csname dtldb@#1\endcsname%
+\@for\@dtl@currentrow:=\@dtl@db\do{%
+\dtl@gathervalues{#1}{\@dtl@currentrow}%
+\def\@dtl@outputrow{}%
+\@for\@dtl@key:=\@dtl@keys\do{%
+\protected@edef\@dtl@element{\csname @dtl@key@\@dtl@key\endcsname}%
+\expandafter\@dtl@toks\expandafter{\@dtl@outputrow}%
+\ifx\@dtl@outputrow\@empty
+ \IfSubStringInString{\@dtl@separator}{\@dtl@element}{%
+ \protected@edef\@dtl@outputrow{%
+ \@dtl@delimiter\@dtl@element\@dtl@delimiter}%
+ }{%
+ \protected@edef\@dtl@outputrow{\@dtl@element}%
+ }%
+\else
+ \IfSubStringInString{\@dtl@separator}{\@dtl@element}{%
+ \protected@edef\@dtl@outputrow{\the\@dtl@toks\@dtl@separator
+ \@dtl@delimiter\@dtl@element\@dtl@delimiter}%
+ }{%
+ \protected@edef\@dtl@outputrow{\the\@dtl@toks\@dtl@separator
+ \@dtl@element}%
+ }%
+\fi
+}%
+\protected@write\@dtl@write{}{\@dtl@outputrow}%
+}%
+\closeout\@dtl@write
+}{%
+\PackageError{datatool}{Database `#1' doesn't exist}{}%
+}}
+\newcommand*{\DTLsavetexdb}[2]{%
+\DTLifdbexists{#1}{%
+\def\@dtl@dbname{#1}%
+\openout\@dtl@write=#2%
+\edef\@dtl@keys{\csname dtlkeys@#1\endcsname}%
+\protected@write\@dtl@write{}{\string\DTLnewdb{#1}}%
+\expandafter\let\expandafter\@dtl@db\csname dtldb@#1\endcsname%
+\@for\@dtl@currentrow:=\@dtl@db\do{%
+\dtl@gathervalues{#1}{\@dtl@currentrow}%
+\protected@write\@dtl@write{}{\string\DTLnewrow{#1}}%
+\@for\@dtl@key:=\@dtl@keys\do{%
+\expandafter\DTLifnull\csname @dtl@key@\@dtl@key\endcsname
+{}{%
+\protected@edef\@dtl@element{\csname @dtl@key@\@dtl@key\endcsname}%
+\protected@write\@dtl@write{}{\string\DTLnewdbentry
+ {#1}{\@dtl@key}{\@dtl@element}}%
+}%
+}%
+}%
+\closeout\@dtl@write
+}{%
+\PackageError{datatool}{Database `#1' doesn't exist}{}%
+}}
+\newread\@dtl@read
+\newcount\dtl@entrycr
+\gdef\DTLloaddb#1#2{%
+\IfFileExists{#2}{%
+\begingroup
+\catcode`\"12\relax
+\openin\@dtl@read=#2%
+\dtl@message{Reading `#2'}%
+\DTLnewdb{#1}%
+\ifeof\@dtl@read
+\else
+ \loop
+ \@dtl@conditionfalse
+ \ifeof\@dtl@read
+ \else
+ \read\@dtl@read to \@dtl@line
+ \dtl@trim\@dtl@line
+ \if\@dtl@line\par
+ \@dtl@conditiontrue
+ \fi
+ \fi
+ \if@dtl@condition
+ \repeat
+ \ifeof\@dtl@read
+ \else
+ \protected@edef\@dtl@lin@{\@dtl@separator\@dtl@line\@dtl@separator}%
+ \@dtl@tmpcount=0\relax
+ \whiledo{\not\equal{\@dtl@lin@}{\@dtl@separator}}{%
+ \expandafter\@dtl@lopoff\@dtl@lin@\to\@dtl@lin@\@dtl@key
+ \advance\@dtl@tmpcount by 1\relax
+ \expandafter\@dtl@toks\expandafter{\@dtl@key}%
+ \expandafter
+ \edef\csname @dtl@inky@\romannumeral\@dtl@tmpcount\endcsname{%
+ \the\@dtl@toks}%
+ }%
+ \ifeof\@dtl@read
+ \else
+ \@dtl@conditiontrue
+ \loop
+ \read\@dtl@read to \@dtl@line
+ \dtl@trim\@dtl@line
+ \ifthenelse{\equal{\@dtl@line}{}}{}%
+ {%
+ \DTLnewrow{#1}%
+ \expandafter\@dtl@toks\expandafter{\@dtl@line}%
+ \edef\@dtl@lin@{\@dtl@separator\the\@dtl@toks
+ \@dtl@separator}%
+ \dtl@entrycr=0\relax
+ \whiledo{\not\equal{\@dtl@lin@}{\@dtl@separator}}{%
+ \expandafter\@dtl@lopoff\@dtl@lin@\to
+ \@dtl@lin@\@dtl@thisentry
+ \advance\dtl@entrycr by 1\relax
+ \edef\@dtl@thiskey{%
+ \csname @dtl@inky@\romannumeral\dtl@entrycr\endcsname}%
+ \expandafter\@dtl@toks\expandafter{\@dtl@thisentry}%
+ \edef\@do@dtlnewentry{\noexpand\DTLnewdbentry
+ {#1}{\@dtl@thiskey}{\the\@dtl@toks}}%
+ \@do@dtlnewentry
+ }%
+ }%
+ \ifeof\@dtl@read \@dtl@conditionfalse\fi
+ \if@dtl@condition
+ \repeat
+ \fi
+ \fi
+\fi
+\closein\@dtl@read
+\endgroup
+}{%
+\PackageError{datatool}{Can't load database `#1' (file `#2'
+doesn't exist)}{}%
+}}
+\newcommand{\dtl@trim}[1]{%
+\def\@dtl@trmstr{}%
+\expandafter\@dtl@starttrim#1\@nil%
+\let#1=\@dtl@trmstr
+}
+\long\def\@dtl@starttrim#1#2{%
+\ifx\par#1%
+ \def\@dtl@dotrim{\@dtl@trim{} #2}%
+\else
+ \def\@dtl@dotrim{\@dtl@trim#1#2}%
+\fi
+\@dtl@dotrim%
+}
+\long\def\@dtl@trim#1 \@nil{\long\def\@dtl@trmstr{#1}}
+\gdef\DTLloadrawdb#1#2{%
+\IfFileExists{#2}{%
+\openin\@dtl@read=#2%
+\dtl@message{Reading `#2'}%
+\DTLnewdb{#1}%
+\ifeof\@dtl@read
+\else
+ \loop
+ \@dtl@conditionfalse
+ \ifeof\@dtl@read
+ \else
+ \@dtl@rawread\@dtl@read to\@dtl@line
+ \dtl@trim\@dtl@line
+ \if\@dtl@line\par
+ \@dtl@conditiontrue
+ \fi
+ \fi
+ \if@dtl@condition
+ \repeat
+ \ifeof\@dtl@read
+ \else
+ \dtl@domappings\@dtl@line
+ \protected@edef\@dtl@lin@{\@dtl@separator\@dtl@line\@dtl@separator}%
+ \@dtl@tmpcount=0\relax
+ \whiledo{\not\equal{\@dtl@lin@}{\@dtl@separator}}{%
+ \expandafter\@dtl@lopoff\@dtl@lin@\to\@dtl@lin@\@dtl@key
+ \advance\@dtl@tmpcount by 1\relax
+ \expandafter\@dtl@toks\expandafter{\@dtl@key}%
+ \expandafter
+ \edef\csname @dtl@inky@\romannumeral\@dtl@tmpcount\endcsname{%
+ \the\@dtl@toks}%
+ }%
+ \ifeof\@dtl@read
+ \else
+ \@dtl@conditiontrue
+ \loop
+ \@dtl@rawread\@dtl@read to\@dtl@line
+ \dtl@trim\@dtl@line
+ \ifthenelse{\equal{\@dtl@line}{}}{}%
+ {%
+ \DTLnewrow{#1}%
+ \dtl@domappings\@dtl@line
+ \expandafter\@dtl@toks\expandafter{\@dtl@line}%
+ \edef\@dtl@lin@{\@dtl@separator\the\@dtl@toks
+ \@dtl@separator}%
+ \dtl@entrycr=0\relax
+ \whiledo{\not\equal{\@dtl@lin@}{\@dtl@separator}}{%
+ \expandafter\@dtl@lopoff\@dtl@lin@\to
+ \@dtl@lin@\@dtl@thisentry
+ \advance\dtl@entrycr by 1\relax
+ \edef\@dtl@thiskey{%
+ \csname @dtl@inky@\romannumeral\dtl@entrycr\endcsname}%
+ \expandafter\@dtl@toks\expandafter{\@dtl@thisentry}%
+ \edef\@do@dtlnewentry{\noexpand\DTLnewdbentry
+ {#1}{\@dtl@thiskey}{\the\@dtl@toks}}%
+ \@do@dtlnewentry
+ }%
+ }%
+ \ifeof\@dtl@read \@dtl@conditionfalse\fi
+ \if@dtl@condition
+ \repeat
+ \fi
+ \fi
+\fi
+\closein\@dtl@read
+}{%
+\PackageError{datatool}{Can't load database `#1' (file `#2'
+doesn't exist)}{}%
+}}
+\begingroup
+\catcode`\%=\active
+\catcode`$=\active
+\catcode`&=\active
+\catcode`~=\active
+\catcode`_=\active
+\catcode`^=\active
+\catcode`#=\active
+\catcode`?=6\relax
+\catcode`<=1\relax
+\catcode`>=2\relax
+\catcode`\{=\active
+\catcode`\}=\active
+\gdef\@dtl@rawread?1to?2<\relax
+<<\catcode`\%=\active
+\catcode`$=\active
+\catcode`&=\active
+\catcode`~=\active
+\catcode`_=\active
+\catcode`^=\active
+\catcode`#=\active
+\catcode`\{=\active
+\catcode`\}=\active
+\def%<\noexpand\%>\relax
+\def$<\noexpand\$>\relax
+\def&<\&>\relax
+\def#<\#>\relax
+\def~<\noexpand\textasciitilde>\relax
+\def_<\noexpand\_>\relax
+\def^<\noexpand\textasciicircum>\relax
+\@dtl@activatebraces
+\@dtl@doreadraw?1?2>>>
+\gdef\@dtl@doreadraw?1?2<\relax
+\read?1 to \tmp
+\xdef?2<\tmp>\relax
+>
+\endgroup
+\begingroup
+\catcode`\{=\active
+\catcode`\}=\active
+\catcode`<=1\relax
+\catcode`>=2\relax
+\gdef\@dtl@activatebraces<%
+ \catcode`\{=\active
+ \catcode`\}=\active
+ \def{<\noexpand\{>%
+ \def}<\noexpand\}>%
+>%
+\endgroup
+\newcommand*{\DTLrawmap}[2]{%
+\expandafter\@dtl@toks\expandafter{\@dtl@rawmappings}%
+\ifx\@dtl@rawmappings\@empty
+ \def\@dtl@rawmappings{{#1}{#2}}%
+\else
+ \def\@dtl@tmp{{#1}{#2}}
+ \protected@edef\@dtl@rawmappings{\the\@dtl@toks,\@dtl@tmp}
+\fi
+}
+\newcommand*{\@dtl@rawmappings}{}
+\newcommand*{\dtl@domappings}[1]{%
+\@for\@dtl@map:=\@dtl@rawmappings\do{%
+ \expandafter\DTLsubstitute\expandafter#1\@dtl@map
+}}
+\newcommand{\DTLsubstitute}[3]{%
+\expandafter\DTLsplitstring\expandafter
+ {#1}{#2}{\@dtl@beforepart}{\@dtl@afterpart}%
+\ifx\@dtl@replaced\@empty
+\else
+ \def#1{}%
+ \expandafter\@dtl@toks\expandafter{\@dtl@beforepart}%
+ \expandafter\toks@\expandafter{#1}%
+ \protected@edef#1{\the\toks@\the\@dtl@toks#3}%
+ \expandafter\@dtl@toks\expandafter{\@dtl@afterpart}%
+ \expandafter\toks@\expandafter{#1}%
+ \edef#1{\the\toks@\the\@dtl@toks}%
+\fi
+}
+\newcommand*{\DTLsplitstring}[4]{%
+\def\dtl@splitstr##1#2##2\@nil{%
+\def#3{##1}%
+\def#4{##2}%
+\ifx#4\@empty
+ \let\@dtl@replaced=\@empty
+\else
+ \def\@dtl@replaced{#2}%
+ \dtl@split@str##2\@nil
+\fi
+}%
+\def\dtl@split@str##1#2\@nil{%
+\def#4{##1}}%
+\dtl@splitstr#1#2\@nil
+}
+\newcommand{\DTLsubstituteall}[3]{%
+\def\@dtl@splitsubstr{}%
+\let\@dtl@afterpart=#1\relax
+\@dtl@dosubstitute{#2}{#3}%
+\expandafter\toks@\expandafter{\@dtl@splitsubstr}%
+\expandafter\@dtl@toks\expandafter{\@dtl@afterpart}%
+\edef#1{\the\toks@\the\@dtl@toks}%
+}
+\def\@dtl@dosubstitute#1#2{%
+\expandafter\DTLsplitstring\expandafter
+ {\@dtl@afterpart}{#1}{\@dtl@beforepart}{\@dtl@afterpart}%
+\expandafter\toks@\expandafter{\@dtl@splitsubstr}%
+\expandafter\@dtl@toks\expandafter{\@dtl@beforepart}%
+\edef\@dtl@splitsubstr{\the\toks@\the\@dtl@toks}%
+\ifx\@dtl@replaced\@empty
+ \let\@dtl@dosubstnext=\@dtl@dosubstitutenoop
+\else
+ \expandafter\toks@\expandafter{\@dtl@splitsubstr}%
+ \@dtl@toks{#2}%
+ \edef\@dtl@splitsubstr{\the\toks@\the\@dtl@toks}%
+ \let\@dtl@dosubstnext=\@dtl@dosubstitute
+\fi
+\@dtl@dosubstnext{#1}{#2}%
+}
+\def\@dtl@dosubstitutenoop#1#2{}
+\newcommand*{\@dtl@currencies}{\$,\pounds}
+\newcommand*{\DTLnewcurrencysymbol}[1]{%
+\expandafter\toks@\expandafter{\@dtl@currencies}%
+\@dtl@toks{#1}%
+\edef\@dtl@currencies{\the\@dtl@toks,\the\toks@}%
+}
+\AtBeginDocument{%
+\@ifundefined{texteuro}{}{\DTLnewcurrencysymbol{\texteuro}}%
+\@ifundefined{textdollar}{}{\DTLnewcurrencysymbol{\textdollar}}%
+\@ifundefined{textstirling}{}{\DTLnewcurrencysymbol{\textstirling}}%
+\@ifundefined{textyen}{}{\DTLnewcurrencysymbol{\textyen}}%
+\@ifundefined{textwon}{}{\DTLnewcurrencysymbol{\textwon}}%
+\@ifundefined{textcurrency}{}{\DTLnewcurrencysymbol{\textcurrency}}%
+\@ifundefined{euro}{}{\DTLnewcurrencysymbol{\euro}}%
+\@ifundefined{yen}{}{\DTLnewcurrencysymbol{\yen}}%
+}
+\newcommand{\@dtl@standardize@currency}[1]{%
+\def\@dtl@org@currency{}%
+\@for\@dtl@thiscurrency:=\@dtl@currencies\do{%
+ \expandafter\toks@\expandafter{\@dtl@thiscurrency}%
+ \edef\@dtl@dosubs{\noexpand\DTLsubstitute{\noexpand#1}%
+ {\the\toks@}{\noexpand\$}}%
+ \@dtl@dosubs
+ \ifx\@dtl@replaced\@empty
+ \else
+ \let\@dtl@org@currency=\@dtl@replaced
+ \@endfortrue
+ \fi
+}%
+\@endforfalse}
+\newcommand*{\@dtl@currency}{\$}
+\newcommand*{\DTLsetdefaultcurrency}[1]{%
+\renewcommand*{\@dtl@currency}{#1}}
+\newcommand{\dtl@ifsingle}[3]{%
+\def\@dtl@arg{#1}%
+\ifx\@dtl@arg\@empty
+ #3%
+\else
+ \@dtl@ifsingle#1\@nil{#2}{#3}%
+\fi
+}
+\def\@dtl@ifsingle#1#2\@nil#3#4{%
+\def\dtl@sg@arg{#2}%
+\ifx\dtl@sg@arg\@empty
+ #3%
+\else
+ #4%
+\fi
+}
+\newcommand*{\dtlshowdb}[1]{%
+\expandafter\show\csname dtldb@#1\endcsname}
+\newcommand*{\dtlshowdbkeys}[1]{%
+\expandafter\show\csname dtlkeys@#1\endcsname}
+\newcommand*{\dtlshowtype}[2]{%
+\expandafter\show\csname @dtl@idtype@#1@#2\endcsname}
+\endinput
+%%
+%% End of file `datatool.sty'.