From 20149d661e5c2763abbd1999e6c76bba077bdb12 Mon Sep 17 00:00:00 2001
From: Karl Berry <karl@freefriends.org>
Date: Wed, 18 Jun 2014 23:15:16 +0000
Subject: datatool (10jun14)

git-svn-id: svn://tug.org/texlive/trunk@34305 c570f23f-e606-0410-a88d-b1316a301751
---
 Master/texmf-dist/tex/latex/datatool/databib.sty | 305 +++++++++++++----------
 1 file changed, 180 insertions(+), 125 deletions(-)

(limited to 'Master/texmf-dist/tex/latex/datatool/databib.sty')

diff --git a/Master/texmf-dist/tex/latex/datatool/databib.sty b/Master/texmf-dist/tex/latex/datatool/databib.sty
index 8a158804268..d0c658f9926 100644
--- a/Master/texmf-dist/tex/latex/datatool/databib.sty
+++ b/Master/texmf-dist/tex/latex/datatool/databib.sty
@@ -39,7 +39,7 @@
 %%   Grave accent  \`     Left brace    \{     Vertical bar  \|
 %%   Right brace   \}     Tilde         \~}
 \NeedsTeXFormat{LaTeX2e}
-\ProvidesPackage{databib}[2014/03/08 v2.21 (NLCT)]
+\ProvidesPackage{databib}[2014/06/10 v2.22 (NLCT)]
 \RequirePackage{datatool}
 \newcommand*{\dtlbib@style}{plain}
 \define@choicekey{databib.sty}{style}{plain,abbrv,alpha}{%
@@ -103,6 +103,14 @@
      \csname DTLformat\DBIBentrytype\endcsname
   }%
 }
+\newcommand*{\DTLformatthisbibentry}[2]{%
+  \edef\DBIBname{#1}%
+  \edef\DBIBcitekey{#2}%
+  \edtlgetrowforvalue{#1}{\dtlcolumnindex{#1}{CiteKey}}{\DBIBcitekey}%
+  \dtl@gathervalues{#1}{\dtlcurrentrow}%
+  \letcs{\DBIBentrytype}{@dtl@key@EntryType}%
+  \DTLformatbibentry
+}
 \newcommand*{\DTLendbibitem}{}
 \newlength\dtl@widest
 \newcommand*{\DTLcomputewidestbibentry}[4]{%
@@ -171,6 +179,9 @@
 \newcounter{DTLbibrow}
 \def\theHDTLbibrow{\theHDTLrow.bib.\arabic{DTLbibrow}}%
 \newcommand*{\DTLbibfield}[1]{\csname @dtl@key@#1\endcsname}
+\newcommand*{\DTLbibfieldlet}[2]{%
+  \letcs{#1}{@dtl@key@#2}%
+}
 \newcommand*{\DTLifbibfieldexists}[3]{%
 \@ifundefined{@dtl@key@#1}{#3}{%
 \expandafter\DTLifnull\csname @dtl@key@#1\endcsname
@@ -484,8 +495,7 @@
 {\em\DTLbibfield{Series}}}{}%
 }%
 }%
-\edef\@dtl@tmp{\DTLbibfield{CrossRef}}%
-~\cite{\@dtl@tmp}%
+~\DTLpcite{\DTLbibfield{CrossRef}}%
 }
 \newcommand*{\DTLformatincollproccrossref}{%
 \DTLifbibfieldexists{Editor}{%
@@ -511,10 +521,9 @@
 \else
   \DTLstartsentencespace
   \expandafter\MakeUppercase\inname
-\fi\ {\em\DTLbibfield{BookTitle}}}{}%
+\fi\ \DTLformatbooktitle{\DTLbibfield{BookTitle}}}{}%
 }}%
-\edef\@dtl@tmp{\DTLbibfield{CrossRef}}%
-~\cite{\@dtl@tmp}%
+~\DTLpcite{\DTLbibfield{CrossRef}}%
 }
 \newcommand*{\DTLformatinedbooktitle}{%
 \DTLifbibfieldexists{BookTitle}{%
@@ -525,9 +534,9 @@
   \expandafter\MakeUppercase\inname
 \fi\
 \DTLifbibfieldexists{Editor}{%
-\DTLformateditorlist\DTLaddcomma {\em\DTLbibfield{BookTitle}}%
+\DTLformateditorlist\DTLaddcomma \DTLformatbooktitle{\DTLbibfield{BookTitle}}%
 \DTLcheckbibfieldendsperiod{BookTitle}%
-}{{\em\DTLbibfield{BookTitle}}%
+}{\DTLformatbooktitle{\DTLbibfield{BookTitle}}%
 \DTLcheckbibfieldendsperiod{BookTitle}%
 }}{}}
 \newcommand*{\DTLformatdate}{%
@@ -570,8 +579,11 @@
  \expandafter\MakeUppercase\inname
 \fi
 \ {\em\DTLbibfield{Journal}}}{}}%
-\edef\@dtl@tmp{\DTLbibfield{CrossRef}}%
-~\cite{\@dtl@tmp}%
+~\DTLpcite{\DTLbibfield{CrossRef}}%
+}
+\newrobustcmd*{\DTLpcite}[1]{%
+  \protected@edef\@dtl@tmp{#1}%
+  \cite{\@dtl@tmp}%
 }
 \newcommand*{\DTLbibfieldexists}[1]{%
 \TE@throw\noexpand\dtl@testbibfieldexists{#1}%
@@ -726,6 +738,13 @@
 \fi}
 \newcommand*{\DTLbibitem}{\bibitem{\DBIBcitekey}}
 \newcommand*{\DTLmbibitem}[1]{\bibitem{#1@\DBIBcitekey}}
+\newcommand*{\DTLcustombibitem}[3]{%
+  #1%
+  \if@filesw
+    \immediate\write\@auxout{\string\bibcite{#3}{#2}}%
+  \fi
+  \ignorespaces
+}
 \newcommand*{\DTLformatauthor}[4]{%
 \DTLformatforenames{#4}
 \DTLformatvon{#1}%
@@ -774,125 +793,160 @@ Systems}
 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*{\DTLmbibitem}[1]{\bibitem{##1@\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
+  \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*{\DTLmbibitem}[1]{\bibitem{##1@\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
+  \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
+  \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*{\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}{}%
+  \DTLifbibfieldexists{Author}%
+  {%
+    \DTLformatauthorlist\DTLaddperiod
+  }%
+  {%
+    \DTLformateditorlist
+    \DTLifbibfieldexists{Editor}%
+    {%
+      \DTLaddperiod
+    }%
+    {}%
+  }%
+  \DTLifbibfieldexists{Title}%
+  {%
+    \DTLstartsentencespace
+    \DTLformatbooktitle{\DTLbibfield{Title}}%
+    \DTLcheckbibfieldendsperiod{Title}%
+  }%
+  {}%
+  \DTLifbibfieldexists{CrossRef}%
+  {%
+    \DTLifbibfieldexists{Title}{\DTLaddperiod}{}%
+    \DTLformatbookcrossref
+    \DTLifanybibfieldexists{Edition,Month,Year}%
+    {\DTLaddcomma}%
+    {\DTLaddperiod}%
+  }%
+  {%
+    \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}{%
@@ -1382,6 +1436,7 @@ Month,Year}{\DTLaddcomma}{\DTLaddperiod}}{}%
 \DTLifanybibfieldexists{Month,Year}{\DTLaddperiod}{}%
 }%
 }
+\newcommand*{\DTLformatbooktitle}[1]{\emph{#1}}
 \newcommand{\dtlbst@abbrv}{%
 \dtlbst@plain
 \renewcommand*{\DTLformatauthor}[4]{%
-- 
cgit v1.2.3

