diff options
Diffstat (limited to 'Master/texmf-dist/tex/latex/biblatex/biblatex.sty')
-rw-r--r-- | Master/texmf-dist/tex/latex/biblatex/biblatex.sty | 1903 |
1 files changed, 1407 insertions, 496 deletions
diff --git a/Master/texmf-dist/tex/latex/biblatex/biblatex.sty b/Master/texmf-dist/tex/latex/biblatex/biblatex.sty index fdb30d4b2c5..85de524be78 100644 --- a/Master/texmf-dist/tex/latex/biblatex/biblatex.sty +++ b/Master/texmf-dist/tex/latex/biblatex/biblatex.sty @@ -12,8 +12,8 @@ % particular purpose. % Set up the version strings here -\def\abx@date{2018/03/04} -\def\abx@version{3.11} +\def\abx@date{2018/11/02} +\def\abx@version{3.12} \def\abx@bbxid{\abx@date\space v\abx@version\space biblatex bibliography style (PK/MW)} \def\abx@cbxid{\abx@date\space v\abx@version\space biblatex citation style (PK/MW)} \def\abx@lbxid{\abx@date\space v\abx@version\space biblatex localization (PK/MW)} @@ -22,26 +22,25 @@ % This is not updated by build script as the control file version % does not necessarily change with the package version. % This is used when writing the .bcf -\def\blx@bcfversion{3.4} +\def\blx@bcfversion{3.5} % This is not updated by build script as the bbl version % does not necessarily change with the package version. % This is used when checking the .bbl -\def\blx@bblversion{2.9} +\def\blx@bblversion{3.0} \NeedsTeXFormat{LaTeX2e}[2005/12/01] \ProvidesPackage{biblatex} [\abx@date\space v\abx@version\space programmable bibliographies (PK/MW)] %% Dependencies -\RequirePackage{pdftexcmds} +\RequirePackage{pdftexcmds}[2018/01/30] \RequirePackage{etoolbox} \RequirePackage{keyval} \RequirePackage{kvoptions} \RequirePackage{logreq} \RequirePackage{ifthen} \RequirePackage{url} -\RequirePackage{xstring} %\RequirePackage{trace} \@ifpackagelater{etoolbox}{2010/11/29} @@ -53,15 +52,6 @@ This is a fatal error. I'm aborting now}% \endinput} -\@ifpackagelater{xstring}{2013/10/13} - {} - {\PackageError{biblatex} - {Outdated 'xstring' package} - {Upgrade to xstring v1.7c (2013/10/13) or later.\MessageBreak - I found: '\csuse{xstringversion}'.\MessageBreak - This is a fatal error. I'm aborting now}% - \endinput} - % polyglossia pretends to be babel, so we need to make sure % we are definitely talking to babel here. \AtEndPreamble{% @@ -99,7 +89,94 @@ \catcode`\^=7 \def\blx@nl{^^J} +\protected\def\blx@safe@actives{% + \let\blx@if@safe@actives\if@safe@actives + \let\if@safe@actives\iftrue} + +\protected\def\blx@rest@actives{% + \let\if@safe@actives\blx@if@safe@actives} + +%% Early errors and warnings +\protected\def\blx@error#1#2{% + \begingroup + \blx@safe@actives + \PackageError{biblatex}{#1}{#2.}% + \endgroup} + +\protected\def\blx@warning@noline#1{% + \begingroup + \blx@safe@actives + \PackageWarningNoLine{biblatex}{#1}% + \endgroup} +\let\blx@warning\blx@warning@noline +\AtEndOfPackage{% + \protected\def\blx@warning#1{% + \begingroup + \blx@safe@actives + \PackageWarning{biblatex}{#1}% + \endgroup}} + %% Compatibility +\def\blx@packageincompatibility{% + \def\do##1{% + \@ifpackageloaded{##1} + {\ifcsundef{blx@pkgloaded@##1} + {\global\cslet{blx@pkgloaded@##1}\@empty + \blx@error + {Incompatible package '##1'} + {The '##1' package and biblatex are incompatible}} + {}} + {}}% + \docsvlist{% + amsrefs,apacite,babelbib,backref,bibtopic,bibunits,chapterbib, + cite,citeref,drftcite,footbib,inlinebib,jurabib,mcite,mciteplus, + mlbib,multibbl,multibib,natbib,opcit,overcite,splitbib,ucs}% + % etextools is special, it gets an option to demote the error to a warning + % remind people to restore \forlistloop + \ifcsdef{blx@noerroretextools} + {\@ifpackageloaded{etextools} + {\ifcsundef{blx@pkgloaded@etextools} + {\global\cslet{blx@pkgloaded@etextools}\@empty + \blx@warning@noline{% + Incompatible package 'etextools' loaded,\MessageBreak + no error is thrown because you defined\MessageBreak + '\string\blx@noerroretextools'.\MessageBreak + 'etextools' redefines '\string\forlistloop', you must\MessageBreak + restore the definition from 'etoolbox'\MessageBreak + before you load biblatex}} + {}} + {}} + {\@ifpackageloaded{etextools} + {\ifcsundef{blx@pkgloaded@etextools} + {\global\cslet{blx@pkgloaded@etextools}\@empty + \blx@error + {Incompatible package 'etextools'} + {The 'etextools' package and biblatex are + incompatible.\MessageBreak + If you must load 'etextools' at all costs, define the command% + \MessageBreak '\string\blx@noerroretextools'}} + {}} + {}}} + +% Call this right here, almost immediately after loading to give sensible +% errors for incompatibilities that arise at loading-time. +% The macro is called again a second time in \AtEndPreamble when all packages +% should be loaded. +% This still can't catch all cases, \usepackage{biblatex}\usepackage{natbib} +% still gives a weird error. +\blx@packageincompatibility + +% people should not be abusing noerroretextools, so warn if it is not needed +\def\blx@packageincompatibility@endpreambleonly{% + \ifcsdef{blx@noerroretextools} + {\@ifpackageloaded{etextools} + {} + {\blx@warning@noline{% + You defined '\string\blx@noerroretextools',\MessageBreak + but 'etextools' is not loaded.\MessageBreak + Please do not define '\string\blx@noerroretextools'\MessageBreak + unless you really need it}}} + {}} \begingroup \catcode`\#=12 @@ -122,35 +199,8 @@ \endgroup \AtEndPreamble{% - \def\do#1{% - \@ifpackageloaded{#1} - {\blx@error - {Incompatible package '#1'} - {The '#1' package and biblatex are incompatible}} - {}}% - \docsvlist{% - amsrefs,apacite,babelbib,backref,bibtopic,bibunits,chapterbib, - cite,citeref,drftcite,footbib,inlinebib,jurabib,mcite,mciteplus, - mlbib,multibbl,multibib,natbib,opcit,overcite,splitbib,ucs}% - \iftoggle{blx@noerroretextools} - {\@ifpackageloaded{etextools} - {\blx@warning@noline{% - Incompatible package 'etextools' loaded,\MessageBreak - no error is thrown because you set\MessageBreak - 'noerroretextools=true'.\MessageBreak - 'etextools' redefines '\string\forlistloop', you will\MessageBreak - need to restore the definition from 'etoolbox'}} - {\blx@warning@noline{% - You set 'noerroretextools=true',\MessageBreak - but 'etextools' is not loaded.\MessageBreak - Please do not set 'noerroretextools' to 'true'\MessageBreak - unless you really need it}}} - {\@ifpackageloaded{etextools} - {\blx@error - {Incompatible package 'etextools'} - {The 'etextools' package and biblatex are incompatible.\MessageBreak - If you must load 'etextools' at all costs, set 'noerroretextools=true'}} - {}}% + \blx@packageincompatibility + \blx@packageincompatibility@endpreambleonly \def\blx@langstrings{}% % Set up sortlocale defaults and default language if babel/polyglossia is not loaded \ifdefstring\blx@sortlocale{auto} @@ -164,15 +214,15 @@ \ifundef\xpg@loaded {\let\xpg@loaded\@empty \let\xpg@vloaded\@empty - \PackageWarningNoLine{biblatex}{Upgrade package 'polyglossia' to > v1.42.0 recommended}} + \blx@warning@noline{Upgrade package 'polyglossia' to > v1.42.0 recommended}} {}% \def\do#1{\blx@langsetup{#1}}% \expandafter\docsvlist\expandafter{\xpg@loaded}% \expandafter\docsvlist\expandafter{\xpg@vloaded}% \ifboolexpr{ - not test {\iftoggle{blx@autolangbib}} + not togl {blx@autolangbib} and - not test {\iftoggle{blx@autolangcite}}} + not togl {blx@autolangcite}} {\blx@mknoautolang} {\blx@mkautolangpoly}} {\@ifpackageloaded{babel} @@ -180,9 +230,9 @@ \def\do#1{\blx@langsetup{#1}}% \expandafter\docsvlist\expandafter{\bbl@loaded}% \ifboolexpr{ - not test {\iftoggle{blx@autolangbib}} + not togl {blx@autolangbib} and - not test {\iftoggle{blx@autolangcite}}} + not togl {blx@autolangcite}} {\blx@mknoautolang} {\blx@mkautolangbabel}} {\blx@mknoautolang}}% @@ -256,12 +306,15 @@ \l@doldold@footnotetext,% ledmac \predefinedfootnotetext,% linguex \@fntORI}% frenchle - \iftoggle{blx@tempa}% ams classes - {\patchcmd\@footnotetext - {\@makefntext} - {\toggletrue{blx@footnote}\@makefntext} - {\togglefalse{blx@tempa}} - {}} + \iftoggle{blx@tempa}% ams classes ... + {\def\do#1{% + \patchcmd#1 + {\@makefntext} + {\toggletrue{blx@footnote}\@makefntext} + {\togglefalse{blx@tempa}} + {}}% + \docsvlist{\@footnotetext,% ams classes standard + \H@@footnotetext}}% hyperref {}% \@ifpackageloaded{bidi}% bidi {\blx@patchbidifootnotes} @@ -378,7 +431,14 @@ {}% \@ifpackagelater{csquotes}{2010/06/09} {} - {\newcommand*{\@quotereset}{}\newcount\@quotereset}} + {\newcommand*{\@quotereset}{}\newcount\@quotereset}% + \newcommand*{\blx@initoquote}{\initoquote}% + \newcommand*{\blx@textooquote}{\textooquote}% + \newcommand*{\blx@textcoquote}{\textcoquote}% + \newcommand*{\blx@initiquote}{\initiquote}% + \newcommand*{\blx@textoiquote}{\textoiquote}% + \newcommand*{\blx@textciquote}{\textciquote}% + \newcommand*{\blx@enquote}{\enquote}} {\@ifpackageloaded{babel} {\blx@warning@noline{% 'babel/polyglossia' detected but 'csquotes' missing.\MessageBreak @@ -390,26 +450,27 @@ \newcount\@quotereset \newcommand*{\@setquotesfcodes}{}% \let\@setquotesfcodes\relax - \newrobustcmd*{\initoquote}{\@quotelevel\@ne}% - \newrobustcmd*{\initiquote}{\@quotelevel\tw@}% - \newrobustcmd*{\textooquote}{``}% - \newrobustcmd*{\textcoquote}{''}% - \newrobustcmd*{\textoiquote}{`\relax}% block ligs - \newrobustcmd*{\textciquote}{'\relax}% block ligs - \newrobustcmd*{\enquote}{\@ifstar\blx@enquote@ii\blx@enquote}% - \def\blx@enquote{% + \newrobustcmd*{\blx@initoquote}{\@quotelevel\@ne}% + \newrobustcmd*{\blx@initiquote}{\@quotelevel\tw@}% + \newrobustcmd*{\blx@textooquote}{``}% + \newrobustcmd*{\blx@textcoquote}{''}% + \newrobustcmd*{\blx@textoiquote}{`\relax}% block ligs + \newrobustcmd*{\blx@textciquote}{'\relax}% block ligs + \newrobustcmd*{\blx@enquote} + {\@ifstar\blx@enquote@iii\blx@enquote@i}% + \def\blx@enquote@i{% \ifnum\@quotelevel>\z@ - \expandafter\blx@enquote@ii + \expandafter\blx@enquote@iii \else - \expandafter\blx@enquote@i + \expandafter\blx@enquote@ii \fi}% - \long\def\blx@enquote@i#1{% - \begingroup\initoquote - \textooquote#1\textcoquote - \endgroup}% \long\def\blx@enquote@ii#1{% - \begingroup\initiquote - \textoiquote#1\textciquote + \begingroup\blx@initoquote + \blx@textooquote#1\blx@textcoquote + \endgroup}% + \long\def\blx@enquote@iii#1{% + \begingroup\blx@initiquote + \blx@textoiquote#1\blx@textciquote \endgroup}% \appto\blx@setsfcodes{% \sfcode`\`=\z@ @@ -448,10 +509,70 @@ % trick showkeys into believing we're havard \let\HAR@checkdef\@empty -%% Allocation - \providecommand{\@gobblefive}[5]{} +\ifundef\pdf@mdfivesum + {\let\blx@mdfivesum\@firstofone + \blx@warning@noline{Command '\string\pdf@mdfivesum' undefined.\MessageBreak + 'labelprefix' may not be able to accept all input}} + {\let\blx@mdfivesum\pdf@mdfivesum} + + +% xstring replacements + +% reverse a given string +% idea by egreg (https://tex.stackexchange.com/users/4427/egreg) +% from https://tex.stackexchange.com/q/36034/ +% relicensed under LPPL according to +% https://tex.meta.stackexchange.com/a/3333/ +\def\blx@revstr#1{% + \ifblank{#1} + {} + {\blx@revstr@l #1\blx@revstr@b@i\blx@revstr@b@ii}} + +\def\blx@revstr@l#1#2\blx@revstr@b@i#3\blx@revstr@b@ii{% + \ifblank{#2} + {#1#3} + {\blx@revstr@l#2\blx@revstr@b@i#1#3\blx@revstr@b@ii}} + +% these tests are inspired by Stephan v. Bechtolsheim's TUGboat article +% https://www.tug.org/TUGboat/tb09-1/tb20bechtolsheim.pdf +% but we need to test for start and end and not for generic substring +% start is easy, delimited arguments help there +\protected\def\blx@ifstrstartswith#1#2{% + \def\blx@ifstrstartswith@i ##1#2##2&{% + \ifblank{##1}}% + \blx@ifstrstartswith@i #1#2&} + +% end is harder, so we reverse everything and apply the start test +\protected\def\blx@ifstrendswith#1#2{% + \begingroup + \edef\blx@tempa{\endgroup + \noexpand\blx@ifstrstartswith{\blx@revstr{#1}}{\blx@revstr{#2}}}% + \blx@tempa} + +% not expandable, so write the result to the macro given in #3 +% {<string>}{<strip>}{<result>} +% <result> will contain the bit of <string> +% after the first occurrence of <strip> +\protected\def\blx@stripfromstartinto#1#2#3{% + \def\blx@stripfromstart@i ##1#2##2&{% + \def#3{##2}}% + \blx@stripfromstart@i #1&} + +% {<string>}{<strip>}{<result>} +% <result> will contain the bit of <string> +% before the last occurence of <strip> +\protected\def\blx@stripfromendinto#1#2#3{% + \begingroup + \edef\blx@tempa{\endgroup + \noexpand\blx@stripfromstartinto{\blx@revstr{#1}}{\blx@revstr{#2}}}% + \blx@tempa{#3}% + \edef#3{\noexpand\blx@revstr{#3}}% + \edef#3{#3}} + +%% Allocation + % Counter to track nested tabularx environemnts so we don't % try to patch the commands more than once below as this undefs some % macros and an error is thrown @@ -486,6 +607,8 @@ \def\theminitems{\the\c@minitems} \newcounter{citecounter} \def\thecitecount{\the\c@citecounter} +\newcounter{maxcitecounter} +\def\themaxcitecounter{\the\c@maxcitecounter} \newcounter{savedcitecounter} \def\thecitecount{\the\c@savedcitecounter} \newcounter{uniquelist} @@ -500,6 +623,8 @@ \def\themaxextratitle{\the\c@maxextratitle} \newcounter{maxextratitleyear} \def\themaxextratitleyear{\the\c@maxextratitleyear} +\newcounter{maxextraname} +\def\themaxextraname{\the\c@maxextraname} \newcounter{maxextradate} \def\themaxextradate{\the\c@maxextradate} \newcounter{maxextraalpha} @@ -524,6 +649,8 @@ \newcount\blx@parenlevel@text \newcount\blx@parenlevel@foot \expandafter\newcount\csname blx@sectionciteorder@0\endcsname +\newcount\blx@entrysetcounter + \def\blx@uniquename{0} \def\blx@uniquelist{0} @@ -531,10 +658,14 @@ \def\blx@minbibnames{0} \def\blx@maxcitenames{0} \def\blx@mincitenames{0} +\def\blx@maxsortnames{0} +\def\blx@minsortnames{0} \def\blx@maxbibnames@type{\blx@maxbibnames} \def\blx@minbibnames@type{\blx@minbibnames} \def\blx@maxcitenames@type{\blx@maxcitenames} \def\blx@mincitenames@type{\blx@mincitenames} +\def\blx@maxsortnames@type{\blx@maxsortnames} +\def\blx@minsortnames@type{\blx@minsortnames} \def\blx@maxalphanames{0} \def\blx@minalphanames{0} \def\blx@maxitems{0} @@ -590,6 +721,7 @@ \newtoggle{blx@labeltitleyear} \newtoggle{blx@labeldateparts} \newtoggle{blx@natbib} +\newtoggle{blx@noroman} \newtoggle{blx@mcite} \newtoggle{blx@loadfiles} \newtoggle{blx@singletitle} @@ -615,14 +747,12 @@ \newtoggle{blx@localnumber} \newtoggle{blx@refcontext} -% Nice command from etextools which causes too many problems if you load -% the whole package -% Don't use it on arbitrary user input as it dies on non-expandable arguments -\newcommand*{\blx@xifempty}[1]{\blx@xifstrcmp{#1}{}} -% {string1}{string2}{true}{false} -\newcommand*{\blx@xifstrcmp}[2]{\csname @% - \ifnum\pdf@strcmp{#1}{#2}=0 first\else second\fi - oftwo\endcsname} +\newcommand*{\blx@xifstrequal}[2]{% + \begingroup + \edef\blx@tempa{% + \endgroup + \noexpand\ifstrequal{#1}{#2}}% + \blx@tempa} % Special fields which need resolution using the information provided by biber \listadd\abx@rfields{labeltitle} @@ -658,6 +788,8 @@ % Initialise some lists which track changing citations/sortingtemplates % etc. between runs \global\let\blx@cites\@empty +\global\let\blx@nocites\@empty +\global\let\blx@directcites\@empty \global\let\blx@refcontexts\@empty \global\let\blx@lastrefcontexts\@empty \global\let\blx@sortingtemplatenames\@empty @@ -680,16 +812,22 @@ % Deprecations \newrobustcmd*{\DeprecateField}[2]{% \csdef{abx@field@#1}{% - \ifcsundef{abx@field@legacy@warning@#1}{\blx@warning@noline{Field '#1' is deprecated. #2}}{}% - \global\cslet{abx@field@legacy@warning@#1}\@empty}}% + \ifcsundef{abx@legacywarning@field@#1} + {\blx@warning@noline{Field '#1' is deprecated. #2}} + {}% + \global\cslet{abx@legacywarning@field@#1}\@empty}}% \newrobustcmd*{\DeprecateList}[2]{% \csdef{abx@list@#1}{% - \ifcsundef{abx@list@legacy@warning@#1}{\blx@warning@noline{List '#1' is deprecated. #2}}{}% - \global\cslet{abx@list@legacy@warning@#1}\@empty}}% + \ifcsundef{abx@legacywarning@list@#1} + {\blx@warning@noline{List '#1' is deprecated. #2}} + {}% + \global\cslet{abx@legacywarning@list@#1}\@empty}} \newrobustcmd*{\DeprecateName}[2]{% \csdef{abx@name@#1}{% - \ifcsundef{abx@name@legacy@warning@#1}{\blx@warning@noline{Name '#1' is deprecated. #2}}{}% - \global\cslet{abx@name@legacy@warning@#1}\@empty}}% + \ifcsundef{abx@legacywarning@name@#1} + {\blx@warning@noline{Name '#1' is deprecated. #2}} + {}% + \global\cslet{abx@legacywarning@name@#1}\@empty}} \let\blx@aliasfields\@empty @@ -698,39 +836,39 @@ \ifcsundef{abx@field@#2} {} {\csdef{abx@field@#1}{% - \csuse{abx@field@#2}% - \ifcsundef{abx@field@legacy@warning@#1} - {\blx@warning@noline{Field '#1' is deprecated.\MessageBreak - Please use '#2' instead.\MessageBreak - Using '#2' now}} - {}% - \global\cslet{abx@field@legacy@warning@#1}\@empty}}}} + \csuse{abx@field@#2}% + \ifcsundef{abx@legacywarning@field@#1} + {\blx@warning@noline{Field '#1' is deprecated.\MessageBreak + Please use '#2' instead.\MessageBreak + Using '#2' now}} + {}% + \global\cslet{abx@legacywarning@field@#1}\@empty}}}} \newrobustcmd*{\DeprecateListWithReplacement}[2]{% \appto\blx@aliasfields{% \ifcsundef{abx@list@#2} {} {\csdef{abx@list@#1}{% - \csuse{abx@list@#2}% - \ifcsundef{abx@list@legacy@warning@#1} - {\blx@warning@noline{List '#1' is deprecated.\MessageBreak - Please use '#2' instead.\MessageBreak - Using '#2' now}} - {}% - \global\cslet{abx@list@legacy@warning@#1}\@empty}}}} + \csuse{abx@list@#2}% + \ifcsundef{abx@legacywarning@list@#1} + {\blx@warning@noline{List '#1' is deprecated.\MessageBreak + Please use '#2' instead.\MessageBreak + Using '#2' now}} + {}% + \global\cslet{abx@legacywarning@list@#1}\@empty}}}} \newrobustcmd*{\DeprecateNameWithReplacement}[2]{% \appto\blx@aliasfields{% \ifcsundef{abx@name@#2} {} {\csdef{abx@name@#1}{% - \csuse{abx@name@#2}% - \ifcsundef{abx@name@legacy@warning@#1} - {\blx@warning@noline{Name '#1' is deprecated.\MessageBreak - Please use '#2' instead.\MessageBreak - Using '#2' now}} - {}% - \global\cslet{abx@name@legacy@warning@#1}\@empty}}}} + \csuse{abx@name@#2}% + \ifcsundef{abx@legacywarning@name@#1} + {\blx@warning@noline{Name '#1' is deprecated.\MessageBreak + Please use '#2' instead.\MessageBreak + Using '#2' now}} + {}% + \global\cslet{abx@legacywarning@name@#1}\@empty}}}} %% Initialisation \def\blx@blxinit{% @@ -760,13 +898,6 @@ {}} %% Auxiliary commands -\protected\def\blx@safe@actives{% - \let\blx@if@safe@actives\if@safe@actives - \let\if@safe@actives\iftrue} - -\protected\def\blx@rest@actives{% - \let\if@safe@actives\blx@if@safe@actives} - \protected\def\blx@regimc#1{% \xappto\blx@blxinit{% \let\noexpand#1\expandafter\noexpand\csname @@ -980,27 +1111,7 @@ ) }} -%% User feedback - -\protected\def\blx@error#1#2{% - \begingroup - \blx@safe@actives - \PackageError{biblatex}{#1}{#2.}% - \endgroup} - -\protected\def\blx@warning@noline#1{% - \begingroup - \blx@safe@actives - \PackageWarningNoLine{biblatex}{#1}% - \endgroup} -\let\blx@warning\blx@warning@noline -\AtEndOfPackage{ - \protected\def\blx@warning#1{% - \begingroup - \blx@safe@actives - \PackageWarning{biblatex}{#1}% - \endgroup}} - +%% More user feedback \protected\def\blx@warning@entry#1{% \ifdef\abx@field@entrykey {\blx@warning{#1\MessageBreak at entry '\abx@field@entrykey'}} @@ -1012,7 +1123,7 @@ \PackageInfo{biblatex}{#1\@gobble}% \endgroup} \let\blx@info\blx@info@noline -\AtEndOfPackage{ +\AtEndOfPackage{% \protected\def\blx@info#1{% \begingroup \blx@safe@actives @@ -1160,7 +1271,8 @@ \blx@warning{Conflicting options.\MessageBreak#1}} \def\blx@warn@badoptdt#1{% - \blx@warning{Invalid option datatype '#1'.\MessageBreak Defaulting to 'boolean'}} + \blx@warning{Invalid option datatype '#1'.\MessageBreak + Defaulting to 'boolean'}} \def\blx@warn@depropt#1{% \blx@warning{Deprecated option.\MessageBreak Ignoring '#1'}} @@ -2046,6 +2158,8 @@ \def\blx@imc@ifbibmacroundef#1{% \ifcsundef{abx@macro@#1}} +\def\ifbibmacroundef{\blx@imc@ifbibmacroundef} + % {<field>} \def\blx@imc@thefield#1{\csuse{abx@field@#1}} @@ -2732,7 +2846,7 @@ \blx@imc@iffieldundef{#1} {\@secondoftwo} {\expandafter\expandafter - \expandafter\ifinteger + \expandafter\blx@imc@ifinteger \expandafter\expandafter \expandafter{\csname abx@field@#1\endcsname}}} @@ -3246,12 +3360,15 @@ {\blx@declaredelimclear} {\blx@declaredelim}} -\newrobustcmd*{\blx@declaredelimclear}[3][]{% - \ifcsvoid{blx@declaredelimcontexts@#2} +\def\blx@cleardelim#1{% + \ifcsvoid{blx@declaredelimcontexts@#1} {} - {\def\do##1{\csundef{blx@printdelim@##1@#2}}% - \dolistcsloop{blx@declaredelimcontexts@#2}}% - \cslet{blx@declaredelimcontexts@#2}\@empty + {\def\do##1{\csundef{blx@printdelim@##1@#1}}% + \dolistcsloop{blx@declaredelimcontexts@#1}}% + \cslet{blx@declaredelimcontexts@#1}\@empty} + +\newrobustcmd*{\blx@declaredelimclear}[3][]{% + \blx@cleardelim{#2}% \ifblank{#1} {\blx@declaredelim{#2}{#3}} {\blx@declaredelim[#1]{#2}{#3}}} @@ -3272,32 +3389,64 @@ \csdef{#1##1}{#4}}% \forcsvlist{\do@i}{#3}} -% *[<contextname, ...>]{<alias>}{<delim>} +% *[<alias context, ...>]{<alias>}[<delim context>]{<delim>} \newrobustcmd*{\DeclareDelimAlias}{% \@ifstar - {\blx@declaredelimalias} - {\blx@declaredelimaliasauto}} - -\newrobustcmd*{\blx@declaredelimalias}[3][]{% - \ifblank{#1} - {\blx@declaredelimalias@i{}{#2}{#3}} - {\def\do##1{% - \blx@declaredelimalias@i{blx@printdelim@##1@}{#2}{#3}}% - \docsvlist{#1}}} + {\blx@declaredelimalias@expl} + {\blx@declaredelimalias@auto}} -\newrobustcmd*{\blx@declaredelimaliasauto}[2]{% - \blx@declaredelimalias@i{}{#1}{#2}% +\newrobustcmd*{\blx@declaredelimalias@auto}[2]{% + \blx@cleardelim{#1}% + \blx@declaredelimalias@def{}{#1}{}{#2}% \ifcsvoid{blx@declaredelimcontexts@#2} {} {\def\do##1{% - \blx@declaredelimalias@i{blx@printdelim@##1@}{#1}{#2}}% + \blx@declaredelimalias@def + {blx@printdelim@##1@}{#1}{blx@printdelim@##1@}{#2}}% \dolistcsloop{blx@declaredelimcontexts@#2}}} -\def\blx@declaredelimalias@i#1#2#3{% +\def\blx@declaredelimalias@expl{% + \@ifnextchar[%] + {\blx@declaredelimalias@expl@i} + {\blx@declaredelimalias@expl@i[]}} + +\def\blx@declaredelimalias@expl@i[#1]#2{% + \@ifnextchar[%] + {\blx@declaredelimalias@expl@iii{#1}{#2}} + {\blx@declaredelimalias@expl@ii{#1}{#2}}} + +\def\blx@declaredelimalias@expl@ii#1#2#3{% + \ifblank{#1} + {\blx@declaredelimalias@def{}{#2}{}{#3}} + {\def\do##1{% + \blx@declaredelimalias@def + {blx@printdelim@##1@}{#2}{blx@printdelim@##1@}{#3}}% + \docsvlist{#1}}} + +\def\blx@declaredelimalias@expl@iii#1#2[#3]#4{% + \ifblank{#1} + {\ifblank{#3} + {\blx@declaredelimalias@def{}{#2}{}{#4}} + {\blx@declaredelimalias@def{}{#2}{blx@printdelim@#3@}{#4}}} + {\ifblank{#3} + {\def\do##1{% + \blx@declaredelimalias@def + {blx@printdelim@##1@}{#2}{}{#4}}} + {\def\do##1{% + \blx@declaredelimalias@def + {blx@printdelim@##1@}{#2}{blx@printdelim@#3@}{#4}}}% + \docsvlist{#1}}} + +\def\blx@declaredelimalias@def#1#2#3#4{% \ifcsdef{#1#2} {\blx@inf@delimdeclare{#2}{#1}} {}% - \csdef{#1#2}{\csuse{#1#3}}} + \ifblank{#1} + {} + {\ifinlistcs{#1}{blx@declaredelimcontexts@#2} + {} + {\listcsadd{blx@declaredelimcontexts@#2}{#1}}}% + \csdef{#1#2}{\ifcsundef{#3#4}{\csuse{#4}}{\csuse{#3#4}}}} \def\blx@delimcontext{none} \newcommand*{\printdelim}[2][]{% @@ -3320,7 +3469,7 @@ {#1}} \newcommand*{\DeclareDelimcontextAlias}[2]{% - \csgdef{blx@delimcontextalias@#1}{#2}} + \csdef{blx@delimcontextalias@#1}{#2}} \newrobustcmd*{\AtUsedriver}{% \@ifstar @@ -3483,6 +3632,10 @@ or (not test {\ifdatehastime{#1}} and test {\ifdatehastime{#2}})}} +\def\blx@imc@ifdateyearsequal#1#2{% + \ifboolexpr{ test {\iffieldsequal{#1year}{#2year}} + and test {\iffieldsequal{#1dateera}{#2dateera}}}} + \blx@regimcs{% \ifdriver \thefield \strfield \csfield \usefield \thelist \strlist \thename \strname \clearfield \clearlist \clearname \restorefield \restorelist \restorename @@ -3490,7 +3643,7 @@ \ifciteseen \ifciteibid \ifciteidem \ifopcit \ifloccit \ifcurrentfield \ifcurrentlist \ifcurrentname \ifentrytype \iffieldequalcs \iffieldequals \iffieldequalstr \iffieldsequal - \ifbibmacroundef \iffieldundef \iffieldxref \iflistequalcs \iflistequals + \iffieldundef \iffieldxref \iflistequalcs \iflistequals \iflistsequal \iflistundef \iflistxref \ifmorenames \ifmoreitems \iffirstcitekey \iflastcitekey \ifnameequalcs \ifnameequals \ifnamesequal \ifnameundef \ifnamexref @@ -3500,6 +3653,7 @@ \iffieldint \iffieldnum \iffieldnums \iffieldpages \iflabeldateisdate \ifdatehasyearonlyprecision \ifdatehastime \ifdateshavedifferentprecision + \ifdateyearsequal \mkpageprefix \mkpagetotal \newblock \newunit \setunit \printunit \finentry} @@ -3515,6 +3669,7 @@ \def\ifcrossrefsource{\iftoggle{abx@bool@crossrefsource}}% \def\ifxrefsource{\iftoggle{abx@bool@xrefsource}}% \def\ifsingletitle{\iftoggle{abx@bool@singletitle}}% + \def\ifnocite{\iftoggle{abx@bool@nocite}}% \def\ifuniquetitle{\iftoggle{abx@bool@uniquetitle}}% \def\ifuniquebaretitle{\iftoggle{abx@bool@uniquebaretitle}}% \def\ifuniquework{\iftoggle{abx@bool@uniquework}}% @@ -3851,6 +4006,24 @@ {\blx@defformat\blx@defplainformat{fid}*} {\blx@defformat\blx@defplainformat{fid}{}}} +\newrobustcmd*{\DeclareNameWrapperFormat}{% + \@ifstar + {\blx@defformat\blx@defnameformat{nwd}*} + {\blx@defformat\blx@defnameformat{nwd}{}}} +\newrobustcmd*{\DeclareIndexNameWrapperFormat}{% + \@ifstar + {\blx@defformat\blx@defnameformat{nxd}*} + {\blx@defformat\blx@defnameformat{nxd}{}}} + +\newrobustcmd*{\DeclareListWrapperFormat}{% + \@ifstar + {\blx@defformat\blx@defplainformat{lwd}*} + {\blx@defformat\blx@defplainformat{lwd}{}}} +\newrobustcmd*{\DeclareIndexListWrapperFormat}{% + \@ifstar + {\blx@defformat\blx@defplainformat{lxd}*} + {\blx@defformat\blx@defplainformat{lxd}{}}} + % {<macro>}{<class>}{<*>} \def\blx@defformat#1#2#3{% \@ifnextchar[%] @@ -3936,15 +4109,21 @@ \newrobustcmd*{\savefieldformat}[2][*]{\blx@save{abx@ffd@#1@#2}} \newrobustcmd*{\savelistformat}[2][*]{\blx@save{abx@lfd@#1@#2}} \newrobustcmd*{\savenameformat}[2][*]{\blx@save{abx@nfd@#1@#2}} +\newrobustcmd*{\savelistwrapperformat}[2][*]{\blx@save{abx@lwd@#1@#2}} +\newrobustcmd*{\savenamewrapperformat}[2][*]{\blx@save{abx@nwd@#1@#2}} \newrobustcmd*{\restorefieldformat}[2][*]{\blx@restore{abx@ffd@#1@#2}} \newrobustcmd*{\restorelistformat}[2][*]{\blx@restore{abx@lfd@#1@#2}} \newrobustcmd*{\restorenameformat}[2][*]{\blx@restore{abx@nfd@#1@#2}} +\newrobustcmd*{\restorelistwrapperformat}[2][*]{\blx@restore{abx@lwd@#1@#2}} +\newrobustcmd*{\restorenamewrapperformat}[2][*]{\blx@restore{abx@nwd@#1@#2}} % [<entrytype>]{<name>}{<true>}{<false>} \newrobustcmd*{\iffieldformatundef}[2][*]{\ifcsundef{abx@ffd@#1@#2}} \newrobustcmd*{\iflistformatundef}[2][*]{\ifcsundef{abx@lfd@#1@#2}} \newrobustcmd*{\ifnameformatundef}[2][*]{\ifcsundef{abx@nfd@#1@#2}} +\newrobustcmd*{\iflistwrapperformatundef}[2][*]{\ifcsundef{abx@lwd@#1@#2}} +\newrobustcmd*{\ifnamewrapperformatundef}[2][*]{\ifcsundef{abx@nwd@#1@#2}} % [<entrytype>]{<alias>}[<entrytype>]{<name>} \newrobustcmd*{\DeclareNameAlias}{\blx@defalias{nfd}} @@ -3956,6 +4135,62 @@ \newrobustcmd*{\DeclareFieldAlias}{\blx@defalias{ffd}} \newrobustcmd*{\DeclareIndexFieldAlias}{\blx@defalias{fid}} +\newrobustcmd*{\DeclareNameWrapperAlias}{\blx@defalias{nwd}} +\newrobustcmd*{\DeclareIndexNameWrapperAlias}{\blx@defalias{nxd}} + +\newrobustcmd*{\DeclareListWrapperAlias}{\blx@defalias{lwd}} +\newrobustcmd*{\DeclareIndexListWrapperAlias}{\blx@defalias{lxd}} + +% #1: internal type signature, #2: type text for warning +% #3 #4 #5 #6 +% [aliastype]{aliasname}[formattype]{formatname} +\def\blx@deprecateformat#1#2{% + \@ifnextchar[%] + {\blx@deprecateformat@i{#1}{#2}} + {\blx@deprecateformat@i{#1}{#2}[*]}} +\def\blx@deprecateformat@i#1#2[#3]#4{% + \@ifnextchar[%] + {\blx@deprecateformat@ii{#1}{#2}{#3}{#4}} + {\blx@deprecateformat@ii{#1}{#2}{#3}{#4}[*]}} +\def\blx@deprecateformat@ii#1#2#3#4[#5]#6{% + \blx@safe@actives + \afterassignment\blx@rest@actives + \csdef{abx@#1@#3@#4}{% + \ifcsundef{abx@legacywarning@#1@#3@#4} + {\global\cslet{abx@legacywarning@#1@#3@#4}\@empty + \blx@warning@noline{% + #2 '#4' deprecated.\MessageBreak + Please use '#6' instead.\MessageBreak + Using '#6' now}} + {}% + \csname abx@#1@#5@#6\endcsname}} + +% [<entrytype>]{<alias>}[<entrytype>]{<name>} +\newrobustcmd*{\DeprecateNameFormatWithReplacement}{% + \blx@deprecateformat{nfd}{Name format}} +\newrobustcmd*{\DeprecateIndexNameFormatWithReplacement}{% + \blx@deprecateformat{nid}{Index name format}} + +\newrobustcmd*{\DeprecateListFormatWithReplacement}{% + \blx@deprecateformat{lfd}{List format}} +\newrobustcmd*{\DeprecateIndexListFormatWithReplacement}{% + \blx@deprecateformat{lid}{Index list format}} + +\newrobustcmd*{\DeprecateFieldFormatWithReplacement}{% + \blx@deprecateformat{ffd}{Field format}} +\newrobustcmd*{\DeprecateIndexFieldFormatWithReplacement}{% + \blx@deprecateformat{fid}{Index field format}} + +\newrobustcmd*{\DeprecateNameWrapperFormatWithReplacement}{% + \blx@deprecateformat{nwd}{Name wrapper format}} +\newrobustcmd*{\DeprecateIndexNameWrapperFormatWithReplacement}{% + \blx@deprecateformat{nxd}{Index name wrapper format}} + +\newrobustcmd*{\DeprecateListWrapperFormatWithReplacement}{% + \blx@deprecateformat{lwd}{List wrapper format}} +\newrobustcmd*{\DeprecateIndexListWrapperFormatWithReplacement}{% + \blx@deprecateformat{lxd}{Index list wrapper format}} + % [<format>]{<text>} \newrobustcmd{\blx@imc@printtext}[2][]{% \ifblank{#2} @@ -4032,13 +4267,16 @@ \def\blx@printnames#1#2#3#4{% \blx@imc@ifnameundef{#4} {\blx@nounit} - {\blx@getformat\blx@theformat{nfd}{#1}{#4}% - \ifdefvoid\blx@theformat + {\blx@getformat\blx@thewrapperformat{nwd}{#1}{#4}% + \ifdefvoid\blx@thewrapperformat {\blx@nounit} - {\blx@begunit - \blx@namesetup{#2}{#3}{#4}% - \expandafter\blx@nameparser\blx@thedata{}&% - \blx@endunit}}} + {\blx@getformat\blx@theformat{nfd}{#1}{#4}% + \ifdefvoid\blx@theformat + {\blx@nounit} + {\blx@begunit + \blx@namesetup{#2}{#3}{#4}% + \blx@thewrapperformat{\expandafter\blx@nameparser\blx@thedata{}&}% + \blx@endunit}}}} \def\blx@namesetup#1#2#3{% \def\currentname{#3}% @@ -4119,14 +4357,17 @@ \def\blx@indexnames#1#2#3#4{% \blx@imc@ifnameundef{#4} {} - {\blx@getformat\blx@theformat{nid}{#1}{#4}% - \ifdefvoid\blx@theformat + {\blx@getformat\blx@thewrapperformat{nxd}{#1}{#4}% + \ifdefvoid\blx@thewrapperformat {} - {\begingroup - \blx@namesetup{#2}{#3}{#4}% - \blx@indexnamesetup - \expandafter\blx@nameparser\blx@thedata{}&% - \endgroup}}} + {\blx@getformat\blx@theformat{nid}{#1}{#4}% + \ifdefvoid\blx@theformat + {} + {\begingroup + \blx@namesetup{#2}{#3}{#4}% + \blx@indexnamesetup + \expandafter\blx@nameparser\blx@thedata{}&% + \endgroup}}}} \def\blx@indexnamesetup{% \let\bibinitperiod\bibindexinitperiod @@ -4154,6 +4395,7 @@ % {name opts}{nameparts} \long\def\blx@nameparser@i#1#2{% + \begingroup \ifblank{#1} {} {\setkeys{blx@opt@name}{#1}}% @@ -4166,7 +4408,8 @@ % Still pass the nameparts forward for backwards compat % When \nameparts is finally removed, remove the "{2}" and remove the % arg to \blx@defformat@d in def of \blx@defnameformat - \blx@theformat{#2}} + \blx@theformat{#2}% + \endgroup} \long\def\blx@namebreak#1&{} @@ -4178,13 +4421,16 @@ \def\blx@printlist#1#2#3#4{% \blx@imc@iflistundef{#4} {\blx@nounit} - {\blx@getformat\blx@theformat{lfd}{#1}{#4}% - \ifdefvoid\blx@theformat + {\blx@getformat\blx@thewrapperformat{lwd}{#1}{#4}% + \ifdefvoid\blx@thewrapperformat {\blx@nounit} - {\blx@begunit - \blx@listsetup{#2}{#3}{#4}% - \expandafter\blx@listparser\blx@thedata{}&% - \blx@endunit}}} + {\blx@getformat\blx@theformat{lfd}{#1}{#4}% + \ifdefvoid\blx@theformat + {\blx@nounit} + {\blx@begunit + \blx@listsetup{#2}{#3}{#4}% + \blx@thewrapperformat{\expandafter\blx@listparser\blx@thedata{}&}% + \blx@endunit}}}} \def\blx@listsetup#1#2#3{% \def\currentlist{#3}% @@ -4221,13 +4467,16 @@ \def\blx@indexlist#1#2#3#4{% \blx@imc@iflistundef{#4} {} - {\blx@getformat\blx@theformat{lid}{#1}{#4}% - \ifdefvoid\blx@theformat + {\blx@getformat\blx@thewrapperformat{lxd}{#1}{#4}% + \ifdefvoid\blx@thewrapperformat {} - {\begingroup - \blx@listsetup{#2}{#3}{#4}% - \expandafter\blx@listparser\blx@thedata{}&% - \endgroup}}} + {\blx@getformat\blx@theformat{lid}{#1}{#4}% + \ifdefvoid\blx@theformat + {} + {\begingroup + \blx@listsetup{#2}{#3}{#4}% + \expandafter\blx@listparser\blx@thedata{}&% + \endgroup}}}} % {<item1>}{<item2>}{...} \long\def\blx@listparser#1{% @@ -4285,7 +4534,8 @@ \blx@getdata{#1}% \blx@setoptions@type\abx@field@entrytype \blx@setoptions@entry - \def\abx@field@entrysetcount{1}% + \global\blx@entrysetcounter\@ne + \edef\abx@field@entrysetcount{\the\blx@entrysetcounter}% \blx@execute \blx@beglangbib \blx@begunit @@ -4304,9 +4554,10 @@ {\begingroup \blx@resetdata \blx@getdata{#1}% - \blx@entrysetcount \blx@setoptions@type\abx@field@entrytype \blx@setoptions@entry + \global\advance\blx@entrysetcounter\@ne + \edef\abx@field@entrysetcount{\the\blx@entrysetcounter}% \addtocounter{instcount}\@ne \blx@execute \blx@beglangbib @@ -4820,6 +5071,7 @@ \do{langgalician}% \do{langgerman}% \do{langgreek}% + \do{langhungarian}% \do{langitalian}% \do{langjapanese}% \do{langlatin}% @@ -4848,6 +5100,7 @@ \do{fromgalician}% \do{fromgerman}% \do{fromgreek}% + \do{fromhungarian}% \do{fromitalian}% \do{fromjapanese}% \do{fromlatin}% @@ -5081,33 +5334,39 @@ % .lbx files must be read with one of the two following commands, % do not use \blx@inputonce. Only the commands here make sure that the file % is read as many times as necessary. +% blx@file@lbx@simple@#1 only blocks the file being added to the file list +% blx@file@lbx@once@#1 blocks a file from being loaded again by the input-once +% routine % {<file>}{<message>}{<preload>}{<postload>}{<success>}{<failure>} \protected\long\def\blx@lbx@input@handler@simple#1#2#3#4#5#6{% \blx@info@noline{Trying to load #2..}% \IfFileExists{#1} {\blx@info@noline{... file '#1' found}% #3\@@input\@filef@und#4#5% - \ifcsundef{blx@file@lbx@#1} + \ifcsundef{blx@file@lbx@simple@#1} {\listxadd\blx@list@req@stat{#1}% \@addtofilelist{#1}% - \global\cslet{blx@file@lbx@#1}\@empty} + \global\cslet{blx@file@lbx@simple@#1}\@empty} {}} {\blx@info@noline{... file '#1' not found}#6}} % {<file>}{<message>}{<preload>}{<postload>}{<success>}{<failure>} \protected\long\def\blx@lbx@input@handler@once#1#2#3#4#5#6{% - \ifcsundef{blx@file@lbx@#1} + \ifcsundef{blx@file@lbx@once@#1} {\blx@info@noline{Trying to load #2..}% - \global\cslet{blx@file@lbx@#1}\@empty \IfFileExists{#1} {\blx@info@noline{... file '#1' found}% #3\@@input\@filef@und#4#5% - \listxadd\blx@list@req@stat{#1}% - \@addtofilelist{#1}} - {\blx@info@noline{... file '#1' not found}#6}} + \ifcsundef{blx@file@lbx@simple@#1} + {\listxadd\blx@list@req@stat{#1}% + \@addtofilelist{#1}} + {}} + {\blx@info@noline{... file '#1' not found}#6}% + \global\cslet{blx@file@lbx@once@#1}\@empty + \global\cslet{blx@file@lbx@simple@#1}\@empty} {#5}} -\def\blx@lbx@input@process@strings#1{ +\def\blx@lbx@input@process@strings#1{% \global\cslet{abx@strings@#1}\@empty \def\InheritBibliographyStrings{% \blx@letbibstrings{#1}}% @@ -5129,7 +5388,7 @@ \blx@lbx@input@process@extras{#1}% \def\DeclareHyphenationExceptions{\blx@hyphexcept{#1}}} -\def\blx@lbx@input@postprocess@strings#1{ +\def\blx@lbx@input@postprocess@strings#1{% \csuse{blx@hook@strings@#1}} \def\blx@lbx@input@postprocess@extras#1{% @@ -5220,39 +5479,42 @@ \mktimerange{12h}} \expandafter\newrobustcmd\expandafter*\csname mktimerange24hcomp\endcsname[1]{% - \iffieldundef{#1hour}{} + \iffieldundef{#1hour} + {} {\ifboolexpr{test {\iffieldundef{#1endhour}} or test {\iffieldequalstr{#1endhour}{}}} {\mktimerange{24h}{#1}} {\iffieldsequal{#1hour}{#1endhour} - % 14:xx:xx 14:xx:xx - {\iffieldsequal{#1minute}{#1endminute} - % 14:13:xx 14:13:xx - {\toggletrue{blx@seconds}% - \printtext[#1time]{\csuse{mkbibtime24h}{#1hour}{#1minute}{#1second}{}% - \bibtimerangesep - \csuse{mkbibtime24h}{}{}{#1endsecond}{}}} - % 14:13:xx 14:14:xx - {\toggletrue{blx@seconds}% - \printtext[#1time]{\csuse{mkbibtime24h}{#1hour}{#1minute}{}{}% - \bibtimerangesep - \csuse{mkbibtime24h}{}{#1endminute}{}{}}}} - % 14:xx:xx 15:xx:xx - {\mktimerange{24h}{#1}}}}} + % 14:xx:xx 14:xx:xx + {\iffieldsequal{#1minute}{#1endminute} + % 14:13:xx 14:13:xx + {\toggletrue{blx@seconds}% + \printtext[#1time]{% + \csuse{mkbibtime24h}{#1hour}{#1minute}{#1second}{}% + \bibtimerangesep + \csuse{mkbibtime24h}{}{}{#1endsecond}{}}} + % 14:13:xx 14:14:xx + {\toggletrue{blx@seconds}% + \printtext[#1time]{\csuse{mkbibtime24h}{#1hour}{#1minute}{}{}% + \bibtimerangesep + \csuse{mkbibtime24h}{}{#1endminute}{}{}}}} + % 14:xx:xx 15:xx:xx + {\mktimerange{24h}{#1}}}}} % {<24h|24hcomp|12h>}{<datetype>} \newrobustcmd*{\mktimerange}[2]{% - \iffieldundef{#2hour}{} + \iffieldundef{#2hour} + {\blx@nounit} {\blx@timepre{#2}{}% \printtext[#2time]{\csuse{mkbibtime#1}{#2hour}{#2minute}{#2second}{#2timezone}% - \iffieldundef{#2endhour} - {} - {\blx@timepre{#2}{end}% - \iffieldequalstr{#2endhour}{} - {\mbox{\bibtimerangesep}} - {\bibtimerangesep - \csuse{mkbibtime#1}{#2endhour}{#2endminute}{#2endsecond}{#2endtimezone}}}}}} + \iffieldundef{#2endhour} + {} + {\blx@timepre{#2}{end}% + \iffieldequalstr{#2endhour}{} + {\mbox{\bibtimerangesep}} + {\bibtimerangesep + \csuse{mkbibtime#1}{#2endhour}{#2endminute}{#2endsecond}{#2endtimezone}}}}}} % {<datetype>}{''|end} \newrobustcmd*{\blx@timepre}[2]{% @@ -5266,7 +5528,7 @@ \begingroup \blx@metadateinfo{#2}% \iffieldundef{#2year} - {} + {\blx@nounit} {\printtext[#2date]{% \datecircaprint % Such a season component can only come from an ISO8601 season which replaces @@ -5297,20 +5559,20 @@ \begingroup \blx@metadateinfo{#2}% \iffieldundef{#2year} - {} + {\blx@nounit} {\printtext[#2date]{% \datecircaprint % Such a season component can only come from an ISO8601 season which replaces % a normal month so if it exists, we know that a normal date print is ruled out \iffieldundef{#2season} - {\iffieldsequal{#2year}{#2endyear} + {\ifdateyearsequal{#2}{#2end} {\iffieldsequal{#2month}{#2endmonth} {\csuse{mkbibdate#1}{}{}{#2day}} {\csuse{mkbibdate#1}{}{#2month}{#2day}}} {\csuse{mkbibdate#1}{#2year}{#2month}{#2day}% \iffieldsequal{#2dateera}{#2enddateera}{} - {\dateeraprint{#2year}}}} - {\iffieldsequal{#2year}{#2endyear} + {\dateeraprint{#2year}}}} + {\ifdateyearsequal{#2}{#2end} {\csuse{mkbibseasondate#1}{}{#2season}} {\csuse{mkbibseasondate#1}{#2year}{#2season}% \iffieldsequal{#2dateera}{#2enddateera}{} @@ -5333,7 +5595,7 @@ \begingroup \blx@metadateinfo{#2}% \iffieldundef{#2year} - {} + {\blx@nounit} {\printtext[#2date]{% \datecircaprint % Such a season component can only come from an ISO8601 season which replaces @@ -5367,23 +5629,23 @@ \begingroup \blx@metadateinfo{#2}% \iffieldundef{#2year} - {} + {\blx@nounit} {\printtext[#2date]{% \datecircaprint % Such a season component can only come from an ISO8601 season which replaces % a normal month so if it exists, we know that a normal date print is ruled out \iffieldundef{#2season} - {\iffieldsequal{#2year}{#2endyear} + {\ifdateyearsequal{#2}{#2end} {\iffieldsequal{#2month}{#2endmonth} {\csuse{mkbibdate#1}{}{}{#2day}} {\csuse{mkbibdate#1}{}{#2month}{#2day}}} {\csuse{mkbibdate#1}{#2year}{#2month}{#2day}% \iffieldsequal{#2dateera}{#2enddateera}{} {\dateeraprint{#2year}}}} - {\iffieldsequal{#2year}{#2endyear} + {\ifdateyearsequal{#2}{#2end} {\csuse{mkbibseasondate#1}{}{#2season}} {\csuse{mkbibseasondate#1}{#2year}{#2season}% - \iffieldsequal{#2dateera}{#2enddateera}{} + \iffieldsequal{#2dateera}{#2enddateera}{} {\dateeraprint{#2year}}}}% \dateuncertainprint \iffieldundef{#2endyear} @@ -5417,7 +5679,7 @@ \blx@imc@clearfield{#1endminute}% \blx@imc@clearfield{#1endsecond}% \blx@imc@clearfield{#1endtimezone}% - \iffieldsequal{#1year}{#1endyear} + \ifdateyearsequal{#1}{#1end} {\blx@imc@clearfield{#1endyear}} {}% \mkdaterangefull{short}{#1}} @@ -5427,7 +5689,7 @@ \begingroup \blx@metadateinfo{#1}% \iffieldundef{#1year} - {} + {\blx@nounit} {\printtext[#1date]{% \datecircaprint % Such a season component can only come from an ISO8601 season which replaces @@ -5459,7 +5721,7 @@ \begingroup \blx@metadateinfo{#1}% \iffieldundef{#1year} - {} + {\blx@nounit} {\printtext[#1date]{% \datecircaprint % Such a season component can only come from an ISO8601 season which replaces @@ -5509,7 +5771,7 @@ \blx@imc@clearfield{#1endminute}% \blx@imc@clearfield{#1endsecond}% \blx@imc@clearfield{#1endtimezone}% - \iffieldsequal{#1year}{#1endyear} + \ifdateyearsequal{#1}{#1end} {\blx@imc@clearfield{#1endyear}} {}% \mkdaterangefullextra{short}{#1}} @@ -5521,8 +5783,8 @@ and not test {\iffieldundef{#1#2hour}}} {\blx@timepre{#1}{#2}% - \printtext{\bibdatetimesep}% - \printtext[#1time]{\csuse{mkbibtime\csuse{blx@timeformat@#1time}}{#1#2hour}{#1#2minute}{#1#2second}{#1#2timezone}}} + \printtext{\bibdatetimesep}% + \printtext[#1time]{\csuse{mkbibtime\csuse{blx@timeformat@#1time}}{#1#2hour}{#1#2minute}{#1#2second}{#1#2timezone}}} {}} \newrobustcmd*{\mkdaterangeiso}[1]{% @@ -5530,7 +5792,7 @@ \blx@metadateinfo{#1}% \def\bibdatetimesep{T}% \iffieldundef{#1year} - {} + {\blx@nounit} {\printtext[#1date]{% \blx@isodate{#1}{}% \ifboolexpr{% @@ -5562,7 +5824,7 @@ \blx@metadateinfo{#1}% \def\bibdatetimesep{T}% \iffieldundef{#1year} - {} + {\blx@nounit} {\printtext[#1date]{% \blx@isodate[extradate]{#1}{}% \ifboolexpr{% @@ -5601,10 +5863,10 @@ {\hyphen\blx@seasonmap{\thefield{#2#3season}}}} \def\blx@seasonmap#1{% - \blx@xifstrcmp{#1}{spring}{21} - {\blx@xifstrcmp{#1}{summer}{22} - {\blx@xifstrcmp{#1}{autumn}{23} - {\blx@xifstrcmp{#1}{winter}{24}{}}}}} + \blx@xifstrequal{#1}{spring}{21} + {\blx@xifstrequal{#1}{summer}{22} + {\blx@xifstrequal{#1}{autumn}{23} + {\blx@xifstrequal{#1}{winter}{24}{}}}}} \newrobustcmd*{\blx@isotime}[2]{% \blx@imc@forcezerosmdt{\thefield{#1#2hour}}% @@ -5614,6 +5876,11 @@ {\mkbibtimezone{\thefield{#1#2timezone}}} {}} +% some sane defaults for bibliography extras +% many of these should be redefined in the .lbx files +% all .lbx files should have date and time handling, so the fallback values +% issue a warning to make people aware of the deficiency in their file +% \mkbibordinal should also only be used if it is defined, so it warns as well % times \newrobustcmd*{\bibtimesep}{:} \newrobustcmd*{\bibtimerangesep}{\textendash} @@ -5633,19 +5900,132 @@ \newrobustcmd*{\bibrangedash}{\textendash} \newrobustcmd*{\bibrangessep}{,\space} % formatters -\newrobustcmd*{\mkbibtimezone}[1]{\blx@xifstrcmp{#1}{UTC}{\bibutctimezone}{#1}} -\newrobustcmd*{\mkbibdatelong}[3]{} -\newrobustcmd*{\mkbibdateshort}[3]{} -\newrobustcmd*{\mkbibseasondateshort}[2]{} -\newrobustcmd*{\mkbibseasondatelong}[2]{} -\expandafter\newrobustcmd\expandafter*\csname mkbibtime24h\endcsname[4]{} -\expandafter\newrobustcmd\expandafter*\csname mkbibtime12h\endcsname[4]{} +\newrobustcmd*{\mkbibtimezone}[1]{\blx@xifstrequal{#1}{Z}{\bibutctimezone}{#1}} +% you should never end up needing the next few definitions +% but it is safer to do something than just swallow the input +\newrobustcmd*{\mkbibdatelong}[3]{% + \blx@warning@noline{% + Using fallback definition for \string\mkbibdatelong.\MessageBreak + The command should be defined in the .lbx file.\MessageBreak + If you see this message, the .lbx file could not be\MessageBreak + loaded, is faulty or does not contain a definition\MessageBreak + for \string\mkbibdatelong + }% + \iffieldundef{#3} + {} + {\mkbibordinal{\thefield{#3}}% + \iffieldundef{#2}{}{\nobreakspace}}% + \iffieldundef{#2} + {} + {\mkbibmonth{\thefield{#2}}% + \iffieldundef{#1}{}{\space}}% + \iffieldbibstring{#1} + {\bibstring{\thefield{#1}}} + {\dateeraprintpre{#1}\stripzeros{\thefield{#1}}}} + +\newrobustcmd*{\mkbibdateshort}[3]{% + \blx@warning@noline{% + Using fallback definition for \string\mkbibdateshort.\MessageBreak + The command should be defined in the .lbx file.\MessageBreak + If you see this message, the .lbx file could not be\MessageBreak + loaded, is faulty or does not contain a definition\MessageBreak + for \string\mkbibdateshort + }% + \iffieldundef{#3} + {} + {\mkdayzeros{\thefield{#3}}% + \iffieldundef{#2}{}{/}}% + \iffieldundef{#2} + {} + {\mkmonthzeros{\thefield{#2}}% + \iffieldundef{#1}{}{/}}% + \iffieldbibstring{#1} + {\bibstring{\thefield{#1}}} + {\dateeraprintpre{#1}\mkyearzeros{\thefield{#1}}}} + +\expandafter\newrobustcmd\expandafter*\csname mkbibtime24h\endcsname[4]{% + \blx@warning@noline{% + Using fallback definition for + \expandafter\string\csname mkbibtime24h\endcsname.\MessageBreak + The command should be defined in the .lbx file.\MessageBreak + If you see this message, the .lbx file could not be\MessageBreak + loaded, is faulty or does not contain a definition\MessageBreak + for \expandafter\string\csname mkbibtime24h\endcsname + }% + \iffieldundef{#1}{} + {\printtext{\mktimezeros{\thefield{#1}}}\setunit{\bibtimesep}}% + \iffieldundef{#2}{} + {\printtext{\mktimezeros{\thefield{#2}}}\setunit{\bibtimesep}}% + \iffieldundef{#3}{} + {\printtext{\mktimezeros{\thefield{#3}}}}% + \setunit{}% + \iffieldundef{#4}{} + {\bibtimezonesep + \mkbibtimezone{\thefield{#4}}}} + +\expandafter\newrobustcmd\expandafter*\csname mkbibtime12h\endcsname[4]{% + \blx@warning@noline{% + Using fallback definition for + \expandafter\string\csname mkbibtime12h\endcsname.\MessageBreak + The command should be defined in the .lbx file.\MessageBreak + If you see this message, the .lbx file could not be\MessageBreak + loaded, is faulty or does not contain a definition\MessageBreak + for \expandafter\string\csname mkbibtime12h\endcsname + }% + \stripzeros{\mktimehh{\thefield{#1}}}% + \bibtimesep + \forcezerosmdt{\thefield{#2}}% + \iffieldundef{#3}{} + {\bibtimesep + \forcezeros{\thefield{#3}}}% + \space + \ifnumless{\thefield{#1}}{12} + {\bibstring{am}} + {\bibstring{pm}}% + \iffieldundef{#4}{} + {\space\bibtimezonesep + \parentext{\mkbibtimezone{\thefield{#4}}}}} + +\newrobustcmd*{\mkbibseasondateshort}[2]{% + \blx@warning@noline{% + Using fallback definition for \string\mkbibseasondateshort.\MessageBreak + The command should be defined in the .lbx file.\MessageBreak + If you see this message, the .lbx file could not be\MessageBreak + loaded, is faulty or does not contain a definition\MessageBreak + for \string\mkbibseasondateshort + }% + \mkbibseason{\thefield{#2}}% + \iffieldundef{#1}{}{\space}% + \dateeraprintpre{#1}\mkyearzeros{\thefield{#1}}} + +\newrobustcmd*{\mkbibseasondatelong}[2]{% + \blx@warning@noline{% + Using fallback definition for \string\mkbibseasondatelong.\MessageBreak + The command should be defined in the .lbx file.\MessageBreak + If you see this message, the .lbx file could not be\MessageBreak + loaded, is faulty or does not contain a definition\MessageBreak + for \string\mkbibseasondatelong + }% + \mkbibseason{\thefield{#2}}% + \iffieldundef{#1}{}{\space}% + \dateeraprintpre{#1}\mkyearzeros{\thefield{#1}}} + \newrobustcmd*{\finalandcomma}{} \newrobustcmd*{\finalandsemicolon}{} -\newrobustcmd*{\mkbibordinal}[1]{#1} +\newrobustcmd*{\mkbibordinal}[1]{% + \blx@warning@noline{% + Using fallback definition for \string\mkbibordinal.\MessageBreak + The command should be defined in the .lbx file.\MessageBreak + If you see this message, the .lbx file could not be\MessageBreak + loaded, is faulty or does not contain a definition\MessageBreak + for \string\mkbibordinal + }% + #1% +} \newrobustcmd*{\mkbibmascord}{\mkbibordinal} \newrobustcmd*{\mkbibfemord}{\mkbibordinal} \newrobustcmd*{\mkbibneutord}{\mkbibordinal} +% the following is usually not redefined in an .lbx \newrobustcmd*{\mkbibseason}[1]{\abx@bibseason{#1}} \newrobustcmd*{\mkbibmonth}[1]{% \ifcase0#1\relax @@ -5669,24 +6049,36 @@ % strip leading zeros and prepend zero for month/day/timeparts % Allow for non numeric labelyear values \protected\def\blx@imc@forcezerosmdt#1{% - \IfInteger{#1} - {\ifnumless{#1}{10} - {0\the\numexpr(#1)\relax} - {#1}} + \protected@edef\blx@tempa{#1}% + \expandafter\blx@imc@forcezerosmdt@i\expandafter{\blx@tempa}} + +\protected\def\blx@imc@forcezerosmdt@i#1{% + \notblank{#1} + {\blx@imc@ifinteger{#1} + {\ifnumless{#1}{10} + {0\the\numexpr(#1)\relax} + {#1}} + {#1}} {#1}} % strip leading zeros and prepend zero(s) for year % Allow for non numeric labelyear values \protected\def\blx@imc@forcezerosy#1{% - \IfInteger{#1} - {\ifnumless{#1}{10}% 1-digit year - {000\the\numexpr(#1)\relax} - {\ifnumless{#1}{100}% 2-digit year - {00\the\numexpr(#1)\relax} - {\ifnumless{#1}{1000}% 3-digit year - {0\the\numexpr(#1)\relax} - {#1}}}} - {#1}} + \protected@edef\blx@tempa{#1}% + \expandafter\blx@imc@forcezerosy@i\expandafter{\blx@tempa}} + +\protected\def\blx@imc@forcezerosy@i#1{% + \notblank{#1} + {\blx@imc@ifinteger{#1} + {\ifnumless{#1}{10}% 1-digit year + {000\the\numexpr(#1)\relax} + {\ifnumless{#1}{100}% 2-digit year + {00\the\numexpr(#1)\relax} + {\ifnumless{#1}{1000}% 3-digit year + {0\the\numexpr(#1)\relax} + {#1}}}} + {#1}} + {#1}}% \let\blx@imc@mkyearzeros\blx@imc@forcezerosy \let\blx@imc@mkmonthzeros\blx@imc@forcezerosmdt @@ -5711,7 +6103,9 @@ \let\blx@imc@printlabeltime\@empty \let\blx@imc@printlabeldateextra\@empty -\blx@regimcs{\printlabeldate \printlabeltime \printlabeldateextra \stripzeros \forcezerosy \forcezerosmdt \mkyearzeros \mkmonthzeros \mkdayzeros \mktimezeros} +\blx@regimcs{\printlabeldate \printlabeltime \printlabeldateextra + \stripzeros \forcezerosy \forcezerosmdt + \mkyearzeros \mkmonthzeros \mkdayzeros \mktimezeros} % User macro for retrieving currrent language \def\currentlang{\blx@languagename} @@ -6010,7 +6404,7 @@ % '', event, url, orig etc. \def\do#1{% - \StrCut{#1}{date}\blx@datetype\blx@tempnull + \blx@stripfromendinto{#1}{date}\blx@datetype \listxadd\blx@datetypes{\blx@datetype}} \abx@dodates % main date field has an empty prefix (''date) which can't be added to a list @@ -6058,7 +6452,7 @@ % to biblatex. For options which only biber needs to see, they can be % passed to the .bcf directly using \blx@collectopts % [<datatype>]{<key>}[<value>]{<code>} -\newrobustcmd*{\DeclareBibliographyOption}[2][]{ +\newrobustcmd*{\DeclareBibliographyOption}[2][]{% \ifblank{#1} {\def\blx@tempa{boolean}} {\ifcsundef{blx@globalopts@#1} @@ -6121,7 +6515,7 @@ % Sanity check on date field names - they *must* end in 'date' to make things easier/possible later \def\do#1{% - \IfEndWith{#1}{date} + \blx@ifstrendswith{#1}{date} {} {\blx@error {Invalid date field name '#1'} @@ -6207,6 +6601,7 @@ \do{entrysetcount}% \do{entrytype}% \do{extraalpha}% + \do{extraname}% \do{extratitle}% \do{extratitleyear}% \do{extradate}% @@ -6233,6 +6628,7 @@ \do{uniquebaretitle}% \do{uniquework}% \do{uniqueprimaryauthor}% + \do{nocite}% \dolistloop\blx@datemetabooleans} % Date datatype fields @@ -6298,10 +6694,10 @@ \iffieldnum{#1} {\begingroup \let\blx@tempa\@empty - \IfEndWith{#1}{endyear} - {\StrCut{#1}{endyear}\blx@datetype\blx@tempnull + \blx@ifstrendswith{#1}{endyear} + {\blx@stripfromendinto{#1}{endyear}\blx@datetype \def\blx@tempa{end}} - {\StrCut{#1}{year}\blx@datetype\blx@tempnull}% + {\blx@stripfromendinto{#1}{year}\blx@datetype}% \csuse{if\blx@datetype\blx@tempa dateera}{bce} {\ifnumless{0-\thefield{#1}}{0} {\printtext{\csuse{bibdateera\blx@tempa prefix}}} @@ -6313,10 +6709,10 @@ \iffieldnum{#1} {\begingroup \let\blx@tempa\@empty - \IfEndWith{#1}{endyear} - {\StrCut{#1}{endyear}\blx@datetype\blx@tempnull + \blx@ifstrendswith{#1}{endyear} + {\blx@stripfromendinto{#1}{endyear}\blx@datetype \def\blx@tempa{end}} - {\StrCut{#1}{year}\blx@datetype\blx@tempnull}% + {\blx@stripfromendinto{#1}{year}\blx@datetype}% \csuse{if\blx@datetype\blx@tempa dateera}{bce} {\ifnum\numexpr0-\thefield{#1}\relax<\blx@dateeraauto % \midsentence is to suppress automatic capitalisation @@ -6722,59 +7118,188 @@ \catcode\endlinechar=12\relax \blx@bbl@verbadd@i} -% {<scope>}{<field>}{<itemcount>}{<part>}{<value>} -\protected\def\blx@bbl@annotationdef#1#2#3#4#5{% +% {<scope>}{<field>}{<name>}{<itemcount>}{<part>}{<isliteral>}{<value>} +\protected\def\blx@bbl@annotationdef#1#2#3#4#5#6#7{% \ifstrequal{#1}{field} {\csxappto\blx@bbl@data{% - \listadd\noexpand\abx@annotation@defined{#1@#2}% - \def\do####1{\listcsadd{abx@annotation@#1@#2}{####1}}% - \docsvlist{#5}}} + \listadd\noexpand\abx@annotation@defined{field@#2@#3}}% + \ifstrequal{#6}{1} + {\csgappto\blx@bbl@data{% + \csdef{abx@annotation@literal@field@#2@#3}{#7}}} + {\csxappto\blx@bbl@data{% + \def\do####1{\listcsadd{abx@annotation@field@#2@#3}{####1}}% + \docsvlist{#7}}}} {}% \ifstrequal{#1}{item} {\csxappto\blx@bbl@data{% - \listadd\noexpand\abx@annotation@defined{#1@#2@#3}% - \def\do####1{\listcsadd{abx@annotation@#1@#2@#3}{####1}}% - \docsvlist{#5}}} + \listadd\noexpand\abx@annotation@defined{item@#2@#3@#4}}% + \ifstrequal{#6}{1} + {\csgappto\blx@bbl@data{% + \csdef{abx@annotation@literal@item@#2@#3@#4}{#7}}} + {\csxappto\blx@bbl@data{% + \def\do####1{\listcsadd{abx@annotation@item@#2@#3@#4}{####1}}% + \docsvlist{#7}}}} {}% \ifstrequal{#1}{part} {\csxappto\blx@bbl@data{% - \listadd\noexpand\abx@annotation@defined{#1@#2@#3@#4}% - \def\do####1{\listcsadd{abx@annotation@#1@#2@#3@#4}{####1}}% - \docsvlist{#5}}} + \listadd\noexpand\abx@annotation@defined{part@#2@#3@#4@#5}}% + \ifstrequal{#6}{1} + {\csgappto\blx@bbl@data{% + \csdef{abx@annotation@literal@part@#2@#3@#4@#5}{#7}}} + {\csxappto\blx@bbl@data{% + \def\do####1{\listcsadd{abx@annotation@part@#2@#3@#4@#5}{####1}}% + \docsvlist{#7}}}} {}} -% [<field>]{<annotation>} -\newcommand*{\blx@imc@iffieldannotation}[2][]{% - \ifblank{#1} - {\ifdefvoid\currentfield{}{\let\blx@tempa\currentfield}% - \ifdefvoid\currentlist{}{\let\blx@tempa\currentlist}% - \ifdefvoid\currentname{}{\let\blx@tempa\currentname}} - {\def\blx@tempa{#1}}% - \blx@resolve@annotation@label{\blx@tempa}% - \ifinlistcs{#2}{abx@annotation@field@\blx@tempa}} +% [<field>][<annotationname>] +\def\blx@imc@getfieldannotation{% + \let\blx@tempa\@empty + \ifdefvoid\currentfield{}{\let\blx@tempa\currentfield}% + \ifdefvoid\currentlist{}{\let\blx@tempa\currentlist}% + \ifdefvoid\currentname{}{\let\blx@tempa\currentname}% + \@ifnextchar[%] + {\blx@imc@getfieldannotation@i} + {\blx@imc@getfieldannotation@i[\blx@tempa]}} -% [<field>][<item>]{<annotation>} -\def\blx@imc@ifitemannotation{% +\def\blx@imc@getfieldannotation@i[#1]{% + \ifstrempty{#1} + {\blx@imc@getfieldannotation@i[\blx@tempa]} + {\@ifnextchar[%] + {\blx@imc@getfieldannotation@ii{#1}} + {\blx@imc@getfieldannotation@ii{#1}[default]}}} + +\def\blx@imc@getfieldannotation@ii#1[#2]{% + \def\blx@tempb{#1}% + \blx@resolve@annotation@label{\blx@tempb}% + \ifcsdef{abx@annotation@literal@field@\blx@tempb @#2} + {\csuse{abx@annotation@literal@field@\blx@tempb @#2}} + {}} + +% [<field>][<annotationname>][<item>] +\def\blx@imc@getitemannotation{% + \let\blx@tempa\@empty \ifdefvoid\currentfield{}{\let\blx@tempa\currentfield}% \ifdefvoid\currentlist{}{\let\blx@tempa\currentlist}% \ifdefvoid\currentname{}{\let\blx@tempa\currentname}% \@ifnextchar[%] + {\blx@imc@getitemannotation@i} + {\blx@imc@getitemannotation@i[\blx@tempa]}} + +\def\blx@imc@getitemannotation@i[#1]{% + \ifstrempty{#1} + {\blx@imc@getitemannotation@i[\blx@tempa]} + {\@ifnextchar[%] + {\blx@imc@getitemannotation@ii{#1}} + {\blx@imc@getitemannotation@ii{#1}[default]}}} + +\def\blx@imc@getitemannotation@ii#1[#2]{% + \ifstrempty{#2} + {\def\blx@tempb{default}} + {\def\blx@tempb{#2}}% + \@ifnextchar[%] + {\blx@imc@getitemannotation@iii{#1}{\blx@tempb}} + {\blx@imc@getitemannotation@iii{#1}{\blx@tempb}[\the\value{listcount}]}} + +\def\blx@imc@getitemannotation@iii#1#2[#3]{% + \def\blx@tempc{#1}% + \blx@resolve@annotation@label{\blx@tempc}% + \ifcsdef{abx@annotation@literal@item@\blx@tempc @#2@#3} + {\csuse{abx@annotation@literal@item@\blx@tempc @#2@#3}} + {}} + +% [<field>][<annotationname>][<item>]{<part>} +\def\blx@imc@getpartannotation{% + \let\blx@tempa\@empty + \ifdefvoid\currentfield{}{\let\blx@tempa\currentfield}% + \ifdefvoid\currentlist{}{\let\blx@tempa\currentlist}% + \ifdefvoid\currentname{}{\let\blx@tempa\currentname}% + \@ifnextchar[%] + {\blx@imc@getpartannotation@i} + {\blx@imc@getpartannotation@i[\blx@tempa]}} + +\def\blx@imc@getpartannotation@i[#1]{% + \ifstrempty{#1} + {\blx@imc@getpartannotation@i[\blx@tempa]} + {\@ifnextchar[%] + {\blx@imc@getpartannotation@ii{#1}} + {\blx@imc@getpartannotation@ii{#1}[default]}}} + +\def\blx@imc@getpartannotation@ii#1[#2]{% + \ifstrempty{#2} + {\def\blx@tempb{default}} + {\def\blx@tempb{#2}}% + \@ifnextchar[%] + {\blx@imc@getpartannotation@iii{#1}{\blx@tempb}} + {\blx@imc@getpartannotation@iii{#1}{\blx@tempb}[\the\value{listcount}]}} + +\def\blx@imc@getpartannotation@iii#1#2[#3]#4{% + \ifstrempty{#3} + {\def\blx@tempc{\the\value{listcount}}} + {\def\blx@tempc{#3}}% + \def\blx@tempd{#1}% + \blx@resolve@annotation@label{\blx@tempd}% + \ifcsdef{abx@annotation@literal@part@\blx@tempd @#2@\blx@tempc @#4} + {\csuse{abx@annotation@literal@part@\blx@tempd @#2@\blx@tempc @#4}} + {}} + +% [<field>][<annotationname>]{<annotation>} +\def\blx@imc@iffieldannotation{% + \let\blx@tempa\@empty + \ifdefvoid\currentfield{}{\let\blx@tempa\currentfield}% + \ifdefvoid\currentlist{}{\let\blx@tempa\currentlist}% + \ifdefvoid\currentname{}{\let\blx@tempa\currentname}% + \@ifnextchar[%] + {\blx@imc@iffieldannotation@i} + {\blx@imc@iffieldannotation@i[\blx@tempa]}} + +\def\blx@imc@iffieldannotation@i[#1]{% + \ifstrempty{#1} + {\blx@imc@iffieldannotation@i[\blx@tempa]} + {\@ifnextchar[%] + {\blx@imc@iffieldannotation@ii{#1}} + {\blx@imc@iffieldannotation@ii{#1}[default]}}} + +\def\blx@imc@iffieldannotation@ii#1[#2]#3{% + \ifstrempty{#2} + {\def\blx@tempb{default}} + {\def\blx@tempb{#2}}% + \def\blx@tempc{#1}% + \blx@resolve@annotation@label{\blx@tempc}% + \ifinlistcs{#3}{abx@annotation@field@\blx@tempc @\blx@tempb}} + +% [<field>][<annotationname>][<item>]{<annotation>} +\def\blx@imc@ifitemannotation{% + \let\blx@tempa\@empty + \ifdefvoid\currentfield{}{\let\blx@tempa\currentfield}% + \ifdefvoid\currentlist{}{\let\blx@tempa\currentlist}% + \ifdefvoid\currentname{}{\let\blx@tempa\currentname}% + \@ifnextchar[%] {\blx@imc@ifitemannotation@i} - {\blx@imc@ifitemannotation@i[\blx@tempa]} -} + {\blx@imc@ifitemannotation@i[\blx@tempa]}} \def\blx@imc@ifitemannotation@i[#1]{% + \ifstrempty{#1} + {\blx@imc@ifitemannotation@i[\blx@tempa]} + {\@ifnextchar[%] + {\blx@imc@ifitemannotation@ii{#1}} + {\blx@imc@ifitemannotation@ii{#1}[default]}}} + +\def\blx@imc@ifitemannotation@ii#1[#2]{% + \ifstrempty{#2} + {\def\blx@tempb{default}} + {\def\blx@tempb{#2}}% \@ifnextchar[%] - {\blx@imc@ifitemannotation@ii{#1}} - {\blx@imc@ifitemannotation@ii{#1}[\the\value{listcount}]}} + {\blx@imc@ifitemannotation@iii{#1}{\blx@tempb}} + {\blx@imc@ifitemannotation@iii{#1}{\blx@tempb}[\the\value{listcount}]}} -\def\blx@imc@ifitemannotation@ii#1[#2]#3{% - \def\blx@tempb{#1}% - \blx@resolve@annotation@label{\blx@tempb}% - \ifinlistcs{#3}{abx@annotation@item@\blx@tempb @#2}} +\def\blx@imc@ifitemannotation@iii#1#2[#3]#4{% + \def\blx@tempc{#1}% + \blx@resolve@annotation@label{\blx@tempc}% + \ifinlistcs{#4}{abx@annotation@item@\blx@tempc @#2@#3}} -% [<field>][<item>]{<part>}{<annotation>} +% [<field>][<annotationname>][<item>]{<part>}{<annotation>} \def\blx@imc@ifpartannotation{% + \let\blx@tempa\@empty \ifdefvoid\currentfield{}{\let\blx@tempa\currentfield}% \ifdefvoid\currentlist{}{\let\blx@tempa\currentlist}% \ifdefvoid\currentname{}{\let\blx@tempa\currentname}% @@ -6783,30 +7308,164 @@ {\blx@imc@ifpartannotation@i[\blx@tempa]}} \def\blx@imc@ifpartannotation@i[#1]{% + \ifstrempty{#1} + {\blx@imc@ifpartannotation@i[\blx@tempa]} + {\@ifnextchar[%] + {\blx@imc@ifpartannotation@ii{#1}} + {\blx@imc@ifpartannotation@ii{#1}[default]}}} + +\def\blx@imc@ifpartannotation@ii#1[#2]{% + \ifstrempty{#2} + {\def\blx@tempb{default}} + {\def\blx@tempb{#2}}% \@ifnextchar[%] - {\blx@imc@ifpartannotation@ii{#1}} - {\blx@imc@ifpartannotation@ii{#1}[\the\value{listcount}]}} + {\blx@imc@ifpartannotation@iii{#1}{\blx@tempb}} + {\blx@imc@ifpartannotation@iii{#1}{\blx@tempb}[\the\value{listcount}]}} -\def\blx@imc@ifpartannotation@ii#1[#2]#3#4{% - \def\blx@tempb{#1}% - \blx@resolve@annotation@label{\blx@tempb}% - \ifinlistcs{#4}{abx@annotation@part@\blx@tempb @#2@#3}} +\def\blx@imc@ifpartannotation@iii#1#2[#3]#4#5{% + \ifstrempty{#3} + {\def\blx@tempc{\the\value{listcount}}} + {\def\blx@tempc{#3}}% + \def\blx@tempd{#1}% + \blx@resolve@annotation@label{\blx@tempd}% + \ifinlistcs{#5}{abx@annotation@part@\blx@tempd @#2@\blx@tempc @#4}} + +% [<field>][<annotationname>] +\def\blx@imc@hasfieldannotation{% + \let\blx@tempa\@empty + \ifdefvoid\currentfield{}{\let\blx@tempa\currentfield}% + \ifdefvoid\currentlist{}{\let\blx@tempa\currentlist}% + \ifdefvoid\currentname{}{\let\blx@tempa\currentname}% + \@ifnextchar[%] + {\blx@imc@hasfieldannotation@i} + {\blx@imc@hasfieldannotation@i[\blx@tempa]}} + +\def\blx@imc@hasfieldannotation@i[#1]{% + \ifstrempty{#1} + {\blx@imc@hasfieldannotation@i[\blx@tempa]} + {\@ifnextchar[%] + {\blx@imc@hasfieldannotation@ii{#1}} + {\blx@imc@hasfieldannotation@ii{#1}[default]}}} + +\def\blx@imc@hasfieldannotation@ii#1[#2]{% + \ifstrempty{#2} + {\def\blx@tempb{default}} + {\def\blx@tempb{#2}}% + \def\blx@tempc{#1}% + \blx@resolve@annotation@label{\blx@tempc}% + \ifcsdef{abx@annotation@literal@field@\blx@tempc @\blx@tempb}} + +% [<field>][<annotationname>][<item>] +\def\blx@imc@hasitemannotation{% + \let\blx@tempa\@empty + \ifdefvoid\currentfield{}{\let\blx@tempa\currentfield}% + \ifdefvoid\currentlist{}{\let\blx@tempa\currentlist}% + \ifdefvoid\currentname{}{\let\blx@tempa\currentname}% + \@ifnextchar[%] + {\blx@imc@hasitemannotation@i} + {\blx@imc@hasitemannotation@i[\blx@tempa]}} + +\def\blx@imc@hasitemannotation@i[#1]{% + \ifstrempty{#1} + {\blx@imc@hasitemannotation@i[\blx@tempa]} + {\@ifnextchar[%] + {\blx@imc@hasitemannotation@ii{#1}} + {\blx@imc@hasitemannotation@ii{#1}[default]}}} + +\def\blx@imc@hasitemannotation@ii#1[#2]{% + \ifstrempty{#2} + {\def\blx@tempb{default}} + {\def\blx@tempb{#2}}% + \@ifnextchar[%] + {\blx@imc@hasitemannotation@iii{#1}{\blx@tempb}} + {\blx@imc@hasitemannotation@iii{#1}{\blx@tempb}[\the\value{listcount}]}} + +\def\blx@imc@hasitemannotation@iii#1#2[#3]{% + \def\blx@tempc{#1}% + \blx@resolve@annotation@label{\blx@tempc}% + \ifcsdef{abx@annotation@literal@item@\blx@tempc @#2@#3}} + +% [<field>][<annotationname>][<item>]{<part>} +\def\blx@imc@haspartannotation{% + \let\blx@tempa\@empty + \ifdefvoid\currentfield{}{\let\blx@tempa\currentfield}% + \ifdefvoid\currentlist{}{\let\blx@tempa\currentlist}% + \ifdefvoid\currentname{}{\let\blx@tempa\currentname}% + \@ifnextchar[%] + {\blx@imc@haspartannotation@i} + {\blx@imc@haspartannotation@i[\blx@tempa]}} + +\def\blx@imc@haspartannotation@i[#1]{% + \ifstrempty{#1} + {\blx@imc@haspartannotation@i[\blx@tempa]} + {\@ifnextchar[%] + {\blx@imc@haspartannotation@ii{#1}} + {\blx@imc@haspartannotation@ii{#1}[default]}}} + +\def\blx@imc@haspartannotation@ii#1[#2]{% + \ifstrempty{#2} + {\def\blx@tempb{default}} + {\def\blx@tempb{#2}}% + \@ifnextchar[%] + {\blx@imc@haspartannotation@iii{#1}{\blx@tempb}} + {\blx@imc@haspartannotation@iii{#1}{\blx@tempb}[\the\value{listcount}]}} + +\def\blx@imc@haspartannotation@iii#1#2[#3]#4{% + \ifstrempty{#3} + {\def\blx@tempc{\the\value{listcount}}} + {\def\blx@tempc{#3}}% + \def\blx@tempd{#1}% + \blx@resolve@annotation@label{\blx@tempd}% + \ifcsdef{abx@annotation@literal@part@\blx@tempd @#2@\blx@tempc @#4}} -% {<datetype>}{<annotation>} % labeldatesource has a slightly different format than other <field>sources % that's one reason for a dedicated command, the other being that this command % is probably only used in contexts where \currentfield is not defined, so % the <datetype> argument is always required -\newcommand*{\blx@imc@ifdateannotation}[2]{% - \def\blx@tempa{#1}% - \ifcsundef{abx@field@\blx@tempa source} +% [<annotationname>]{<datetype>}{<annotation>} +\newcommand*{\blx@imc@ifdateannotation}[3][]{% + \ifblank{#1} + {\def\blx@tempa{default}} + {\def\blx@tempa{#1}}% + \def\blx@tempb{#2}% + \ifcsundef{abx@field@\blx@tempb source} {}% - {\letcs\blx@tempa{abx@field@\blx@tempa source}% - \edef\blx@tempa{\blx@tempa date}}% - \ifinlistcs{#2}{abx@annotation@field@\blx@tempa}} + {\letcs\blx@tempa{abx@field@\blx@tempb source}% + \edef\blx@tempb{\blx@tempb date}}% + \ifinlistcs{#3}{abx@annotation@field@\blx@tempb @\blx@tempa}} + +% [<annotationname>]{<datetype>} +\newcommand*{\blx@imc@hasdateannotation}[2][]{% + \ifblank{#1} + {\def\blx@tempa{default}} + {\def\blx@tempa{#1}}% + \def\blx@tempb{#2}% + \ifcsundef{abx@field@\blx@tempb source} + {}% + {\letcs\blx@tempa{abx@field@\blx@tempb source}% + \edef\blx@tempb{\blx@tempb date}}% + \ifboolexpr { test {\ifcsdef{abx@annotation@field@\blx@tempb @\blx@tempa}} + or + test {\ifcsdef{abx@annotation@literal@field@\blx@tempb @\blx@tempa}} }} + +% [<annotationname>]{<datetype>} +\newcommand*{\blx@imc@getdateannotation}[2][]{% + \ifblank{#1} + {\def\blx@tempa{default}} + {\def\blx@tempa{#1}}% + \def\blx@tempb{#1}% + \ifcsundef{abx@field@\blx@tempb source} + {}% + {\letcs\blx@tempb{abx@field@\blx@tempb source}% + \edef\blx@tempb{\blx@tempb date}}% + \ifcsdef{abx@annotation@literal@field@\blx@tempb @\blx@tempa} + {\csuse{abx@annotation@literal@field@\blx@tempb @\blx@tempa}} + {}} \blx@regimcs{\iffieldannotation \ifitemannotation \ifpartannotation - \ifdateannotation} + \ifdateannotation \getfieldannotation \getitemannotation \getpartannotation + \getdateannotation \hasfieldannotation \hasitemannotation \haspartannotation + \hasdateannotation} % {<fieldname>} \def\blx@resolve@annotation@label#1{% @@ -6902,10 +7561,8 @@ % {<keyword>,...} \protected\def\blx@bbl@keyw#1{% - \iftoggle{blx@skipbib} - {} - {\forcsvlist{\blx@addkeyword{\abx@field@entrykey}}{#1}% - \blx@bbl@fielddef{keywords}{#1}}} + \forcsvlist{\blx@addkeyword{\abx@field@entrykey}}{#1}% + \blx@bbl@fielddef{keywords}{#1}} \def\blx@addkeyword#1#2{% \listcsxadd{blx@keyw@\the\c@refsection @\detokenize{#2}}{#1}} @@ -7269,20 +7926,21 @@ {}% \nottoggle{blx@skiplab} {\iftoggle{blx@labelnumber} - {\blx@bbl@labelnumber} - {}% - \iftoggle{blx@labelalpha} - {\blx@bbl@labelalpha} - {}% - \iftoggle{blx@labeltitle} - {\blx@bbl@labeltitle} - {}% - \iftoggle{blx@labeltitleyear} - {\blx@bbl@labeltitleyear} - {}% - \iftoggle{blx@labeldateparts} - {\blx@bbl@labeldate} - {}} + {\blx@bbl@labelnumber} + {}% + \iftoggle{blx@labelalpha} + {\blx@bbl@labelalpha} + {}% + \iftoggle{blx@labeltitle} + {\blx@bbl@labeltitle} + {}% + \iftoggle{blx@labeltitleyear} + {\blx@bbl@labeltitleyear} + {}% + \iftoggle{blx@labeldateparts} + {\blx@bbl@labeldate} + {}% + \blx@bbl@labelname} {}% \blx@bbl@titles \blx@bbl@hooks @@ -7301,7 +7959,7 @@ {\letcs\blx@tempa{blx@dlist@centry@\the\c@refsection @\blx@refcontext@context}% \global\cslet{blx@dlist@centry@\the\c@refsection @\blx@refcontext@context}\@empty \forlistloop\blx@addset@i\blx@tempa} - {\PackageWarningNoLine{biblatex}{Sorting template has changed}}% + {\blx@warning@noline{Sorting template has changed}}% \endgroup} \def\blx@addset@i#1{% @@ -7470,6 +8128,13 @@ \global\c@maxextratitleyear\abx@field@extratitleyear\relax \fi}} +\def\blx@bbl@labelname{% + \ifundef\abx@field@extraname + {} + {\ifnum\abx@field@extraname>\c@maxextraname + \global\c@maxextraname\abx@field@extraname\relax + \fi}} + \def\blx@bbl@labeldate{% \ifundef\abx@field@extradate {} @@ -7555,7 +8220,7 @@ % {<refcontext>} % Get the saved information on which refcontexts were mentioned last run \protected\def\abx@aux@refcontext#1{% - \listgadd\blx@lastrefcontexts{#1}} + \listxadd\blx@lastrefcontexts{\detokenize{#1}}} % {<sortingtemplatename>} % Get the saved information on which shorthand sorting templates were mentioned last run @@ -8202,7 +8867,7 @@ {} {\listxadd\blx@dlistnames{\blx@refcontext@context @\blx@tempe @entry}% \csxappto{blx@dlists}{% - \blx@xml@dlist{\blx@refcontext@context}{entry}{\blx@tempe}{\blx@xml@dlist@refcontext{\blx@refcontext@sortingtemplatename}{\blx@refcontext@sortingnamekeytemplatename}{\blx@refcontext@labelprefix}{\blx@refcontext@uniquenametemplatename}{\blx@refcontext@labelalphanametemplatename}}{}}}% + \blx@xml@dlist{\blx@refcontext@context}{entry}{\blx@tempe}{\blx@xml@dlist@refcontext{\blx@refcontext@sortingtemplatename}{\blx@refcontext@sortingnamekeytemplatename}{\blx@refcontext@labelprefix@real}{\blx@refcontext@uniquenametemplatename}{\blx@refcontext@labelalphanametemplatename}}{}}}% \ifdefvoid\blx@tempa {\blx@warn@bibempty\endgroup} {\blx@bibliography\blx@tempa}} @@ -8451,6 +9116,17 @@ \let\blx@bibcheck\relax +\def\blx@edef@refcontext#1{% + \edef\blx@refcontext@context{#1}% + \expandafter\edef\expandafter\blx@refcontext@context\expandafter{% + \expandafter\detokenize\expandafter{\blx@refcontext@context}}} + +\def\blx@xdef@refcontext#1{% + \edef\blx@refcontext@context{#1}% + \expandafter\xdef\expandafter\blx@refcontext@context\expandafter{% + \expandafter\detokenize\expandafter{\blx@refcontext@context}}} + + % This sets and saves to the .aux the default refcontext for an entry. The % default refcontext for an entry is the refcontext of the last % bibliography in the refsection in which it is actually printed. This @@ -8468,7 +9144,7 @@ % <refsection><key><refcontext> \def\abx@aux@defaultrefcontext#1#2#3{% \global\boolfalse{refcontextdefaults}% - \csxdef{blx@assignedrefcontextbib@#1@#2}{#3}} + \csxdef{blx@assignedrefcontextbib@#1@#2}{\detokenize{#3}}} \def\abx@aux@refcontextdefaultsdone{% \global\boolfalse{refcontextdefaults}} @@ -8609,9 +9285,12 @@ \ifcsdef{blx@sortingtemplate@#2} {#2} {\blx@refcontext@sortingtemplatename}}% - % locally define this since we want to fetch data from the datalist named - % after the list we are printing rather than the data in refcontext list - \edef\blx@refcontext@context{\blx@tempc/\blx@refcontext@sortingnamekeytemplatename/\blx@refcontext@labelprefix/\blx@refcontext@uniquenametemplatename/\blx@refcontext@labelalphanametemplatename}% + % locally define this since we want to fetch data from the datalist named + % after the list we are printing rather than the data in refcontext list + % Note that the name must be unique so we prepend "#2:" because the combination of + % options might not generate a unique name since sortschemename has a fallback to the + % refcontext scheme if there is no sortscheme named after the list + \blx@edef@refcontext{#2:\blx@tempc/\blx@refcontext@sortingnamekeytemplatename/\blx@refcontext@labelprefix/\blx@refcontext@uniquenametemplatename/\blx@refcontext@labelalphanametemplatename}% \xifinlist\blx@tempc\blx@sortingtemplatenames {} {\listxadd\blx@sortingtemplatenames\blx@tempc}% @@ -8642,8 +9321,8 @@ \xifinlist{\blx@refcontext@context @\blx@tempe @list}\blx@dlistnames {} {\listxadd\blx@dlistnames{\blx@refcontext@context @\blx@tempe @list}% - \csxappto{blx@dlists}{% - \blx@xml@dlist{\blx@refcontext@context}{list}{\blx@tempe}{\blx@xml@dlist@refcontext{\blx@tempc}{\blx@refcontext@sortingnamekeytemplatename}{\blx@refcontext@labelprefix}{\blx@refcontext@uniquenametemplatename}{\blx@refcontext@labelalphanametemplatename}}{\csuse{blx@biblistfilters@\blx@thebiblistfilter}}}}% + \xappto\blx@dlists{% + \blx@xml@dlist{\blx@refcontext@context}{list}{\blx@tempe}{\blx@xml@dlist@refcontext{\blx@tempc}{\blx@refcontext@sortingnamekeytemplatename}{\blx@refcontext@labelprefix@real}{\blx@refcontext@uniquenametemplatename}{\blx@refcontext@labelalphanametemplatename}}{\csuse{blx@biblistfilters@\blx@thebiblistfilter}}}}% \ifdefvoid\blx@tempa {\blx@warn@biblistempty{#2}\endgroup} {\blx@biblist\blx@tempa}} @@ -8759,7 +9438,7 @@ \xifinlist\blx@refcontext@sortingtemplatename\blx@sortingtemplatenames {} {\listxadd\blx@sortingtemplatenames\blx@refcontext@sortingtemplatename}% - \xdef\blx@refcontext@context{\blx@refcontext@sortingtemplatename/\blx@refcontext@sortingnamekeytemplatename/\blx@refcontext@labelprefix/\blx@refcontext@uniquenametemplatename/\blx@refcontext@labelalphanametemplatename}% + \blx@xdef@refcontext{\blx@refcontext@sortingtemplatename/\blx@refcontext@sortingnamekeytemplatename/\blx@refcontext@labelprefix/\blx@refcontext@uniquenametemplatename/\blx@refcontext@labelalphanametemplatename}% % Add the refcontext to the list of refcontexts so we can compare on next run \xifinlist\blx@refcontext@context\blx@refcontexts {} @@ -8782,11 +9461,12 @@ \protected\def\endrefcontext{% \togglefalse{blx@refcontext}% \global\let\blx@refcontext@labelprefix\@empty + \global\let\blx@refcontext@labelprefix@real\@empty \xdef\blx@refcontext@sortingtemplatename{\blx@sorting}% \gdef\blx@refcontext@sortingnamekeytemplatename{global}% \gdef\blx@refcontext@uniquenametemplatename{global}% \gdef\blx@refcontext@labelalphanametemplatename{global}% - \xdef\blx@refcontext@context{\blx@refcontext@sortingtemplatename/\blx@refcontext@sortingnamekeytemplatename//\blx@refcontext@uniquenametemplatename/\blx@refcontext@labelalphanametemplatename}} + \blx@xdef@refcontext{\blx@refcontext@sortingtemplatename/\blx@refcontext@sortingnamekeytemplatename//\blx@refcontext@uniquenametemplatename/\blx@refcontext@labelalphanametemplatename}} % Meta option to set all name template options \define@key{blx@refcontext}{nametemplates}{% @@ -8798,8 +9478,16 @@ \define@key{blx@refcontext}{sortingnamekeytemplatename}{\gdef\blx@refcontext@sortingnamekeytemplatename{#1}} \define@key{blx@refcontext}{uniquenametemplatename}{\gdef\blx@refcontext@uniquenametemplatename{#1}} \define@key{blx@refcontext}{labelalphanametemplatename}{\gdef\blx@refcontext@labelalphanametemplatename{#1}} + +% labelprefix cannot be used as is because it is used to construct the internal +% refcontext name which is referenced/expanded a lot all over the place. So, +% we hash the given input and use the safe hash as internal name. +% But that is not enough since the MD5 hash function expands the argument all +% the way and so unexpandable content like \dag breaks. +% Unexpandable content should be protected with \detokenize. \define@key{blx@refcontext}{labelprefix}{% - \gdef\blx@refcontext@labelprefix{#1}% + \xdef\blx@refcontext@labelprefix{\blx@mdfivesum{#1}}% + \gdef\blx@refcontext@labelprefix@real{#1}% \iftoggle{blx@defernumbers} {}% {\iftoggle{blx@labelnumber} @@ -8823,7 +9511,8 @@ \setkeys{blx@assignrefcontext}{#2}% \def\do##1{% \listxadd\blx@assignedrefcontextkeywlist{##1}% - \csxdef{blx@assignedrefcontextkeyws#1@\the\c@refsection @##1}{\blx@tempa/\blx@tempb/\blx@tempc/\blx@tempd/\blx@tempe}} + \csxdef{blx@assignedrefcontextkeyws#1@\the\c@refsection @##1}% + {\blx@tempa/\blx@tempb/\blx@tempc/\blx@tempd/\blx@tempe}}% \docsvlist{#3}} % [refcontext keys]{<category1>,<category2>,...} @@ -8841,7 +9530,8 @@ \setkeys{blx@assignrefcontext}{#2}% \def\do##1{% \listxadd\blx@assignedrefcontextcatlist{##1}% - \csxdef{blx@assignedrefcontextcats#1@\the\c@refsection @##1}{\blx@tempa/\blx@tempb/\blx@tempc/\blx@tempd/\blx@tempe}} + \csxdef{blx@assignedrefcontextcats#1@\the\c@refsection @##1}% + {\blx@tempa/\blx@tempb/\blx@tempc/\blx@tempd/\blx@tempe}}% \docsvlist{#3}} % [refcontext keys]{<entrykey1>,<entrykey2>,...} @@ -8858,7 +9548,8 @@ \def\blx@tempe{global}% \setkeys{blx@assignrefcontext}{#2}% \def\do##1{% - \csxdef{blx@assignedrefcontextkeys#1@\the\c@refsection @##1}{\blx@tempa/\blx@tempb/\blx@tempc/\blx@tempd/\blx@tempe}}% + \csxdef{blx@assignedrefcontextkeys#1@\the\c@refsection @##1}% + {\blx@tempa/\blx@tempb/\blx@tempc/\blx@tempd/\blx@tempe}}% \docsvlist{#3}} % Meta option to set all name template options @@ -8869,7 +9560,8 @@ \define@key{blx@assignrefcontext}{sorting}{\def\blx@tempa{#1}} \define@key{blx@assignrefcontext}{sortingnamekeytemplatename}{\def\blx@tempb{#1}} -\define@key{blx@assignrefcontext}{labelprefix}{\def\blx@tempc{#1}} +\define@key{blx@assignrefcontext}{labelprefix}{% + \edef\blx@tempc{\blx@mdfivesum{#1}}} \define@key{blx@assignrefcontext}{uniquenametemplatename}{\def\blx@tempd{#1}} \define@key{blx@assignrefcontext}{labelalphanametemplatename}{\def\blx@tempe{#1}} @@ -8955,6 +9647,7 @@ \endgroup} \protected\def\endrefsection{% + \endrefcontext \blx@endrefsection \blx@inf@refsec} @@ -8969,11 +9662,11 @@ % Make sure this counter exists. Sometimes it might not when using, e.g: % refsection=chapter and \includeonly to put in the chapters or when % inserting citations into table of contents - \ifcsname blx@sectionciteorder@\the\c@refsection\endcsname\else - \expandafter\newcount\csname blx@sectionciteorder@\the\c@refsection\endcsname - \fi + \ifcscounter{blx@sectionciteorder@\the\c@refsection} + {} + {\expandafter\newcount\csname blx@sectionciteorder@\the\c@refsection\endcsname}% \global\advance\csname blx@sectionciteorder@\the\c@refsection\endcsname\@ne - \blx@auxwrite\blx@bcfout{}{\blx@xml@citekey{##1}{\expandafter\the\csname blx@sectionciteorder@\the\c@refsection\endcsname}}}% + \blx@auxwrite\blx@bcfout{}{\blx@xml@citekey{##1}{}{\expandafter\the\csname blx@sectionciteorder@\the\c@refsection\endcsname}}}% \dolistcsloop{blx@keyaliases@\the\c@refsection}% \ifnum\c@refsection>\z@ \blx@auxwrite\blx@bcfout{}{% @@ -9047,22 +9740,36 @@ \def\blx@refpatch@chapter#1{% \ifundef\chapter {\blx@err@nodocdiv{chapter}} - {\pretocmd\@makechapterhead{#1} - {} - {\blx@err@patch{\string\@makechapterhead}} - \pretocmd\@makeschapterhead{#1} - {} - {\blx@err@patch{\string\@makeschapterhead}}}} + {% the \ifcsundef{KOMAClassName} should be redundant, but you never know + \ifboolexpr{test {\ifcsundef{KOMAClassName}} + or test {\ifcsundef{startsection@secnumdepth}}} + {\pretocmd\@makechapterhead{#1} + {} + {\blx@err@patch{\string\@makechapterhead}} + \pretocmd\@makeschapterhead{#1} + {} + {\blx@err@patch{\string\@makeschapterhead}}} + {% <- new KOMA >= 3.26 defines \startsection@secnumdepth + \At@startsection{\ifnumequal{\startsection@secnumdepth}{0}{#1}{}}}}} \def\blx@refpatch@sect#1{% \ifcsundef{#1} {\blx@err@nodocdiv{#1}\@gobbletwo} - {\blx@refpatch@sect@i}} + {% the \ifcsundef{KOMAClassName} should be redundant, but you never know + \ifboolexpr{test {\ifcsundef{KOMAClassName}} + or test {\ifcsundef{startsection@secnumdepth}}} + {\blx@refpatch@sect@i} + {\blx@refpatch@sect@koma}}} + +% KOMA >= 3.26 defines \startsection@secnumdepth to check the sectioning level, +% so we can now use \At@startsection +\def\blx@refpatch@sect@koma#1#2{% + \At@startsection{\ifnumequal{\startsection@secnumdepth}{#2}{#1}{}}} \edef\blx@refpatch@sect@i#1#2{% \def\noexpand\do##1{% - \pretocmd##1% - {\noexpand\blx@refpatch@sect@ii{#1}{#2}{\string#2}} + \pretocmd##1% + {\noexpand\blx@refpatch@sect@ii{#1}{#2}{\string#2}} {\togglefalse{blx@tempa}\noexpand\listbreak} {}}% \noexpand\blx@refpatch@sect@iii} @@ -9078,7 +9785,7 @@ \H@old@sect,% hyperref \NR@sect,% nameref \scr@sect,% koma-script 3.x - \scr@startsection,% bad hack for koma >= 3.15 + \scr@startsection,% bad hack for koma 3.15 <= v <= 3.25 \@startsection}% latex \iftoggle{blx@tempa} {\blx@err@patch{\string\@sect}} @@ -9137,6 +9844,8 @@ \def\blx@tempa{file}% \def\blx@tempb{bibtex}% \def\blx@tempc{local}% + \undef\blx@tempd + \let\blx@tempe\@empty \blx@xsanitizeafter{\forcsvlist\blx@addbib@legacy}{#1}% \endgroup} \@onlypreamble\bibliography @@ -9183,6 +9892,7 @@ \def\blx@tempb{bibtex}% \def\blx@tempc{local}% \undef\blx@tempd + \let\blx@tempe\@empty \setkeys{blx@addbib}{#2}% \blx@xsanitizeafter{#1}{#3}% \endgroup} @@ -9198,6 +9908,7 @@ \define@key{blx@addbib}{datatype}{\def\blx@tempb{#1}} \define@key{blx@addbib}{location}{\def\blx@tempc{#1}} \define@key{blx@addbib}{label}{\edef\blx@tempd{\detokenize{#1}}} +\define@key{blx@addbib}{bibencoding}{\def\blx@tempe{#1}} % \blx@res@type@<resource> resource -> type % \blx@res@data@<resource> resource -> datatype @@ -9208,6 +9919,7 @@ \csxdef{blx@res@type@#1}{\blx@tempa}% \csxdef{blx@res@data@#1}{\blx@tempb}% \csxdef{blx@res@loca@#1}{\blx@tempc}% + \csxdef{blx@res@bibencoding@#1}{\blx@tempe}% \ifdef\blx@tempd {\csxdef{blx@res@labl@\blx@tempd}{#1}} {}} @@ -9237,6 +9949,9 @@ {\ifcsdef{blx@res@data@#2} {\csuse{blx@res@data@#2}} {bibtex}} + {\ifcsvoid{blx@res@bibencoding@#2} + {} + { encoding="\csuse{blx@res@bibencoding@#2}"}} {#3}}} %% Citations @@ -9311,8 +10026,22 @@ \blx@loccitreset} % {<entrykey>}{<message>} +% Wrapper to track cite keys which are \nocited +\def\blx@nocitation#1#2{% + \ifinlist{#1}\blx@nocites + {} + {\listgadd\blx@nocites{#1}}% + \blx@citation@i{#1}{#2}} + +% {<entrykey>}{<message>} % Just a wrapper to suppress citation tracking in toc/lof etc. \def\blx@citation#1#2{% + \ifinlist{#1}\blx@directcites + {} + {\listgadd\blx@directcites{#1}}% + \blx@citation@i{#1}{#2}} + +\def\blx@citation@i#1#2{% \ifbool{citerequest} {\blx@citation@entry{#1}{#2}} {}} @@ -9338,6 +10067,12 @@ \protected\def\abx@aux@segm#1#2#3{% \listcsxadd{blx@segm@#1@#2}{\detokenize{#3}}} +\def\blx@nocitation@all{% + \ifinlist{*}\blx@nocites + {} + {\listgadd\blx@nocites{*}}% + \blx@citation@all} + \def\blx@citation@all{% \ifbool{citerequest} {\blx@bibreq{*}% @@ -9352,11 +10087,21 @@ \protected\def\blx@bibreq#1{% \begingroup \blx@xmlsanitizeafter{\def\blx@tempa}{#1}% + \let\blx@tempb\@empty + % Only output as \nocited if a key wasn't also directly \cite'd + % Since citekey output is sequential as cites are read, the .bcf might contain + % duplicate keys with differring nocite attributes if \nocite{X} and \cite{X} both occur + % but biber deals with this and priorities \cites + \ifboolexpr{test {\ifinlist{#1}\blx@nocites} + and + not test {\ifinlist{#1}\blx@directcites}} + {\def\blx@tempb{ nocite="1"}} + {}% % citeall is always order "0" - this makes no real difference as biber % ignores all other citekeys in the section if citeall is present \ifstrequal{*}{#1} - {\blx@auxwrite\blx@bcfout{}{\blx@xml@citekey{\blx@tempa}{0}}} - {\blx@auxwrite\blx@bcfout{}{\blx@xml@citekey{\blx@tempa}{\expandafter\the\csname blx@sectionciteorder@\the\c@refsection\endcsname}}}% + {\blx@auxwrite\blx@bcfout{}{\blx@xml@citekey{\blx@tempa}{\blx@tempb}{0}}} + {\blx@auxwrite\blx@bcfout{}{\blx@xml@citekey{\blx@tempa}{\blx@tempb}{\expandafter\the\csname blx@sectionciteorder@\the\c@refsection\endcsname}}}% \endgroup} % {<set>}{<key1,key2,key3>} @@ -9405,12 +10150,15 @@ \begingroup % This must be here and not after \blx@citeadd as this changes the refcontext \letcs\blx@tempb{blx@dlist@centry@\the\c@refsection @\blx@refcontext@context}% + \ifundef\blx@tempb + {\let\blx@tempb\@empty} + {}% % Make sure this counter exists. Sometimes it might not when using, e.g: % refsection=chapter and \includeonly to put in the chapters or when % inserting citations into table of contents - \ifcsname blx@sectionciteorder@\the\c@refsection\endcsname\else - \expandafter\newcount\csname blx@sectionciteorder@\the\c@refsection\endcsname - \fi + \ifcscounter{blx@sectionciteorder@\the\c@refsection} + {} + {\expandafter\newcount\csname blx@sectionciteorder@\the\c@refsection\endcsname}% \global\advance\csname blx@sectionciteorder@\the\c@refsection\endcsname\@ne \blx@tempcnta\z@ \blx@tempcntb\z@ @@ -9450,6 +10198,9 @@ \def\blx@citenosort{% \let\blx@tempb\blx@tempa} +\def\abx@missing@entry#1{% + \abx@missing{#1}} + % {<entrykey>} \def\blx@citeadd#1{% \ifcsdef{blx@keyalias@\the\c@refsection @#1} @@ -9461,7 +10212,7 @@ {\advance\blx@tempcnta\@ne \listeadd\blx@tempa{\blx@realkey}} {\ifnum\blx@tempcntb>\z@\multicitedelim\fi - \expandafter\abx@missing\expandafter{\blx@realkey}% + \expandafter\abx@missing@entry\expandafter{\blx@realkey}% \advance\blx@tempcntb\@ne}} % set default refcontext for one citation key @@ -9478,7 +10229,7 @@ % refcontext defined \ifcsdef{blx@assignedrefcontextbib@\the\c@refsection @#1} {\letcs\blx@refcontext@context{blx@assignedrefcontextbib@\the\c@refsection @#1}} - {\edef\blx@refcontext@context{\blx@sorting/global//global/global}}% + {\blx@edef@refcontext{\blx@sorting/global//global/global}}% % assignment via keyword list \ifdef\blx@assignedrefcontextkeywlist {\def\do##1{% @@ -9594,10 +10345,35 @@ {}} % {<refsection>}{<entrykey>} +% set maxcitecounter as well, note that we also define a maxcitecounter across +% all refsections, but that does not have a high-level interface \protected\def\blx@aux@count#1#2{% - \csnumgdef{blx@count@#1@\detokenize{#2}}{\csuse{blx@count@#1@\detokenize{#2}}+1}} + \csnumgdef{blx@count@#1@\detokenize{#2}}{% + \csuse{blx@count@#1@\detokenize{#2}}+1}% + \ifnumgreater{\csuse{blx@count@#1@\detokenize{#2}}}{% + 0\csuse{blx@maxcitecounter@#1}} + {\csnumgdef{blx@maxcitecounter@#1}{% + \csuse{blx@count@#1@\detokenize{#2}}}} + {}% + \ifnumgreater{\csuse{blx@count@#1@\detokenize{#2}}}{% + 0\csuse{blx@maxcitecounter}} + {\csnumgdef{blx@maxcitecounter}{% + \csuse{blx@count@#1@\detokenize{#2}}}} + {}} + \protected\def\blx@aux@fncount#1#2{% - \csnumgdef{blx@fncount@#1@\detokenize{#2}}{\csuse{blx@fncount@#1@\detokenize{#2}}+1}} + \csnumgdef{blx@fncount@#1@\detokenize{#2}}{% + \csuse{blx@fncount@#1@\detokenize{#2}}+1}% + \ifnumgreater{\csuse{blx@fncount@#1@\detokenize{#2}}}{% + 0\csuse{blx@maxfncitecounter@#1}} + {\csnumgdef{blx@maxfncitecounter@#1}{% + \csuse{blx@fncount@#1@\detokenize{#2}}}} + {}% + \ifnumgreater{\csuse{blx@fncount@#1@\detokenize{#2}}}{% + 0\csuse{blx@maxfncitecounter}} + {\csnumgdef{blx@maxfncitecounter}{% + \csuse{blx@fncount@#1@\detokenize{#2}}}} + {}} \let\abx@aux@count\@gobbletwo \let\abx@aux@fncount\@gobbletwo @@ -9608,14 +10384,22 @@ \protected\def\blx@setcitecounter@global{% \c@citecounter0% - \csuse{blx@count@\the\c@refsection @\abx@field@entrykey}% + \csuse{blx@count@\the\c@refsection @\abx@field@entrykey}% + \relax + \c@maxcitecounter0% + \csuse{blx@maxcitecounter@\the\c@refsection}% \relax} \protected\def\blx@setcitecounter@context{% \c@citecounter0% - \iftoggle{blx@footnote} - {\csuse{blx@fncount@\the\c@refsection @\abx@field@entrykey}} - {\csuse{blx@count@\the\c@refsection @\abx@field@entrykey}}% + \iftoggle{blx@footnote} + {\csuse{blx@fncount@\the\c@refsection @\abx@field@entrykey}} + {\csuse{blx@count@\the\c@refsection @\abx@field@entrykey}}% + \relax + \c@maxcitecounter0% + \iftoggle{blx@footnote} + {\csuse{blx@maxfncitecounter@\the\c@refsection}} + {\csuse{blx@maxcitecounter@\the\c@refsection}}% \relax} % cite tracker @@ -10069,7 +10853,7 @@ \iftoggle{blx@bibliography} {} {\ifstrequal{*}{#1} - {\blx@citation@all} + {\blx@nocitation@all} {\blx@xsanitizeafter{\forcsvlist\blx@nocite@do}{#1}}}}% \@esphack} @@ -10077,11 +10861,11 @@ % Make sure this counter exists. Sometimes it might not when using, e.g: % refsection=chapter and \includeonly to put in the chapters or when % inserting citations into table of contents - \ifcsname blx@sectionciteorder@\the\c@refsection\endcsname\else - \expandafter\newcount\csname blx@sectionciteorder@\the\c@refsection\endcsname - \fi + \ifcscounter{blx@sectionciteorder@\the\c@refsection} + {} + {\expandafter\newcount\csname blx@sectionciteorder@\the\c@refsection\endcsname}% \global\advance\csname blx@sectionciteorder@\the\c@refsection\endcsname\@ne - \blx@citation{#1}\blx@msg@cundef} + \blx@nocitation{#1}\blx@msg@cundef} % {<macro>}[<arg1>][<arg2>]{<arg3>} % => <macro>{<arg1>}{<arg2>}{<arg3>} @@ -10202,18 +10986,52 @@ {\blx@defcitecmd@ii{#2#1}}} \long\def\blx@defcitecmd@ii#1{% - \protected\csedef{blx@cite@#1}{\blxciteicmd{#1}}% - \blx@defcitecmd@iv{#1}} + \csundef{blx@defcite@wrapper@#1}% + \blx@defcitecmd@iv{#1}% + \blx@defcitecmd@v{#1}} \long\def\blx@defcitecmd@iii#1[#2]{% + \csdef{blx@defcite@wrapper@#1}{#2}% + \blx@defcitecmd@iv{#1}% + \blx@defcitecmd@v{#1}} + +\long\def\blx@defcitecmd@iv#1{% \protected\long\csedef{blx@cite@#1}##1##2##3##4{% - \begingroup - \blx@citeinit - \unexpanded{#2}{\blxciteicmd{#1}{##1}{##2}{##3}{}}% - ##4\endgroup}% - \blx@defcitecmd@iv{#1}} + \ifboolexpe{test {\ifcsundef{blx@defcite@wrapper@#1}} + and + (test {\ifcsundef{blx@citepunct@#1}} + or + test {\ifcsequal{blx@citepunct@#1}{blx@citepunctid@pos@c}})} + {} + {\begingroup + \blx@citeinit}% + \ifcsequal{blx@citepunct@#1}{blx@citepunctid@pos@l} + {\noexpand\unspace##4} + {}% + \ifcsequal{blx@citepunct@#1}{blx@citepunctid@pos@f} + {\noexpand\iftoggle{blx@footnote}{}{\unspace##4}} + {}% + \ifcsundef{blx@defcite@wrapper@#1} + {\blxciteicmd{#1}{##1}{##2}{##3}{% + \ifcsundef{blx@citepunct@#1}{##4}{}% + \ifcsequal{blx@citepunct@#1}{blx@citepunctid@pos@c}{##4}{}}} + {\csexpandonce{blx@defcite@wrapper@#1}{% + \blxciteicmd{#1}{##1}{##2}{##3}{% + \ifcsequal{blx@citepunct@#1}{blx@citepunctid@pos@c}{##4}{}}}% + \ifcsundef{blx@citepunct@#1}{##4}{}}% + \ifcsequal{blx@citepunct@#1}{blx@citepunctid@pos@r}{##4}{}% + \ifcsequal{blx@citepunct@#1}{blx@citepunctid@pos@f} + {\noexpand\iftoggle{blx@footnote}{##4}{}} + {}% + \ifboolexpe{test {\ifcsundef{blx@defcite@wrapper@#1}} + and + (test {\ifcsundef{blx@citepunct@#1}} + or + test {\ifcsequal{blx@citepunct@#1}{blx@citepunctid@pos@c}})} + {} + {\endgroup}}} -\long\def\blx@defcitecmd@iv#1#2#3#4#5{% +\long\def\blx@defcitecmd@v#1#2#3#4#5{% \protected\long\csdef{blx@citei@#1}##1##2##3##4{% \ifblank{##1} {} @@ -10436,14 +11254,15 @@ \blx@citecmdinit \noexpand\@ifstar {\expandafter\noexpand - \csname blx@mcite@#4\endcsname*% + \csname blx@macitei@#1\endcsname*% \expandafter\noexpand - \csname blx@macitei@#1\endcsname} + \csname blx@maciteii@#1\endcsname} {\expandafter\noexpand - \csname blx@mcite@#4\endcsname{}% + \csname blx@macitei@#1\endcsname{}% \expandafter\noexpand - \csname blx@macitei@#1\endcsname}}% - \protected\csedef{blx@macitei@#1}##1##2##3{% + \csname blx@maciteii@#1\endcsname}}% + \csedef{blx@macitei@#1}{\csname blx@mcite@#4\endcsname}% + \protected\csedef{blx@maciteii@#1}##1##2##3{% \if l#2\noexpand\unspace##3\fi \if f#2\noexpand\iftoggle{blx@footnote}{}{\unspace##3}\fi ##1{##2}% @@ -10458,6 +11277,36 @@ {\let\blx@thecheckpunct\blx@checkpunct \def\blx@autopunct{#1}}} +% {<command>}{<pos marker>} +% pos markers are: +% l: move punctuation before the command (i.e. left of it) +% r: leave punctuation after the command (i.e. to the right) +% f: like l in normal text, like r in footnotes +% c: pass on to the cite command, +% the punctuation will eventually end up as field 'postpunct' +% d: discard the punctuation +% o (or any other value): restores the old standard behaviour +% r for wrapped citation commands, +% c for unwrapped ones +\newrobustcmd*{\DeclareCitePunctuationPosition}[2]{% + \begingroup + \escapechar\m@ne + \edef\blx@tempa{\endgroup + \noexpand\blx@defcitepunctpos@i{\string#1}{#2}}% + \blx@tempa} + +\def\blx@citepunctid@pos@l{l} +\def\blx@citepunctid@pos@r{r} +\def\blx@citepunctid@pos@f{f} +\def\blx@citepunctid@pos@c{c} +\def\blx@citepunctid@pos@d{d} + +\def\blx@defcitepunctpos@i#1#2{% + \ifcsundef{blx@citepunctid@pos@#2} + {\csundef{blx@citepunct@#1}} + {\csletcs{blx@citepunct@#1}{blx@citepunctid@pos@#2}}% + \blx@defcitecmd@iv{#1}} + \AfterEndPreamble{% babel \begingroup \makeatletter @@ -10637,6 +11486,7 @@ \def\ifuseprefix{\blx@TE{\iftoggle{blx@useprefix}}}% \def\ifterseinits{\blx@TE{\iftoggle{blx@terseinits}}}% \def\ifsingletitle{\blx@TE{\iftoggle{abx@bool@singletitle}}}% + \def\ifnocite{\blx@TE{\iftoggle{abx@bool@nocite}}}% \def\ifuniquetitle{\blx@TE{\iftoggle{abx@bool@uniquetitle}}}% \def\ifuniquebaretitle{\blx@TE{\iftoggle{abx@bool@uniquebaretitle}}}% \def\ifuniquework{\blx@TE{\iftoggle{abx@bool@uniquework}}}% @@ -10647,7 +11497,9 @@ \blx@TE{\blx@imc@ifdatehasyearonlyprecision{#1}}}% \def\ifdatehastime#1{\blx@TE{\blx@imc@ifdatehastime{#1}}}% \def\ifdateshavedifferentprecision#1#2{% - \blx@TE{\blx@imc@ifdateshavedifferentprecision{#1}{#2}}}}} + \blx@TE{\blx@imc@ifdateshavedifferentprecision{#1}{#2}}}% + \def\ifdateyearsequal#1#2{% + \blx@TE{\blx@imc@ifdateyearsequal{#1}{#2}}}}} % {<listmacro>}{<filtercsname>} => matches in <listmacro> \protected\def\blx@bibfilter#1#2{% @@ -10667,9 +11519,9 @@ \blx@tempa} %% Auxiliary macros -\newrobustcmd*{\mkbibquote}{\enquote} +\newrobustcmd*{\mkbibquote}{\blx@enquote} \protected\def\blx@imc@mkbibquote{% - \blx@ifuspunct\blx@usquote\enquote} + \blx@ifuspunct\blx@usquote\blx@enquote} \def\blx@usquote{% \ifnum\@quotelevel>\z@ @@ -10680,26 +11532,26 @@ \long\def\blx@usoquote#1{% \begingroup - \initoquote - \textooquote#1% + \blx@initoquote + \blx@textooquote#1% \futurelet\@let@token\blx@usoquote@i} \def\blx@usoquote@i{% \blx@usqcheck {\ifx\blx@postpunct\@empty\else\blx@dopostpunct\fi - \textcoquote\endgroup} - {\blx@setpostpunct\textcoquote\endgroup}} + \blx@textcoquote\endgroup} + {\blx@setpostpunct\blx@textcoquote\endgroup}} \long\def\blx@usiquote#1{% \begingroup - \initiquote - \textoiquote#1% + \blx@initiquote + \blx@textoiquote#1% \futurelet\@let@token\blx@usiquote@i} \def\blx@usiquote@i{% \blx@usqcheck - {\textciquote\endgroup} - {\blx@setpostpunct\textciquote\endgroup}} + {\blx@textciquote\endgroup} + {\blx@setpostpunct\blx@textciquote\endgroup}} \long\def\blx@usqcheck#1#2{% \def\blx@tempa{#1}% @@ -11041,8 +11893,8 @@ ~~<bcf:transliteration entrytype="#1">\blx@nl #2% ~~</bcf:transliteration>\blx@nl} -\xdef\blx@xml@translit#1#2#3{% - ~~~~<bcf:translit target="#1" from="#2" to="#3"/>\blx@nl} +\xdef\blx@xml@translit#1#2#3#4{% + ~~~~<bcf:translit #1target="#2" from="#3" to="#4"/>\blx@nl} \xdef\blx@xml@sourcemap#1{% ~~<bcf:sourcemap>\blx@nl @@ -11220,10 +12072,10 @@ ~~<bcf:bibdata section="#1">\blx@nl #2% ~~</bcf:bibdata>\blx@nl} -\xdef\blx@xml@datasource#1#2#3{% - ~~~~<bcf:datasource type="#1" datatype="#2">#3</bcf:datasource>\blx@nl} -\xdef\blx@xml@citekey#1#2{% - ~~~~<bcf:citekey order="#2">#1</bcf:citekey>} +\xdef\blx@xml@datasource#1#2#3#4{% + ~~~~<bcf:datasource type="#1" datatype="#2"#3>#4</bcf:datasource>\blx@nl} +\xdef\blx@xml@citekey#1#2#3{% + ~~~~<bcf:citekey order="#3"#2>#1</bcf:citekey>} \xdef\blx@xml@citeset#1#2{% ~~~~<bcf:citekey type="set" members="#2">#1</bcf:citekey>} \xdef\blx@xml@svalue#1#2{% @@ -11260,10 +12112,12 @@ \blx@xml@svalue{maxalphanames}{\blx@maxalphanames}% \blx@xml@svalue{maxbibnames}{\blx@maxbibnames}% \blx@xml@svalue{maxcitenames}{\blx@maxcitenames}% + \blx@xml@svalue{maxsortnames}{\blx@maxsortnames}% \blx@xml@svalue{maxitems}{\blx@maxitems}% \blx@xml@svalue{minalphanames}{\blx@minalphanames}% \blx@xml@svalue{minbibnames}{\blx@minbibnames}% \blx@xml@svalue{mincitenames}{\blx@mincitenames}% + \blx@xml@svalue{minsortnames}{\blx@minsortnames}% \blx@xml@svalue{minitems}{\blx@minitems}% \blx@xml@toggle{singletitle}% \blx@xml@svalue{sortalphaothers}{\sortalphaothers}% @@ -11303,10 +12157,12 @@ \blx@xml@svalue{maxalphanames}{\blx@maxalphanames}% \blx@xml@svalue{maxbibnames}{\blx@maxbibnames@type}% \blx@xml@svalue{maxcitenames}{\blx@maxcitenames@type}% + \blx@xml@svalue{maxsortnames}{\blx@maxsortnames@type}% \blx@xml@svalue{maxitems}{\blx@maxitems@type}% \blx@xml@svalue{minalphanames}{\blx@minalphanames}% \blx@xml@svalue{minbibnames}{\blx@minbibnames@type}% \blx@xml@svalue{mincitenames}{\blx@mincitenames@type}% + \blx@xml@svalue{minsortnames}{\blx@minsortnames@type}% \blx@xml@svalue{minitems}{\blx@minitems@type}% \blx@xml@toggle{singletitle}% \blx@xml@toggle{skipbib}% @@ -11354,15 +12210,13 @@ \ifdef\blx@opts@type {\def\do##1{% \begingroup + \let\protect\relax \blx@setoptions@type{##1}% % Expand the type use* name toggles \let\blx@xml@nametoggles\@empty \def\do####1{\eappto\blx@xml@nametoggles{\blx@xml@toggle{use####1}}}% \abx@donames - \begingroup - \let\protect\relax \blx@checkoptions@type - \endgroup \xappto\blx@tempa{\blx@bcf@options@type{##1}}% \endgroup}% \dolistloop\blx@opts@type} @@ -11849,8 +12703,12 @@ {}} \define@key{blx@sourcemap@step}{match}{% characters \appto\blx@tempf{ map\string_match="#1"}} +\define@key{blx@sourcemap@step}{matchi}{% characters + \appto\blx@tempf{ map\string_matchi="#1"}} \define@key{blx@sourcemap@step}{notmatch}{% characters \appto\blx@tempf{ map\string_notmatch="#1"}} +\define@key{blx@sourcemap@step}{notmatchi}{% characters + \appto\blx@tempf{ map\string_notmatchi="#1"}} \define@key{blx@sourcemap@step}{replace}{% characters \eappto\blx@tempf{ map\string_replace="#1"}} @@ -12143,15 +13001,15 @@ Use '\string\DeclareBiblistFilter' to define it}} {\def\blx@thebiblistfilter{#1}}} -% [<entrytype>] +% [<langids>][<entrytype>]{translitsource}{translittarget} \newrobustcmd*{\DeclareSortTranslit}[2][]{% \begingroup \ifblank{#1} {\def\blx@tempa{*}} {\def\blx@tempa{#1}}% - \let\translit\blx@translit@setup - \let\blx@tempb\@empty - #2% + \let\translit\blx@translit@setup + \let\blx@tempb\@empty + #2% \global\cslet{blx@translit@\blx@tempa}\blx@tempb \xifinlist\blx@tempa\blx@translits {} @@ -12161,9 +13019,11 @@ \blx@collectopts{xml}{blx@globalopts}{translit}% for passing to the .bcf \blx@collectopts{xml}{blx@typeopts}{translit}% for passing to the .bcf -\newcommand*{\blx@translit@setup}[3][*]{% +\newcommand*{\blx@translit@setup}[4][]{% \eappto\blx@tempb{% - \blx@xml@translit{#1}{#2}{#3}}} + \ifblank{#1} + {\blx@xml@translit{}{#2}{#3}{#4}} + {\blx@xml@translit{langids="#1" }{#2}{#3}{#4}}}} % [<specname>]{<spec>} \newrobustcmd*{\DeclareUniquenameTemplate}[2][]{% @@ -12598,9 +13458,14 @@ \define@key{blx@opt@ldt}{mcite}[true]{% \settoggle{blx@mcite}{#1}} -\newtoggle{blx@noerroretextools} \define@key{blx@opt@ldt}{noerroretextools}[true]{% - \settoggle{blx@noerroretextools}{#1}} + \blx@warning@noline{% + The option 'noerroretextools' is deprecated.\MessageBreak + Define the control sequence '\string\blx@noerroretextools'\MessageBreak + before loading biblatex instead}% + \ifstrequal{#1}{true} + {\global\cslet{blx@noerroretextools}\@empty} + {\csgundef{blx@noerroretextools}}} % load-time and preamble @@ -12667,9 +13532,10 @@ \listxadd\blx@sortingtemplatenames\blx@sorting \def\blx@refcontext@sortingnamekeytemplatename{global}% \let\blx@refcontext@labelprefix\@empty + \let\blx@refcontext@labelprefix@real\@empty \def\blx@refcontext@uniquenametemplatename{global}% \def\blx@refcontext@labelalphanametemplatename{global}% - \xdef\blx@refcontext@context{\blx@refcontext@sortingtemplatename/\blx@refcontext@sortingnamekeytemplatename/\blx@refcontext@labelprefix/\blx@refcontext@uniquenametemplatename/\blx@refcontext@labelalphanametemplatename}% + \blx@xdef@refcontext{\blx@refcontext@sortingtemplatename/\blx@refcontext@sortingnamekeytemplatename/\blx@refcontext@labelprefix/\blx@refcontext@uniquenametemplatename/\blx@refcontext@labelalphanametemplatename}% \listxadd\blx@refcontexts\blx@refcontext@context} \DeclareBibliographyOption[boolean]{sortcase}[true]{% @@ -12680,17 +13546,21 @@ \DeclareBibliographyOption[integer]{maxnames}{% \numdef\blx@maxcitenames{#1}% - \numdef\blx@maxbibnames{#1}} + \numdef\blx@maxbibnames{#1}% + \numdef\blx@maxsortnames{#1}} \DeclareBibliographyOption[integer]{minnames}{% \numdef\blx@mincitenames{#1}% - \numdef\blx@minbibnames{#1}} + \numdef\blx@minbibnames{#1}% + \numdef\blx@minsortnames{#1}} \DeclareTypeOption[integer]{maxnames}{% \numdef\blx@maxcitenames@type{#1}% \numdef\blx@maxbibnames@type{#1}% + \numdef\blx@maxsortnames@type{#1}% \c@maxnames#1\relax} \DeclareTypeOption[integer]{minnames}{% \numdef\blx@mincitenames@type{#1}% \numdef\blx@minbibnames@type{#1}% + \numdef\blx@minsortnames@type{#1}% \c@minnames#1\relax} \DeclareEntryOption[integer]{maxnames}{% \c@maxnames#1\relax} @@ -12698,16 +13568,20 @@ \c@minnames#1\relax} \DeclareBibliographyOption[integer]{maxbibnames}{% - \numdef\blx@maxbibnames{#1}} + \numdef\blx@maxbibnames{#1}% + \numdef\blx@maxsortnames{#1}} \DeclareBibliographyOption[integer]{minbibnames}{% - \numdef\blx@minbibnames{#1}} + \numdef\blx@minbibnames{#1}% + \numdef\blx@minsortnames{#1}} \DeclareTypeOption[integer]{maxbibnames}{% \numdef\blx@maxbibnames@type{#1}% + \numdef\blx@maxsortnames@type{#1}% \iftoggle{blx@bibliography} {\c@maxnames#1\relax} {}} \DeclareTypeOption[integer]{minbibnames}{% \numdef\blx@minbibnames@type{#1}% + \numdef\blx@minsortnames@type{#1}% \iftoggle{blx@bibliography} {\c@minnames#1\relax} {}} @@ -12743,12 +13617,25 @@ {} {\c@minnames#1\relax}} +\DeclareBibliographyOption[integer]{maxsortnames}{% + \numdef\blx@maxsortnames{#1}} +\DeclareBibliographyOption[integer]{minsortnames}{% + \numdef\blx@minsortnames{#1}} +\DeclareTypeOption[integer]{maxsortnames}{% + \numdef\blx@maxsortnames@type{#1}} +\DeclareTypeOption[integer]{minsortnames}{% + \numdef\blx@minsortnames@type{#1}} +\DeclareEntryOption[integer]{maxsortnames}{} +\DeclareEntryOption[integer]{minsortnames}{} + \appto\blx@checkoptions@global{% \blx@maxmin@num{maxbibnames}{minbibnames}\blx@maxbibnames\blx@minbibnames - \blx@maxmin@num{maxcitenames}{mincitenames}\blx@maxcitenames\blx@mincitenames} + \blx@maxmin@num{maxcitenames}{mincitenames}\blx@maxcitenames\blx@mincitenames + \blx@maxmin@num{maxsortnames}{minsortnames}\blx@maxsortnames\blx@minsortnames} \appto\blx@checkoptions@type{% \blx@maxmin@num{maxbibnames}{minbibnames}\blx@maxbibnames@type\blx@minbibnames@type - \blx@maxmin@num{maxcitenames}{mincitenames}\blx@maxcitenames@type\blx@mincitenames@type} + \blx@maxmin@num{maxcitenames}{mincitenames}\blx@maxcitenames@type\blx@mincitenames@type + \blx@maxmin@num{maxsortnames}{minsortnames}\blx@maxsortnames@type\blx@minsortnames@type} \appto\blx@checkoptions@entry{% \blx@maxmin@cnt{maxnames}{minnames}\c@maxnames\c@minnames} @@ -13571,6 +14458,13 @@ \def\blx@opt@uniquename@mininit{5} \def\blx@opt@uniquename@minfull{6} +\DeclareBibliographyOption[boolean]{noroman}[true]{% + \settoggle{blx@noroman}{#1}} +\DeclareTypeOption[boolean]{noroman}[true]{% + \settoggle{blx@noroman}{#1}} +\DeclareEntryOption[boolean]{noroman}[true]{% + \settoggle{blx@noroman}{#1}} + \DeclareBibliographyOption[boolean]{singletitle}[true]{% \settoggle{blx@singletitle}{#1}} \DeclareTypeOption[boolean]{singletitle}[true]{% @@ -13606,81 +14500,96 @@ \DeclareBibliographyOption[boolean]{locallabelwidth}[true]{% \blx@key@locallabelwidth{#1}} +%{<switch>}{<patch>}{<pre>}{<post>} +\def\blx@patchsection@switch#1#2#3#4{% + \AtEndPreamble{% + #3% + \ifcase#1 + \or % 1: part + \blx@refpatch@part{#2}% + \or % 2: chapter + \blx@refpatch@chapter{#2}% + \or % 3: section + \blx@refpatch@sect{section}{#2}{1}% + \or % 4: subsection + \blx@refpatch@sect{subsection}{#2}{2}% + \or % 5: chapter+ = part, chapter + \blx@refpatch@part{#2}% + \blx@refpatch@chapter{#2}% + \or % 6: section+ = part, chapter, section + \blx@refpatch@part{#2}% + \ifundef\chapter + {} + {\blx@refpatch@chapter{#2}}% + \blx@refpatch@sect{section}{#2}{1}% + \or % 7: subsection+ = part, chapter, section, subsection + \blx@refpatch@part{#2}% + \ifundef\chapter + {} + {\blx@refpatch@chapter{#2}}% + \blx@refpatch@sect{section}{#2}{1}% + \blx@refpatch@sect{subsection}{#2}{2}% + \fi + #4% + }% +} + \DeclareBibliographyOption[string]{refsection}{% \ifcsdef{blx@opt@refsection@#1} {\letcs\blx@refsecreset@level{blx@opt@refsection@#1}} {\blx@err@invopt{refsection=#1}{}}} -\def\blx@opt@refsection@none{0} -\def\blx@opt@refsection@part{1} -\def\blx@opt@refsection@chapter{2} -\def\blx@opt@refsection@section{3} -\def\blx@opt@refsection@subsection{4} +\csdef{blx@opt@refsection@none}{0} +\csdef{blx@opt@refsection@part}{1} +\csdef{blx@opt@refsection@chapter}{2} +\csdef{blx@opt@refsection@section}{3} +\csdef{blx@opt@refsection@subsection}{4} +\csdef{blx@opt@refsection@chapter+}{5} +\csdef{blx@opt@refsection@section+}{6} +\csdef{blx@opt@refsection@subsection+}{7} -\AtEndPreamble{% - \ifcase\blx@refsecreset@level - \or % 1 - \blx@refpatch@part\newrefsection - \or % 2 - \blx@refpatch@chapter\newrefsection - \or % 3 - \blx@refpatch@sect{section}{\newrefsection}{1}% - \or % 4 - \blx@refpatch@sect{subsection}{\newrefsection}{2}% - \fi} +\blx@patchsection@switch{\blx@refsecreset@level}{\newrefsection}{}{} \DeclareBibliographyOption[string]{refsegment}{% \ifcsdef{blx@opt@refsegment@#1} {\letcs\blx@refsegreset@level{blx@opt@refsegment@#1}} {\blx@err@invopt{refsegment=#1}{}}} -\def\blx@opt@refsegment@none{0} -\def\blx@opt@refsegment@part{1} -\def\blx@opt@refsegment@chapter{2} -\def\blx@opt@refsegment@section{3} -\def\blx@opt@refsegment@subsection{4} - -\AtEndPreamble{% - \ifnumgreater\blx@refsegreset@level\z@ - {\ifnumgreater\blx@refsegreset@level\blx@refsecreset@level - {} - {\blx@err@confopt - {refsegment/refsection} - {The 'refsegment' option must point to a - lower-level\MessageBreak document division - than 'refsection'}% - \def\blx@refsegreset@level{0}}} - {}% - \ifcase\blx@refsegreset@level - \or % 1 - \blx@refpatch@part\newrefsegment - \or % 2 - \blx@refpatch@chapter\newrefsegment - \or % 3 - \blx@refpatch@sect{section}{\newrefsegment}{1}% - \or % 4 - \blx@refpatch@sect{subsection}{\newrefsegment}{2}% - \fi} +\csdef{blx@opt@refsegment@none}{0} +\csdef{blx@opt@refsegment@part}{1} +\csdef{blx@opt@refsegment@chapter}{2} +\csdef{blx@opt@refsegment@section}{3} +\csdef{blx@opt@refsegment@subsection}{4} +\csdef{blx@opt@refsegment@chapter+}{5} +\csdef{blx@opt@refsegment@section+}{6} +\csdef{blx@opt@refsegment@subsection+}{7} + +\blx@patchsection@switch{\blx@refsegreset@level} + {\newrefsegment} + {\ifnumgreater\blx@refsegreset@level\z@ + {\ifnumgreater\blx@refsegreset@level\blx@refsecreset@level + {} + {\blx@err@confopt + {refsegment/refsection} + {The 'refsegment' option must point to a + lower-level\MessageBreak document division + than 'refsection'}% + \def\blx@refsegreset@level{0}}} + {}} + {} \DeclareBibliographyOption[string]{citereset}{% \ifcsdef{blx@opt@citereset@#1} {\letcs\blx@citereset@level{blx@opt@citereset@#1}} {\blx@err@invopt{citereset=#1}{}}} -\def\blx@opt@citereset@none{0} -\def\blx@opt@citereset@part{1} -\def\blx@opt@citereset@chapter{2} -\def\blx@opt@citereset@section{3} -\def\blx@opt@citereset@subsection{4} +\csdef{blx@opt@citereset@none}{0} +\csdef{blx@opt@citereset@part}{1} +\csdef{blx@opt@citereset@chapter}{2} +\csdef{blx@opt@citereset@section}{3} +\csdef{blx@opt@citereset@subsection}{4} +\csdef{blx@opt@citereset@chapter+}{5} +\csdef{blx@opt@citereset@section+}{6} +\csdef{blx@opt@citereset@subsection+}{7} -\AtEndPreamble{% - \ifcase\blx@citereset@level - \or % 1 - \blx@refpatch@part{\citereset\blx@inf@creset}% - \or % 2 - \blx@refpatch@chapter{\citereset\blx@inf@creset}% - \or % 3 - \blx@refpatch@sect{section}{\citereset\blx@inf@creset}{1}% - \or % 4 - \blx@refpatch@sect{subsection}{\citereset\blx@inf@creset}{2}% - \fi} +\blx@patchsection@switch{\blx@citereset@level}{\citereset\blx@inf@creset}{}{} \DeclareBibliographyOption[boolean]{bibwarn}[true]{% \ifstrequal{#1}{true} @@ -13848,7 +14757,7 @@ {}% \def\do#1{% \ifcsstring{blx@dateformat@#1}{iso} - {\StrCut{#1}{date}\blx@datetype\blx@tempnull + {\blx@stripfromendinto{#1}{date}\blx@datetype \ifdefstring\blx@dateera{astronomical}{} {\blx@warn@conflopt{% '#1=iso' requires 'dateera=astronomical'.\MessageBreak @@ -13952,9 +14861,9 @@ \blx@checkencoding \if@filesw \blx@ctrlwrite - \blx@bblinput - \blx@maxsection\z@ \fi + \blx@bblinput + \blx@maxsection\z@ \csuse{abx@preamble}% \blx@inf@refsec \blx@inf@refseg} @@ -13976,4 +14885,6 @@ \blx@dopreamblecmds \let\do\noexpand}} +\def\BiblatexHungarianWarningOff{\global\let\lbx@hu@loadinfo\@empty} + \endinput |