Advertisement
Guest User

Broken biblatex version 2 :D

a guest
Apr 29th, 2019
45
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Latex 480.02 KB | None | 0 0
  1. % Copyright (c) 2006-2011 Philipp Lehman.
  2. %               2012-2017 Philip Kime, Audrey Boruvka, Joseph Wright
  3. %               2018- Philip Kime, Moritz Wemheuer
  4. %
  5. % Permission is granted to copy, distribute and/or modify this
  6. % software under the terms of the LaTeX Project Public License
  7. % (LPPL), version 1.3c.
  8. %
  9. % This software is provided 'as is', without warranty of any kind,
  10. % either expressed or implied, including, but not limited to, the
  11. % implied warranties of merchantability and fitness for a
  12. % particular purpose.
  13.  
  14. % Set up the version strings here
  15. \def\abx@date{2018/11/02}
  16. \def\abx@version{3.12}
  17. \def\abx@bbxid{\abx@date\space v\abx@version\space biblatex bibliography style (PK/MW)}
  18. \def\abx@cbxid{\abx@date\space v\abx@version\space biblatex citation style (PK/MW)}
  19. \def\abx@lbxid{\abx@date\space v\abx@version\space biblatex localization (PK/MW)}
  20. \def\abx@cptid{\abx@date\space v\abx@version\space biblatex compatibility (PK/MW)}
  21.  
  22. % This is not updated by build script as the control file version
  23. % does not necessarily change with the package version.
  24. % This is used when writing the .bcf
  25. \def\blx@bcfversion{3.5}
  26.  
  27. % This is not updated by build script as the bbl version
  28. % does not necessarily change with the package version.
  29. % This is used when checking the .bbl
  30. \def\blx@bblversion{3.0}
  31.  
  32. \NeedsTeXFormat{LaTeX2e}[2005/12/01]
  33. \ProvidesPackage{biblatex}
  34. [\abx@date\space v\abx@version\space programmable bibliographies (PK/MW)]
  35.  
  36. %% Dependencies
  37. \RequirePackage{pdftexcmds}[2018/01/30]
  38. \RequirePackage{etoolbox}
  39. \RequirePackage{keyval}
  40. \RequirePackage{kvoptions}
  41. \RequirePackage{logreq}
  42. \RequirePackage{ifthen}
  43. \RequirePackage{url}
  44. %\RequirePackage{trace}
  45.  
  46. \@ifpackagelater{etoolbox}{2010/11/29}
  47.  {}
  48.  {\PackageError{biblatex}
  49.     {Outdated 'etoolbox' package}
  50.     {Upgrade to etoolbox v2.1 (2010/11/29) or later.\MessageBreak
  51.      I found: '\csuse{ver@etoolbox.sty}'.\MessageBreak
  52.      This is a fatal error. I'm aborting now}%
  53.    \endinput}
  54.  
  55. % polyglossia pretends to be babel, so we need to make sure
  56. % we are definitely talking to babel here.
  57. \AtEndPreamble{%
  58.   \@ifpackageloaded{polyglossia}
  59.    {}
  60.    {\@ifpackageloaded{babel}
  61.       {\@ifpackagelater{babel}{2016/04/23}
  62.          {}
  63.          {\PackageError{biblatex}
  64.             {Outdated 'babel' package}
  65.             {Upgrade to babel 3.9r (2016/04/23) or later.\MessageBreak
  66.              I found: '\csuse{ver@babel.sty}'.\MessageBreak
  67.              This is a fatal error. I'm aborting now}%
  68.             \endinput}}
  69.        {}}}
  70.  
  71. %% Category codes
  72.  
  73. \def\blx@docatcodes{%
  74.   \do\=\do\<\do\>\do\-\do\"\do\'\do\`\do\.%
  75.   \do\,\do\;\do\:\do\!\do\?\do\/}
  76. \def\do#1{\catcode\number`#1=\the\catcode`#1\relax}
  77. \edef\blx@catcodes{\blx@docatcodes\do\^\do\~\do\&\do\|}
  78. \let\do\noexpand
  79.  
  80. \def\blx@saneccodes{%
  81.   \catcode`\~=\active
  82.   \let\do\@makeother
  83.   \blx@docatcodes
  84.   \let\do\noexpand}
  85.  
  86. \blx@saneccodes
  87. \catcode`\&=3
  88. \catcode`\|=3
  89. \catcode`\^=7
  90. \def\blx@nl{^^J}
  91.  
  92. \protected\def\blx@safe@actives{%
  93.   \let\blx@if@safe@actives\if@safe@actives
  94.   \let\if@safe@actives\iftrue}
  95.  
  96. \protected\def\blx@rest@actives{%
  97.   \let\if@safe@actives\blx@if@safe@actives}
  98.  
  99. %% Early errors and warnings
  100. \protected\def\blx@error#1#2{%
  101.   \begingroup
  102.   \blx@safe@actives
  103.   \PackageError{biblatex}{#1}{#2.}%
  104.   \endgroup}
  105.  
  106. \protected\def\blx@warning@noline#1{%
  107.   \begingroup
  108.   \blx@safe@actives
  109.   \PackageWarningNoLine{biblatex}{#1}%
  110.   \endgroup}
  111. \let\blx@warning\blx@warning@noline
  112. \AtEndOfPackage{%
  113.   \protected\def\blx@warning#1{%
  114.     \begingroup
  115.     \blx@safe@actives
  116.     \PackageWarning{biblatex}{#1}%
  117.     \endgroup}}
  118.  
  119. %% Compatibility
  120. \def\blx@packageincompatibility{%
  121.   \def\do##1{%
  122.     \@ifpackageloaded{##1}
  123.      {\ifcsundef{blx@pkgloaded@##1}
  124.         {\global\cslet{blx@pkgloaded@##1}\@empty
  125.          \blx@error
  126.            {Incompatible package '##1'}
  127.            {The '##1' package and biblatex are incompatible}}
  128.         {}}
  129.      {}}%
  130.   \docsvlist{%
  131.     amsrefs,apacite,babelbib,backref,bibtopic,bibunits,chapterbib,
  132.     cite,citeref,drftcite,footbib,inlinebib,jurabib,mcite,mciteplus,
  133.     mlbib,multibbl,multibib,natbib,opcit,overcite,splitbib,ucs}%
  134.   % etextools is special, it gets an option to demote the error to a warning
  135.   % remind people to restore \forlistloop
  136.   \ifcsdef{blx@noerroretextools}
  137.    {\@ifpackageloaded{etextools}
  138.       {\ifcsundef{blx@pkgloaded@etextools}
  139.          {\global\cslet{blx@pkgloaded@etextools}\@empty
  140.            \blx@warning@noline{%
  141.              Incompatible package 'etextools' loaded,\MessageBreak
  142.              no error is thrown because you defined\MessageBreak
  143.              '\string\blx@noerroretextools'.\MessageBreak
  144.              'etextools' redefines '\string\forlistloop', you must\MessageBreak
  145.              restore the definition from 'etoolbox'\MessageBreak
  146.              before you load biblatex}}
  147.           {}}
  148.       {}}
  149.    {\@ifpackageloaded{etextools}
  150.       {\ifcsundef{blx@pkgloaded@etextools}
  151.          {\global\cslet{blx@pkgloaded@etextools}\@empty
  152.           \blx@error
  153.             {Incompatible package 'etextools'}
  154.              {The 'etextools' package and biblatex are
  155.               incompatible.\MessageBreak
  156.               If you must load 'etextools' at all costs, define the command%
  157.               \MessageBreak '\string\blx@noerroretextools'}}
  158.           {}}
  159.       {}}}
  160.  
  161. % Call this right here, almost immediately after loading to give sensible
  162. % errors for incompatibilities that arise at loading-time.
  163. % The macro is called again a second time in \AtEndPreamble when all packages
  164. % should be loaded.
  165. % This still can't catch all cases, \usepackage{biblatex}\usepackage{natbib}
  166. % still gives a weird error.
  167. \blx@packageincompatibility
  168.  
  169. % people should not be abusing noerroretextools, so warn if it is not needed
  170. \def\blx@packageincompatibility@endpreambleonly{%
  171.   \ifcsdef{blx@noerroretextools}
  172.    {\@ifpackageloaded{etextools}
  173.       {}
  174.        {\blx@warning@noline{%
  175.           You defined '\string\blx@noerroretextools',\MessageBreak
  176.           but 'etextools' is not loaded.\MessageBreak
  177.           Please do not define '\string\blx@noerroretextools'\MessageBreak
  178.           unless you really need it}}}
  179.     {}}
  180.  
  181. \begingroup
  182. \catcode`\#=12
  183. \gdef\blx@patchbidifootnotes{%
  184.   \patchcmd\@footnotetext
  185.     {#1}
  186.    {\toggletrue{blx@footnote}#1}
  187.    {\togglefalse{blx@tempa}}
  188.    {}%
  189.   \patchcmd\@LTRfootnotetext
  190.     {#1}
  191.    {\toggletrue{blx@footnote}#1}
  192.    {\togglefalse{blx@tempa}}
  193.    {}%
  194.   \patchcmd\@RTLfootnotetext
  195.     {#1}
  196.    {\toggletrue{blx@footnote}#1}
  197.    {\togglefalse{blx@tempa}}
  198.    {}}
  199. \endgroup
  200.  
  201. \AtEndPreamble{%
  202.   \blx@packageincompatibility
  203.   \blx@packageincompatibility@endpreambleonly
  204.   \def\blx@langstrings{}%
  205.   % Set up sortlocale defaults and default language if babel/polyglossia is not loaded
  206.   \ifdefstring\blx@sortlocale{auto}
  207.     {\ifdef\bbl@main@language% babel or polyglossia is loaded
  208.       {\edef\blx@sortlocale{\bbl@main@language}}
  209.      {\def\blx@sortlocale{english}}}
  210.    {}%
  211.   \@ifpackageloaded{polyglossia}
  212.     {% This is required for languages which are never explicitly selected
  213.      % This check because \xpg@loaded is not defined in polyglossia <= v1.42.0
  214.      \ifundef\xpg@loaded
  215.        {\let\xpg@loaded\@empty
  216.        \let\xpg@vloaded\@empty
  217.        \blx@warning@noline{Upgrade package 'polyglossia' to > v1.42.0 recommended}}
  218.       {}%
  219.      \def\do#1{\blx@langsetup{#1}}%
  220.      \expandafter\docsvlist\expandafter{\xpg@loaded}%
  221.      \expandafter\docsvlist\expandafter{\xpg@vloaded}%
  222.      \ifboolexpr{
  223.      not togl {blx@autolangbib}
  224.      and
  225.      not togl {blx@autolangcite}}
  226.       {\blx@mknoautolang}
  227.       {\blx@mkautolangpoly}}
  228.    {\@ifpackageloaded{babel}
  229.       {% This is required for languages which are never explicitly selected
  230.        \def\do#1{\blx@langsetup{#1}}%
  231.        \expandafter\docsvlist\expandafter{\bbl@loaded}%
  232.        \ifboolexpr{
  233.        not togl {blx@autolangbib}
  234.        and
  235.        not togl {blx@autolangcite}}
  236.         {\blx@mknoautolang}
  237.         {\blx@mkautolangbabel}}
  238.      {\blx@mknoautolang}}%
  239.   % These already have defaults set to basically do nothing
  240.   % so if the toggles are true, we need to define again since
  241.   % mkautolang* redefines \blx@beglang
  242.   % In turn, \blx@beglang defines \blx@endlang and so \blx@beglangcite and
  243.   % \blx@endlangcite need redefining inside \blx@beglang after \blx@endlang
  244.   % has been defined.
  245.   \iftoggle{blx@autolangbib}
  246.    {\let\blx@beglangbib\blx@beglang}
  247.    {}%
  248.   \iftoggle{blx@autolangcite}
  249.    {\let\blx@beglangcite\blx@beglang}
  250.    {}%
  251.   \csuse{abx@extras@\blx@languagename}%
  252.   \csuse{abx@strings@\blx@languagename}%
  253.   \undef\blx@mkautolangbabel
  254.   \undef\blx@mkautolangpoly
  255.   \undef\blx@mknoautolang
  256.   \ifnum\blx@hyperref=\thr@@
  257.   \else
  258.     \ifnum\blx@hyperref=\z@
  259.       \blx@mknohyperref
  260.     \else
  261.       \@ifpackageloaded{hyperref}
  262.        {\blx@mkhyperref}
  263.         {\ifnum\blx@hyperref=\@ne
  264.            \blx@warning@noline{%
  265.              Missing 'hyperref' package.\MessageBreak
  266.              Setting 'hyperref=false'}%
  267.          \fi
  268.          \blx@mknohyperref}%
  269.     \fi
  270.     \undef\blx@mkhyperref
  271.     \undef\blx@mknohyperref
  272.   \fi
  273.   \providecommand*{\nolinkurl}{\url}%
  274.   \ifundef\TE@hook
  275.     {\let\TE@hook\@empty
  276.     \toggletrue{blx@tempa}%
  277.      \def\do#1{%
  278.        \patchcmd#1%
  279.          {\let\isundefined\TE@undef}
  280.         {\let\isundefined\TE@undef\TE@hook}
  281.         {\togglefalse{blx@tempa}\listbreak}
  282.         {}}%
  283.      \docsvlist{%
  284.        \ifthenelse,%          ifthen
  285.        \org@ifthenelse,%      babel
  286.        \HyOrg@ifthenelse,%    hyperref
  287.        \NROrg@ifthenelse}%    nameref
  288.      \iftoggle{blx@tempa}
  289.       {\blx@err@patch{'ifthen' package}}
  290.       {}}
  291.    {}%
  292.   \appto\TE@hook{\blx@TE@hook}%
  293.   \toggletrue{blx@tempa}%
  294.   \def\do#1{%
  295.     \patchcmd#1%
  296.       {\color@begingroup}
  297.      {\color@begingroup\toggletrue{blx@footnote}}
  298.      {\togglefalse{blx@tempa}\listbreak}
  299.      {}}%
  300.   \docsvlist{%
  301.     \@footnotetext,%          latex
  302.     \H@@footnotetext,%        hyperref
  303.     \V@@footnotetext,%        fancyvrb
  304.     \scr@saved@footnotetext,% koma-script 3.x
  305.     \l@dold@footnotetext,%    ledmac
  306.     \l@doldold@footnotetext,% ledmac
  307.     \predefinedfootnotetext,% linguex
  308.     \@fntORI}%                frenchle
  309.   \iftoggle{blx@tempa}%       ams classes ...
  310.     {\def\do#1{%
  311.        \patchcmd#1
  312.          {\@makefntext}
  313.         {\toggletrue{blx@footnote}\@makefntext}
  314.         {\togglefalse{blx@tempa}}
  315.         {}}%
  316.      \docsvlist{\@footnotetext,%    ams classes standard
  317.                 \H@@footnotetext}}% hyperref
  318.     {}%
  319.   \@ifpackageloaded{bidi}%    bidi
  320.     {\blx@patchbidifootnotes}
  321.    {}%
  322.   \@ifclassloaded{memoir}
  323.     {\def\do#1{%
  324.        \patchcmd#1%
  325.          {\color@begingroup}
  326.         {\color@begingroup\toggletrue{blx@footnote}}
  327.         {}
  328.         {}}%
  329.      \docsvlist{%
  330.        \m@mold@footnotetext,%
  331.        \@plainfootnotetext,%
  332.        \@twocolfootnotetext,%
  333.        \@threecolfootnotetext,%
  334.        \@parafootnotetext}%
  335.      \def\do#1{%
  336.        \patchcmd#1%
  337.          {\color@begingroup\@makefntext}
  338.         {\color@begingroup\toggletrue{blx@footnote}\@makefntext}
  339.         {}
  340.         {}}%
  341.      \docsvlist{%
  342.        \@footnotetext,% patch twice
  343.        \H@@footnotetext,% patch twice
  344.        \@plainfootnotetext}}
  345.     {}%
  346.   \@ifclassloaded{beamer}
  347.    {\expandafter\patchcmd\csname beamerx@\string\beamer@framefootnotetext\endcsname
  348.       {\color@begingroup}
  349.       {\color@begingroup\toggletrue{blx@footnote}}
  350.       {\togglefalse{blx@tempa}}
  351.       {}%
  352.      \expandafter\patchcmd\csname beamerx@\string\@mpfootnotetext\endcsname
  353.        {\color@begingroup}
  354.       {\color@begingroup\toggletrue{blx@footnote}}
  355.       {}
  356.       {}}
  357.    {}%
  358.   \iftoggle{blx@tempa}
  359.     {\blx@warning@noline{%
  360.        Patching footnotes failed.\MessageBreak
  361.        Footnote detection will not work}}
  362.     {}%
  363.   \def\do#1{%
  364.     \patchcmd#1%
  365.       {\color@begingroup}
  366.      {\color@begingroup\toggletrue{blx@footnote}}
  367.      {\listbreak}
  368.      {}}%
  369.   \docsvlist{%
  370.     \@mpfootnotetext,%        minipages
  371.     \H@@mpfootnotetext}%      hyperref minipages
  372.   \@ifpackageloaded{endnotes}
  373.    {\patchcmd\theendnotes
  374.       {\enoteformat}
  375.       {\toggletrue{blx@footnote}\enoteformat}
  376.       {}
  377.       {\blx@err@patch{'endnotes' package}}}
  378.    {}%
  379.   \@ifpackageloaded{bigfoot}
  380.    {\apptocmd\@makefnstartbox
  381.       {\toggletrue{blx@footnote}}
  382.       {}
  383.       {\blx@err@patch{'bigfoot' package}}}
  384.    {}%
  385.   \@ifpackageloaded{showkeys}
  386.    {\ifdef\SK@
  387.       {\AtEveryBibitem{\SK@\SK@@label{\thefield{entrykey}}}%
  388.         \AtEveryLositem{\SK@\SK@@label{\thefield{entrykey}}}%
  389.         \ifundef\SK@cite % = 'notcite' disabled
  390.           {\AtEveryCitekey{\SK@\SK@@ref{\thefield{entrykey}}}}
  391.          {}}
  392.       {}}
  393.    {}%
  394.   \apptocmd\@floatboxreset
  395.     {\boolfalse{citetracker}%
  396.      \boolfalse{pagetracker}}
  397.    {}
  398.    {\blx@err@patch{floats}}%
  399.   \ifdef\TX@endtabularx % tabularx/memoir
  400.     {\pretocmd\TX@endtabularx
  401.      {\addtocounter{tabx@nest}{1}}% track nested tabularx environments
  402.       {}
  403.      {\blx@err@patch{'tabularx'}}%
  404.       % no need to conditionalise on top-level tabx as the search/replace
  405.       % will only match once anyway
  406.      \patchcmd\TX@endtabularx
  407.       {\edef\TX@ckpt{\cl@@ckpt}}
  408.      {\edef\TX@ckpt{\cl@@ckpt\abx@resttrackers}%
  409.        \abx@savetrackers}
  410.       {}
  411.      {\blx@err@patch{'tabularx'}}%
  412.      \apptocmd\TX@endtabularx
  413.       {\ifnum\value{tabx@nest}=1% only clear trackers for top-level tabularx
  414.          \abx@cleartrackers
  415.        \fi
  416.        \addtocounter{tabx@nest}{-1}}
  417.      {}
  418.      {\blx@err@patch{'tabularx'}}}
  419.    {}%
  420.   \@ifpackageloaded{csquotes}
  421.    {\@ifpackagelater{csquotes}{2009/05/30}
  422.       {}
  423.       {\blx@error
  424.          {Outdated 'csquotes' package}
  425.          {Upgrade to csquotes v4.4 (2009/05/30) or later.\MessageBreak
  426.           I found: '\csuse{ver@csquotes.sty}'}}%
  427.      \BlockquoteDisable{\let\blx@thecheckpunct\@gobble}%
  428.      \@ifpackagelater{csquotes}{2009/08/27}
  429.       {\appto\@blockquote@prehook{\abx@savetrackers}%
  430.         \appto\@blockquote@posthook{\abx@resttrackers\abx@cleartrackers}}
  431.       {}%
  432.      \@ifpackagelater{csquotes}{2010/06/09}
  433.       {}
  434.       {\newcommand*{\@quotereset}{}\newcount\@quotereset}%
  435.      \newcommand*{\blx@initoquote}{\initoquote}%
  436.      \newcommand*{\blx@textooquote}{\textooquote}%
  437.      \newcommand*{\blx@textcoquote}{\textcoquote}%
  438.      \newcommand*{\blx@initiquote}{\initiquote}%
  439.      \newcommand*{\blx@textoiquote}{\textoiquote}%
  440.      \newcommand*{\blx@textciquote}{\textciquote}%
  441.      \newcommand*{\blx@enquote}{\enquote}}
  442.    {\@ifpackageloaded{babel}
  443.        {\blx@warning@noline{%
  444.           'babel/polyglossia' detected but 'csquotes' missing.\MessageBreak
  445.           Loading 'csquotes' recommended}}
  446.        {}%
  447.      \newcommand*{\@quotelevel}{}%
  448.      \newcount\@quotelevel
  449.      \newcommand*{\@quotereset}{}%
  450.      \newcount\@quotereset
  451.      \newcommand*{\@setquotesfcodes}{}%
  452.      \let\@setquotesfcodes\relax
  453.      \newrobustcmd*{\blx@initoquote}{\@quotelevel\@ne}%
  454.      \newrobustcmd*{\blx@initiquote}{\@quotelevel\tw@}%
  455.      \newrobustcmd*{\blx@textooquote}{``}%
  456.      \newrobustcmd*{\blx@textcoquote}{''}%
  457.      \newrobustcmd*{\blx@textoiquote}{`\relax}% block ligs
  458.      \newrobustcmd*{\blx@textciquote}{'\relax}% block ligs
  459.      \newrobustcmd*{\blx@enquote}
  460.       {\@ifstar\blx@enquote@iii\blx@enquote@i}%
  461.      \def\blx@enquote@i{%
  462.        \ifnum\@quotelevel>\z@
  463.          \expandafter\blx@enquote@iii
  464.        \else
  465.          \expandafter\blx@enquote@ii
  466.        \fi}%
  467.      \long\def\blx@enquote@ii#1{%
  468.        \begingroup\blx@initoquote
  469.        \blx@textooquote#1\blx@textcoquote
  470.        \endgroup}%
  471.      \long\def\blx@enquote@iii#1{%
  472.        \begingroup\blx@initiquote
  473.        \blx@textoiquote#1\blx@textciquote
  474.        \endgroup}%
  475.      \appto\blx@setsfcodes{%
  476.        \sfcode`\`=\z@
  477.        \sfcode`\'=\z@}}%
  478.   \let\do\noexpand}
  479.  
  480. \begingroup
  481. \@makeother\#
  482. % \relax: gobble newline -> titletoc.sty
  483. \AtEndPreamble{%
  484.   \addtocontents{toc}{%
  485.      \boolfalse{citerequest}%
  486.      \boolfalse{citetracker}%
  487.      \boolfalse{pagetracker}%
  488.      \boolfalse{backtracker}\relax}%
  489.   \addtocontents{lof}{%
  490.      \boolfalse{citerequest}%
  491.      \boolfalse{citetracker}%
  492.      \boolfalse{pagetracker}%
  493.      \boolfalse{backtracker}\relax}%
  494.   \addtocontents{lot}{%
  495.      \boolfalse{citerequest}%
  496.      \boolfalse{citetracker}%
  497.      \boolfalse{pagetracker}%
  498.      \boolfalse{backtracker}\relax}%
  499.   \patchcmd\addtocontents
  500.     {\string\@writefile}
  501.    {\string\@writefile{#1}{\defcounter{refsection}{\the\c@refsection}\relax}%
  502.      \string\@writefile}
  503.     {}
  504.    {\blx@err@patch{\string\addtocontents}}}
  505. \endgroup
  506.  
  507. % trick hyperref into believing we're natbib
  508. \let\NAT@parse\@empty
  509. % trick showkeys into believing we're havard
  510. \let\HAR@checkdef\@empty
  511.  
  512. \providecommand{\@gobblefive}[5]{}
  513.  
  514. \ifundef\pdf@mdfivesum
  515.  {\let\blx@mdfivesum\@firstofone
  516.   \blx@warning@noline{Command '\string\pdf@mdfivesum' undefined.\MessageBreak
  517.     'labelprefix' may not be able to accept all input}}
  518.  {\let\blx@mdfivesum\pdf@mdfivesum}
  519.  
  520.  
  521. % xstring replacements
  522.  
  523. % reverse a given string
  524. % idea by egreg (https://tex.stackexchange.com/users/4427/egreg)
  525. % from https://tex.stackexchange.com/q/36034/
  526. % relicensed under LPPL according to
  527. % https://tex.meta.stackexchange.com/a/3333/
  528. \def\blx@revstr#1{%
  529.   \ifblank{#1}
  530.    {}
  531.    {\blx@revstr@l #1\blx@revstr@b@i\blx@revstr@b@ii}}
  532.  
  533. \def\blx@revstr@l#1#2\blx@revstr@b@i#3\blx@revstr@b@ii{%
  534.   \ifblank{#2}
  535.    {#1#3}
  536.    {\blx@revstr@l#2\blx@revstr@b@i#1#3\blx@revstr@b@ii}}
  537.  
  538. % these tests are inspired by Stephan v. Bechtolsheim's TUGboat article
  539. % https://www.tug.org/TUGboat/tb09-1/tb20bechtolsheim.pdf
  540. % but we need to test for start and end and not for generic substring
  541. % start is easy, delimited arguments help there
  542. \protected\def\blx@ifstrstartswith#1#2{%
  543.   \def\blx@ifstrstartswith@i ##1#2##2&{%
  544.     \ifblank{##1}}%
  545.   \blx@ifstrstartswith@i #1#2&}
  546.  
  547. % end is harder, so we reverse everything and apply the start test
  548. \protected\def\blx@ifstrendswith#1#2{%
  549.   \begingroup
  550.   \edef\blx@tempa{\endgroup
  551.    \noexpand\blx@ifstrstartswith{\blx@revstr{#1}}{\blx@revstr{#2}}}%
  552.   \blx@tempa}
  553.  
  554. % not expandable, so write the result to the macro given in #3
  555. % {<string>}{<strip>}{<result>}
  556. % <result> will contain the bit of <string>
  557. % after the first occurrence of <strip>
  558. \protected\def\blx@stripfromstartinto#1#2#3{%
  559.   \def\blx@stripfromstart@i ##1#2##2&{%
  560.     \def#3{##2}}%
  561.   \blx@stripfromstart@i #1&}
  562.  
  563. % {<string>}{<strip>}{<result>}
  564. % <result> will contain the bit of <string>
  565. % before the last occurence of <strip>
  566. \protected\def\blx@stripfromendinto#1#2#3{%
  567.   \begingroup
  568.   \edef\blx@tempa{\endgroup
  569.    \noexpand\blx@stripfromstartinto{\blx@revstr{#1}}{\blx@revstr{#2}}}%
  570.   \blx@tempa{#3}%
  571.   \edef#3{\noexpand\blx@revstr{#3}}%
  572.   \edef#3{#3}}
  573.  
  574. %% Allocation
  575.  
  576. % Counter to track nested tabularx environemnts so we don't
  577. % try to patch the commands more than once below as this undefs some
  578. % macros and an error is thrown
  579. \newcounter{tabx@nest}
  580. \setcounter{tabx@nest}{0}
  581.  
  582. \newcounter{listtotal}
  583. \def\thelisttotal{\the\c@listtotal}
  584. \newcounter{listcount}
  585. \def\thelistcount{\the\c@listcount}
  586. \newcounter{liststart}
  587. \def\theliststart{\the\c@liststart}
  588. \newcounter{liststop}
  589. \def\theliststop{\the\c@liststop}
  590. \newcounter{citecount}
  591. \def\thecitecount{\the\c@citecount}
  592. \newcounter{citetotal}
  593. \def\thecitetotal{\the\c@citetotal}
  594. \newcounter{multicitecount}
  595. \def\themulticitecount{\the\c@multicitecount}
  596. \newcounter{multicitetotal}
  597. \def\themulticitetotal{\the\c@multicitetotal}
  598. \newcounter{overallcitecount}
  599. \def\theoverallcitecount{\the\c@overallcitecount}
  600. \newcounter{overallcitetotal}
  601. \def\theoverallcitetotal{\the\c@overallcitetotal}
  602. \newcounter{instcount}
  603. \def\theinstcount{\the\c@instcount}
  604. \newcounter{maxnames}
  605. \def\themaxnames{\the\c@maxnames}
  606. \newcounter{minnames}
  607. \def\theminnames{\the\c@minnames}
  608. \newcounter{maxitems}
  609. \def\themaxitems{\the\c@maxitems}
  610. \newcounter{minitems}
  611. \def\theminitems{\the\c@minitems}
  612. \newcounter{citecounter}
  613. \def\thecitecount{\the\c@citecounter}
  614. \newcounter{maxcitecounter}
  615. \def\themaxcitecounter{\the\c@maxcitecounter}
  616. \newcounter{savedcitecounter}
  617. \def\thecitecount{\the\c@savedcitecounter}
  618. \newcounter{uniquelist}
  619. \def\theuniquelist{\the\c@uniquelist}
  620. \newcounter{uniquename}
  621. \def\theuniquename{\the\c@uniquename}
  622. \newcounter{refsection}
  623. \def\therefsection{\the\c@refsection}
  624. \newcounter{refsegment}
  625. \def\therefsegment{\the\c@refsegment}
  626. \newcounter{maxextratitle}
  627. \def\themaxextratitle{\the\c@maxextratitle}
  628. \newcounter{maxextratitleyear}
  629. \def\themaxextratitleyear{\the\c@maxextratitleyear}
  630. \newcounter{maxextraname}
  631. \def\themaxextraname{\the\c@maxextraname}
  632. \newcounter{maxextradate}
  633. \def\themaxextradate{\the\c@maxextradate}
  634. \newcounter{maxextraalpha}
  635. \def\themaxextraalpha{\the\c@maxextraalpha}
  636. \newcounter{abbrvpenalty}
  637. \def\theabbrvpenalty{\the\c@abbrvpenalty}
  638. \newcounter{highnamepenalty}
  639. \def\thehighnamepenalty{\the\c@highnamepenalty}
  640. \newcounter{lownamepenalty}
  641. \def\thelownamepenalty{\the\c@lownamepenalty}
  642. \newcounter{maxparens}
  643. \def\themaxparens{\the\c@maxparens}
  644. \newcounter{parenlevel}
  645. \def\theparenlevel{\the\c@parenlevel}
  646.  
  647. \newcount\blx@tempcnta
  648. \newcount\blx@tempcntb
  649. \newcount\blx@tempcntc
  650. \newcount\blx@maxsection
  651. \expandafter\newcount\csname blx@maxsegment@0\endcsname
  652. \newcount\blx@notetype
  653. \newcount\blx@parenlevel@text
  654. \newcount\blx@parenlevel@foot
  655. \expandafter\newcount\csname blx@sectionciteorder@0\endcsname
  656. \newcount\blx@entrysetcounter
  657.  
  658.  
  659. \def\blx@uniquename{0}
  660. \def\blx@uniquelist{0}
  661. \def\blx@maxbibnames{0}
  662. \def\blx@minbibnames{0}
  663. \def\blx@maxcitenames{0}
  664. \def\blx@mincitenames{0}
  665. \def\blx@maxsortnames{0}
  666. \def\blx@minsortnames{0}
  667. \def\blx@maxbibnames@type{\blx@maxbibnames}
  668. \def\blx@minbibnames@type{\blx@minbibnames}
  669. \def\blx@maxcitenames@type{\blx@maxcitenames}
  670. \def\blx@mincitenames@type{\blx@mincitenames}
  671. \def\blx@maxsortnames@type{\blx@maxsortnames}
  672. \def\blx@minsortnames@type{\blx@minsortnames}
  673. \def\blx@maxalphanames{0}
  674. \def\blx@minalphanames{0}
  675. \def\blx@maxitems{0}
  676. \def\blx@minitems{0}
  677. \def\blx@maxitems@type{\blx@maxitems}
  678. \def\blx@minitems@type{\blx@minitems}
  679.  
  680. \newlength{\labelnumberwidth}
  681. \newlength{\labelalphawidth}
  682. \newlength{\biblabelsep}
  683. \ifdef\bibitemsep % memoir
  684.   {}
  685.  {\newlength{\bibitemsep}}
  686. \newlength{\bibnamesep}
  687. \newlength{\bibinitsep}
  688. \newlength{\bibparsep}
  689. \newlength{\bibhang}
  690.  
  691. \newbool{refcontextdefaults}
  692. \booltrue{refcontextdefaults}%
  693. \newbool{sourcemap}
  694. \newbool{citetracker}
  695. \newbool{pagetracker}
  696. \newbool{backtracker}
  697. \newbool{citerequest}
  698. \booltrue{citerequest}
  699. \newbool{sortcites}
  700.  
  701. \newtoggle{blx@bbldone}
  702. \newtoggle{blx@tempa}
  703. \newtoggle{blx@tempb}
  704. \newtoggle{blx@runltx}
  705. \newtoggle{blx@runbiber}
  706. \newtoggle{blx@block}
  707. \newtoggle{blx@unit}
  708. \newtoggle{blx@skipentry}
  709. \newtoggle{blx@insert}
  710. \newtoggle{blx@lastins}
  711. \newtoggle{blx@keepunit}
  712. \newtoggle{blx@bibtex}
  713. \newtoggle{blx@debug}
  714. \newtoggle{blx@sortcase}
  715. \newtoggle{blx@sortupper}
  716. \newtoggle{blx@autolangbib}
  717. \newtoggle{blx@autolangcite}
  718. \newtoggle{blx@clearlang}
  719. \newtoggle{blx@defernumbers}
  720. \newtoggle{blx@omitnumbers}
  721. \newtoggle{blx@footnote}
  722. \newtoggle{blx@labelalpha}
  723. \newtoggle{blx@labelnumber}
  724. \newtoggle{blx@labeltitle}
  725. \newtoggle{blx@labeltitleyear}
  726. \newtoggle{blx@labeldateparts}
  727. \newtoggle{blx@natbib}
  728. \newtoggle{blx@noroman}
  729. \newtoggle{blx@mcite}
  730. \newtoggle{blx@loadfiles}
  731. \newtoggle{blx@singletitle}
  732. \newtoggle{blx@sortsets}
  733. \newtoggle{blx@crossrefsource}
  734. \newtoggle{blx@xrefsource}
  735. \newtoggle{blx@uniqueprimaryauthor}
  736. \newtoggle{blx@uniquetitle}
  737. \newtoggle{blx@uniquebaretitle}
  738. \newtoggle{blx@uniquework}
  739. \newtoggle{blx@terseinits}
  740. \newtoggle{blx@useprefix}
  741. \newtoggle{blx@addset}
  742. \newtoggle{blx@setonly}
  743. \newtoggle{blx@dataonly}
  744. \newtoggle{blx@skipbib}
  745. \newtoggle{blx@skipbiblist}
  746. \newtoggle{blx@skiplab}
  747. \newtoggle{blx@citation}
  748. \newtoggle{blx@bibliography}
  749. \newtoggle{blx@citeindex}
  750. \newtoggle{blx@bibindex}
  751. \newtoggle{blx@localnumber}
  752. \newtoggle{blx@refcontext}
  753.  
  754. \newcommand*{\blx@xifstrequal}[2]{%
  755.   \begingroup
  756.   \edef\blx@tempa{%
  757.     \endgroup
  758.     \noexpand\ifstrequal{#1}{#2}}%
  759.   \blx@tempa}
  760.  
  761. % Special fields which need resolution using the information provided by biber
  762. \listadd\abx@rfields{labeltitle}
  763. \def\abx@dorfields{%
  764.   \dolistloop\abx@rfields%
  765. }
  766. \listadd\abx@rnames{labelname}
  767. \def\abx@dornames{%
  768.   \dolistloop\abx@rnames%
  769. }
  770.  
  771. % Used to track default refcontexts for citations
  772. \cslet{blx@defaultrefcontexts@0}\@empty
  773. \listadd\blx@allrefsections{0}
  774.  
  775. % Used to track sorting name key specifications
  776. \global\let\blx@sortingnamekeytemplates\@empty
  777.  
  778. % Used to track uniquename templates
  779. \global\let\blx@untemplatespecs\@empty
  780.  
  781. % Used to track labelalphaname templates
  782. \global\let\blx@lantemplatespecs\@empty
  783.  
  784. % Used to track transliterations
  785. \global\let\blx@translits\@empty
  786.  
  787. % Use to track every entry found in .bbl
  788. % Used to issue defernumbers warning about missing keys because this causes
  789. % defernumbers labelling to fail.
  790. \global\let\blx@entries\@empty
  791.  
  792. % Initialise some lists which track changing citations/sortingtemplates
  793. % etc. between runs
  794. \global\let\blx@cites\@empty
  795. \global\let\blx@nocites\@empty
  796. \global\let\blx@directcites\@empty
  797. \global\let\blx@refcontexts\@empty
  798. \global\let\blx@lastrefcontexts\@empty
  799. \global\let\blx@sortingtemplatenames\@empty
  800. \global\let\blx@dlistnames\@empty
  801. \global\let\blx@biblists\@empty
  802. \global\let\blx@lastbiblists\@empty
  803. \global\let\blx@lastcites\@empty
  804. \global\let\blx@localnumaux\@empty
  805.  
  806. \newread\blx@bcfin
  807. \newwrite\blx@bcfout
  808.  
  809. \def\blx@onlypreamble#1{%
  810.   \gappto\blx@dopreamblecmds{\do#1}}
  811.  
  812. \def\blx@dopreamblecmds{%
  813.   \do\blx@dopreamblecmds
  814.   \do\blx@onlypreamble}
  815.  
  816. % Deprecations
  817. \newrobustcmd*{\DeprecateField}[2]{%
  818.   \csdef{abx@field@#1}{%
  819.     \ifcsundef{abx@legacywarning@field@#1}
  820.      {\blx@warning@noline{Field '#1' is deprecated. #2}}
  821.      {}%
  822.     \global\cslet{abx@legacywarning@field@#1}\@empty}}%
  823. \newrobustcmd*{\DeprecateList}[2]{%
  824.   \csdef{abx@list@#1}{%
  825.     \ifcsundef{abx@legacywarning@list@#1}
  826.      {\blx@warning@noline{List '#1' is deprecated. #2}}
  827.      {}%
  828.     \global\cslet{abx@legacywarning@list@#1}\@empty}}
  829. \newrobustcmd*{\DeprecateName}[2]{%
  830.   \csdef{abx@name@#1}{%
  831.     \ifcsundef{abx@legacywarning@name@#1}
  832.      {\blx@warning@noline{Name '#1' is deprecated. #2}}
  833.      {}%
  834.     \global\cslet{abx@legacywarning@name@#1}\@empty}}
  835.  
  836. \let\blx@aliasfields\@empty
  837.  
  838. \newrobustcmd*{\DeprecateFieldWithReplacement}[2]{%
  839.   \appto\blx@aliasfields{%
  840.     \ifcsundef{abx@field@#2}
  841.      {}
  842.      {\csdef{abx@field@#1}{%
  843.          \csuse{abx@field@#2}%
  844.          \ifcsundef{abx@legacywarning@field@#1}
  845.           {\blx@warning@noline{Field '#1' is deprecated.\MessageBreak
  846.              Please use '#2' instead.\MessageBreak
  847.              Using '#2' now}}
  848.           {}%
  849.          \global\cslet{abx@legacywarning@field@#1}\@empty}}}}
  850.  
  851. \newrobustcmd*{\DeprecateListWithReplacement}[2]{%
  852.   \appto\blx@aliasfields{%
  853.     \ifcsundef{abx@list@#2}
  854.      {}
  855.      {\csdef{abx@list@#1}{%
  856.          \csuse{abx@list@#2}%
  857.          \ifcsundef{abx@legacywarning@list@#1}
  858.           {\blx@warning@noline{List '#1' is deprecated.\MessageBreak
  859.              Please use '#2' instead.\MessageBreak
  860.              Using '#2' now}}
  861.           {}%
  862.          \global\cslet{abx@legacywarning@list@#1}\@empty}}}}
  863.  
  864. \newrobustcmd*{\DeprecateNameWithReplacement}[2]{%
  865.   \appto\blx@aliasfields{%
  866.     \ifcsundef{abx@name@#2}
  867.      {}
  868.      {\csdef{abx@name@#1}{%
  869.          \csuse{abx@name@#2}%
  870.          \ifcsundef{abx@legacywarning@name@#1}
  871.           {\blx@warning@noline{Name '#1' is deprecated.\MessageBreak
  872.              Please use '#2' instead.\MessageBreak
  873.              Using '#2' now}}
  874.           {}%
  875.          \global\cslet{abx@legacywarning@name@#1}\@empty}}}}
  876.  
  877. %% Initialisation
  878. \def\blx@blxinit{%
  879.   \let\blx@blxinit\relax
  880.   \blx@initunit}
  881.  
  882. \def\blx@secinit{%
  883.   \csgdef{blx@sections@\the\c@refsection}{true}% just to say we have a section for tests later
  884.   \ifcsundef{blx@bsee@\the\c@refsection}
  885.    {\global\cslet{blx@bsee@\the\c@refsection}\@empty}
  886.    {}%
  887.   \ifcsundef{blx@fsee@\the\c@refsection}
  888.    {\global\cslet{blx@fsee@\the\c@refsection}\@empty}
  889.    {}%
  890.   \blx@ibidreset@force
  891.   \blx@idemreset@force
  892.   \blx@opcitreset@force
  893.   \blx@loccitreset@force
  894.   % List to track all aliases in a section. We need to output all aliases
  895.   % to the .bcf every time so that they are visible to biber
  896.   % Reset only if undefined
  897.   \ifcsundef{blx@keyaliases@\the\c@refsection}
  898.    {\global\cslet{blx@keyaliases@\the\c@refsection}\@empty}
  899.    {}%
  900.   \ifcsundef{blx@segm@\the\c@refsection @\the\c@refsegment}
  901.    {\global\cslet{blx@segm@\the\c@refsection @\the\c@refsegment}\@empty}
  902.    {}}
  903.  
  904. %% Auxiliary commands
  905. \protected\def\blx@regimc#1{%
  906.   \xappto\blx@blxinit{%
  907.     \let\noexpand#1\expandafter\noexpand\csname
  908.     blx@imc@\expandafter\@gobble\string#1\endcsname}}
  909.  
  910. \protected\def\blx@regimcs#1{\blx@regimcs@i#1&}
  911. \def\blx@regimcs@i#1{%
  912.   \ifx#1&\else
  913.     \blx@regimc#1%
  914.     \expandafter\blx@regimcs@i
  915.   \fi}
  916.  
  917. % {<field>} => \do{<item1>}\do{<item2>}...
  918. \def\blx@imc@docsvfield#1{%
  919.   \blx@imc@iffieldundef{#1}
  920.    {}
  921.     {\expandafter\expandafter\expandafter\docsvlist
  922.      \expandafter\expandafter\expandafter{%
  923.        \csname abx@field@#1\endcsname}}}
  924.  
  925. % {<handler>}{<field>} => <handler>{<item1>}<handler>{<item2>}...
  926. \def\blx@imc@forcsvfield#1#2{%
  927.   \blx@imc@iffieldundef{#2}
  928.    {}
  929.     {\expandafter\expandafter\expandafter\blx@imc@forcsvfield@i
  930.      \expandafter\expandafter\expandafter{%
  931.        \csname abx@field@#2\endcsname}{#1}}}
  932.  
  933. \def\blx@imc@forcsvfield@i#1#2{\forcsvlist{#2}{#1}}
  934.  
  935. \blx@regimcs{\docsvfield \forcsvfield}
  936.  
  937. % {<list>|<listmacro>}
  938. \protected\long\def\blx@listloop#1{%
  939.   \expandafter\blx@listloop@i#1|&}
  940. \long\def\blx@listloop@i#1|{%
  941.   \ifblank{#1}
  942.    {\blx@break}
  943.    {\blx@do{#1}\blx@listloop@i}}
  944.  
  945. \long\def\blx@break#1&{%
  946.   \blx@done
  947.   \undef\blx@do
  948.   \undef\blx@done}
  949.  
  950. % {<listmacro>}{<listcsname>} => matches in <listmacro>
  951. \protected\def\blx@filter#1#2{%
  952.   \def\do##1{%
  953.     \ifinlistcs{##1}{#2}
  954.      {\listadd#1{##1}}
  955.      {}}%
  956.   \blx@runfilter#1}
  957.  
  958. % {<listmacro>}{<listcsname>} => matches in <listmacro>
  959. % Slightly odd use of filtering to do citation sorting.
  960. % Same as blx@filter but it keeps \tempcnta in step with the
  961. % resulting number of things in the filtered list. This is
  962. % because \tempcnta is used to set citetotal - this use
  963. % of filtering for cite sorting has the side-effect of stripping
  964. % duplicates like \cite{foo,foo} but we need then to keep citetotal
  965. % in sync.
  966. \protected\def\blx@filtercitesort#1#2{%
  967.  \blx@tempcnta\z@
  968.  \def\do##1{%
  969.    \ifinlistcs{##1}{#2}
  970.     {\listadd#1{##1}%
  971.       \advance\blx@tempcnta\@ne}
  972.      {}}%
  973.  \blx@runfilter#1}
  974.  
  975. % {<listmacro>}{<listcsname>} => neg. matches in <listmacro>
  976. \protected\def\blx@notfilter#1#2{%
  977.   \def\do##1{%
  978.     \ifinlistcs{##1}{#2}
  979.      {}
  980.      {\listadd#1{##1}}}%
  981.   \blx@runfilter#1}
  982.  
  983. \def\blx@runfilter#1{%
  984.   \begingroup\edef#1{\endgroup
  985.    \unexpanded{\let#1\@empty\dolistloop}{#1}}%
  986.   #1\let\do\noexpand}
  987.  
  988. % {<code>}{<string>} => <code>{<string>}
  989. \protected\def\blx@xsanitizeafter#1#2{%
  990.   \begingroup
  991.   \abx@hook@xsanitize
  992.   \def\blx@tempa{\endgroup#1}%
  993.   \edef\blx@tempb{#2}%
  994.   \expandafter\blx@tempa
  995.   \expandafter{\detokenize\expandafter{\blx@tempb}}}
  996.  
  997. \def\abx@hook@xsanitize{%
  998.   \blx@safe@actives
  999.   \let\protect\string}
  1000.  
  1001. % {<code>}{<string>} => <code>{<string>}
  1002. \begingroup
  1003. \catcode`\<=\active
  1004. \catcode`\>=\active
  1005. \catcode`\&=\active
  1006. \catcode`\"=\active
  1007. \catcode`\'=\active
  1008. \protected\gdef\blx@xmlsanitizeafter#1#2{%
  1009.   \begingroup
  1010.   \abx@hook@xsanitize
  1011.   \def\blx@tempa{\endgroup#1}%
  1012.   \edef\blx@tempb{#2}%
  1013.   \let\do\@makeother
  1014.   \dospecials
  1015.   \catcode`\<=\active
  1016.   \catcode`\>=\active
  1017.   \catcode`\&=\active
  1018.   \catcode`\"=\active
  1019.   \catcode`\'=\active
  1020.   \edef<{\string&lt\string;}%
  1021.   \edef>{\string&gt\string;}%
  1022.   \edef&{\string&amp\string;}%
  1023.   \edef"{\string&quot\string;}%
  1024.   \edef'{\string&apos\string;}%
  1025.   \endlinechar\m@ne
  1026.   \everyeof{\noexpand}%
  1027.   \edef\blx@tempb{\scantokens\expandafter{\blx@tempb}}%
  1028.   \expandafter\blx@tempa
  1029.   \expandafter{\detokenize\expandafter{\blx@tempb}}}
  1030. \endgroup
  1031.  
  1032. % {<file>}{<message>}{<preload>}{<postload>}{<success>}{<failure>}
  1033. \protected\long\def\blx@inputonce#1#2#3#4#5#6{%
  1034.   \ifcsundef{blx@file@#1}
  1035.    {\blx@info@noline{Trying to load #2..}%
  1036.      \IfFileExists{#1}
  1037.       {\blx@info@noline{... file '#1' found}%
  1038.         #3\@@input\@filef@und#4#5%
  1039.         \listxadd\blx@list@req@stat{#1}%
  1040.         \@addtofilelist{#1}}
  1041.       {\blx@info@noline{... file '#1' not found}#6}%
  1042.      \global\cslet{blx@file@#1}\@empty}
  1043.    {#5}}
  1044.  
  1045. % {<write>}{<precode>}{<string>}
  1046. \protected\def\blx@auxwrite#1#2#3{%
  1047.   \if@filesw
  1048.     \begingroup
  1049.     \blx@safe@actives
  1050.     \let\protect\string
  1051.     #2%
  1052.     \immediate\write#1{#3}%
  1053.     \endgroup
  1054.   \fi}
  1055.  
  1056. % {<file>}{<signature>}{<true>}{<false>}
  1057. \def\blx@ifsigned#1#2{%
  1058.   \begingroup
  1059.   \let\blx@tempa\@firstoftwo
  1060.   \edef\blx@tempb{\csuse{blx@sig@#2}}%
  1061.   \edef\blx@tempb{\detokenize\expandafter{\blx@tempb}}%
  1062.   \openin\blx@bcfin #1.#2\relax
  1063.     \ifeof\blx@bcfin
  1064.     \else
  1065.       \endlinechar\m@ne
  1066.       \readline\blx@bcfin to \blx@tempc
  1067.       \ifeof\blx@bcfin
  1068.       \else
  1069.         \ifx\blx@tempb\blx@tempc
  1070.           \readline\blx@bcfin to \blx@tempc
  1071.           \edef\blx@tempb{\csuse{blx@ver@#2}}%
  1072.           \edef\blx@tempb{\detokenize\expandafter{\blx@tempb}}%
  1073.           \ifx\blx@tempb\blx@tempc
  1074.           \else
  1075.             \blx@warning@noline{%
  1076.               File '#1.#2' is wrong format version - expected \blx@bblversion}
  1077.           \fi
  1078.         \else
  1079.           \blx@error
  1080.             {File '#1.#2' not created by biblatex}
  1081.             {This file was apparently not created by biblatex.
  1082.              Rename it or\MessageBreak move it to a location were
  1083.              TeX will not find it. If this error\MessageBreak
  1084.              persists, consider redefining \string\blxauxsuffix.%
  1085.              See the biblatex\MessageBreak manual for details}%
  1086.           \let\blx@tempa\@secondoftwo
  1087.         \fi
  1088.       \fi
  1089.     \fi
  1090.   \closein\blx@bcfin
  1091.   \expandafter\endgroup\blx@tempa}
  1092.  
  1093. \edef\blx@sig@bbl{\@percentchar\space $ biblatex auxiliary file $}
  1094. \edef\blx@ver@bbl{\@percentchar\space $ biblatex bbl format version \blx@bblversion\space $}
  1095. \edef\blx@sig@bcf{\detokenize{<?xml version="1.0" encoding="UTF-8"?>}}
  1096. \edef\blx@ver@bcf{%
  1097.   \detokenize{<bcf:controlfile version="}\blx@bcfversion
  1098.  \detokenize{" bltxversion="}\abx@version
  1099.  \detokenize{" xmlns:bcf="https://sourceforge.net/projects/biblatex">}}
  1100.  
  1101. % {<true>}{<false>}
  1102. \newrobustcmd*{\lbx@ifutfinput}{\ifboolexpr{%
  1103.   test {\ifdefstring\inputencodingname{utf8}}
  1104.  or
  1105.  test {\ifdefstring\inputencodingname{utf8x}}
  1106.  or
  1107.  test {\ifdefstring\inputencodingname{lutf8}}
  1108.  or
  1109.  ( test {\ifundef\inputencodingname}
  1110.    and
  1111.    ( not test {\ifundef\XeTeXrevision}
  1112.      or
  1113.      not test {\ifundef\luatexversion}
  1114.    )
  1115.  )
  1116. }}
  1117.  
  1118. %% More user feedback
  1119. \protected\def\blx@warning@entry#1{%
  1120.   \ifdef\abx@field@entrykey
  1121.     {\blx@warning{#1\MessageBreak at entry '\abx@field@entrykey'}}
  1122.    {\blx@warning{#1}}}
  1123.  
  1124. \protected\def\blx@info@noline#1{%
  1125.   \begingroup
  1126.   \blx@safe@actives
  1127.   \PackageInfo{biblatex}{#1\@gobble}%
  1128.   \endgroup}
  1129. \let\blx@info\blx@info@noline
  1130. \AtEndOfPackage{%
  1131.   \protected\def\blx@info#1{%
  1132.     \begingroup
  1133.     \blx@safe@actives
  1134.     \PackageInfo{biblatex}{#1}%
  1135.     \endgroup}}
  1136.  
  1137. \let\blx@noline\@gobble
  1138. \AtEndOfPackage{\let\blx@noline\@empty}
  1139. \def\blx@imc@BibliographyWarning{\blx@warning@entry}
  1140. \blx@regimc\BibliographyWarning
  1141.  
  1142. \protected\def\abx@missing#1{%
  1143.   \mbox{\reset@font\bfseries#1}}
  1144.  
  1145. \def\blx@err@patch#1{%
  1146.   \blx@error
  1147.     {Patching #1 failed}
  1148.    {This is an internal issue typically caused by a
  1149.     conflict\MessageBreak between biblatex and some
  1150.     other package. Modifying\MessageBreak the package
  1151.     loading order may fix the problem}}
  1152.  
  1153. \def\blx@err@nolang#1{%
  1154.   \blx@error
  1155.     {Language '#1' not found}
  1156.    {The localization module for '#1' could not be found}}
  1157.  
  1158. \def\blx@err@invarg#1#2{%
  1159.   \blx@error
  1160.     {Argument '#1' invalid}
  1161.    {\ifblank{#2}
  1162.       {The argument you have supplied is invalid.\MessageBreak
  1163.        See the biblatex manual for details}
  1164.       {#2}}}
  1165.  
  1166. \def\blx@err@invopt#1#2{%
  1167.   \blx@error
  1168.     {Option '#1' invalid}
  1169.    {\ifblank{#2}
  1170.       {The option you have supplied is invalid.\MessageBreak
  1171.        See the biblatex manual for valid option keys and
  1172.        possible values}
  1173.       {#2}}}
  1174.  
  1175. \def\blx@err@confopt#1#2{%
  1176.   \blx@error
  1177.     {Conflicting options\ifblank{#1}{}{ (#1)}}
  1178.    {\ifblank{#2}
  1179.       {The option you have supplied conflicts with another one.\MessageBreak
  1180.        See the biblatex manual for valid option keys and possible values}
  1181.       {#2}}}
  1182.  
  1183. \def\blx@err@optdef#1{%
  1184.   \blx@error
  1185.     {Conflicting options}
  1186.    {The option '#1' is already defined}}
  1187.  
  1188. \def\blx@err@nodocdiv#1{%
  1189.   \blx@error
  1190.     {\@backslashchar#1 not provided by class}
  1191.    {The document class does not seems to support #1s}}
  1192.  
  1193. \def\blx@err@nosec#1{%
  1194.   \blx@error
  1195.     {Section '#1' not found}
  1196.    {The reference section '#1' could not be found}}
  1197.  
  1198. \def\blx@err@nosort#1{%
  1199.   \blx@error
  1200.     {Sorting template '#1' not found}
  1201.    {The sorting template '#1' does not seem to have been defined anywhere}}
  1202.  
  1203. \def\blx@err@secfirst{%
  1204.   \blx@error
  1205.     {'section' not first filter}
  1206.    {When passing multiple filter options,
  1207.     the 'section' filter must be given first}}
  1208.  
  1209. \protected\def\blx@err@nestcite{%
  1210.   \blx@error
  1211.     {Nested citation command}
  1212.    {Citation commands may not be nested}}
  1213.  
  1214. \def\blx@err@nestenv#1{%
  1215.   \blx@error
  1216.     {Nested '#1' environment}
  1217.    {This environment may not be nested}}
  1218.  
  1219. \protected\def\blx@err@citecmd#1{%
  1220.   \begingroup
  1221.   \escapechar\m@ne
  1222.   \blx@error
  1223.     {Command '\@backslashchar\string#1' undefined}
  1224.    {The citation command '\@backslashchar\string#1'
  1225.     has not been defined\MessageBreak by the
  1226.     selected citation style}%
  1227.   \endgroup}
  1228.  
  1229. \def\blx@err@endnote#1{%
  1230.   \blx@error
  1231.     {Missing or incomplete endnote support}
  1232.    {There does not seem to be endnote support available\MessageBreak
  1233.     or the available support is incomplete.\MessageBreak
  1234.     If you continue, I will fall back to '\string#1'}%
  1235.   #1}
  1236.  
  1237. \def\blx@err@matchparen#1{%
  1238.   \blx@error
  1239.     {Unbalanced parentheses or brackets}
  1240.    {\iftoggle{blx@footnote}{#1 in foot or endnote}{#1}.\MessageBreak
  1241.     This error is triggered if \string\bibopenparen\space and
  1242.     \string\bibcloseparen\MessageBreak or
  1243.     \string\bibopenbracket\space and \string\bibclosebracket\space
  1244.     are unbalanced\MessageBreak or mismatched}}
  1245.  
  1246. \def\blx@err@nestparen#1{%
  1247.   \blx@error
  1248.     {Too deeply nested parentheses or brackets}
  1249.     {#1 nested too deeply%
  1250.      \iftoggle{blx@footnote}{\space in foot or endnote}{}.\MessageBreak
  1251.     This error may also be triggered if \string\mkbibparens\MessageBreak
  1252.     or \string\mkbibbrackets\space are nested too deeply}}
  1253.  
  1254. \def\blx@err@filter{%
  1255.   \blx@error
  1256.     {Invalid filter expression}
  1257.    {The filter expression you have supplied is invalid.\MessageBreak
  1258.     See the biblatex manual for details}}
  1259.  
  1260. \def\blx@warn@nohyph#1{%
  1261.   \blx@warning{No hyphenation patterns for '#1'}}
  1262.  
  1263. \protected\def\blx@warn@citecmd#1#2{%
  1264.   \blx@warning{%
  1265.     '\string#1' not defined by citation style.\MessageBreak
  1266.     Falling back to '\string#2'}%
  1267.   #2}
  1268.  
  1269. \protected\def\blx@warn@nostring#1{%
  1270.   \blx@warning@entry{Bibliography string '#1'
  1271.                     \ifcsundef{KV@blx@lbx@#1}{undefined}{untranslated}}%
  1272.   \abx@missing{#1}}
  1273.  
  1274. \def\blx@warn@conflopt#1{%
  1275.   \blx@warning{Conflicting options.\MessageBreak#1}}
  1276.  
  1277. \def\blx@warn@badoptdt#1{%
  1278.   \blx@warning{Invalid option datatype '#1'.\MessageBreak
  1279.    Defaulting to 'boolean'}}
  1280.  
  1281. \def\blx@warn@depropt#1{%
  1282.   \blx@warning{Deprecated option.\MessageBreak Ignoring '#1'}}
  1283.  
  1284. \def\blx@warn@bibempty{%
  1285.   \@latex@warning{Empty bibliography}}
  1286.  
  1287. \def\blx@warn@biblistempty#1{%
  1288.   \@latex@warning{Empty biblist '#1'}}
  1289.  
  1290. \def\blx@inf@refsec{%
  1291.   \blx@info{Reference section=\the\c@refsection}}%
  1292.  
  1293. \def\blx@inf@delimdeclare#1#2{%
  1294.   \blx@info{Delimiter '#1' in context '#2' already defined, overwriting}}
  1295.  
  1296. \def\blx@warn@delimuse#1#2{%
  1297.   \blx@warning{Delimiter '#1' in context '#2' undefined}}
  1298.  
  1299. \def\blx@inf@refseg{%
  1300.   \ifnum\c@refsection=\z@
  1301.     \blx@info{Reference segment=\the\c@refsegment}%
  1302.   \else
  1303.     \blx@info{%
  1304.       Reference section/segment=%
  1305.       \the\c@refsection/\the\c@refsegment}%
  1306.   \fi}
  1307.  
  1308. \def\blx@inf@creset{%
  1309.   \blx@info{Resetting trackers}}%
  1310.  
  1311. \def\blx@msg@cundef#1{%
  1312.   Citation '#1' undefined}
  1313. \def\blx@msg@cundefon#1{%
  1314.   Citation '#1' on page \the\c@page\space undefined}
  1315.  
  1316. % Dummy as backend is biber by default. Some style may still use this to
  1317. % check though.
  1318. \newrobustcmd*{\RequireBiber}[1][2]{}
  1319.  
  1320. % \blx@list@active                      active aux files (basename)
  1321. %                                       [internal list]
  1322. % \blx@list@inactive                    inactive aux files (basename)
  1323. %                                       [internal list]
  1324. % \blx@list@bibfiles@<auxfile>          aux file -> bib file mapping (refsections)
  1325. %                                       aux file (basename) -> bib files (full)
  1326. %                                       [internal list]
  1327.  
  1328. \let\blx@list@active\@empty
  1329. \let\blx@list@inactive\@empty
  1330. \listeadd\blx@list@inactive{\jobname}
  1331.  
  1332. \protected\def\blx@regbibfiles#1#2{%
  1333.   \forlistloop{\blx@regbibfile{#1}}{#2}}
  1334.  
  1335. \def\blx@regbibfile#1#2{%
  1336.   \ifcsundef{blx@res@loca@#2}
  1337.    {\blx@regbibfile@i{#1}{#2}}
  1338.    {\ifcsstring{blx@res@loca@#2}{local}
  1339.       {\blx@regbibfile@i{#1}{#2}}
  1340.       {}}}
  1341.  
  1342. \def\blx@regbibfile@i#1#2{%
  1343.   \ifinlistcs{#2}{blx@list@bibfiles@#1}
  1344.    {}
  1345.    {\listcsxadd{blx@list@bibfiles@#1}{#2}}}
  1346.  
  1347. \def\blx@check@logreq{%
  1348.   \begingroup
  1349.   \ltxrequest{biblatex}{{\iftoggle{blx@runltx}{1}{0}}}{%
  1350.     \provides[type=dynamic]{
  1351.      \file{\jobname.bcf}
  1352.    }
  1353.    \requires[type=dynamic]{
  1354.      \file{\jobname.bbl}
  1355.    }
  1356.    \ifdef\blx@list@req@edit
  1357.      {\requires[type=editable]{
  1358.         \forlistloop\file\blx@list@req@edit
  1359.       }}
  1360.      {}
  1361.    \ifdef\blx@list@req@stat
  1362.      {\requires[type=static]{
  1363.         \forlistloop\file\blx@list@req@stat
  1364.       }}
  1365.      {}
  1366.  }%
  1367.   \logrequest[package=biblatex,priority=5,active={{\iftoggle{blx@runbiber}{1}{0}}}]{%
  1368.     \generic{biber}
  1369.    \cmdline{
  1370.      \binary{biber}
  1371.      \infile{\jobname}
  1372.    }
  1373.    \input{
  1374.      \file{\jobname.bcf}
  1375.    }
  1376.    \output{
  1377.      \file{\jobname.bbl}
  1378.    }
  1379.    \provides[type=dynamic]{
  1380.      \file{\jobname.bbl}
  1381.    }
  1382.    \requires[type=dynamic]{
  1383.      \file{\jobname.bcf}
  1384.    }
  1385.    \ifcsdef{blx@list@bibfiles@\jobname}
  1386.      {\requires[type=editable]{
  1387.         \def\do{\file}
  1388.         \dolistcsloop{blx@list@bibfiles@\jobname}
  1389.       }}
  1390.      {}
  1391.  }%
  1392.   \endgroup}
  1393.  
  1394. \def\blx@logreq@active#1{%
  1395.   \ifblank{#1}
  1396.    {}
  1397.    {\@latex@warning{#1}}%
  1398.   \blx@rerun@latex
  1399.   \blx@rerun@biber}
  1400.  
  1401. \def\blx@rerun@latex{%
  1402.   \G@refundefinedtrue
  1403.   \global\toggletrue{blx@runltx}%
  1404.   \global\let\blx@rerun@latex\relax}
  1405.  
  1406. \def\blx@rerun@biber{%
  1407.   \global\toggletrue{blx@runbiber}%
  1408.   \global\let\blx@rerun@biber\relax}
  1409.  
  1410. \let\blx@checksum@old\@empty
  1411. \let\blx@checksum@new\@empty
  1412. \let\blx@pagesum@old\@empty
  1413. \let\blx@pagesum@new\@empty
  1414.  
  1415. \def\blx@checksum#1#2#3{%
  1416.   \begingroup
  1417.   \blx@tempcnta\the\numexpr0#2*0#3\relax
  1418.   \blx@tempcntb\blx@tempcnta
  1419.   \divide\blx@tempcntb10
  1420.   \multiply\blx@tempcntb10
  1421.   \advance\blx@tempcnta-\blx@tempcntb
  1422.   \xdef#1{#1\the\blx@tempcnta}%
  1423.   \endgroup}
  1424.  
  1425. \def\blx@addchecksum{\blx@checksum\blx@checksum@old}
  1426. \def\blx@addpagesum{\blx@checksum\blx@pagesum@old}
  1427. \AtEndDocument{%
  1428.   \def\blx@addchecksum{\blx@checksum\blx@checksum@new}%
  1429.   \def\blx@addpagesum{\blx@checksum\blx@pagesum@new}}
  1430.  
  1431. \protected\def\blx@check@rerun{%
  1432.   \begingroup
  1433.   \blx@tempcnta\z@
  1434.   \iftoggle{blx@runltx}
  1435.    {\blx@tempcnta\@ne}
  1436.    {\ifx\blx@checksum@old\blx@checksum@new
  1437.       \ifx\blx@pagesum@old\blx@pagesum@new
  1438.       \else
  1439.         \blx@tempcnta\@ne
  1440.       \fi
  1441.     \else
  1442.       \blx@tempcnta\@ne
  1443.     \fi}%
  1444.   \iftoggle{blx@runbiber}
  1445.    {\advance\blx@tempcnta\tw@}
  1446.    {}%
  1447.   \ifcase\blx@tempcnta
  1448.   \or
  1449.     \blx@rerun@latex
  1450.     \blx@warning@noline{%
  1451.       Please rerun LaTeX%
  1452.       \ifx\blx@pagesum@old\blx@pagesum@new\else
  1453.         .\MessageBreak Page breaks have changed%
  1454.       \fi}%
  1455.   \else
  1456.     \blx@rerun@latex
  1457.     \blx@warn@auxlist
  1458.   \fi
  1459.   \endgroup}
  1460.  
  1461. \def\blx@warn@auxlist{%
  1462.   \begingroup
  1463.   \edef\blx@tempa{%
  1464.     Please (re)run Biber on the file:\MessageBreak
  1465.     \jobname}%
  1466.   \blx@warning@noline{%
  1467.     \blx@tempa\MessageBreak
  1468.     and rerun LaTeX afterwards}%
  1469.   \endgroup}
  1470.  
  1471. \AfterEndDocument{%
  1472.   \blx@check@rerun
  1473.   \blx@check@logreq}
  1474.  
  1475. %% Punctuation and capitalization
  1476.  
  1477. % 1001       prefix sep for names (e.g. d'Argent ... \printnames only)
  1478. % 1002       abbreviation period (dot)
  1479. % 1003/1250  comma
  1480. % 1004/1500  semicolon
  1481. % 1005/2000  colon
  1482. % 1006/3000  period
  1483. % 1007/3001  exclamation mark
  1484. % 1008/3002  question mark
  1485. % 1009       suppress punctuation
  1486. % 1010       new paragaph
  1487.  
  1488. \mathchardef\blx@sf@prefixchar=1001% e.g. apostrophe or equivalent for prefix handling
  1489. \mathchardef\blx@sf@dot=1002
  1490. \mathchardef\blx@sf@comma=1003
  1491. \mathchardef\blx@sf@semicolon=1004
  1492. \mathchardef\blx@sf@colon=1005
  1493. \mathchardef\blx@sf@period=1006
  1494. \mathchardef\blx@sf@exclam=1007
  1495. \mathchardef\blx@sf@question=1008
  1496. \mathchardef\blx@sf@nopunct=1009
  1497. \mathchardef\blx@sf@par=1010
  1498. \mathchardef\blx@sf@threshold@low=1002
  1499. \mathchardef\blx@sf@threshold@high=1009
  1500.  
  1501. \csdef{blx@sf@1250}{\the\blx@sf@comma}
  1502. \csdef{blx@sf@1500}{\the\blx@sf@semicolon}
  1503. \csdef{blx@sf@2000}{\the\blx@sf@colon}
  1504. \csdef{blx@sf@3000}{\the\blx@sf@period}
  1505. \csdef{blx@sf@3001}{\the\blx@sf@exclam}
  1506. \csdef{blx@sf@3002}{\the\blx@sf@question}
  1507.  
  1508. \csdef{blx@pm@,}{comma}
  1509. \csdef{blx@pm@;}{semicolon}
  1510. \csdef{blx@pm@:}{colon}
  1511. \csdef{blx@pm@.}{period}
  1512. \csdef{blx@pm@!}{exclam}
  1513. \csdef{blx@pm@?}{question}
  1514.  
  1515. \def\blx@setsfcodes{%
  1516.   \let\blx@setsfcodes\relax
  1517.   \let\frenchspacing\blx@setfrcodes
  1518.   \let\nonfrenchspacing\blx@setencodes
  1519.   \ifnum\sfcode`\.>2000
  1520.     \blx@setencodes
  1521.   \else
  1522.     \blx@setfrcodes
  1523.   \fi
  1524.   \@setquotesfcodes
  1525.   \sfcode`\(=\z@
  1526.   \sfcode`\)=\z@
  1527.   \sfcode`\[=\z@
  1528.  \sfcode`\]=\z@
  1529.   \sfcode`\<=\z@
  1530.   \sfcode`\>=\z@}
  1531.  
  1532. \def\blx@setfrcodes{%
  1533.   \ifnum\sfcode`\A=\@m
  1534.   \else
  1535.     \blx@setazcodes
  1536.   \fi
  1537.   \sfcode`\,=\blx@sf@comma
  1538.   \sfcode`\;=\blx@sf@semicolon
  1539.   \sfcode`\:=\blx@sf@colon
  1540.   \sfcode`\.=\blx@sf@period
  1541.   \sfcode`\!=\blx@sf@exclam
  1542.   \sfcode`\?=\blx@sf@question
  1543. }
  1544.  
  1545. \def\blx@setencodes{%
  1546.   \sfcode`\,=1250
  1547.   \sfcode`\;=1500
  1548.   \sfcode`\:=2000
  1549.   \sfcode`\.=3000
  1550.   \sfcode`\!=3001
  1551.   \sfcode`\?=3002
  1552. }
  1553.  
  1554. % Defining characters that count as prefices in names like d'Argent
  1555. % Code from moewe
  1556. \let\blx@prefchars\@empty
  1557.  
  1558. \def\blx@defprefchars@loop#1{%
  1559.   \ifx#1\relax
  1560.   \else
  1561.     \listadd{\blx@prefchars}{#1}%
  1562.     \expandafter\blx@defprefchars@loop
  1563.   \fi}
  1564.  
  1565. \def\blx@defprefchars#1{%
  1566.   \expandafter\blx@defprefchars@loop\detokenize{#1}\relax}
  1567.  
  1568. \newrobustcmd*{\DeclarePrefChars}{%
  1569.   \@ifstar
  1570.     {\blx@defprefchars}
  1571.    {\global\let\blx@prefchars\@empty
  1572.     \blx@defprefchars}}
  1573. \DeclarePrefChars{'-}
  1574.  
  1575. \protected\def\blx@imc@ifprefchar{%
  1576.   \ifhmode
  1577.     \begingroup
  1578.     \ifnum\spacefactor=\blx@sf@prefixchar
  1579.       \endgroup
  1580.       \expandafter\expandafter
  1581.       \expandafter\@firstoftwo
  1582.     \else
  1583.       \endgroup
  1584.       \expandafter\expandafter
  1585.       \expandafter\@secondoftwo
  1586.     \fi
  1587.   \else
  1588.     \expandafter\@secondoftwo
  1589.   \fi}
  1590.  
  1591. \blx@regimcs{\ifprefchar}
  1592.  
  1593. \def\blx@namecodes{%
  1594.   \ifnum\sfcode`\A=\@m
  1595.   \else
  1596.     \blx@setazcodes
  1597.   \fi
  1598.   \def\do##1{\sfcode`##1=\blx@sf@prefixchar}%
  1599.   \dolistloop\blx@prefchars
  1600. }
  1601.  
  1602. \begingroup
  1603. \let\blx@setazcodes\@empty
  1604. \def\blx@tempa{%
  1605.   \xdef\blx@setazcodes{%
  1606.     \blx@setazcodes
  1607.     \sfcode\the\blx@tempcnta=\@m}
  1608.   \ifnum\blx@tempcnta<\blx@tempcntb
  1609.     \advance\blx@tempcnta\@ne
  1610.     \expandafter\blx@tempa
  1611.   \fi}
  1612. \blx@tempcnta`\A
  1613. \blx@tempcntb`\Z
  1614. \blx@tempa
  1615. \ifnum\inputlineno=\m@ne\else
  1616.   \blx@tempcnta"80
  1617.   \blx@tempcntb"9C
  1618.   \blx@tempa
  1619.   \blx@tempcnta"C0
  1620.   \blx@tempcntb"DF
  1621.   \blx@tempa
  1622. \fi
  1623. \endgroup
  1624.  
  1625. \def\blx@spacefactor{%
  1626.   \ifhmode
  1627.     \ifcsundef{blx@sf@\the\spacefactor}
  1628.      {\the\spacefactor}
  1629.      {\csname blx@sf@\the\spacefactor\endcsname}%
  1630.   \else
  1631.     \the\blx@sf@par
  1632.   \fi}
  1633.  
  1634. \protected\def\blx@leavevmode{%
  1635.   \ifhmode
  1636.   \else
  1637.     \leavevmode\spacefactor\blx@sf@par
  1638.   \fi}
  1639.  
  1640. \protected\def\blx@leavevmode@cite{%
  1641.   \ifhmode
  1642.     \ifnum\spacefactor=\blx@sf@par
  1643.     \else
  1644.       \spacefactor\@m
  1645.     \fi
  1646.   \else
  1647.     \leavevmode
  1648.   \fi}
  1649.  
  1650. \protected\def\blx@imc@setpunctfont#1{%
  1651.   \blx@ifpuncthook
  1652.     {\gdef\abx@puncthook{%
  1653.        \ifdim\lastkern>\z@\unkern\fi
  1654.        \blx@imc@resetpunctfont#1}}
  1655.     {}}
  1656. \protected\def\blx@imc@resetpunctfont{%
  1657.   \blx@ifpuncthook
  1658.     {\global\let\abx@puncthook\@firstofone}
  1659.    {}}
  1660.  
  1661. \protected\def\blx@setpostpunct#1{%
  1662.   \blx@ifuspunct
  1663.     {\global\let\blx@postpunct\blx@dopostpunct
  1664.     \ifdef\blx@thepostpunct
  1665.       {\gappto\blx@thepostpunct{#1}}
  1666.       {\gdef\blx@thepostpunct{#1}}}
  1667.    {}}
  1668.  
  1669. \def\blx@dopostpunct{%
  1670.   \blx@thepostpunct
  1671.   \global\let\blx@postpunct\@empty
  1672.   \global\undef\blx@thepostpunct}
  1673.  
  1674. \protected\def\blx@postpunct@agroup{%
  1675.   \aftergroup\blx@postpunct
  1676.   \let\blx@postpunct@agroup\@empty}
  1677.  
  1678. % {<characters>}
  1679. \newrobustcmd*{\DeclareCapitalPunctuation}[1]{%
  1680.   \cslet{blx@cap@\the\blx@sf@par}\@empty
  1681.  \csundef{blx@cap@\the\blx@sf@comma}%
  1682.   \csundef{blx@cap@\the\blx@sf@semicolon}%
  1683.   \csundef{blx@cap@\the\blx@sf@colon}%
  1684.   \csundef{blx@cap@\the\blx@sf@period}%
  1685.   \csundef{blx@cap@\the\blx@sf@exclam}%
  1686.   \csundef{blx@cap@\the\blx@sf@question}%
  1687.   \ifblank{#1}
  1688.    {}
  1689.    {\expandafter\blx@defcapstring\detokenize{#1}\relax}}
  1690.  
  1691. \def\blx@defcapstring#1{%
  1692.   \ifx#1\relax
  1693.   \else
  1694.     \begingroup
  1695.     \blx@setfrcodes
  1696.     \ifcsdef{blx@pm@#1}
  1697.      {\expandafter\endgroup
  1698.       \expandafter\let
  1699.         \csname blx@cap@\the\sfcode`#1\endcsname\@empty}
  1700.      {\blx@warning{Ignoring invalid punctuation mark '#1'}%
  1701.        \endgroup}%
  1702.     \expandafter\blx@defcapstring
  1703.   \fi}
  1704.  
  1705. % {<characters>}
  1706. \newrobustcmd*{\DeclareQuotePunctuation}[1]{%
  1707.   \csdef{blx@qp@comma}{\blx@postpunct}%
  1708.   \csdef{blx@qp@semicolon}{\blx@postpunct}%
  1709.   \csdef{blx@qp@colon}{\blx@postpunct}%
  1710.   \csdef{blx@qp@period}{\blx@postpunct}%
  1711.   \csdef{blx@qp@exclam}{\blx@postpunct}%
  1712.   \csdef{blx@qp@question}{\blx@postpunct}%
  1713.   \cslet{blx@pq@comma}\@empty
  1714.  \cslet{blx@pq@semicolon}\@empty
  1715.  \cslet{blx@pq@colon}\@empty
  1716.  \cslet{blx@pq@period}\@empty
  1717.  \cslet{blx@pq@exclam}\@empty
  1718.  \cslet{blx@pq@question}\@empty
  1719.  \let\blx@quotepunct\@empty
  1720.  \ifblank{#1}
  1721.    {\let\blx@ifuspunct\@secondoftwo}
  1722.    {\let\blx@ifuspunct\@firstoftwo
  1723.     \expandafter\blx@defquotepunct\detokenize{#1}&}}
  1724.  
  1725. \def\blx@defquotepunct#1{%
  1726.   \ifx&#1\relax
  1727.   \else
  1728.     \ifcsdef{blx@pm@#1}
  1729.      {\appto\blx@quotepunct{#1}%
  1730.        \cslet{blx@qp@\csuse{blx@pm@#1}}\@empty
  1731.       \csdef{blx@pq@\csuse{blx@pm@#1}}{\blx@postpunct}}
  1732.      {\blx@warning{Ignoring invalid punctuation mark '#1'}}%
  1733.     \expandafter\blx@defquotepunct
  1734.   \fi}
  1735.  
  1736. % {<mark>}{<characters>}
  1737. \newrobustcmd*{\DeclarePunctuationPairs}[2]{%
  1738.   \ifcsdef{blx@sf@\detokenize{#1}}
  1739.    {\ifnum\csname blx@sf@\detokenize{#1}\endcsname>\blx@sf@prefixchar
  1740.       \ifnum\csname blx@sf@\detokenize{#1}\endcsname<\blx@sf@nopunct
  1741.         \expandafter\blx@defpunctpairs
  1742.         \expandafter{\the\csname blx@sf@\detokenize{#1}\endcsname}{#2}%
  1743.        \else
  1744.          \blx@err@invarg{\detokenize{#1}{}}%
  1745.        \fi
  1746.      \else
  1747.        \blx@err@invarg{\detokenize{#1}{}}%
  1748.      \fi}
  1749.     {\blx@err@invarg{\detokenize{#1}{}}}}
  1750.  
  1751. \def\blx@defpunctpairs#1#2{%
  1752.   \blx@undefpair{#1}{\the\blx@sf@dot}%
  1753.   \blx@undefpair{#1}{\the\blx@sf@comma}%
  1754.   \blx@undefpair{#1}{\the\blx@sf@semicolon}%
  1755.   \blx@undefpair{#1}{\the\blx@sf@colon}%
  1756.   \blx@undefpair{#1}{\the\blx@sf@period}%
  1757.   \blx@undefpair{#1}{\the\blx@sf@exclam}%
  1758.   \blx@undefpair{#1}{\the\blx@sf@question}%
  1759.   \ifblank{#2}
  1760.    {}
  1761.    {\begingroup
  1762.     \def\blx@tempa{#1}%
  1763.      \let\blx@tempb\@empty
  1764.      \blx@setfrcodes
  1765.      \sfcode`\*=\blx@sf@dot
  1766.      \expandafter\blx@defpair\detokenize{#2}&%
  1767.      \expandafter\endgroup\blx@tempb}}
  1768.  
  1769. \def\blx@defpair#1{%
  1770.   \ifx&#1%
  1771.   \else
  1772.     \ifnum\the\sfcode`#1>\blx@sf@prefixchar
  1773.       \ifnum\the\sfcode`#1<\blx@sf@nopunct
  1774.         \eappto\blx@tempb{%
  1775.           \cslet{blx@pp@\blx@tempa @\the\sfcode`#1}\noexpand\@empty}%
  1776.       \else
  1777.         \blx@err@invarg{#1}{}%
  1778.       \fi
  1779.     \else
  1780.       \blx@err@invarg{#1}{}%
  1781.     \fi
  1782.     \expandafter\blx@defpair
  1783.   \fi}
  1784.  
  1785. \def\blx@undefpair#1#2{%
  1786.   \ifcsdef{blx@pp@#1@#2}
  1787.    {\csundef{blx@pp@#1@#2}}
  1788.    {}}
  1789.  
  1790. \protected\def\blx@resetpunct{%
  1791.   \DeclareCapitalPunctuation{.!?}%
  1792.   \DeclarePunctuationPairs{dot}{}%
  1793.   \DeclarePunctuationPairs{comma}{*!?}%
  1794.   \DeclarePunctuationPairs{semicolon}{*!?}%
  1795.   \DeclarePunctuationPairs{colon}{*!?}%
  1796.   \DeclarePunctuationPairs{period}{}%
  1797.   \DeclarePunctuationPairs{exclam}{*}%
  1798.   \DeclarePunctuationPairs{question}{*}%
  1799.   \DeclareQuotePunctuation{}%
  1800.   \def\abx@dot{\ifdim\lastkern>\z@\unkern\fi.\spacefactor\blx@sf@dot}%
  1801.   \def\abx@comma{\ifdim\lastkern>\z@\unkern\fi\abx@puncthook{,}}%
  1802.   \def\abx@semicolon{\abx@puncthook{;}}%
  1803.   \def\abx@colon{\abx@puncthook{:}}%
  1804.   \def\abx@period{\ifdim\lastkern>\z@\unkern\fi\abx@puncthook{.}}%
  1805.   \def\abx@exclam{\abx@puncthook{!}}%
  1806.   \def\abx@question{\abx@puncthook{?}}%
  1807.   \global\let\abx@puncthook\@firstofone
  1808.   \global\let\blx@postpunct\@empty}
  1809.  
  1810. \blx@resetpunct
  1811.  
  1812. % {<character>}{<true>}{<false>}
  1813. \protected\def\blx@imc@ifpunctmark#1{%
  1814.   \ifhmode
  1815.     \begingroup
  1816.     \sfcode`\*=\blx@sf@dot
  1817.     \ifnum\sfcode`#1=\spacefactor
  1818.       \endgroup
  1819.       \expandafter\expandafter
  1820.       \expandafter\@firstoftwo
  1821.     \else
  1822.       \endgroup
  1823.       \expandafter\expandafter
  1824.       \expandafter\@secondoftwo
  1825.     \fi
  1826.   \else
  1827.     \expandafter\@secondoftwo
  1828.   \fi}
  1829.  
  1830. % {<true>}{<false>}
  1831. \protected\def\blx@imc@ifterm{%
  1832.   \ifhmode
  1833.     \expandafter\blx@imc@ifcapital
  1834.   \else
  1835.     \expandafter\@secondoftwo
  1836.   \fi}
  1837.  
  1838. % {<true>}{<false>}
  1839. \protected\def\blx@imc@ifcapital{%
  1840.   \ifcsdef{blx@cap@\blx@spacefactor}}
  1841.  
  1842. % {<true>}{<false>}
  1843. \protected\def\blx@imc@ifpunct{%
  1844.   \ifnum\blx@spacefactor>\blx@sf@threshold@low
  1845.     \ifnum\blx@spacefactor<\blx@sf@threshold@high
  1846.       \expandafter\expandafter
  1847.       \expandafter\@firstoftwo
  1848.     \else
  1849.       \expandafter\expandafter
  1850.       \expandafter\@secondoftwo
  1851.     \fi
  1852.   \else
  1853.     \expandafter\@secondoftwo
  1854.   \fi}
  1855.  
  1856. % {<character>}
  1857. \newrobustcmd*{\autocap}[1]{#1}
  1858.  
  1859. \protected\def\blx@imc@autocap{%
  1860.   \blx@imc@ifcapital\MakeUppercase\@firstofone}
  1861.  
  1862. \protected\def\blx@imc@nopunct{%
  1863.   \leavevmode\spacefactor\blx@sf@nopunct}
  1864.  
  1865. \protected\def\blx@imc@isdot{%
  1866.   \ifnum\blx@spacefactor=\blx@sf@period
  1867.     \spacefactor\blx@sf@dot
  1868.   \fi}
  1869.  
  1870. \protected\def\blx@imc@adddot{%
  1871.   \blx@addpunct{dot}%
  1872.   \ifnum\blx@spacefactor=\blx@sf@period
  1873.     \spacefactor\blx@sf@dot
  1874.   \fi}
  1875.  
  1876. \protected\def\blx@imc@addperiod{%
  1877.   \blx@addpunct{period}%
  1878.   \ifnum\blx@spacefactor=\blx@sf@dot
  1879.     \spacefactor\blx@sf@period
  1880.   \fi}
  1881.  
  1882. \protected\def\blx@imc@addcomma{\blx@addpunct{comma}}
  1883. \protected\def\blx@imc@addsemicolon{\blx@addpunct{semicolon}}
  1884. \protected\def\blx@imc@addcolon{\blx@addpunct{colon}}
  1885. \protected\def\blx@imc@addexclam{\blx@addpunct{exclam}}
  1886. \protected\def\blx@imc@addquestion{\blx@addpunct{question}}
  1887.  
  1888. \def\blx@addpunct#1{%
  1889.   \unspace
  1890.   \ifnum\blx@spacefactor<\blx@sf@threshold@low
  1891.     \csuse{blx@qp@#1}\csuse{abx@#1}%
  1892.   \else
  1893.     \ifnum\blx@spacefactor>\blx@sf@threshold@high
  1894.       \csuse{blx@qp@#1}\csuse{abx@#1}%
  1895.     \else
  1896.       \ifcsdef{blx@pp@\the\csname blx@sf@#1\endcsname @\blx@spacefactor}
  1897.        {\csuse{blx@qp@#1}\csuse{abx@#1}}
  1898.        {\csuse{blx@qp@#1}}%
  1899.     \fi
  1900.   \fi
  1901.   \csuse{blx@pq@#1}}
  1902.  
  1903. \providerobustcmd*{\unspace}{%
  1904.   \ifbool{hmode}
  1905.    {\ifdimgreater\lastskip\z@
  1906.       {\unskip\unspace}
  1907.       {\ifnumgreater\lastpenalty\z@
  1908.          {\unpenalty\unspace}
  1909.          {}}}
  1910.    {}}
  1911.  
  1912. \newrobustcmd*{\bibsentence}{%
  1913.   \leavevmode\spacefactor\blx@sf@par
  1914.   \ignorespaces}
  1915.  
  1916. \newrobustcmd*{\midsentence}{%
  1917.   \leavevmode
  1918.   \@ifstar
  1919.     {\ifnum\spacefactor=\blx@sf@dot
  1920.     \else
  1921.       \spacefactor\@m
  1922.     \fi}
  1923.    {\spacefactor\@m}}
  1924.  
  1925. \newrobustcmd*{\addslash}{%
  1926.   \unspace/\penalty\hyphenpenalty\hskip\z@skip}
  1927.  
  1928. \newrobustcmd*{\addspace}{%
  1929.   \unspace\blx@postpunct
  1930.   \space\blx@imc@resetpunctfont}
  1931.  
  1932. \newrobustcmd*{\addnbspace}{%
  1933.   \unspace\blx@postpunct
  1934.   \nobreak\space\blx@imc@resetpunctfont}
  1935.  
  1936. \newrobustcmd*{\addthinspace}{%
  1937.   \unspace\blx@postpunct
  1938.   \hskip0.16667em\relax
  1939.   \blx@imc@resetpunctfont}
  1940.  
  1941. \newrobustcmd*{\addnbthinspace}{%
  1942.   \unspace\blx@postpunct
  1943.   \nobreak\hskip0.16667em\relax
  1944.   \blx@imc@resetpunctfont}
  1945.  
  1946. \newrobustcmd*{\addlowpenspace}{%
  1947.   \unspace\blx@postpunct
  1948.   \penalty\value{lownamepenalty}\space
  1949.  \blx@imc@resetpunctfont}
  1950.  
  1951. \newrobustcmd*{\addhighpenspace}{%
  1952.   \unspace\blx@postpunct
  1953.   \penalty\value{highnamepenalty}\space
  1954.  \blx@imc@resetpunctfont}
  1955.  
  1956. \newrobustcmd*{\addlpthinspace}{%
  1957.   \unspace\blx@postpunct
  1958.   \penalty\value{lownamepenalty}%
  1959.   \hskip0.16667em\relax\blx@imc@resetpunctfont}
  1960.  
  1961. \newrobustcmd*{\addhpthinspace}{%
  1962.   \unspace\blx@postpunct
  1963.   \penalty\value{highnamepenalty}%
  1964.   \hskip0.16667em\relax\blx@imc@resetpunctfont}
  1965.  
  1966. \newrobustcmd*{\addabbrvspace}{%
  1967.   \unspace\blx@postpunct
  1968.   \penalty\value{abbrvpenalty}%
  1969.   \space\blx@imc@resetpunctfont}
  1970.  
  1971. \newrobustcmd*{\addabthinspace}{%
  1972.   \unspace\blx@postpunct
  1973.   \penalty\value{abbrvpenalty}%
  1974.   \hskip0.16667em\relax
  1975.   \blx@imc@resetpunctfont}
  1976.  
  1977. \newrobustcmd*{\adddotspace}{%
  1978.   \unspace\adddot\blx@postpunct
  1979.   \penalty\value{abbrvpenalty}%
  1980.   \space\blx@imc@resetpunctfont}
  1981.  
  1982. \providerobustcmd*{\noligature}{%
  1983.   \penalty\@M\discretionary{-}{}{\kern0.03em}%
  1984.   \nobreak\hskip\z@skip}
  1985.  
  1986. \providerobustcmd*{\hyphen}{%
  1987.   \nobreak-\nobreak\hskip\z@skip}
  1988.  
  1989. \providerobustcmd*{\nbhyphen}{%
  1990.   \nobreak\mbox{-}\nobreak\hskip\z@skip}
  1991.  
  1992. \providerobustcmd*{\hyphenate}{%
  1993.   \nobreak\-\nobreak\hskip\z@skip}
  1994.  
  1995. \providerobustcmd*{\allowhyphens}{%
  1996.   \nobreak\hskip\z@skip}
  1997.  
  1998. \providerobustcmd*{\nohyphenation}{%
  1999.   \lefthyphenmin\@m}
  2000.  
  2001. \providerobustcmd*{\textnohyphenation}[1]{%
  2002.   \bgroup\nohyphenation#1\egroup}
  2003.  
  2004. \blx@regimcs{%
  2005.   \setpunctfont \resetpunctfont \ifcapital \autocap \ifpunctmark
  2006.   \ifpunct \ifterm \nopunct \isdot \adddot \addperiod \addcomma
  2007.   \addsemicolon \addcolon \addexclam \addquestion}
  2008.  
  2009. \appto\blx@blxinit{%
  2010.   \appto\nocorrlist{\isdot\adddot\addperiod\addcomma}}
  2011.  
  2012. %% Style definition
  2013.  
  2014. % {<bibstyle>}
  2015. \newrobustcmd*{\RequireBibliographyStyle}[1]{%
  2016.   \blx@inputonce{#1.bbx}{bibliography style '#1'}{}{}{}
  2017.    {\blx@error
  2018.       {Style '#1' not found}
  2019.       {The bibliography style '#1' could not be found}}}
  2020. \@onlypreamble\RequireBibliographyStyle
  2021.  
  2022. % {<code>}
  2023. \newrobustcmd*{\InitializeBibliographyStyle}{\appto\blx@hook@bbxinit}
  2024. \@onlypreamble\InitializeBibliographyStyle
  2025.  
  2026. % {<entry type>}{<driverdef>}
  2027. \newrobustcmd*{\DeclareBibliographyDriver}[1]{%
  2028.   \long\csdef{blx@bbx@#1}}
  2029. \@onlypreamble\DeclareBibliographyDriver
  2030.  
  2031. % {<entry type>}
  2032. \def\blx@driver#1{%
  2033.   \ifcsdef{blx@bbx@#1}
  2034.    {\csuse{blx@bbx@#1}}
  2035.    {\ifcsdef{blx@bbx@*}
  2036.        {\blx@warning{%
  2037.           No driver for entry type '#1'.\MessageBreak
  2038.           Using fallback driver}%
  2039.         \csuse{blx@bbx@*}}
  2040.       {\blx@error
  2041.          {No driver found}
  2042.          {I can't find a driver for the entry type
  2043.           '\abx@field@entrytype'\MessageBreak
  2044.           and there is no fallback driver either}}}}
  2045.  
  2046. % {<type>}{<true>}{<false>}
  2047. \def\blx@imc@ifdriver#1{\ifcsdef{blx@bbx@#1}}
  2048.  
  2049. % {<alias>}{<type>}
  2050. \newrobustcmd*{\DeclareBibliographyAlias}[2]{%
  2051.   \csedef{blx@bbx@#1}{%
  2052.     \expandafter\noexpand\csname blx@bbx@#2\endcsname}}
  2053. \@onlypreamble\DeclareBibliographyAlias
  2054.  
  2055. %% Auxiliary commands
  2056. \newrobustcmd*{\citereset}{%
  2057.   \csuse{blx@hook@cbxinit}%
  2058.   \@ifstar
  2059.     {}
  2060.    {\global\cslet{blx@bsee@\the\c@refsection}\@empty
  2061.     \global\cslet{blx@fsee@\the\c@refsection}\@empty
  2062.     \blx@ibidreset@force
  2063.     \blx@idemreset@force
  2064.     \blx@opcitreset@force
  2065.     \blx@loccitreset@force}}
  2066.  
  2067. \def\blx@save#1{%
  2068.   \ifcsdef{blx@saved@#1}
  2069.    {}
  2070.    {\blx@safe@actives
  2071.     \csletcs{blx@saved@#1}{#1}%
  2072.      \blx@rest@actives}}
  2073.  
  2074. \def\blx@restore#1{%
  2075.   \ifcsdef{blx@saved@#1}
  2076.    {\blx@safe@actives
  2077.     \csletcs{#1}{blx@saved@#1}%
  2078.      \csundef{blx@saved@#1}%
  2079.      \blx@rest@actives}
  2080.     {}}
  2081.  
  2082. \newrobustcmd*{\savecommand}[1]{%
  2083.   \ifcsdef{blx@saved@cmd@\detokenize{#1}}
  2084.    {}
  2085.    {\cslet{blx@saved@cmd@\detokenize{#1}}{#1}}}
  2086.  
  2087. \newrobustcmd*{\restorecommand}[1]{%
  2088.   \ifcsdef{blx@saved@cmd@\detokenize{#1}}
  2089.    {\letcs{#1}{blx@saved@cmd@\detokenize{#1}}%
  2090.      \csundef{blx@saved@cmd@\detokenize{#1}}}
  2091.    {}}
  2092.  
  2093. % {<name>}
  2094. \newrobustcmd*{\savebibmacro}[1]{%
  2095.   \blx@save{abx@macro@\detokenize{#1}}}
  2096.  
  2097. \newrobustcmd*{\restorebibmacro}[1]{%
  2098.   \blx@restore{abx@macro@\detokenize{#1}}}
  2099.  
  2100. % {<name>}[<args>][<optarg>]{<definition>}
  2101. \newrobustcmd*{\newbibmacro}{%
  2102.   \@star@or@long\blx@newbibmacro}
  2103.  
  2104. \def\blx@newbibmacro#1{%
  2105.   \ifcsundef{abx@macro@\detokenize{#1}}
  2106.    {\blx@defbibmacro\new@command{#1}}
  2107.     {\blx@warning{%
  2108.        Macro '\detokenize{#1}' already defined.\MessageBreak
  2109.       Using \string\renewbibmacro}
  2110.     \blx@defbibmacro\renew@command{#1}}}
  2111.  
  2112. \newrobustcmd*{\renewbibmacro}{%
  2113.   \@star@or@long\blx@renewbibmacro}
  2114.  
  2115. \def\blx@renewbibmacro#1{%
  2116.   \ifcsundef{abx@macro@\detokenize{#1}}
  2117.     {\blx@warning{%
  2118.        Macro '\detokenize{#1}' undefined.\MessageBreak
  2119.       Using \string\newbibmacro}
  2120.     \blx@defbibmacro\new@command{#1}}
  2121.    {\blx@defbibmacro\renew@command{#1}}}
  2122.  
  2123. \newrobustcmd*{\providebibmacro}{%
  2124.   \@star@or@long{\blx@defbibmacro\provide@command}}
  2125.  
  2126. \def\blx@defbibmacro#1#2{%
  2127.   \expandafter#1\csname abx@macro@\detokenize{#2}\endcsname}
  2128.  
  2129. % {<alias>}{<name>}
  2130. \newrobustcmd*{\letbibmacro}{%
  2131.   \@ifstar
  2132.     {\blx@letbibmacro@i}
  2133.    {\blx@letbibmacro}}
  2134.  
  2135. \def\blx@letbibmacro#1#2{%
  2136.   \blx@letbibmacro@i{\detokenize{#1}}{\detokenize{#2}}}
  2137.  
  2138. \def\blx@letbibmacro@i#1#2{%
  2139.   \ifcsundef{abx@macro@#2}
  2140.    {\blx@error
  2141.       {Bibliography macro '#2' undefined}
  2142.       {Use '\string\newbibmacro' to define this macro}}
  2143.    {\csletcs{abx@macro@#1}{abx@macro@#2}}}
  2144.  
  2145. % {<name>}
  2146. \newrobustcmd*{\usebibmacro}{%
  2147.   \@ifstar
  2148.     {\blx@usebibmacro@i}
  2149.    {\blx@usebibmacro}}
  2150.  
  2151. \def\blx@usebibmacro#1{%
  2152.   \blx@usebibmacro@i{\detokenize{#1}}}
  2153.  
  2154. \def\blx@usebibmacro@i#1{%
  2155.   \ifcsundef{abx@macro@#1}
  2156.    {\blx@error
  2157.       {Bibliography macro '#1' undefined}
  2158.       {Use '\string\newbibmacro' to define this macro}}
  2159.    {\csuse{abx@macro@#1}}}
  2160.  
  2161. % {<name>}{<true>}{<false>}
  2162. \def\blx@imc@ifbibmacroundef#1{%
  2163.   \ifcsundef{abx@macro@#1}}
  2164.  
  2165. \def\ifbibmacroundef{\blx@imc@ifbibmacroundef}
  2166.  
  2167. % {<field>}
  2168. \def\blx@imc@thefield#1{\csuse{abx@field@#1}}
  2169.  
  2170. \def\blx@imc@strfield#1{%
  2171.   \ifcsdef{abx@field@#1}
  2172.    {\detokenize\expandafter\expandafter\expandafter
  2173.       {\csname abx@field@#1\endcsname}}
  2174.    {}}
  2175.  
  2176. \def\blx@imc@csfield#1{\usefield{\unexpanded}{#1}}
  2177.  
  2178. % {<command>}{<field>}
  2179. \def\blx@imc@usefield#1#2{%
  2180.   \expandafter\expandafter\expandafter#1%
  2181.   \expandafter\expandafter\expandafter{\csname abx@field@#2\endcsname}}
  2182.  
  2183. % {<plainlist>}
  2184. \def\blx@imc@thelist#1{\csuse{abx@list@#1}}
  2185.  
  2186. \def\blx@imc@strlist#1{%
  2187.   \ifcsdef{abx@list@#1}
  2188.    {\detokenize\expandafter\expandafter\expandafter
  2189.       {\csname abx@list@#1\endcsname}}
  2190.    {}}
  2191.  
  2192. % {<namelist>}
  2193. \def\blx@imc@thename#1{\csuse{abx@name@#1}}
  2194.  
  2195. \def\blx@imc@strname#1{%
  2196.   \ifcsdef{abx@name@#1}
  2197.    {\detokenize\expandafter\expandafter\expandafter
  2198.       {\csname abx@name@#1\endcsname}}
  2199.    {}}
  2200.  
  2201.  
  2202. % We have to save cleared fields/lists/names in case a related entry
  2203. % needs them for tests
  2204. \let\abx@dorelfields\@empty
  2205. \let\abx@dorellists\@empty
  2206. \let\abx@dorelnames\@empty
  2207.  
  2208. % {<field>}
  2209. % If there is a related field in the entry, save a special copy in case
  2210. % the related entry needs it for tests. See the corresponding tests in
  2211. % \blx@save{field,list,name}
  2212. \protected\def\blx@imc@clearfield#1{%
  2213.   \ifdef\abx@field@related
  2214.     {\csletcs{abx@field@relsaved#1}{abx@field@#1}%
  2215.      \listadd\abx@dorelfields{#1}}
  2216.    {}%
  2217.   \csundef{abx@field@#1}}
  2218.  
  2219. % {<plainlist>}
  2220. % If there is a related field in the entry, save a special copy in case
  2221. % the related entry needs it for tests. See the corresponding tests in
  2222. % \blx@save{field,list,name}
  2223. \protected\def\blx@imc@clearlist#1{%
  2224.   \ifcsundef{abx@list@#1}
  2225.    {}
  2226.    {\ifdef\abx@field@related
  2227.       {\csletcs{abx@list@relsaved#1}{abx@list@#1}%
  2228.         \csletcs{etb@tgl@abx@bool@morerelsaved#1}{etb@tgl@abx@bool@more#1}%
  2229.         \csletcs{c@relsaved#1}{c@#1}%
  2230.         \listadd\abx@dorellists{#1}}
  2231.       {}%
  2232.      \togglefalse{abx@bool@more#1}%
  2233.      \csundef{abx@list@#1}%
  2234.      \csname c@#1\endcsname\z@}}
  2235.  
  2236. % {<namelist>}
  2237. % If there is a related field in the entry, save a special copy in case
  2238. % the related entry needs it for tests. See the corresponding tests in
  2239. % \blx@save{field,list,name}
  2240. \protected\def\blx@imc@clearname#1{%
  2241.   \ifcsundef{abx@name@#1}
  2242.    {}
  2243.    {\ifdef\abx@field@related
  2244.      {\csletcs{abx@name@relsaved#1}{abx@name@#1}%
  2245.        \csletcs{etb@tgl@abx@bool@morerelsaved#1}{etb@tgl@abx@bool@more#1}%
  2246.        \csletcs{c@relsaved#1}{c@#1}%
  2247.        \listadd\abx@dorelnames{#1}}
  2248.      {}%
  2249.      \togglefalse{abx@bool@more#1}%
  2250.      \csundef{abx@name@#1}%
  2251.      \csname c@#1\endcsname\z@}}
  2252.  
  2253. % {<field>}{<macro>}
  2254. \protected\def\blx@imc@restorefield#1{\cslet{abx@field@#1}}
  2255.  
  2256. % {<plainlist>}{<macro>}
  2257. \protected\def\blx@imc@restorelist#1{\cslet{abx@list@#1}}
  2258.  
  2259. % {<namelist>}{<macro>}
  2260. \protected\def\blx@imc@restorename#1{\cslet{abx@name@#1}}
  2261.  
  2262. % {<field>}{<macro>}
  2263. \protected\def\blx@imc@savefield{%
  2264.   \@ifstar{\blx@savedata{field}}{\global\blx@savedata{field}}}
  2265. \def\blx@savedata#1#2#3{\letcs#3{abx@#1@#2}}
  2266.  
  2267. % {<plainlist>}{<macro>}
  2268. \protected\def\blx@imc@savelist{%
  2269.   \@ifstar{\blx@savedata{list}}{\global\blx@savedata{list}}}
  2270.  
  2271. % {<namelist>}{<macro>}
  2272. \protected\def\blx@imc@savename{%
  2273.   \@ifstar{\blx@savedata{name}}{\global\blx@savedata{name}}}
  2274.  
  2275. % {<field>}{<csname>}
  2276. \protected\def\blx@imc@savefieldcs{%
  2277.   \@ifstar{\blx@savedatacs{field}}{\global\blx@savedatacs{field}}}
  2278. \def\blx@savedatacs#1#2#3{\csletcs{#3}{abx@#1@#2}}
  2279.  
  2280. % {<plainlist>}{<csname>}
  2281. \protected\def\blx@imc@savelistcs{%
  2282.   \@ifstar{\blx@savedatacs{list}}{\global\blx@savedatacs{list}}}
  2283.  
  2284. % {<namelist>}{<csname>}
  2285. \protected\def\blx@imc@savenamecs{%
  2286.   \@ifstar{\blx@savedatacs{name}}{\global\blx@savedatacs{name}}}
  2287.  
  2288. % {<field>}{<true>}{<false>}
  2289. \def\blx@imc@iffieldundef#1{%
  2290.   \ifcsundef{abx@field@#1}}
  2291.  
  2292. % {<plainlist>}{<true>}{<false>}
  2293. \def\blx@imc@iflistundef#1{%
  2294.   \ifcsundef{abx@list@#1}}
  2295.  
  2296. % {<namelist>}{<true>}{<false>}
  2297. \def\blx@imc@ifnameundef#1{%
  2298.   \ifcsundef{abx@name@#1}}
  2299.  
  2300. % {<field1>}{<field2>}{<true>}{<false>}
  2301. \def\blx@imc@iffieldsequal#1#2{%
  2302.   \ifcsequal{abx@field@#1}{abx@field@#2}}
  2303.  
  2304. % {<plainlist1>}{<plainlist2>}{<true>}{<false>}
  2305. \def\blx@imc@iflistsequal#1#2{%
  2306.   \ifcsequal{abx@list@#1}{abx@list@#2}}
  2307.  
  2308. % {<namelist1>}{<namelist2>}{<true>}{<false>}
  2309. \def\blx@imc@ifnamesequal#1#2{%
  2310.   \ifcsundef{abx@name@#1}
  2311.    {\@secondoftwo}
  2312.    {\ifcsundef{abx@name@#2}
  2313.       {\@secondoftwo}
  2314.       {\blx@ifnamesequal{#1}{#2}}}}
  2315.  
  2316. \def\blx@ifnamesequal#1#2{%
  2317.   \begingroup
  2318.   \let\blx@tempa\@empty
  2319.   \expandafter\expandafter
  2320.   \expandafter\blx@ifnamesequal@i\csname abx@name@#2\endcsname
  2321.   \let\blx@tempb\blx@tempa
  2322.   \let\blx@tempa\@empty
  2323.   \expandafter\expandafter
  2324.   \expandafter\blx@ifnamesequal@i\csname abx@name@#1\endcsname
  2325.   \expandafter\endgroup
  2326.   \ifx\blx@tempa\blx@tempb
  2327.     \expandafter\@firstoftwo
  2328.   \else
  2329.     \expandafter\@secondoftwo
  2330.   \fi}
  2331.  
  2332. \def\blx@ifnamesequal@i#1#2{%
  2333.   \expandafter\blx@ifnamesequal@ii#2{}&}
  2334.  
  2335. \def\blx@ifnamesequal@ii#1{%
  2336.   \ifblank{#1}
  2337.    {\blx@namebreak}
  2338.     {\blx@ifnamesequal@iii#1%
  2339.      \blx@ifnamesequal@ii}}
  2340.  
  2341. % These explicit nameparts are alright as they are for bibtex only
  2342. % biber names will always have a hash generated from all nameparts in datamodel
  2343. \def\blx@ifnamesequal@iii#1#2{%
  2344.   \setkeys{blx@opt@name}{#1}%
  2345.   \setkeys{blx@opt@namepart}{#2}%
  2346.   \ifdef\abx@field@hash
  2347.     {\eappto\blx@tempa{{\abx@field@hash}}}
  2348.    {\eappto\blx@tempa{{{\namepartfamily}{\namepartgiven}{\namepartprefix}{\namepartsuffix}}}}}
  2349.  
  2350. % {<field>}{<macro>}{<true>}{<false>}
  2351. \def\blx@imc@iffieldequals#1#2{%
  2352.   \blx@imc@iffieldundef{#1}
  2353.    {\@secondoftwo}
  2354.     {\ifundef#2%
  2355.        {\@secondoftwo}
  2356.        {\expandafter\ifx\csname abx@field@#1\endcsname#2%
  2357.           \expandafter\@firstoftwo
  2358.         \else
  2359.           \expandafter\@secondoftwo
  2360.         \fi}}}
  2361.  
  2362. % {<plainlist>}{<macro>}{<true>}{<false>}
  2363. \def\blx@imc@iflistequals#1#2{%
  2364.   \blx@imc@iflistundef{#1}
  2365.    {\@secondoftwo}
  2366.     {\ifundef#2%
  2367.        {\@secondoftwo}
  2368.        {\expandafter\ifx\csname abx@list@#1\endcsname#2%
  2369.           \expandafter\@firstoftwo
  2370.         \else
  2371.           \expandafter\@secondoftwo
  2372.         \fi}}}
  2373.  
  2374. % {<namelist>}{<macro>}{<true>}{<false>}
  2375. \def\blx@imc@ifnameequals#1#2{% FIXME
  2376.   \blx@imc@ifnameundef{#1}
  2377.    {\@secondoftwo}
  2378.     {\ifundef#2%
  2379.        {\@secondoftwo}
  2380.        {\expandafter\ifx\csname abx@name@#1\endcsname#2%
  2381.           \expandafter\@firstoftwo
  2382.         \else
  2383.           \expandafter\@secondoftwo
  2384.         \fi}}}
  2385.  
  2386. % {<field>}{<csname>}{<true>}{<false>}
  2387. \def\blx@imc@iffieldequalcs#1{%
  2388.   \ifcsequal{abx@field@#1}}
  2389.  
  2390. % {<plainlist>}{<csname>}{<true>}{<false>}
  2391. \def\blx@imc@iflistequalcs#1{%
  2392.   \ifcsequal{abx@list@#1}}
  2393.  
  2394. % {<namelist>}{<csname>}{<true>}{<false>}
  2395. \def\blx@imc@ifnameequalcs#1{% FIXME
  2396.   \ifcsequal{abx@name@#1}}
  2397.  
  2398. % {<field>}{<string>}{<true>}{<false>}
  2399. \protected\long\def\blx@imc@iffieldequalstr#1#2{%
  2400.   \blx@imc@iffieldundef{#1}
  2401.    {\@secondoftwo}
  2402.     {\expandafter\expandafter\expandafter\ifstrequal
  2403.      \expandafter\expandafter\expandafter{%
  2404.        \csname abx@field@#1\endcsname}{#2}}}
  2405.  
  2406. % {<field>}{<true>}{<false>}
  2407. \protected\def\blx@imc@iffieldxref#1{%
  2408.   \blx@imc@iffieldundef{#1}
  2409.    {\@secondoftwo}
  2410.    {\blx@whichxref
  2411.       {\blx@iffieldxref{#1}}
  2412.       {\@secondoftwo}}}
  2413.  
  2414. \def\blx@iffieldxref#1#2{%
  2415.   \begingroup
  2416.   \letcs\blx@tempa{abx@field@#2}%
  2417.   \letcs\blx@tempb{abx@field@#1}%
  2418.   \blx@resetdata
  2419.   \blx@getdata{\blx@tempa}%
  2420.   \blx@imc@iffieldequals{#1}\blx@tempb
  2421.    {\aftergroup\@firstoftwo}
  2422.    {\aftergroup\@secondoftwo}%
  2423.   \endgroup}
  2424.  
  2425. \def\blx@whichxref#1#2{%
  2426.   \blx@imc@iffieldundef{crossref}
  2427.    {\blx@imc@iffieldundef{xref}
  2428.       {#2}
  2429.       {#1{xref}}}
  2430.    {#1{crossref}}}
  2431.  
  2432. % {<plainlist>}{<true>}{<false>}
  2433. \protected\def\blx@imc@iflistxref#1{%
  2434.   \blx@imc@iflistundef{#1}
  2435.    {\@secondoftwo}
  2436.    {\blx@whichxref
  2437.       {\blx@iflistxref{#1}}
  2438.       {\@secondoftwo}}}
  2439.  
  2440. \def\blx@iflistxref#1#2{%
  2441.   \begingroup
  2442.   \letcs\blx@tempa{abx@field@#2}%
  2443.   \letcs\blx@tempb{abx@list@#1}%
  2444.   \blx@resetdata
  2445.   \blx@getdata{\blx@tempa}%
  2446.   \blx@imc@iflistequals{#1}\blx@tempb
  2447.    {\aftergroup\@firstoftwo}
  2448.    {\aftergroup\@secondoftwo}%
  2449.   \endgroup}
  2450.  
  2451. % {<namelist>}{<true>}{<false>}
  2452. \protected\def\blx@imc@ifnamexref#1{%
  2453.   \blx@imc@ifnameundef{#1}
  2454.    {\@secondoftwo}
  2455.    {\blx@whichxref
  2456.       {\blx@ifnamexref{#1}}
  2457.       {\@secondoftwo}}}
  2458.  
  2459. \def\blx@ifnamexref#1#2{%
  2460.   \begingroup
  2461.   \letcs\blx@tempa{abx@field@#2}%
  2462.   \letcs\blx@tempb{abx@name@#1}%
  2463.   \blx@resetdata
  2464.   \blx@getdata{\blx@tempa}%
  2465.   \blx@imc@ifnameequals{#1}\blx@tempb
  2466.    {\aftergroup\@firstoftwo}
  2467.    {\aftergroup\@secondoftwo}%
  2468.   \endgroup}
  2469.  
  2470. % {<string>}{<true>}{<false>}
  2471. \protected\def\blx@imc@ifcurrentfield#1{%
  2472.   \begingroup
  2473.   \def\blx@tempa{#1}%
  2474.   \ifx\currentfield\blx@tempa
  2475.     \aftergroup\@firstoftwo
  2476.   \else
  2477.     \aftergroup\@secondoftwo
  2478.   \fi
  2479.   \endgroup}
  2480.  
  2481. % {<string>}{<true>}{<false>}
  2482. \protected\def\blx@imc@ifcurrentlist#1{%
  2483.   \begingroup
  2484.   \def\blx@tempa{#1}%
  2485.   \ifx\currentlist\blx@tempa
  2486.     \aftergroup\@firstoftwo
  2487.   \else
  2488.     \aftergroup\@secondoftwo
  2489.   \fi
  2490.   \endgroup}
  2491.  
  2492. % {<string>}{<true>}{<false>}
  2493. \protected\def\blx@imc@ifcurrentname#1{%
  2494.   \begingroup
  2495.   \def\blx@tempa{#1}%
  2496.   \ifx\currentname\blx@tempa
  2497.     \aftergroup\@firstoftwo
  2498.   \else
  2499.     \aftergroup\@secondoftwo
  2500.   \fi
  2501.   \endgroup}
  2502.  
  2503. % {<string>}{<true>}{<false>}
  2504. \protected\def\blx@imc@ifentrytype#1{%
  2505.   \begingroup
  2506.   \def\blx@tempa{#1}%
  2507.   \ifx\abx@field@entrytype\blx@tempa
  2508.     \aftergroup\@firstoftwo
  2509.   \else
  2510.     \aftergroup\@secondoftwo
  2511.   \fi
  2512.   \endgroup}
  2513.  
  2514. % {<true>}{<false>}
  2515. \def\blx@imc@ifmorenames{%
  2516.   \ifundef\currentname
  2517.     {\@secondoftwo}
  2518.    {\iftoggle{abx@bool@more\currentname}
  2519.       {\@firstoftwo}
  2520.       {\ifnum\c@listtotal>\c@liststop
  2521.          \expandafter\@firstoftwo
  2522.        \else
  2523.          \expandafter\@secondoftwo
  2524.        \fi}}}
  2525.  
  2526. % {<true>}{<false>}
  2527. \def\blx@imc@ifmoreitems{%
  2528.   \ifundef\currentlist
  2529.     {\@secondoftwo}
  2530.    {\iftoggle{abx@bool@more\currentlist}
  2531.       {\@firstoftwo}
  2532.       {\ifnum\c@listtotal>\c@liststop
  2533.          \expandafter\@firstoftwo
  2534.        \else
  2535.          \expandafter\@secondoftwo
  2536.        \fi}}}
  2537.  
  2538. % {<true>}{<false>}
  2539. \def\blx@imc@iffirstcitekey{%
  2540.   \ifboolexpr{ ( test {\ifnumequal\c@multicitetotal\z@}
  2541.                 and test {\ifnumequal\c@citecount\@ne} )
  2542.    or ( test {\ifnumgreater\c@multicitetotal\z@}
  2543.         and test {\ifnumequal\c@multicitecount\@ne}
  2544.         and test {\ifnumequal\c@citecount\@ne} ) }}
  2545.  
  2546. \def\blx@imc@iflastcitekey{%
  2547.   \ifboolexpr{ test {\ifnumequal\c@citecount\c@citetotal}
  2548.               and test {\ifnumequal\c@multicitecount\c@multicitetotal} }}
  2549.  
  2550. % {<category>}{<true>}{<false>}
  2551. \protected\def\blx@imc@ifcategory{%
  2552.   \ifdef\abx@field@entrykey
  2553.     {\blx@imc@ifentrycategory\abx@field@entrykey}
  2554.    {\expandafter\@secondoftwo\@gobble}}
  2555.  
  2556. % {<entrykey>}{<category>}{<true>}{<false>}
  2557. \protected\def\blx@imc@ifentrycategory{%
  2558.   \blx@xsanitizeafter\blx@imc@ifentrycategory@i}
  2559.  
  2560. \def\blx@imc@ifentrycategory@i#1#2{%
  2561.   \ifcsdef{blx@catg@\detokenize{#2}}
  2562.    {\ifinlistcs{#1}{blx@catg@\detokenize{#2}}}
  2563.    {\@secondoftwo}}
  2564.  
  2565. % {<keyword>}{<true>}{<false>}
  2566. \protected\def\blx@imc@ifkeyword{%
  2567.   \ifdef\abx@field@entrykey
  2568.     {\blx@imc@ifentrykeyword\abx@field@entrykey}
  2569.    {\expandafter\@secondoftwo\@gobble}}
  2570.  
  2571. % {<entrykey>}{<keyword>}{<true>}{<false>}
  2572. \protected\def\blx@imc@ifentrykeyword{%
  2573.   \blx@xsanitizeafter\blx@imc@ifentrykeyword@i}
  2574.  
  2575. \def\blx@imc@ifentrykeyword@i#1#2{%
  2576.   \ifcsdef{blx@keyw@\the\c@refsection @\detokenize{#2}}
  2577.    {\ifinlistcs{#1}{blx@keyw@\the\c@refsection @\detokenize{#2}}}
  2578.    {\@secondoftwo}}
  2579.  
  2580. % {<true>}{<false>}
  2581. \protected\def\blx@ifciteseen@global{%
  2582.   \ifbool{citetracker}
  2583.    {\ifdef\abx@field@entrykey
  2584.       {\expandafter\blx@ifseen@global
  2585.        \expandafter{\abx@field@entrykey}}
  2586.       {\@secondoftwo}}
  2587.    {\@secondoftwo}}
  2588.  
  2589. \protected\def\blx@ifciteseen@context{%
  2590.   \ifbool{citetracker}
  2591.    {\ifdef\abx@field@entrykey
  2592.       {\expandafter\blx@ifseen@context
  2593.        \expandafter{\abx@field@entrykey}}
  2594.       {\@secondoftwo}}
  2595.    {\@secondoftwo}}
  2596.  
  2597. \protected\def\blx@ifciteseen@context{%
  2598.   \ifbool{citetracker}
  2599.    {\ifdef\abx@field@entrykey
  2600.       {\expandafter\blx@ifseen@context
  2601.        \expandafter{\abx@field@entrykey}}
  2602.       {\@secondoftwo}}
  2603.    {\@secondoftwo}}
  2604.  
  2605. % {<entrykey>}{<true>}{<false>}
  2606. \protected\def\blx@ifentryseen@global{%
  2607.   \blx@xsanitizeafter\blx@ifseen@global}
  2608.  
  2609. \protected\def\blx@ifentryseen@context{%
  2610.   \blx@xsanitizeafter\blx@ifseen@context}
  2611.  
  2612. \def\blx@ifseen@global#1{%
  2613.   \ifbool{citetracker}
  2614.    {\ifinlistcs{#1}{blx@bsee@\the\c@refsection}}
  2615.    {\@secondoftwo}}
  2616.  
  2617. \def\blx@ifseen@context#1{%
  2618.   \ifbool{citetracker}
  2619.    {\iftoggle{blx@footnote}
  2620.       {\ifinlistcs{#1}{blx@fsee@\the\c@refsection}}
  2621.       {\ifinlistcs{#1}{blx@bsee@\the\c@refsection}}}
  2622.    {\@secondoftwo}}
  2623.  
  2624. % {<true>}{<false>}
  2625. \def\blx@ifciteibid@global{%
  2626.   \ifbool{citetracker}
  2627.    {\blx@imc@iffieldequals{entrykey}\blx@lastkey@text}
  2628.    {\@secondoftwo}}
  2629.  
  2630. \def\blx@ifciteibid@context{%
  2631.   \ifbool{citetracker}
  2632.    {\iftoggle{blx@footnote}
  2633.       {\blx@imc@iffieldequals{entrykey}\blx@lastkey@foot}
  2634.       {\blx@imc@iffieldequals{entrykey}\blx@lastkey@text}}
  2635.    {\@secondoftwo}}
  2636.  
  2637. \def\blx@ifciteibid@strict{%
  2638.   \ifbool{citetracker}
  2639.    {\blx@ifcitesingle
  2640.       {\blx@ifciteibid@global}
  2641.       {\@secondoftwo}}
  2642.    {\@secondoftwo}}
  2643.  
  2644. \def\blx@ifciteibid@constrict{%
  2645.   \ifbool{citetracker}
  2646.    {\blx@ifcitesingle
  2647.       {\iftoggle{blx@footnote}
  2648.          {\blx@ifmpfncheck
  2649.             {\blx@imc@iffieldequals{entrykey}\blx@lastkey@foot}
  2650.             {\@secondoftwo}}
  2651.          {\blx@imc@iffieldequals{entrykey}\blx@lastkey@text}}
  2652.       {\@secondoftwo}}
  2653.    {\@secondoftwo}}
  2654.  
  2655. % {<true>}{<false>}
  2656. \def\blx@ifciteidem@global{%
  2657.   \ifbool{citetracker}
  2658.    {\blx@imc@iffieldequals{fullhash}\blx@lasthash@text}
  2659.    {\@secondoftwo}}
  2660.  
  2661. \def\blx@ifciteidem@context{%
  2662.   \ifbool{citetracker}
  2663.    {\iftoggle{blx@footnote}
  2664.       {\blx@imc@iffieldequals{fullhash}\blx@lasthash@foot}
  2665.       {\blx@imc@iffieldequals{fullhash}\blx@lasthash@text}}
  2666.    {\@secondoftwo}}
  2667.  
  2668. \let\blx@ifciteidem@strict\blx@ifciteidem@global
  2669.  
  2670. \def\blx@ifciteidem@constrict{%
  2671.   \ifbool{citetracker}
  2672.    {\iftoggle{blx@footnote}
  2673.       {\blx@ifmpfncheck
  2674.          {\blx@imc@iffieldequals{fullhash}\blx@lasthash@foot}
  2675.          {\@secondoftwo}}
  2676.       {\blx@imc@iffieldequals{fullhash}\blx@lasthash@text}}
  2677.    {\@secondoftwo}}
  2678.  
  2679. % {<true>}{<false>}
  2680. \def\blx@ifopcit@global{%
  2681.   \ifbool{citetracker}
  2682.    {\blx@imc@iffieldundef{namehash}
  2683.       {\@secondoftwo}
  2684.       {\blx@imc@iffieldequalcs{entrykey}{blx@lastkey@text@\abx@field@namehash}}}
  2685.    {\@secondoftwo}}
  2686.  
  2687. \def\blx@ifopcit@context{%
  2688.   \ifbool{citetracker}
  2689.    {\blx@imc@iffieldundef{namehash}
  2690.       {\@secondoftwo}
  2691.       {\iftoggle{blx@footnote}
  2692.          {\blx@imc@iffieldequalcs{entrykey}{blx@lastkey@foot@\abx@field@namehash}}
  2693.          {\blx@imc@iffieldequalcs{entrykey}{blx@lastkey@text@\abx@field@namehash}}}}
  2694.    {\@secondoftwo}}
  2695.  
  2696. \def\blx@ifopcit@strict{%
  2697.   \ifbool{citetracker}
  2698.    {\blx@ifcitesingle
  2699.       {\blx@ifopcit@global}
  2700.       {\@secondoftwo}}
  2701.    {\@secondoftwo}}
  2702.  
  2703. \def\blx@ifopcit@constrict{%
  2704.   \ifbool{citetracker}
  2705.    {\blx@ifcitesingle
  2706.       {\blx@imc@iffieldundef{namehash}
  2707.          {\@secondoftwo}
  2708.          {\iftoggle{blx@footnote}
  2709.             {\blx@ifmpfncheck
  2710.                {\blx@imc@iffieldequalcs{entrykey}{blx@lastkey@foot@\abx@field@namehash}}
  2711.                {\@secondoftwo}}
  2712.             {\blx@imc@iffieldequalcs{entrykey}{blx@lastkey@text@\abx@field@namehash}}}}
  2713.       {\@secondoftwo}}
  2714.    {\@secondoftwo}}
  2715.  
  2716. % {<true>}{<false>}
  2717. \def\blx@ifloccit@global{%
  2718.   \ifbool{citetracker}
  2719.    {\blx@loccit@check{text}}
  2720.    {\@secondoftwo}}
  2721.  
  2722. \def\blx@ifloccit@context{%
  2723.   \ifbool{citetracker}
  2724.    {\iftoggle{blx@footnote}
  2725.       {\blx@loccit@check{foot}}
  2726.       {\blx@loccit@check{text}}}
  2727.    {\@secondoftwo}}
  2728.  
  2729. \def\blx@ifloccit@strict{%
  2730.   \ifbool{citetracker}
  2731.    {\blx@ifcitesingle
  2732.       {\blx@loccit@numcheck{text}}
  2733.       {\@secondoftwo}}
  2734.    {\@secondoftwo}}
  2735.  
  2736. \def\blx@ifloccit@constrict{%
  2737.   \ifbool{citetracker}
  2738.    {\blx@ifcitesingle
  2739.       {\iftoggle{blx@footnote}
  2740.          {\blx@ifmpfncheck
  2741.             {\blx@loccit@numcheck{foot}}
  2742.             {\@secondoftwo}}
  2743.          {\blx@loccit@numcheck{text}}}
  2744.       {\@secondoftwo}}
  2745.    {\@secondoftwo}}
  2746.  
  2747. \def\blx@loccit@check#1{%
  2748.   \blx@imc@iffieldundef{postnote}
  2749.    {\@secondoftwo}
  2750.    {\blx@imc@iffieldequalcs{postnote}{blx@lastnote@#1@\abx@field@entrykey}}}
  2751.  
  2752. \def\blx@loccit@numcheck#1{%
  2753.   \blx@imc@iffieldundef{postnote}
  2754.    {\@secondoftwo}
  2755.    {\expandafter\blx@imc@ifpages
  2756.     \expandafter{\abx@field@postnote}
  2757.       {\blx@imc@iffieldequalcs{postnote}{blx@lastnote@#1@\abx@field@entrykey}}
  2758.       {\@secondoftwo}}}
  2759.  
  2760. % {<true>}{<false>}
  2761. \def\blx@ifmpfncheck{%
  2762.   \ifnum\numexpr\value\@mpfn-\blx@lastmpfn<\tw@
  2763.     \expandafter\@firstoftwo
  2764.   \else
  2765.     \expandafter\@secondoftwo
  2766.   \fi}
  2767.  
  2768. \def\blx@mpfnsave{%
  2769.   \xdef\blx@lastmpfn{\the\value\@mpfn}}
  2770.  
  2771. \def\blx@mpfnreset{%
  2772.   \global\let\blx@lastmpfn\z@}
  2773.  
  2774. \blx@mpfnreset
  2775.  
  2776. % {<true>}{<false>}
  2777. \def\blx@imc@iffirstonpage{%
  2778.   \ifbool{pagetracker}
  2779.    {\iftoggle{blx@footnote}
  2780.       {\blx@iffirstonpage{fnpage}}
  2781.       {\blx@iffirstonpage{page}}}
  2782.    {\@secondoftwo}}
  2783.  
  2784. \def\blx@iffirstonpage#1{%
  2785.   \ifcsundef{blx@#1@\number\c@instcount}
  2786.    {\@secondoftwo}
  2787.    {\expandafter\blx@iffirstonpage@i
  2788.     \expandafter{\number\numexpr\c@instcount-1}{#1}}}
  2789.  
  2790. \def\blx@iffirstonpage@i#1#2{%
  2791.   \ifcsundef{blx@#2@#1}
  2792.    {\ifnum#1>\@ne
  2793.       \expandafter\@firstoftwo
  2794.     \else
  2795.       \expandafter\@secondoftwo
  2796.     \fi
  2797.     {\expandafter\blx@iffirstonpage@i
  2798.      \expandafter{\number\numexpr#1-1}{#2}}
  2799.     {\@firstoftwo}}
  2800.    {\ifnum\csuse{blx@#2@\number\c@instcount}=%
  2801.            \csuse{blx@#2@#1} %
  2802.        \expandafter\@secondoftwo
  2803.      \else
  2804.        \expandafter\@firstoftwo
  2805.      \fi}}
  2806.  
  2807. % {<count1>}{<count2>}{<true>}{<false>}
  2808. \def\blx@imc@ifsamepage#1#2{%
  2809.   \ifbool{pagetracker}
  2810.    {\ifcsundef{blx@page@\number\numexpr#1}
  2811.       {\ifcsundef{blx@fnpage@\number\numexpr#1}
  2812.          {\@secondoftwo}
  2813.          {\blx@ifsamepage{#1}{#2}{fnpage}}}
  2814.       {\blx@ifsamepage{#1}{#2}{page}}}
  2815.    {\@secondoftwo}}
  2816.  
  2817. \def\blx@ifsamepage#1#2#3{%
  2818.   \ifcsundef{blx@page@\number\numexpr#2}
  2819.    {\ifcsundef{blx@fnpage@\number\numexpr#2}
  2820.       {\@secondoftwo}
  2821.       {\blx@ifsamepage@i{#1}{#2}{#3}{fnpage}}}
  2822.    {\blx@ifsamepage@i{#1}{#2}{#3}{page}}}
  2823.  
  2824. \def\blx@ifsamepage@i#1#2#3#4{%
  2825.   \ifnum\csuse{blx@#3@\number\numexpr#1}=%
  2826.         \csuse{blx@#4@\number\numexpr#2} %
  2827.     \expandafter\@firstoftwo
  2828.   \else
  2829.     \expandafter\@secondoftwo
  2830.   \fi}
  2831.  
  2832. % {<string>}{<true>}{<false>}
  2833. \protected\long\def\blx@imc@ifinteger#1{%
  2834.   \begingroup
  2835.   \def\do##1{\uccode`##1=`\%}%
  2836.   \do\0\do\1\do\2\do\3\do\4\do\5\do\6\do\7\do\8\do\9%
  2837.   \makeatletter
  2838.   \catcode`\%=9
  2839.   \endlinechar\m@ne
  2840.   \uppercase{\scantokens{\def\blx@tempa{#1}}}%
  2841.   \ifx\blx@tempa\@empty
  2842.     \aftergroup\@firstoftwo
  2843.   \else
  2844.     \aftergroup\@secondoftwo
  2845.   \fi
  2846.   \endgroup}
  2847.  
  2848. % {<field>}{<true>}{<false>}
  2849. \protected\def\blx@imc@iffieldint#1{%
  2850.   \blx@imc@iffieldundef{#1}
  2851.    {\@secondoftwo}
  2852.    {\expandafter\expandafter
  2853.     \expandafter\blx@imc@ifinteger
  2854.     \expandafter\expandafter
  2855.     \expandafter{\csname abx@field@#1\endcsname}}}
  2856.  
  2857. % {<string>}{<true>}{<false>}
  2858. \protected\def\blx@imc@ifnumeral{%
  2859.   \blx@ifnum\blx@hook@ifnum}
  2860.  
  2861. \protected\def\blx@imc@ifnumerals{%
  2862.   \blx@ifnum\blx@hook@ifnums}
  2863.  
  2864. \protected\def\blx@imc@ifpages{%
  2865.   \blx@ifnum\blx@hook@ifpages}
  2866.  
  2867. \long\def\blx@ifnum#1#2{%
  2868.   \begingroup
  2869.   \let\protect\@unexpandable@protect
  2870.   \uppercase{\edef\blx@tempa{#2}}%
  2871.   \ifx\blx@tempa\@empty
  2872.     \aftergroup\@secondoftwo
  2873.   \else
  2874.     \makeatletter
  2875.     \catcode`\%=9
  2876.     \endlinechar\m@ne
  2877.     \everyeof{\noexpand}#1%
  2878.     \uppercase{\edef\blx@tempa{\scantokens{#2}}}%
  2879.     \ifx\blx@tempa\@empty
  2880.       \aftergroup\@firstoftwo
  2881.     \else
  2882.       \aftergroup\@secondoftwo
  2883.     \fi
  2884.   \fi
  2885.   \endgroup}
  2886.  
  2887. \def\blx@hook@ifnum{%
  2888.   \def\do##1{\uccode`##1=`\%}%
  2889.   \do\ \do\0\do\1\do\2\do\3\do\4\do\5\do\6\do\7\do\8\do\9%
  2890.   \do\i\do\v\do\x\do\l\do\c\do\d\do\m
  2891.   \do\I\do\V\do\X\do\L\do\C\do\D\do\M
  2892.   \blx@donumchars
  2893.   \let\RN\@firstofone
  2894.   \let\Rn\@firstofone}
  2895.  
  2896. \def\blx@hook@ifnums{%
  2897.   \blx@hook@ifnum
  2898.   \def\do##1{\uccode`##1=`\%}%
  2899.   \blx@dorangechars
  2900.   \def\do##1{\let##1\@empty}%
  2901.   \blx@dorangecmds}
  2902.  
  2903. \def\blx@hook@ifpages{%
  2904.   \blx@hook@ifnum
  2905.   \blx@hook@ifnums
  2906.   \def\do##1{\let##1\@empty}%
  2907.   \blx@dopagecmds}
  2908.  
  2909. % {<field>}{<true>}{<false>}
  2910. \protected\def\blx@imc@iffieldnum#1{%
  2911.   \blx@imc@iffieldundef{#1}
  2912.    {\@secondoftwo}
  2913.    {\expandafter\expandafter
  2914.     \expandafter\blx@imc@ifnumeral
  2915.     \expandafter\expandafter
  2916.     \expandafter{\csname abx@field@#1\endcsname}}}
  2917.  
  2918. \protected\def\blx@imc@iffieldnums#1{%
  2919.   \blx@imc@iffieldundef{#1}
  2920.    {\@secondoftwo}
  2921.    {\expandafter\expandafter
  2922.     \expandafter\blx@imc@ifnumerals
  2923.     \expandafter\expandafter
  2924.     \expandafter{\csname abx@field@#1\endcsname}}}
  2925.  
  2926. \protected\def\blx@imc@iffieldpages#1{%
  2927.   \blx@imc@iffieldundef{#1}
  2928.    {\@secondoftwo}
  2929.    {\expandafter\expandafter
  2930.     \expandafter\blx@imc@ifpages
  2931.     \expandafter\expandafter
  2932.     \expandafter{\csname abx@field@#1\endcsname}}}
  2933.  
  2934. % {<chars>}
  2935. \newrobustcmd*{\DeclareNumChars}{%
  2936.   \@ifstar
  2937.     {\blx@defnumchars}
  2938.    {\global\let\blx@donumchars\@empty
  2939.     \blx@defnumchars}}
  2940.  
  2941. \def\blx@defnumchars#1{%
  2942.   \ifblank{#1}
  2943.    {}
  2944.    {\expandafter\blx@defdochars
  2945.     \expandafter\blx@donumchars
  2946.     \detokenize{#1}\relax}}
  2947.  
  2948. % {<chars>}
  2949. \newrobustcmd*{\DeclareRangeChars}{%
  2950.   \@ifstar
  2951.     {\blx@defrangechars}
  2952.    {\global\let\blx@dorangechars\@empty
  2953.     \blx@defrangechars}}
  2954.  
  2955. \def\blx@defrangechars#1{%
  2956.   \ifblank{#1}
  2957.    {}
  2958.    {\expandafter\blx@defdochars
  2959.     \expandafter\blx@dorangechars
  2960.     \detokenize{#1}\relax}}
  2961.  
  2962. \def\blx@defdochars#1#2{%
  2963.   \ifx#2\relax
  2964.   \else
  2965.     \xdef#1{%
  2966.       \expandonce#1\noexpand\do
  2967.       \expandafter\noexpand\csname#2\endcsname}%
  2968.     \expandafter\blx@defdochars
  2969.     \expandafter#1%
  2970.   \fi}
  2971.  
  2972. % {<cstokens>}
  2973. \newrobustcmd*{\DeclareRangeCommands}{%
  2974.   \@ifstar
  2975.     {\blx@defrangecmds}
  2976.    {\global\let\blx@dorangecmds\@empty
  2977.     \blx@defrangecmds}}
  2978.  
  2979. \def\blx@defrangecmds#1{%
  2980.   \ifblank{#1}
  2981.    {}
  2982.    {\blx@defrangecmds@i#1&}}
  2983.  
  2984. \def\blx@defrangecmds@i#1{%
  2985.   \ifx&#1%
  2986.   \else
  2987.     \gappto\blx@dorangecmds{\do#1}%
  2988.     \expandafter\blx@defrangecmds@i
  2989.   \fi}
  2990.  
  2991. % {<cstokens>}
  2992. \newrobustcmd*{\DeclarePageCommands}{%
  2993.   \@ifstar
  2994.     {\blx@defpagecmds}
  2995.    {\global\let\blx@dopagecmds\@empty
  2996.     \blx@defpagecmds}}
  2997.  
  2998. \def\blx@defpagecmds#1{%
  2999.   \ifblank{#1}
  3000.    {}
  3001.    {\blx@defpagecmds@i#1&}}
  3002.  
  3003. \def\blx@defpagecmds@i#1{%
  3004.   \ifx&#1%
  3005.   \else
  3006.     \gappto\blx@dopagecmds{\do#1}%
  3007.     \expandafter\blx@defpagecmds@i
  3008.   \fi}
  3009.  
  3010. \DeclareNumChars{.}
  3011. \DeclareRangeChars{~,;-+/}
  3012. \DeclareRangeCommands{%
  3013.   \ \,\space\nobreakspace\addspace\addnbspace
  3014.   \addthinspace\addnbthinspace\addlowpenspace
  3015.   \addhighpenspace\addlpthinspace\addhpthinspace
  3016.   \adddotspace\addabbrvspace\&\psq\psqq
  3017.   \bibrangedash\bibdaterangesep\bibtimerangesep\textendash\textemdash\bibrangessep}
  3018. \DeclarePageCommands{\pno\ppno}
  3019.  
  3020. % *{<code>}
  3021. \newrobustcmd*{\NumCheckSetup}{\appto\blx@hook@ifnum}
  3022. \newcommand*{\NumcheckSetup}{\NumCheckSetup}
  3023.  
  3024. % [<pagination>][<postpro>]{<string>}
  3025. \newrobustcmd*{\blx@imc@mkpageprefix}[1][pagination]{%
  3026.   \begingroup
  3027.   \def\blx@tempa{\blx@mkpageprefix{page}}%
  3028.   \iffieldundef{#1}
  3029.    {}
  3030.    {\iffieldequalstr{#1}{none}
  3031.       {\def\blx@tempa{\blx@mkpageprefix@i}}
  3032.       {\iffieldbibstring{#1}
  3033.          {\edef\blx@tempa{\blx@mkpageprefix{\thefield{#1}}}}
  3034.           {\blx@warning@entry{%
  3035.              Unknown pagination type '\strfield{#1}'}}}}%
  3036.   \@ifnextchar[%]
  3037.     {\blx@tempa}
  3038.    {\blx@tempa[\@firstofone]}}
  3039.  
  3040. \protected\long\def\blx@mkpageprefix#1[#2]#3{%
  3041.   \ifnumeral{#3}
  3042.    {\bibstring{#1}\ppspace}
  3043.    {\ifnumerals{#3}
  3044.       {\bibstring{#1s}\ppspace}
  3045.       {\def\pno{\bibstring{#1}}%
  3046.         \def\ppno{\bibstring{#1s}}}}%
  3047.   \blx@mkpageprefix@i[#2]{#3}}
  3048.  
  3049. \long\def\blx@mkpageprefix@i[#1]#2{#1{#2}\endgroup}
  3050.  
  3051. % [<pagination>][<postpro>]{<string>}
  3052. \newrobustcmd*{\blx@imc@mkpagetotal}[1][bookpagination]{%
  3053.   \begingroup
  3054.   \def\blx@tempa{\blx@mkpagetotal{pagetotal}}%
  3055.   \iffieldundef{#1}
  3056.    {}
  3057.    {\iffieldequalstr{#1}{none}
  3058.       {\def\blx@tempa{\blx@mkpagetotal@i}}
  3059.       {\iffieldplusstringbibstring{#1}{total}
  3060.          {\edef\blx@tempa{\blx@mkpagetotal{\thefield{#1}total}}}
  3061.           {\blx@warning@entry{%
  3062.              Unknown pagination type '\strfield{#1}total'}}}}%
  3063.   \@ifnextchar[%]
  3064.     {\blx@tempa}
  3065.    {\blx@tempa[\@firstofone]}}
  3066.  
  3067. \protected\long\def\blx@mkpagetotal#1[#2]#3{%
  3068.   \ifnumeral{#3}
  3069.     {\setbox\@tempboxa=\hbox{%
  3070.        \blx@tempcnta0#3\relax
  3071.        \ifnum\blx@tempcnta=\@ne
  3072.          \aftergroup\@firstoftwo
  3073.        \else
  3074.          \aftergroup\@secondoftwo
  3075.        \fi}%
  3076.      {#2{#3}\ppspace\bibstring{#1}}
  3077.     {#2{#3}\ppspace\bibstring{#1s}}}
  3078.    {\def\pno{\bibstring{#1}}%
  3079.      \def\ppno{\bibstring{#1s}}%
  3080.      #2{#3}}%
  3081.   \endgroup}
  3082.  
  3083. \long\def\blx@mkpagetotal@i[#1]#2{#1{#2}\endgroup}
  3084.  
  3085. \newcounter{mincomprange}
  3086. \newcounter{maxcomprange}
  3087. \newcounter{mincompwidth}
  3088. \setcounter{mincomprange}{10}
  3089. \setcounter{maxcomprange}{100000}
  3090. \setcounter{mincompwidth}{1}
  3091. \def\abx@rangeproclimit{100000}
  3092.  
  3093. % {<rangefield>}
  3094. \newcommand*{\rangelen}[1]{%
  3095.   \ifcsdef{abx@range@#1}
  3096.    {\csuse{abx@range@#1}}
  3097.    {}}
  3098.  
  3099. % <*>[<postpro>]{<string>}
  3100. \newrobustcmd*{\mknormrange}{%
  3101.   \begingroup
  3102.   \@ifstar
  3103.     {\blx@range@aux\blx@normrange@ii}
  3104.    {\blx@range@aux\blx@normrange@i}}
  3105.  
  3106. \def\blx@range@aux#1{%
  3107.   \@ifnextchar[{#1}{#1[\@firstofone]}}
  3108.  
  3109. \def\blx@normrange@i[#1]#2{%
  3110.   \let\blx@tempa\@empty
  3111.   \protected\def\blx@range@out@value{\appto\blx@tempa}%
  3112.   \let\blx@range@out@delim\blx@range@out@value
  3113.   \let\blx@range@split\blx@normrange@split
  3114.   \let\blx@range@process\blx@normrange@process
  3115.   \blx@range@chunk{#2}%
  3116.   \edef\blx@tempa{\endgroup
  3117.    \unexpanded{#1}{\expandonce\blx@tempa}}%
  3118.   \blx@tempa}
  3119.  
  3120. \def\blx@normrange@ii[#1]#2{%
  3121.   \protected\def\blx@range@out@value{#1}%
  3122.   \let\blx@range@out@delim\@firstofone
  3123.   \let\blx@range@split\blx@normrange@split
  3124.   \let\blx@range@process\blx@normrange@process
  3125.   \blx@range@chunk{#2}%
  3126.   \endgroup}
  3127.  
  3128. \def\blx@range@chunk#1{%
  3129.   \blx@range@chunk@semcol#1;&}
  3130.  
  3131. \def\blx@range@chunk@semcol#1;#2&{%
  3132.   \notblank{#1}
  3133.    {\blx@range@chunk@comma#1,&}
  3134.    {}%
  3135.   \notblank{#2}
  3136.    {\notblank{#1}{\blx@range@out@delim{\bibrangessep}}{}%
  3137.      \blx@range@chunk@semcol#2&}
  3138.     {}}
  3139.  
  3140. \def\blx@range@chunk@comma#1,#2&{%
  3141.   \notblank{#1}
  3142.    {\blx@range@chunk@sep#1\bibrangessep&}
  3143.    {}%
  3144.   \notblank{#2}
  3145.    {\notblank{#1}{\blx@range@out@delim{\bibrangessep}}{}%
  3146.      \blx@range@chunk@comma#2&}
  3147.     {}}
  3148.  
  3149. \def\blx@range@chunk@sep#1\bibrangessep#2&{%
  3150.   \notblank{#1}
  3151.    {\expandafter\blx@range@split
  3152.     \expandafter{\@firstofone#1}}
  3153.    {}%
  3154.   \notblank{#2}
  3155.    {\notblank{#1}{\blx@range@out@delim{\bibrangessep}}{}%
  3156.      \blx@range@chunk@sep#2&}
  3157.     {}}
  3158.  
  3159. % Unicode en-dashes are supported in blx-unicode.def
  3160. \def\blx@normrange@split#1{%
  3161.   \def\blx@normrange@abort{\blx@range@out@value{#1}}%
  3162.   \blx@imc@ifpages{#1}
  3163.    {\blx@normrange@range#1\bibrangedash\bibrangedash&}
  3164.    {\blx@normrange@abort}}
  3165.  
  3166. \def\blx@normrange@range#1\bibrangedash#2\bibrangedash#3&{%
  3167.   \ifblank{#3}
  3168.    {\blx@normrange@hyphen#1--&}
  3169.    {\ifblank{#2}
  3170.       {\blx@range@out@value{#1\bibrangedash}}
  3171.       {\ifblank{#1}
  3172.          {\blx@range@out@value{\bibrangedash#2}}
  3173.          {\blx@range@process{#1}{#2}}}}}
  3174.  
  3175. \def\blx@normrange@hyphen#1-#2-#3&{%
  3176.   \ifblank{#3}
  3177.    {\blx@normrange@abort}
  3178.    {\ifblank{#2}
  3179.       {\ifblank{#1}
  3180.          {\let\blx@tempb\@empty}
  3181.          {\def\blx@tempb{#1}}%
  3182.         \blx@normrange@hyphen@i#3&}
  3183.        {\ifblank{#1}
  3184.          {\blx@range@out@value{\bibrangedash#2}}
  3185.          {\blx@range@process{#1}{#2}}}}}
  3186.  
  3187. \def\blx@normrange@hyphen@i#1-#2&{%
  3188.   \ifblank{#1#2}
  3189.    {\expandafter\blx@range@out@value
  3190.     \expandafter{\blx@tempb\bibrangedash}}
  3191.    {\notblank{#1}
  3192.       {\ifdefempty\blx@tempb
  3193.          {\blx@range@out@value{\bibrangedash#1}}
  3194.          {\expandafter\blx@range@process
  3195.           \expandafter{\blx@tempb}{#1}}}
  3196.       {\blx@normrange@hyphen@i#2&}}}
  3197.  
  3198. \def\blx@normrange@process#1#2{%
  3199.   \blx@range@out@value{#1\bibrangedash#2}}
  3200.  
  3201. % <*>[<postpro>]{<string>}
  3202. \newrobustcmd*{\mkcomprange}{%
  3203.   \begingroup
  3204.   \@ifstar
  3205.     {\blx@range@aux\blx@comprange@ii}
  3206.    {\blx@range@aux\blx@comprange@i}}
  3207.  
  3208. \def\blx@comprange@i[#1]#2{%
  3209.   \let\blx@tempa\@empty
  3210.   \protected\def\blx@range@out@value{\appto\blx@tempa}%
  3211.   \let\blx@range@out@delim\blx@range@out@value
  3212.   \let\blx@range@split\blx@normrange@split
  3213.   \let\blx@range@process\blx@comprange@check
  3214.   \blx@range@chunk{#2}%
  3215.   \edef\blx@tempa{\endgroup
  3216.    \unexpanded{#1}{\expandonce\blx@tempa}}%
  3217.   \blx@tempa}
  3218.  
  3219. \def\blx@comprange@ii[#1]#2{%
  3220.   \protected\def\blx@range@out@value{#1}%
  3221.   \let\blx@range@out@delim\@firstofone
  3222.   \let\blx@range@split\blx@normrange@split
  3223.   \let\blx@range@process\blx@comprange@check
  3224.   \blx@range@chunk{#2}%
  3225.   \endgroup}
  3226.  
  3227. \def\blx@comprange@check#1#2{%
  3228.   \blx@imc@ifinteger{#1}
  3229.    {\blx@imc@ifinteger{#2}
  3230.       {\blx@comprange@comp{#1}{#2}}
  3231.       {\blx@range@out@value{#1\bibrangedash#2}}}
  3232.    {\blx@range@out@value{#1\bibrangedash#2}}}
  3233.  
  3234. \def\blx@comprange@comp#1#2{%
  3235.   \def\blx@tempb{#1}%
  3236.   \def\blx@tempc{#2}%
  3237.   \let\blx@tempd\blx@tempc
  3238.   \ifnum\c@maxcomprange<\abx@rangeproclimit\relax
  3239.     \numdef\blx@tempe\abx@rangeproclimit
  3240.   \else
  3241.     \numdef\blx@tempe\c@maxcomprange
  3242.   \fi
  3243.   \blx@tempcntc=\blx@tempe\relax
  3244.   \ifnum
  3245.     \ifnum\c@mincompwidth<1\space1\fi
  3246.     \ifnum\c@maxcomprange<10\space1\fi
  3247.     \ifnum\c@mincomprange<\blx@tempb\space\else1\fi
  3248.     \ifnum\blx@tempb<\numexpr\blx@tempcntc*10\relax\else1\fi
  3249.   0=\z@
  3250.     \expandafter\blx@comprange@comp@div
  3251.   \else
  3252.     \expandafter\blx@comprange@end
  3253.   \fi}
  3254.  
  3255. \def\blx@comprange@end{%
  3256.   \numdef\blx@tempb\blx@tempb
  3257.   \ifnum\blx@tempe>\c@maxcomprange\relax
  3258.     \numdef\blx@tempc\blx@tempc
  3259.   \else
  3260.     \numdef\blx@tempc\blx@tempd
  3261.   \fi
  3262.   \edef\blx@tempb{%
  3263.     \blx@range@out@value{\blx@tempb\noexpand\bibrangedash\blx@tempc}}%
  3264.   \blx@tempb}
  3265.  
  3266. \def\blx@comprange@comp@div{%
  3267.   \unless\ifnum\blx@tempb<\blx@tempcntc
  3268.     \blx@tempcnta\blx@tempb\relax
  3269.     \blx@tempcntb\blx@tempc\relax
  3270.     \divide\blx@tempcnta\blx@tempcntc
  3271.     \divide\blx@tempcntb\blx@tempcntc
  3272.     \ifnum\blx@tempcnta=\blx@tempcntb
  3273.       \edef\blx@tempd{\expandafter\@gobble\blx@tempd}%
  3274.       \numdef\blx@tempe\blx@tempcntc
  3275.     \fi
  3276.   \fi
  3277.   \divide\blx@tempcntc10\relax
  3278.   \ifnum
  3279.     \ifnum\blx@tempcntc<10 1\fi
  3280.     \ifnum\blx@tempcntc>\c@mincompwidth\else 1\fi
  3281.   0=\z@
  3282.     \expandafter\blx@comprange@comp@div
  3283.   \else
  3284.     \expandafter\blx@comprange@end
  3285.   \fi}
  3286.  
  3287. % <*>[<postpro>]{<string>}
  3288. \newrobustcmd*{\mkfirstpage}{%
  3289.   \begingroup
  3290.   \@ifstar
  3291.     {\blx@firstpage\blx@firstpage@ii}
  3292.    {\blx@firstpage\blx@firstpage@i}}
  3293.  
  3294. \def\blx@firstpage#1{%
  3295.   \@ifnextchar[{#1}{#1[\@firstofone]}}
  3296.  
  3297. \def\blx@firstpage@i[#1]#2{%
  3298.   \let\blx@tempa\@empty
  3299.   \protected\def\blx@range@out@value{\appto\blx@tempa}%
  3300.   \let\blx@range@out@delim\blx@range@out@value
  3301.   \let\blx@range@split\blx@firstpage@split
  3302.   \blx@range@chunk{#2}%
  3303.   \edef\blx@tempa{\endgroup
  3304.    \unexpanded{#1}{\expandonce\blx@tempa}}%
  3305.   \blx@tempa}
  3306.  
  3307. \def\blx@firstpage@ii[#1]#2{%
  3308.   \protected\def\blx@range@out@value{#1}%
  3309.   \let\blx@range@out@delim\@firstofone
  3310.   \let\blx@range@split\blx@firstpage@split
  3311.   \blx@range@chunk{#2}%
  3312.   \endgroup}
  3313.  
  3314. % Unicode en-dashes are supported in blx-unicode.def
  3315. \def\blx@firstpage@split#1{%
  3316.   \def\blx@firstpage@abort{\blx@range@out@value{#1}}%
  3317.   \blx@firstpage@range#1\bibrangedash\bibrangedash&}
  3318.  
  3319. \def\blx@firstpage@range#1\bibrangedash#2\bibrangedash#3&{%
  3320.   \ifblank{#3}
  3321.    {\blx@firstpage@hyphen#1--&}
  3322.    {\ifblank{#1}
  3323.       {\blx@range@out@value{\bibrangedash#2}}
  3324.       {\blx@range@out@value{#1}}}}
  3325.  
  3326. \def\blx@firstpage@hyphen#1-#2-#3&{%
  3327.   \ifblank{#3}
  3328.    {\blx@firstpage@abort}
  3329.    {\ifblank{#1}
  3330.       {\ifblank{#2}
  3331.          {\blx@firstpage@hyphen@i#3&}
  3332.          {\blx@range@out@value{\bibrangedash#2}}}
  3333.       {\blx@range@out@value{#1}}}}
  3334.  
  3335. \def\blx@firstpage@hyphen@i#1-#2&{%
  3336.   \ifblank{#1}
  3337.    {\ifblank{#2}
  3338.       {\blx@firstpage@abort}
  3339.       {\blx@firstpage@hyphen@i#2&}}
  3340.    {\blx@range@out@value{\bibrangedash#1}}}
  3341.  
  3342. \newcommand*{\ppspace}{\addnbspace}
  3343. \newcommand*{\sqspace}{\addnbspace}
  3344.  
  3345. \newrobustcmd*{\RN}[1]{%
  3346.   \begingroup
  3347.   \expandafter\RNfont
  3348.   \expandafter{\romannumeral#1}%
  3349.   \endgroup}
  3350. \newrobustcmd*{\Rn}[1]{%
  3351.   \begingroup
  3352.   \expandafter\Rnfont
  3353.   \expandafter{\romannumeral#1}%
  3354.   \endgroup}
  3355.  
  3356. \newcommand*{\RNfont}{\uppercase}
  3357. \newcommand*{\Rnfont}{}
  3358.  
  3359. % Delimiter interface
  3360.  
  3361. % [<contextname, ...>]{<name, ...>}{<code>}
  3362. \newrobustcmd*{\DeclareDelimFormat}{%
  3363.   \@ifstar
  3364.     {\blx@declaredelimclear}
  3365.    {\blx@declaredelim}}
  3366.  
  3367. \def\blx@cleardelim#1{%
  3368.   \ifcsvoid{blx@declaredelimcontexts@#1}
  3369.    {}
  3370.    {\def\do##1{\csundef{blx@printdelim@##1@#1}}%
  3371.      \dolistcsloop{blx@declaredelimcontexts@#1}}%
  3372.   \cslet{blx@declaredelimcontexts@#1}\@empty}
  3373.  
  3374. \newrobustcmd*{\blx@declaredelimclear}[3][]{%
  3375.   \blx@cleardelim{#2}%
  3376.   \ifblank{#1}
  3377.    {\blx@declaredelim{#2}{#3}}
  3378.    {\blx@declaredelim[#1]{#2}{#3}}}
  3379.  
  3380. \newrobustcmd*{\blx@declaredelim}[3][]{%
  3381.   \ifblank{#1}
  3382.    {\blx@declaredelim@i{}{}{#2}{#3}}
  3383.     {\def\do##1{%
  3384.        \listcsadd{blx@declaredelimcontexts@#2}{##1}%
  3385.        \blx@declaredelim@i{blx@printdelim@##1@}{##1}{#2}{#3}}%
  3386.      \docsvlist{#1}}}%
  3387.  
  3388. \def\blx@declaredelim@i#1#2#3#4{%
  3389.   \def\do@i##1{%
  3390.     \ifcsdef{#1##1}
  3391.      {\blx@inf@delimdeclare{##1}{#2}}
  3392.      {}%
  3393.     \csdef{#1##1}{#4}}%
  3394.   \forcsvlist{\do@i}{#3}}
  3395.  
  3396. % *[<alias context, ...>]{<alias>}[<delim context>]{<delim>}
  3397. \newrobustcmd*{\DeclareDelimAlias}{%
  3398.   \@ifstar
  3399.     {\blx@declaredelimalias@expl}
  3400.    {\blx@declaredelimalias@auto}}
  3401.  
  3402. \newrobustcmd*{\blx@declaredelimalias@auto}[2]{%
  3403.   \blx@cleardelim{#1}%
  3404.   \blx@declaredelimalias@def{}{#1}{}{#2}%
  3405.   \ifcsvoid{blx@declaredelimcontexts@#2}
  3406.    {}
  3407.     {\def\do##1{%
  3408.        \blx@declaredelimalias@def
  3409.          {blx@printdelim@##1@}{#1}{blx@printdelim@##1@}{#2}}%
  3410.      \dolistcsloop{blx@declaredelimcontexts@#2}}}
  3411.  
  3412. \def\blx@declaredelimalias@expl{%
  3413.   \@ifnextchar[%]
  3414.     {\blx@declaredelimalias@expl@i}
  3415.    {\blx@declaredelimalias@expl@i[]}}
  3416.  
  3417. \def\blx@declaredelimalias@expl@i[#1]#2{%
  3418.   \@ifnextchar[%]
  3419.     {\blx@declaredelimalias@expl@iii{#1}{#2}}
  3420.    {\blx@declaredelimalias@expl@ii{#1}{#2}}}
  3421.  
  3422. \def\blx@declaredelimalias@expl@ii#1#2#3{%
  3423.   \ifblank{#1}
  3424.    {\blx@declaredelimalias@def{}{#2}{}{#3}}
  3425.     {\def\do##1{%
  3426.        \blx@declaredelimalias@def
  3427.          {blx@printdelim@##1@}{#2}{blx@printdelim@##1@}{#3}}%
  3428.      \docsvlist{#1}}}
  3429.  
  3430. \def\blx@declaredelimalias@expl@iii#1#2[#3]#4{%
  3431.   \ifblank{#1}
  3432.    {\ifblank{#3}
  3433.       {\blx@declaredelimalias@def{}{#2}{}{#4}}
  3434.       {\blx@declaredelimalias@def{}{#2}{blx@printdelim@#3@}{#4}}}
  3435.    {\ifblank{#3}
  3436.        {\def\do##1{%
  3437.           \blx@declaredelimalias@def
  3438.             {blx@printdelim@##1@}{#2}{}{#4}}}
  3439.        {\def\do##1{%
  3440.           \blx@declaredelimalias@def
  3441.             {blx@printdelim@##1@}{#2}{blx@printdelim@#3@}{#4}}}%
  3442.      \docsvlist{#1}}}
  3443.  
  3444. \def\blx@declaredelimalias@def#1#2#3#4{%
  3445.   \ifcsdef{#1#2}
  3446.    {\blx@inf@delimdeclare{#2}{#1}}
  3447.    {}%
  3448.   \ifblank{#1}
  3449.    {}
  3450.    {\ifinlistcs{#1}{blx@declaredelimcontexts@#2}
  3451.       {}
  3452.       {\listcsadd{blx@declaredelimcontexts@#2}{#1}}}%
  3453.   \csdef{#1#2}{\ifcsundef{#3#4}{\csuse{#4}}{\csuse{#3#4}}}}
  3454.  
  3455. \def\blx@delimcontext{none}
  3456. \newcommand*{\printdelim}[2][]{%
  3457.   \ifblank{#1}
  3458.    {\ifcsdef{blx@printdelim@\blx@delimcontext @#2}
  3459.      {\csuse{blx@printdelim@\blx@delimcontext @#2}}
  3460.      {\ifcsdef{#2}% fall back on legacy macros
  3461.         {\csuse{#2}}
  3462.        {\blx@warn@delimuse{#2}{*}}}}
  3463.    {\ifcsdef{blx@printdelim@#1@#2}
  3464.      {\csuse{blx@printdelim@#1@#2}}
  3465.      {\blx@warn@delimuse{#2}{#1}}}}
  3466.  
  3467. \newcommand*{\delimcontext}[1]{%
  3468.   \edef\blx@delimcontext{\blx@delimcontextalias{#1}}}
  3469.  
  3470. \def\blx@delimcontextalias#1{%
  3471.   \ifcsdef{blx@delimcontextalias@#1}
  3472.    {\csuse{blx@delimcontextalias@#1}}
  3473.    {#1}}
  3474.  
  3475. \newcommand*{\DeclareDelimcontextAlias}[2]{%
  3476.   \csdef{blx@delimcontextalias@#1}{#2}}
  3477.  
  3478. \newrobustcmd*{\AtUsedriver}{%
  3479.   \@ifstar
  3480.     {\global\undef\blx@hook@usedriver
  3481.     \gappto\blx@hook@usedriver}
  3482.    {\gappto\blx@hook@usedriver}}
  3483. \@onlypreamble\AtUsedriver
  3484. \def\blx@imc@UseUsedriverHook{\csuse{blx@hook@usedriver}}
  3485. \blx@regimcs{\UseUsedriverHook}
  3486.  
  3487. \AtUsedriver{%
  3488.   \let\finentry\blx@finentry@usedrv
  3489.   \let\newblock\relax
  3490.   \let\abx@macro@bibindex\@empty
  3491.   \let\abx@macro@pageref\@empty}
  3492.  
  3493. % {<init>}{<entrytype>}
  3494. \protected\def\blx@imc@usedriver#1#2{%
  3495.   \begingroup
  3496.   \csuse{blx@hook@usedriver}%
  3497.   \csuse{blx@hook@bbxinit}#1%
  3498.   \delimcontext{bib}%
  3499.   \blx@beglangbib
  3500.   \blx@driver{#2}%
  3501.   \blx@endlangbib
  3502.   \endgroup}
  3503.  
  3504. % Punctuation
  3505.  
  3506. \protected\def\blx@initunit{%
  3507.   \global\togglefalse{blx@block}%
  3508.   \global\togglefalse{blx@unit}%
  3509.   \global\togglefalse{blx@insert}%
  3510.   \global\togglefalse{blx@lastins}%
  3511.   \global\togglefalse{blx@keepunit}%
  3512.   \global\let\blx@unitpunct\newunitpunct
  3513.   \blx@imc@resetpunctfont}
  3514.  
  3515. \def\blx@begunit{%
  3516.   \toggletrue{blx@tempa}%
  3517.   \iftoggle{blx@insert}
  3518.    {\iftoggle{blx@unit}
  3519.       {\begingroup
  3520.          \let\blx@begunit\@empty
  3521.          \let\blx@endunit\@empty
  3522.          \let\blx@endnounit\@empty
  3523.          \blx@unitpunct\blx@postpunct
  3524.        \endgroup
  3525.        \global\togglefalse{blx@unit}%
  3526.         \togglefalse{blx@tempa}}
  3527.       {\blx@postpunct}%
  3528.      \iftoggle{blx@block}
  3529.       {\begingroup
  3530.          \let\blx@begunit\@empty
  3531.          \let\blx@endunit\@empty
  3532.          \let\blx@endnounit\@empty
  3533.          \newblockpunct
  3534.        \endgroup
  3535.        \global\togglefalse{blx@block}%
  3536.         \togglefalse{blx@tempa}}
  3537.       {}}
  3538.    {}%
  3539.   \blx@postpunct
  3540.   \blx@imc@resetpunctfont
  3541.   \iftoggle{blx@tempa}
  3542.    {}
  3543.    {\global\togglefalse{blx@insert}}%
  3544.   \blx@leavevmode
  3545.   \begingroup}
  3546.  
  3547. \def\blx@endunit{%
  3548.   \endgroup
  3549.   \global\toggletrue{blx@insert}%
  3550.   \global\toggletrue{blx@lastins}}
  3551.  
  3552. \def\blx@nounit{%
  3553.   \global\togglefalse{blx@lastins}}
  3554.  
  3555. \def\blx@endnounit{%
  3556.   \endgroup\blx@nounit}
  3557.  
  3558. \protected\def\blx@imc@newblock{%
  3559.   \global\toggletrue{blx@block}}%
  3560.  
  3561. \protected\def\blx@imc@newunit{%
  3562.   \iftoggle{blx@keepunit}
  3563.    {}
  3564.    {\global\let\blx@unitpunct\newunitpunct
  3565.     \global\toggletrue{blx@unit}}}
  3566.  
  3567. \protected\def\blx@imc@setunit{%
  3568.   \@ifstar\blx@setunit@i\blx@setunit}
  3569.  
  3570. \long\def\blx@setunit#1{%
  3571.   \iftoggle{blx@keepunit}
  3572.    {}
  3573.    {\long\gdef\blx@unitpunct{#1}%
  3574.      \global\toggletrue{blx@unit}}}
  3575.  
  3576. \def\blx@setunit@i{%
  3577.   \iftoggle{blx@lastins}
  3578.    {\blx@setunit}
  3579.    {\@gobble}}
  3580.  
  3581. \protected\def\blx@imc@printunit{%
  3582.   \@ifstar\blx@printunit@i\blx@printunit}
  3583.  
  3584. \def\blx@printunit#1{%
  3585.   \long\gdef\blx@unitpunct{#1\global\togglefalse{blx@keepunit}}%
  3586.   \global\toggletrue{blx@keepunit}%
  3587.   \global\toggletrue{blx@unit}}
  3588.  
  3589. \def\blx@printunit@i{%
  3590.   \iftoggle{blx@lastins}
  3591.    {\blx@printunit}
  3592.    {\@gobble}}
  3593.  
  3594. \protected\def\blx@imc@finentry{%
  3595.   \unspace\finentrypunct
  3596.   \blx@postpunct
  3597.   \blx@initunit}
  3598.  
  3599. \protected\def\blx@finentry@usedrv{%
  3600.   \blx@setunit\relax}
  3601.  
  3602. \protected\def\blx@finentry@inset{%
  3603.   \blx@setunit\entrysetpunct
  3604.   \global\toggletrue{blx@block}}
  3605.  
  3606. \def\ifentryseen{\blx@imc@ifentryseen}
  3607. \def\ifentryinbib{\blx@imc@ifentryinbib}
  3608. \def\ifentrycategory{\blx@imc@ifentrycategory}
  3609. \def\ifentrykeyword{\blx@imc@ifentrykeyword}
  3610.  
  3611. \def\blx@imc@iflabeldateisdate{%
  3612.   \ifboolexpr{%
  3613.     togl {blx@labeldateparts}
  3614.    and not test {\iffieldundef{labeldatesource}}
  3615.    and
  3616.    (test {\iffieldequalstr{labeldatesource}{}}
  3617.     or test {\iffieldequalstr{labeldatesource}{year}})}}
  3618.  
  3619. \def\blx@imc@ifdatehasyearonlyprecision#1{%
  3620.   \ifboolexpr{not test {\iffieldundef{#1year}}
  3621.              and (test {\ifcsstring{blx@dateformat@#1date}{year}}
  3622.                   or (test {\iffieldundef{#1month}}
  3623.                       and test {\iffieldundef{#1season}}))}}
  3624.  
  3625. \def\blx@imc@ifdatehastime#1{%
  3626.   \ifboolexpr{togl {blx@#1dateusetime}
  3627.                 and not test {\iffieldundef{#1hour}}}}
  3628.  
  3629. \def\blx@imc@ifdateshavedifferentprecision#1#2{%
  3630.   \ifboolexpr{   (test {\ifdatehasyearonlyprecision{#1}}
  3631.                  and not test {\ifdatehasyearonlyprecision{#2}})
  3632.              or (not test {\ifdatehasyearonlyprecision{#1}}
  3633.                  and test {\ifdatehasyearonlyprecision{#2}})
  3634.              or (test {\ifdatehastime{#1}}
  3635.                  and not test {\ifdatehastime{#2}})
  3636.              or (not test {\ifdatehastime{#1}}
  3637.                  and test {\ifdatehastime{#2}})}}
  3638.  
  3639. \def\blx@imc@ifdateyearsequal#1#2{%
  3640.   \ifboolexpr{ test {\iffieldsequal{#1year}{#2year}}
  3641.               and test {\iffieldsequal{#1dateera}{#2dateera}}}}
  3642.  
  3643. \blx@regimcs{%
  3644.   \ifdriver \thefield \strfield \csfield \usefield \thelist \strlist \thename \strname
  3645.   \clearfield \clearlist \clearname \restorefield \restorelist \restorename
  3646.   \ifcategory \ifkeyword
  3647.   \ifciteseen  \ifciteibid \ifciteidem \ifopcit \ifloccit
  3648.   \ifcurrentfield \ifcurrentlist \ifcurrentname \ifentrytype
  3649.   \iffieldequalcs \iffieldequals \iffieldequalstr \iffieldsequal
  3650.   \iffieldundef \iffieldxref \iflistequalcs \iflistequals
  3651.   \iflistsequal \iflistundef \iflistxref
  3652.   \ifmorenames \ifmoreitems \iffirstcitekey \iflastcitekey
  3653.   \ifnameequalcs \ifnameequals \ifnamesequal \ifnameundef \ifnamexref
  3654.   \iffirstonpage \ifsamepage \savefield \savefieldcs \savelist
  3655.   \savelistcs \savename \savenamecs \usedriver
  3656.   \ifinteger \ifnumeral \ifnumerals \ifpages
  3657.   \iffieldint \iffieldnum \iffieldnums \iffieldpages
  3658.   \iflabeldateisdate \ifdatehasyearonlyprecision \ifdatehastime
  3659.   \ifdateshavedifferentprecision
  3660.   \ifdateyearsequal
  3661.   \mkpageprefix \mkpagetotal
  3662.   \newblock \newunit \setunit \printunit \finentry}
  3663.  
  3664. \appto\blx@blxinit{%
  3665.   \def\ifnatbibmode{\iftoggle{blx@natbib}}%
  3666.   \def\ifcitation{\iftoggle{blx@citation}}%
  3667.   \def\ifbibliography{\iftoggle{blx@bibliography}}%
  3668.   \def\ifciteindex{\iftoggle{blx@citeindex}}%
  3669.   \def\ifbibindex{\iftoggle{blx@bibindex}}%
  3670.   \def\iffootnote{\iftoggle{blx@footnote}}%
  3671.   \def\ifuseprefix{\iftoggle{blx@useprefix}}%
  3672.   \def\ifterseinits{\iftoggle{blx@terseinits}}%
  3673.   \def\ifcrossrefsource{\iftoggle{abx@bool@crossrefsource}}%
  3674.   \def\ifxrefsource{\iftoggle{abx@bool@xrefsource}}%
  3675.   \def\ifsingletitle{\iftoggle{abx@bool@singletitle}}%
  3676.   \def\ifnocite{\iftoggle{abx@bool@nocite}}%
  3677.   \def\ifuniquetitle{\iftoggle{abx@bool@uniquetitle}}%
  3678.   \def\ifuniquebaretitle{\iftoggle{abx@bool@uniquebaretitle}}%
  3679.   \def\ifuniquework{\iftoggle{abx@bool@uniquework}}%
  3680.   \def\ifuniqueprimaryauthor{\iftoggle{abx@bool@uniqueprimaryauthor}}%
  3681.   \def\ifandothers#1{\iftoggle{abx@bool@more#1}}%
  3682.   \protected\def\pno{\bibstring{page}}%
  3683.   \protected\def\ppno{\bibstring{pages}}%
  3684.   \let\nopp\relax
  3685.   \protected\def\psq{\sqspace\bibstring{sequens}}%
  3686.   \protected\def\psqq{\sqspace\bibstring{sequentes}}}
  3687.  
  3688. % Make sure that commands which might pop up inside an \edef will be defined
  3689. % as something. If they are taken \AtBeginDocument then we assume that all will
  3690. % be well. If not, then provide a definition which will give an error outside
  3691. % of a citation context.
  3692. \AtBeginDocument{%
  3693.   \protected\def\do#1{%
  3694.     \ifdefined#1%
  3695.     \else
  3696.       \protected\def#1{\ERROR}%
  3697.     \fi
  3698.   }%
  3699.   \docsvlist{\pno,\ppno,\nopp,\psq,\psqq}%
  3700. }
  3701.  
  3702. %% Global formatting hooks
  3703.  
  3704. % capitalization
  3705.  
  3706. % {<text>}
  3707. \newrobustcmd{\MakeCapital}[1]{%
  3708.   \begingroup
  3709.   \blx@mkcp@init
  3710.   \protected@edef\blx@tempa{#1}%
  3711.   \expandafter\blx@mkcp@parse\blx@tempa\@empty\blx@mkcp@end}
  3712.  
  3713. \def\blx@mkcp@init{%
  3714.   \def\blx@mkcp@iec{\noexpand\blx@mkcp@iec\noexpand}%
  3715.   \def\blx@mkcp@bbl{\noexpand\blx@mkcp@bbl\noexpand}%
  3716.   \def\blx@mkcp@sgl{\noexpand\blx@mkcp@sgl\noexpand}%
  3717.   \def\blx@mkcp@dbl{\noexpand\blx@mkcp@dbl\noexpand}%
  3718.   \def\do##1{\def##1{\blx@mkcp@sgl##1}}\abx@dosingleaccents
  3719.  \def\do##1{\def##1{\blx@mkcp@dbl##1}}\abx@dodoubleaccents
  3720.  \def\IeC##1{\blx@mkcp@iec\IeC{##1}}%
  3721.   \def\@tabacckludge##1{%
  3722.     \expandafter\blx@mkcp@sgl\csname\string##1\endcsname}}
  3723.  
  3724. \begingroup
  3725. \catcode`\"=\active
  3726. \gappto\blx@mkcp@init{%
  3727.   \ifnum\catcode`\"=\active
  3728.     \def"#1{\blx@mkcp@bbl"\noexpand#1}%
  3729.   \fi}
  3730. \endgroup
  3731.  
  3732. \def\blx@mkcp@parse{%
  3733.   \futurelet\@let@token\blx@mkcp@eval}
  3734.  
  3735. \long\def\blx@mkcp@eval{%
  3736.   \ifx\@let@token\blx@mkcp@iec
  3737.     \expandafter\blx@mkcp@getiec
  3738.   \fi
  3739.   \ifx\@let@token\blx@mkcp@bbl
  3740.     \expandafter\blx@mkcp@gettwo
  3741.   \fi
  3742.   \ifx\@let@token\blx@mkcp@sgl
  3743.     \expandafter\blx@mkcp@gettwo
  3744.   \fi
  3745.   \ifx\@let@token\blx@mkcp@dbl
  3746.     \expandafter\blx@mkcp@getthree
  3747.   \fi
  3748.   \blx@mkcp@case}
  3749.  
  3750. \def\blx@mkcp@getiec#1\blx@mkcp@case#2#3#4{%
  3751.   \blx@mkcp@case{#2#3{#4}}}
  3752.  
  3753. \def\blx@mkcp@gettwo#1\blx@mkcp@case#2#3#4{%
  3754.   \blx@mkcp@case{#2#3#4}}
  3755.  
  3756. \def\blx@mkcp@getthree#1\blx@mkcp@case#2#3#4#5{%
  3757.   \blx@mkcp@case{#2#3#4#5}}
  3758.  
  3759. \long\def\blx@mkcp@case#1{%
  3760.   \begingroup
  3761.   \def\i{I}\def\j{J}%
  3762.   \def\do##1##2{\let##1##2\do}%
  3763.   \expandafter\do\@uclclist\relax{\relax\@gobble}%
  3764.   \uppercase{\protected@edef\blx@tempa{\endgroup\blx@mkcp@end#1}}%
  3765.   \blx@tempa}
  3766.  
  3767. \protected\long\def\blx@mkcp@end#1\blx@mkcp@end{%
  3768.   \let\blx@mkcp@iec\noexpand
  3769.   \let\blx@mkcp@bbl\noexpand
  3770.   \let\blx@mkcp@sgl\noexpand
  3771.   \let\blx@mkcp@dbl\noexpand
  3772.   \protected@edef\blx@tempa{\endgroup#1}%
  3773.   \blx@tempa}
  3774.  
  3775. \def\abx@dosingleaccents{%
  3776.   \do\"\do\'\do\`\do\^\do\~\do\=\do\.%
  3777.   \do\H\do\b\do\c\do\d\do\r\do\u\do\v}
  3778. \def\abx@dodoubleaccents{%
  3779.   \do\t}
  3780.  
  3781. % {<text>}
  3782. \newrobustcmd*{\MakeSentenceCase}{%
  3783.   \@ifstar\blx@mksc@i\blx@mksc@ii}
  3784.  
  3785. % Check, in order:
  3786. % * explicit option language=<lang>, which overrides everything
  3787. % * langid field of entry
  3788. % * babel/polyglossia lang
  3789. % * main document lang
  3790. \def\blx@mksc@i{%
  3791.   \ifdef\blx@forcelanguagename
  3792.     {\xifinlist\blx@forcelanguagename\blx@cmksc@lang
  3793.       {\blx@mksc@ii}
  3794.       {\@firstofone}}
  3795.    {\ifdef\abx@field@langid
  3796.      {\xifinlist\abx@field@langid\blx@cmksc@lang
  3797.         {\blx@mksc@ii}
  3798.         {\@firstofone}}
  3799.      {\ifdef\bbl@main@language
  3800.        {\xifinlist\bbl@main@language\blx@cmksc@lang
  3801.          {\blx@mksc@ii}
  3802.          {\@firstofone}}
  3803.        {\xifinlist\blx@languagename\blx@cmksc@lang
  3804.          {\blx@mksc@ii}
  3805.          {\@firstofone}}}}}
  3806.  
  3807. \long\def\blx@mksc@ii#1{%
  3808.   \begingroup
  3809.   \let\blx@tempa\@empty
  3810.   \let\blx@tempb\@empty
  3811.   \blx@mksc@init
  3812.   \protected@edef\@tempa{#1}%
  3813.   \expandafter\blx@mksc@parse\@tempa\blx@mksc@end}
  3814.  
  3815. \def\blx@mksc@init{%
  3816.   \blx@mkcp@init
  3817.   \def\blx@mkcp@nil{\noexpand\blx@mkcp@nil\noexpand}%
  3818.   \def\i{\blx@mkcp@nil\i}\def\j{\blx@mkcp@nil\j}%
  3819.   \def\do##1{%
  3820.     \ifx##1\relax
  3821.     \else
  3822.       \def##1{\blx@mkcp@nil##1}%
  3823.       \expandafter\do
  3824.     \fi}%
  3825.   \expandafter\do\@uclclist\relax}
  3826.  
  3827. \def\blx@mksc@parse{%
  3828.   \futurelet\@let@token\blx@mksc@eval}
  3829.  
  3830. \def\blx@mksc@eval{%
  3831.   \ifx\@let@token\blx@mksc@end
  3832.     \expandafter\blx@mksc@end
  3833.   \fi
  3834.   \ifx\@let@token\bgroup
  3835.     \expandafter\blx@mksc@group
  3836.   \fi
  3837.   \ifx\@let@token\@sptoken
  3838.     \expandafter\blx@mksc@space
  3839.   \fi
  3840.   \ifx\@let@token\blx@mkcp@nil
  3841.     \expandafter\blx@mksc@getone
  3842.   \fi
  3843.   \ifx\@let@token\blx@mkcp@iec
  3844.     \expandafter\blx@mksc@getiec
  3845.   \fi
  3846.   \ifx\@let@token\blx@mkcp@bbl
  3847.     \expandafter\blx@mksc@gettwo
  3848.   \fi
  3849.   \ifx\@let@token\blx@mkcp@sgl
  3850.     \expandafter\blx@mksc@gettwo
  3851.   \fi
  3852.   \ifx\@let@token\blx@mkcp@dbl
  3853.     \expandafter\blx@mksc@getthree
  3854.   \fi
  3855.   \if\noexpand\@let@token\relax
  3856.     \expandafter\blx@mksc@cs
  3857.   \fi
  3858.   \blx@mksc@other}
  3859.  
  3860. \def\blx@mksc@end#1\blx@mksc@end{%
  3861.   \blx@mksc@eject
  3862.   \let\blx@mkcp@nil\noexpand
  3863.   \let\blx@mkcp@iec\noexpand
  3864.   \let\blx@mkcp@bbl\noexpand
  3865.   \let\blx@mkcp@sgl\noexpand
  3866.   \let\blx@mkcp@dbl\noexpand
  3867.   \let\MakeUppercase\relax
  3868.   \let\MakeLowercase\relax
  3869.   \protected@edef\blx@tempa{\endgroup\blx@tempa}%
  3870.   \blx@tempa}
  3871.  
  3872. \long\def\blx@mksc@group#1\blx@mksc@other#2{%
  3873.   \futurelet\@let@token\blx@mksc@ingroup#2&{#2}%
  3874.   \blx@mksc@endhead
  3875.   \blx@mksc@parse}
  3876.  
  3877. \long\def\blx@mksc@ingroup#1&#2{%
  3878.   \if\noexpand\@let@token\relax
  3879.     \ifx\@let@token\blx@mkcp@sgl
  3880.       \blx@mksc@nocase{{#2}}%
  3881.     \else
  3882.       \ifx\@let@token\blx@mkcp@dbl
  3883.         \blx@mksc@nocase{{#2}}%
  3884.       \else
  3885.         \blx@mksc@locase{{#2}}%
  3886.       \fi
  3887.     \fi
  3888.   \else
  3889.     \blx@mksc@nocase{{#2}}%
  3890.   \fi}
  3891.  
  3892. \def\blx@mksc@space{\def\blx@mksc@space##1\blx@mksc@other}
  3893. \csuse{blx@mksc@space} {%
  3894.   \blx@mksc@anycase{ }%
  3895.   \blx@mksc@endhead
  3896.   \blx@mksc@parse}
  3897.  
  3898. \long\def\blx@mksc@cs#1\blx@mksc@other#2{%
  3899.   \ifcat\noexpand~\noexpand#2%
  3900.     \blx@mksc@locase{#2}%
  3901.   \else
  3902.     \blx@mksc@nocase{#2}%
  3903.   \fi
  3904.   \blx@mksc@endhead
  3905.   \blx@mksc@parse}
  3906.  
  3907. \def\blx@mksc@getiec#1\blx@mksc@other#2#3#4{%
  3908.   \blx@mksc@other{#2#3{#4}}}
  3909.  
  3910. \def\blx@mksc@getone#1\blx@mksc@other#2#3{%
  3911.   \blx@mksc@other{#2#3}}
  3912.  
  3913. \def\blx@mksc@gettwo#1\blx@mksc@other#2#3#4{%
  3914.   \blx@mksc@other{#2#3#4}}
  3915.  
  3916. \def\blx@mksc@getthree#1\blx@mksc@other#2#3#4#5{%
  3917.   \blx@mksc@other{#2#3#4#5}}
  3918.  
  3919. \long\def\blx@mksc@other#1{%
  3920.   \blx@mksc@locase{#1}%
  3921.   \blx@mksc@endhead
  3922.   \blx@mksc@parse}
  3923.  
  3924. \def\blx@mksc@locase{%
  3925.   \appto\blx@tempb}
  3926.  
  3927. \def\blx@mksc@nocase{%
  3928.   \blx@mksc@eject
  3929.   \appto\blx@tempa}
  3930.  
  3931. \def\blx@mksc@anycase{%
  3932.   \ifx\blx@tempb\@empty
  3933.     \expandafter\appto
  3934.     \expandafter\blx@tempa
  3935.   \else
  3936.     \expandafter\appto
  3937.     \expandafter\blx@tempb
  3938.   \fi}
  3939.  
  3940. \def\blx@mksc@eject{%
  3941.   \ifx\blx@tempb\@empty
  3942.   \else
  3943.     \eappto\blx@tempa{\noexpand\MakeLowercase{\expandonce\blx@tempb}}%
  3944.     \let\blx@tempb\@empty
  3945.   \fi}
  3946.  
  3947. \def\blx@mksc@endhead{%
  3948.   \ifx\blx@tempb\@empty
  3949.   \else
  3950.     \eappto\blx@tempa{\noexpand\MakeCapital{\expandonce\blx@tempb}}%
  3951.     \let\blx@tempb\@empty
  3952.   \fi
  3953.   \let\blx@mksc@endhead\relax}
  3954.  
  3955. % {<language,language,...>}
  3956. \newrobustcmd*{\DeclareCaseLangs}{%
  3957.   \@ifstar
  3958.     {\blx@defcaselangs}
  3959.    {\global\let\blx@cmksc@lang\@empty
  3960.     \blx@defcaselangs}}
  3961.  
  3962. \def\blx@defcaselangs#1{%
  3963.   \ifblank{#1}
  3964.    {}
  3965.    {\forcsvlist{\listgadd\blx@cmksc@lang}{#1}}}
  3966.  
  3967. \DeclareCaseLangs{%
  3968.   american,british,canadian,
  3969.   english,USenglish,UKenglish,
  3970.   australian,newzealand}
  3971.  
  3972. \newrobustcmd*{\ifcaselang}[1][]{%
  3973.   \ifblank{#1}
  3974.    {\xifinlist\blx@languagename\blx@cmksc@lang}
  3975.    {\xifinlist{#1}\blx@cmksc@lang}}
  3976.  
  3977. %% Main formatting commands
  3978. % They work by creating a \let alias:
  3979. % \abx@<class>@<entrytype>@<formatname> -> \blx@defformat@d
  3980. % for later use in \print*
  3981. % Then, \blx@defformat@d is defined by calling
  3982. % \def\blx@defformat@d#1{format body}
  3983.  
  3984. % [<entrytype>]{<name>}{<definiton>}
  3985. \newrobustcmd*{\DeclareNameFormat}{%
  3986.   \@ifstar
  3987.     {\blx@defformat\blx@defnameformat{nfd}*}
  3988.    {\blx@defformat\blx@defnameformat{nfd}{}}}
  3989.  
  3990. \newrobustcmd*{\DeclareIndexNameFormat}{%
  3991.   \@ifstar
  3992.     {\blx@defformat\blx@defnameformat{nid}*}
  3993.    {\blx@defformat\blx@defnameformat{nid}{}}}
  3994.  
  3995. \newrobustcmd*{\DeclareListFormat}{%
  3996.   \@ifstar
  3997.     {\blx@defformat\blx@defplainformat{lfd}*}
  3998.    {\blx@defformat\blx@defplainformat{lfd}{}}}
  3999. \newrobustcmd*{\DeclareIndexListFormat}{%
  4000.   \@ifstar
  4001.     {\blx@defformat\blx@defplainformat{lid}*}
  4002.    {\blx@defformat\blx@defplainformat{lid}{}}}
  4003.  
  4004. \newrobustcmd*{\DeclareFieldFormat}{%
  4005.   \@ifstar
  4006.     {\blx@defformat\blx@defplainformat{ffd}*}
  4007.    {\blx@defformat\blx@defplainformat{ffd}{}}}
  4008. \newrobustcmd*{\DeclareIndexFieldFormat}{%
  4009.   \@ifstar
  4010.     {\blx@defformat\blx@defplainformat{fid}*}
  4011.    {\blx@defformat\blx@defplainformat{fid}{}}}
  4012.  
  4013. \newrobustcmd*{\DeclareNameWrapperFormat}{%
  4014.   \@ifstar
  4015.     {\blx@defformat\blx@defnameformat{nwd}*}
  4016.    {\blx@defformat\blx@defnameformat{nwd}{}}}
  4017. \newrobustcmd*{\DeclareIndexNameWrapperFormat}{%
  4018.   \@ifstar
  4019.     {\blx@defformat\blx@defnameformat{nxd}*}
  4020.    {\blx@defformat\blx@defnameformat{nxd}{}}}
  4021.  
  4022. \newrobustcmd*{\DeclareListWrapperFormat}{%
  4023.   \@ifstar
  4024.     {\blx@defformat\blx@defplainformat{lwd}*}
  4025.    {\blx@defformat\blx@defplainformat{lwd}{}}}
  4026. \newrobustcmd*{\DeclareIndexListWrapperFormat}{%
  4027.   \@ifstar
  4028.     {\blx@defformat\blx@defplainformat{lxd}*}
  4029.    {\blx@defformat\blx@defplainformat{lxd}{}}}
  4030.  
  4031. % {<macro>}{<class>}{<*>}
  4032. \def\blx@defformat#1#2#3{%
  4033.   \@ifnextchar[%]
  4034.     {\blx@defformat@i{#1}{#2}{#3}}
  4035.    {\blx@defformat@i{#1}{#2}{#3}[*]}}
  4036.  
  4037. % {<macro>}{<class>}{<*>}[<entrytype>]{<name>}
  4038. \def\blx@defformat@i#1#2#3[#4]#5{%
  4039.   \notblank{#3}
  4040.    {\blx@resetformat{#2}{#5}}
  4041.    {}%
  4042.   \def\blx@defformat@a{#2}%
  4043.   \def\blx@defformat@b{#4}%
  4044.   \blx@xsanitizeafter{\def\blx@defformat@c}{#5}%
  4045.   \afterassignment\blx@defformat@ii
  4046.   #1}
  4047.  
  4048. \def\blx@defformat@ii{%
  4049.   \expandafter\forcsvlist
  4050.   \expandafter\blx@defformat@iii
  4051.   \expandafter{\blx@defformat@b}}
  4052.  
  4053. \def\blx@defformat@iii#1{%
  4054.   \cslet{abx@\blx@defformat@a @#1@\blx@defformat@c}\blx@defformat@d}
  4055.  
  4056. \def\blx@defplainformat{%
  4057.   \long\def\blx@defformat@d##1}
  4058.  
  4059. \def\blx@defnameformat{%
  4060.   \long\def\blx@defformat@d##1}
  4061.  
  4062. \def\blx@resetformat#1#2{%
  4063.   \let\blx@saved@do\do
  4064.   \def\do##1{\blx@resetformat@i{#1}{#2}{##1}}%
  4065.   \blx@safe@actives
  4066.   \abx@doentrytypes
  4067.   \blx@rest@actives
  4068.   \let\do\blx@saved@do}
  4069.  
  4070. \def\blx@resetformat@i#1#2#3{%
  4071.   \ifcsdef{abx@#1@#3@#2}
  4072.    {\csundef{abx@#1@#3@#2}}
  4073.    {}}
  4074.  
  4075. % {<name>}{<name>}
  4076. \def\blx@letformat#1#2{%
  4077.   \blx@safe@actives
  4078.   \afterassignment\blx@rest@actives
  4079.   \csletcs{#1}{#2}}
  4080.  
  4081. % [aliastype]{aliasname}[formattype]{formatname}
  4082. \def\blx@defalias#1{%
  4083.   \@ifnextchar[%]
  4084.     {\blx@defalias@i{#1}}
  4085.    {\blx@defalias@i{#1}[*]}}
  4086. \def\blx@defalias@i#1[#2]#3{%
  4087.   \@ifnextchar[%]
  4088.     {\blx@defalias@ii{#1}{#2}{#3}}
  4089.    {\blx@defalias@ii{#1}{#2}{#3}[*]}}
  4090. \def\blx@defalias@ii#1#2#3[#4]#5{%
  4091.   \blx@safe@actives
  4092.   \afterassignment\blx@rest@actives
  4093.   \csedef{abx@#1@#2@#3}{%
  4094.     \expandonce{\csname abx@#1@#4@#5\endcsname}}}
  4095.  
  4096.  
  4097.  
  4098. % {<macro>}{<class>}{<name>}{<field>}
  4099. \def\blx@getformat#1#2#3#4{%
  4100.   \blx@safe@actives
  4101.   \afterassignment\blx@rest@actives
  4102.   \ifcsundef{abx@#2@\blx@imc@thefield{entrytype}@#3}
  4103.    {\ifcsundef{abx@#2@*@#3}
  4104.       {\ifcsundef{abx@#2@\blx@imc@thefield{entrytype}@#4}
  4105.          {\ifcsundef{abx@#2@*@#4}
  4106.             {\letcs#1{abx@#2@*@default}}
  4107.             {\letcs#1{abx@#2@*@#4}}}
  4108.          {\letcs#1{abx@#2@\blx@imc@thefield{entrytype}@#4}}}
  4109.       {\letcs#1{abx@#2@*@#3}}}
  4110.    {\letcs#1{abx@#2@\blx@imc@thefield{entrytype}@#3}}}
  4111.  
  4112. % [<entrytype>]{<name>}
  4113. \newrobustcmd*{\savefieldformat}[2][*]{\blx@save{abx@ffd@#1@#2}}
  4114. \newrobustcmd*{\savelistformat}[2][*]{\blx@save{abx@lfd@#1@#2}}
  4115. \newrobustcmd*{\savenameformat}[2][*]{\blx@save{abx@nfd@#1@#2}}
  4116. \newrobustcmd*{\savelistwrapperformat}[2][*]{\blx@save{abx@lwd@#1@#2}}
  4117. \newrobustcmd*{\savenamewrapperformat}[2][*]{\blx@save{abx@nwd@#1@#2}}
  4118.  
  4119. \newrobustcmd*{\restorefieldformat}[2][*]{\blx@restore{abx@ffd@#1@#2}}
  4120. \newrobustcmd*{\restorelistformat}[2][*]{\blx@restore{abx@lfd@#1@#2}}
  4121. \newrobustcmd*{\restorenameformat}[2][*]{\blx@restore{abx@nfd@#1@#2}}
  4122. \newrobustcmd*{\restorelistwrapperformat}[2][*]{\blx@restore{abx@lwd@#1@#2}}
  4123. \newrobustcmd*{\restorenamewrapperformat}[2][*]{\blx@restore{abx@nwd@#1@#2}}
  4124.  
  4125. % [<entrytype>]{<name>}{<true>}{<false>}
  4126. \newrobustcmd*{\iffieldformatundef}[2][*]{\ifcsundef{abx@ffd@#1@#2}}
  4127. \newrobustcmd*{\iflistformatundef}[2][*]{\ifcsundef{abx@lfd@#1@#2}}
  4128. \newrobustcmd*{\ifnameformatundef}[2][*]{\ifcsundef{abx@nfd@#1@#2}}
  4129. \newrobustcmd*{\iflistwrapperformatundef}[2][*]{\ifcsundef{abx@lwd@#1@#2}}
  4130. \newrobustcmd*{\ifnamewrapperformatundef}[2][*]{\ifcsundef{abx@nwd@#1@#2}}
  4131.  
  4132. % [<entrytype>]{<alias>}[<entrytype>]{<name>}
  4133. \newrobustcmd*{\DeclareNameAlias}{\blx@defalias{nfd}}
  4134. \newrobustcmd*{\DeclareIndexNameAlias}{\blx@defalias{nid}}
  4135.  
  4136. \newrobustcmd*{\DeclareListAlias}{\blx@defalias{lfd}}
  4137. \newrobustcmd*{\DeclareIndexListAlias}{\blx@defalias{lid}}
  4138.  
  4139. \newrobustcmd*{\DeclareFieldAlias}{\blx@defalias{ffd}}
  4140. \newrobustcmd*{\DeclareIndexFieldAlias}{\blx@defalias{fid}}
  4141.  
  4142. \newrobustcmd*{\DeclareNameWrapperAlias}{\blx@defalias{nwd}}
  4143. \newrobustcmd*{\DeclareIndexNameWrapperAlias}{\blx@defalias{nxd}}
  4144.  
  4145. \newrobustcmd*{\DeclareListWrapperAlias}{\blx@defalias{lwd}}
  4146. \newrobustcmd*{\DeclareIndexListWrapperAlias}{\blx@defalias{lxd}}
  4147.  
  4148. % #1: internal type signature, #2: type text for warning
  4149. %      #3         #4         #5          #6
  4150. % [aliastype]{aliasname}[formattype]{formatname}
  4151. \def\blx@deprecateformat#1#2{%
  4152.   \@ifnextchar[%]
  4153.     {\blx@deprecateformat@i{#1}{#2}}
  4154.    {\blx@deprecateformat@i{#1}{#2}[*]}}
  4155. \def\blx@deprecateformat@i#1#2[#3]#4{%
  4156.   \@ifnextchar[%]
  4157.     {\blx@deprecateformat@ii{#1}{#2}{#3}{#4}}
  4158.    {\blx@deprecateformat@ii{#1}{#2}{#3}{#4}[*]}}
  4159. \def\blx@deprecateformat@ii#1#2#3#4[#5]#6{%
  4160.   \blx@safe@actives
  4161.   \afterassignment\blx@rest@actives
  4162.   \csdef{abx@#1@#3@#4}{%
  4163.     \ifcsundef{abx@legacywarning@#1@#3@#4}
  4164.      {\global\cslet{abx@legacywarning@#1@#3@#4}\@empty
  4165.        \blx@warning@noline{%
  4166.          #2 '#4' deprecated.\MessageBreak
  4167.          Please use '#6' instead.\MessageBreak
  4168.          Using '#6' now}}
  4169.       {}%
  4170.     \csname abx@#1@#5@#6\endcsname}}
  4171.  
  4172. % [<entrytype>]{<alias>}[<entrytype>]{<name>}
  4173. \newrobustcmd*{\DeprecateNameFormatWithReplacement}{%
  4174.   \blx@deprecateformat{nfd}{Name format}}
  4175. \newrobustcmd*{\DeprecateIndexNameFormatWithReplacement}{%
  4176.   \blx@deprecateformat{nid}{Index name format}}
  4177.  
  4178. \newrobustcmd*{\DeprecateListFormatWithReplacement}{%
  4179.   \blx@deprecateformat{lfd}{List format}}
  4180. \newrobustcmd*{\DeprecateIndexListFormatWithReplacement}{%
  4181.   \blx@deprecateformat{lid}{Index list format}}
  4182.  
  4183. \newrobustcmd*{\DeprecateFieldFormatWithReplacement}{%
  4184.   \blx@deprecateformat{ffd}{Field format}}
  4185. \newrobustcmd*{\DeprecateIndexFieldFormatWithReplacement}{%
  4186.   \blx@deprecateformat{fid}{Index field format}}
  4187.  
  4188. \newrobustcmd*{\DeprecateNameWrapperFormatWithReplacement}{%
  4189.   \blx@deprecateformat{nwd}{Name wrapper format}}
  4190. \newrobustcmd*{\DeprecateIndexNameWrapperFormatWithReplacement}{%
  4191.   \blx@deprecateformat{nxd}{Index name wrapper format}}
  4192.  
  4193. \newrobustcmd*{\DeprecateListWrapperFormatWithReplacement}{%
  4194.   \blx@deprecateformat{lwd}{List wrapper format}}
  4195. \newrobustcmd*{\DeprecateIndexListWrapperFormatWithReplacement}{%
  4196.   \blx@deprecateformat{lxd}{Index list wrapper format}}
  4197.  
  4198. % [<format>]{<text>}
  4199. \newrobustcmd{\blx@imc@printtext}[2][]{%
  4200.   \ifblank{#2}
  4201.    {\blx@nounit}
  4202.    {\ifblank{#1}
  4203.       {\let\blx@theformat\@firstofone}
  4204.       {\blx@getformat\blx@theformat{ffd}{#1}{}}%
  4205.      \ifdefvoid\blx@theformat
  4206.        {\blx@nounit}
  4207.       {\blx@begunit
  4208.        \blx@theformat{#2}%
  4209.         \blx@endunit}}}
  4210.  
  4211. % [<format>]{<field>}
  4212. \newrobustcmd*{\blx@imc@printfield}[2][]{%
  4213.   \blx@imc@iffieldundef{#2}
  4214.    {\blx@nounit}
  4215.    {\blx@getformat\blx@theformat{ffd}{#1}{#2}%
  4216.      \ifdefvoid\blx@theformat
  4217.        {\blx@nounit}
  4218.       {\blx@begunit
  4219.        \edef\currentfield{#2}%
  4220.         \expandafter\expandafter
  4221.         \expandafter\blx@theformat
  4222.         \expandafter\expandafter
  4223.         \expandafter{\csname abx@field@#2\endcsname}%
  4224.         \blx@endunit}}}
  4225.  
  4226. % [<format>]{<field>}
  4227. \newcommand*{\blx@imc@indexfield}[2][]{%
  4228.   \blx@imc@iffieldundef{#2}
  4229.    {}
  4230.    {\blx@getformat\blx@theformat{fid}{#1}{#2}%
  4231.      \ifdefvoid\blx@theformat
  4232.        {}
  4233.       {\begingroup
  4234.        \edef\currentfield{#2}%
  4235.         \letcs\blx@tempa{abx@field@#2}%
  4236.         \expandafter\blx@theformat\expandafter{\blx@tempa}%
  4237.         \endgroup}}}
  4238.  
  4239. % [<format>]{<file>}
  4240. \newrobustcmd*{\blx@imc@printfile}[2][]{%
  4241.   \iftoggle{blx@loadfiles}
  4242.    {\IfFileExists{#2}
  4243.       {\listxadd\blx@list@req@edit{#2}%
  4244.         \blx@imc@printtext[#1]{\input{#2}\unspace}}
  4245.       {\blx@nounit}}
  4246.    {\blx@nounit}}
  4247.  
  4248. % {<macro>}[<format>][<start>-<stop>]
  4249. % => <macro>{<format>}{<start>}{<stop>}
  4250. \def\blx@listargs#1{%
  4251.   \@ifnextchar[%]
  4252.     {\blx@listargs@i{#1}}
  4253.    {#1{}{}{}}}
  4254.  
  4255. \def\blx@listargs@i#1[#2]{%
  4256.   \@ifnextchar[%]
  4257.     {\blx@listargs@ii{#1}{#2}}
  4258.    {#1{#2}{}{}}}
  4259.  
  4260. \def\blx@listargs@ii#1#2[#3]{%
  4261.   \blx@listargs@iii{#1}{#2}#3&}
  4262.  
  4263. \def\blx@listargs@iii#1#2#3-#4&{%
  4264.   #1{#2}{#3}{#4}}
  4265.  
  4266. % [<format>][<start>-<stop>]{<namelist>}
  4267. \protected\def\blx@imc@printnames{%
  4268.   \blx@listargs\blx@printnames}
  4269.  
  4270. % {<format>}{<start>}{<stop>}{<namelist>}
  4271. \def\blx@printnames#1#2#3#4{%
  4272.   \blx@imc@ifnameundef{#4}
  4273.    {\blx@nounit}
  4274.    {\blx@getformat\blx@thewrapperformat{nwd}{#1}{#4}%
  4275.      \ifdefvoid\blx@thewrapperformat
  4276.        {\blx@nounit}
  4277.       {\blx@getformat\blx@theformat{nfd}{#1}{#4}%
  4278.         \ifdefvoid\blx@theformat
  4279.           {\blx@nounit}
  4280.          {\blx@begunit
  4281.           \blx@namesetup{#2}{#3}{#4}%
  4282.            \blx@thewrapperformat{\expandafter\blx@nameparser\blx@thedata{}&}%
  4283.            \blx@endunit}}}}
  4284.  
  4285. \def\blx@namesetup#1#2#3{%
  4286.   \def\currentname{#3}%
  4287.   \c@listcount\@ne
  4288.   \c@listtotal\csname c@#3\endcsname
  4289.   \blx@namesetup@i{#3}%
  4290.   \ifblank{#1}
  4291.    {\c@liststart\@ne}
  4292.    {\ifnum#1<\@ne
  4293.       \c@liststart\@ne
  4294.     \else
  4295.       \c@liststart#1\relax
  4296.     \fi}%
  4297.   \ifblank{#2}
  4298.    {\c@liststop\c@listtotal
  4299.     \ifnum\c@liststop>\c@maxnames
  4300.       \c@liststop\c@minnames
  4301.       \ifnum\c@uniquelist>\c@liststop
  4302.         \c@liststop\c@uniquelist
  4303.       \fi
  4304.     \fi}
  4305.    {\ifnum#2>\c@listtotal
  4306.       \c@liststop\c@listtotal
  4307.     \else
  4308.       \ifnum#2<\@ne
  4309.         \c@liststop\@ne
  4310.       \else
  4311.         \c@liststop#2\relax
  4312.       \fi
  4313.     \fi}%
  4314.   \blx@namecodes}
  4315.  
  4316. \def\blx@namesetup@i#1{%
  4317.   \expandafter\expandafter
  4318.   \expandafter\blx@namesetup@ii\csname abx@name@#1\endcsname}
  4319.  
  4320. \def\blx@namesetup@ii#1#2{%
  4321.   \c@uniquelist\z@
  4322.   \ifblank{#1}
  4323.    {}
  4324.    {\setkeys{blx@opt@namelist}{#1}}%
  4325.   \def\blx@thedata{#2}}
  4326.  
  4327. % These are options in the .bbl that biber makes explicit as they are needed in biblatex
  4328. % for various reasons. Not all namelist/name scope options are necessary in the .bbl as
  4329. % some are used by biber only and are not needed by biblatex after biber has finished
  4330. % generating the .bbl
  4331. % Per-namelist options
  4332. \define@key{blx@opt@namelist}{uniquelist}{\c@uniquelist#1\relax}
  4333. \define@key{blx@opt@namelist}{useprefix}{\settoggle{blx@useprefix}{#1}}
  4334. \define@key{blx@opt@namelist}{sortingnamekeytemplatename}{\def\blx@refcontext@sortingnamekeytemplatename{#1}}
  4335. \define@key{blx@opt@namelist}{uniquenametemplatename}{\def\blx@refcontext@uniquenametemplatename{#1}}
  4336. \define@key{blx@opt@namelist}{labelalphanametemplatename}{\def\blx@refcontext@labelalphanametemplatename{#1}}
  4337.  
  4338. % Per-name options
  4339. \define@key{blx@opt@name}{uniquename}{\c@uniquename#1\relax}
  4340. \define@key{blx@opt@name}{uniquepart}{\def\abx@field@uniquepart{#1}}
  4341. \define@key{blx@opt@name}{hash}{\edef\abx@field@hash{\detokenize{#1}}}
  4342. \define@key{blx@opt@name}{useprefix}{\settoggle{blx@useprefix}{#1}}
  4343. \define@key{blx@opt@name}{sortingnamekeytemplatename}{\def\blx@refcontext@sortingnamekeytemplatename{#1}}
  4344. \define@key{blx@opt@name}{uniquenametemplatename}{\def\blx@refcontext@uniquenametemplatename{#1}}
  4345. \define@key{blx@opt@name}{labelalphanametemplatename}{\def\blx@refcontext@labelalphanametemplatename{#1}}
  4346.  
  4347. \newrobustcmd*{\bibinitperiod}{\adddot}
  4348. \newrobustcmd*{\bibinitdelim}{\addnbspace}
  4349. \newrobustcmd*{\bibinithyphendelim}{.\mbox{-}}
  4350. \newrobustcmd*{\bibnamedelima}{\addhighpenspace}
  4351. \newrobustcmd*{\bibnamedelimb}{\addlowpenspace}
  4352. \newrobustcmd*{\bibnamedelimc}{\addhighpenspace}
  4353. \newrobustcmd*{\bibnamedelimd}{\addlowpenspace}
  4354. \newrobustcmd*{\bibnamedelimi}{\addnbspace}
  4355.  
  4356. % [<format>][<start>-<stop>]{<namelist>}
  4357. \protected\def\blx@imc@indexnames{%
  4358.   \blx@listargs\blx@indexnames}
  4359.  
  4360. % {<format>}{<start>}{<stop>}{<namelist>}
  4361. \def\blx@indexnames#1#2#3#4{%
  4362.   \blx@imc@ifnameundef{#4}
  4363.    {}
  4364.    {\blx@getformat\blx@thewrapperformat{nxd}{#1}{#4}%
  4365.      \ifdefvoid\blx@thewrapperformat
  4366.        {}
  4367.       {\blx@getformat\blx@theformat{nid}{#1}{#4}%
  4368.         \ifdefvoid\blx@theformat
  4369.           {}
  4370.          {\begingroup
  4371.           \blx@namesetup{#2}{#3}{#4}%
  4372.            \blx@indexnamesetup
  4373.            \expandafter\blx@nameparser\blx@thedata{}&%
  4374.            \endgroup}}}}
  4375.  
  4376. \def\blx@indexnamesetup{%
  4377.   \let\bibinitperiod\bibindexinitperiod
  4378.   \let\bibinitdelim\bibindexinitdelim
  4379.   \let\bibinithyphendelim\bibindexinithyphendelim
  4380.   \let\bibnamedelima\bibindexnamedelima
  4381.   \let\bibnamedelimb\bibindexnamedelimb
  4382.   \let\bibnamedelimc\bibindexnamedelimc
  4383.   \let\bibnamedelimd\bibindexnamedelimd
  4384.   \let\bibnamedelimi\bibindexnamedelimi}
  4385.  
  4386. % {<name1>}{<name2>}{...}
  4387. \long\def\blx@nameparser#1{%
  4388.   \ifblank{#1}
  4389.    {\blx@namebreak}
  4390.     {\ifnum\c@listcount<\c@liststart
  4391.      \else
  4392.        \blx@nameparser@i#1%
  4393.      \fi
  4394.      \advance\c@listcount\@ne
  4395.      \ifnum\c@listcount>\c@liststop
  4396.        \expandafter\blx@namebreak
  4397.      \fi
  4398.      \blx@nameparser}}
  4399.  
  4400. % {name opts}{nameparts}
  4401. \long\def\blx@nameparser@i#1#2{%
  4402.   \begingroup
  4403.   \ifblank{#1}
  4404.    {}
  4405.    {\setkeys{blx@opt@name}{#1}}%
  4406.   % reset all the nameparts to empty between names
  4407.   \def\do##1{%
  4408.     \cslet{namepart##1}\@empty
  4409.    \cslet{namepart##1i}\@empty}%
  4410.   \expandafter\docsvlist\expandafter{\blx@datamodel@constant@nameparts}%
  4411.   \setkeys{blx@opt@namepart}{#2}% Extract nameparts information
  4412.   % Still pass the nameparts forward for backwards compat
  4413.   % When \nameparts is finally removed, remove the "{2}" and remove the
  4414.   % arg to \blx@defformat@d in def of \blx@defnameformat
  4415.   \blx@theformat{#2}%
  4416.   \endgroup}
  4417.  
  4418. \long\def\blx@namebreak#1&{}
  4419.  
  4420. % [<format>][<start>-<stop>]{<plainlist>}
  4421. \protected\def\blx@imc@printlist{%
  4422.   \blx@listargs\blx@printlist}
  4423.  
  4424. % {<format>}{<start>}{<stop>}{<plainlist>}
  4425. \def\blx@printlist#1#2#3#4{%
  4426.   \blx@imc@iflistundef{#4}
  4427.    {\blx@nounit}
  4428.    {\blx@getformat\blx@thewrapperformat{lwd}{#1}{#4}%
  4429.      \ifdefvoid\blx@thewrapperformat
  4430.        {\blx@nounit}
  4431.       {\blx@getformat\blx@theformat{lfd}{#1}{#4}%
  4432.         \ifdefvoid\blx@theformat
  4433.           {\blx@nounit}
  4434.          {\blx@begunit
  4435.           \blx@listsetup{#2}{#3}{#4}%
  4436.            \blx@thewrapperformat{\expandafter\blx@listparser\blx@thedata{}&}%
  4437.            \blx@endunit}}}}
  4438.  
  4439. \def\blx@listsetup#1#2#3{%
  4440.   \def\currentlist{#3}%
  4441.   \c@listcount\@ne
  4442.   \expandafter\c@listtotal\csname c@#3\endcsname
  4443.   \letcs\blx@thedata{abx@list@#3}%
  4444.   \ifblank{#1}
  4445.    {\c@liststart\@ne}
  4446.    {\ifnum#1<\@ne
  4447.       \c@liststart\@ne
  4448.     \else
  4449.       \c@liststart#1\relax
  4450.     \fi}%
  4451.   \ifblank{#2}
  4452.    {\c@liststop\c@listtotal
  4453.     \ifnum\c@listtotal>\c@maxitems
  4454.       \c@liststop\c@minitems
  4455.     \fi}
  4456.    {\ifnum#2>\c@listtotal
  4457.       \c@liststop\c@listtotal
  4458.     \else
  4459.       \ifnum#2<\@ne
  4460.         \c@liststop\@ne
  4461.       \else
  4462.         \c@liststop#2\relax
  4463.       \fi
  4464.     \fi}}
  4465.  
  4466. % [<format>][<start>-<stop>]{<plainlist>}
  4467. \protected\def\blx@imc@indexlist{%
  4468.   \blx@listargs\blx@indexlist}
  4469.  
  4470. % {<format>}{<start>}{<stop>}{<plainlist>}
  4471. \def\blx@indexlist#1#2#3#4{%
  4472.   \blx@imc@iflistundef{#4}
  4473.    {}
  4474.    {\blx@getformat\blx@thewrapperformat{lxd}{#1}{#4}%
  4475.      \ifdefvoid\blx@thewrapperformat
  4476.        {}
  4477.       {\blx@getformat\blx@theformat{lid}{#1}{#4}%
  4478.         \ifdefvoid\blx@theformat
  4479.           {}
  4480.          {\begingroup
  4481.           \blx@listsetup{#2}{#3}{#4}%
  4482.            \expandafter\blx@listparser\blx@thedata{}&%
  4483.            \endgroup}}}}
  4484.  
  4485. % {<item1>}{<item2>}{...}
  4486. \long\def\blx@listparser#1{%
  4487.   \ifblank{#1}
  4488.    {\blx@listbreak}
  4489.    {\ifnum\c@listcount<\c@liststart
  4490.     \else
  4491.       \blx@theformat{#1}%
  4492.      \fi
  4493.      \advance\c@listcount\@ne
  4494.      \ifnum\c@listcount>\c@liststop
  4495.        \expandafter\blx@listbreak
  4496.      \fi
  4497.      \blx@listparser}}
  4498.  
  4499. \long\def\blx@listbreak#1&{}
  4500.  
  4501. % <*>{<key>}{<code>}
  4502. \protected\def\blx@imc@entrydata{%
  4503.   \@ifstar
  4504.     {\blx@xsanitizeafter{\blx@imc@entrydata@i\blx@saveentry}}
  4505.    {\blx@xsanitizeafter{\blx@imc@entrydata@i{}}}}
  4506.  
  4507. \long\def\blx@imc@entrydata@i#1#2#3{%
  4508.   \blx@getrefcontext{#2}%
  4509.   \blx@ifdata{#2}
  4510.     {\begingroup
  4511.      #1%
  4512.      \blx@resetdata
  4513.      \blx@getdata{#2}%
  4514.      \blx@entrysetcount
  4515.      \blx@setoptions@type\abx@field@entrytype
  4516.      \blx@setoptions@entry
  4517.      \addtocounter{instcount}\@ne
  4518.     \blx@execute
  4519.     \blx@beglangbib#3\blx@endlangbib
  4520.     \endgroup}
  4521.    {}}
  4522.  
  4523. \protected\def\blx@imc@entryset#1#2{%
  4524.   \blx@imc@iffieldundef{entrykey}
  4525.    {}
  4526.    {\begingroup
  4527.     \long\def\blx@entryset@precode{#1}%
  4528.      \long\def\blx@entryset@postcode{#2}%
  4529.      \let\finentry\blx@finentry@inset
  4530.      \let\do\blx@entryset
  4531.      \blx@imc@docsvfield{entryset}%
  4532.      \endgroup}}
  4533.  
  4534. \def\blx@entryset#1{%
  4535.   \blx@ifdata{#1}
  4536.    {\begingroup
  4537.     \blx@imc@clearlist{pageref}%
  4538.      \blx@getdata{#1}%
  4539.      \blx@setoptions@type\abx@field@entrytype
  4540.      \blx@setoptions@entry
  4541.      \global\blx@entrysetcounter\@ne
  4542.      \edef\abx@field@entrysetcount{\the\blx@entrysetcounter}%
  4543.      \blx@execute
  4544.      \blx@beglangbib
  4545.      \blx@begunit
  4546.      \blx@anchor
  4547.      \blx@entryset@precode
  4548.      \blx@driver{\blx@imc@thefield{entrytype}}%
  4549.      \blx@entryset@postcode
  4550.      \blx@endunit
  4551.      \blx@endlangbib
  4552.      \endgroup}
  4553.     {}%
  4554.   \let\do\blx@entryset@i}
  4555.  
  4556. \def\blx@entryset@i#1{%
  4557.   \blx@ifdata{#1}
  4558.    {\begingroup
  4559.     \blx@resetdata
  4560.     \blx@getdata{#1}%
  4561.      \blx@setoptions@type\abx@field@entrytype
  4562.      \blx@setoptions@entry
  4563.      \global\advance\blx@entrysetcounter\@ne
  4564.      \edef\abx@field@entrysetcount{\the\blx@entrysetcounter}%
  4565.      \addtocounter{instcount}\@ne
  4566.     \blx@execute
  4567.     \blx@beglangbib
  4568.     \blx@begunit
  4569.     \blx@anchor
  4570.     \blx@entryset@precode
  4571.     \blx@driver{\blx@imc@thefield{entrytype}}%
  4572.      \blx@entryset@postcode
  4573.      \blx@endunit
  4574.      \blx@endlangbib
  4575.      \endgroup}
  4576.     {\blx@nounit}}
  4577.  
  4578. \blx@regimcs{%
  4579.   \printtext \printfield \printlist \printnames \printfile
  4580.   \indexfield \indexlist \indexnames \entrydata \entryset}
  4581.  
  4582. %% Localization
  4583.  
  4584. % [<wrapper>]{<string>}
  4585. \newrobustcmd*{\blx@imc@bibstring}[2][\@firstofone]{%
  4586.   \blx@bibstring{#1}{\abx@str}{#2}}
  4587.  
  4588. \newrobustcmd*{\blx@imc@biblstring}[2][\@firstofone]{%
  4589.   \blx@bibstring{#1}{abx@lstr}{#2}}
  4590.  
  4591. \newrobustcmd*{\blx@imc@bibsstring}[2][\@firstofone]{%
  4592.   \blx@bibstring{#1}{abx@sstr}{#2}}
  4593.  
  4594. \def\blx@bibstringsimple{%
  4595.   \let\bibstring\blx@imc@bibxstring
  4596.   \let\biblstring\blx@imc@bibxlstring
  4597.   \let\bibsstring\blx@imc@bibxsstring}
  4598.  
  4599. \def\blx@bibstringnormal{%
  4600.   \let\bibstring\blx@imc@bibstring
  4601.   \let\biblstring\blx@imc@biblstring
  4602.   \let\bibsstring\blx@imc@bibsstring}
  4603.  
  4604. \protected\def\blx@bibstring#1#2#3{%
  4605.   \blx@begunit
  4606.   \blx@hyphenreset
  4607.   \blx@bibstringsimple
  4608.   \lowercase{\edef\blx@tempa{#3}}%
  4609.   \ifcsundef{#2@\blx@tempa}
  4610.    {\blx@warn@nostring\blx@tempa
  4611.     \blx@endnounit}
  4612.    {\blx@imc@ifcapital
  4613.       {#1{\MakeCapital{\csuse{#2@\blx@tempa}}}}
  4614.       {#1{\csuse{#2@\blx@tempa}}}%
  4615.      \blx@endunit}}
  4616.  
  4617. % [<wrapper>]{<string>}
  4618. \newrobustcmd*{\blx@imc@bibcpstring}[2][\@firstofone]{%
  4619.   \blx@bibcpstring{#1}{\abx@str}{#2}}
  4620.  
  4621. \newrobustcmd*{\blx@imc@bibcplstring}[2][\@firstofone]{%
  4622.   \blx@bibcpstring{#1}{abx@lstr}{#2}}
  4623.  
  4624. \newrobustcmd*{\blx@imc@bibcpsstring}[2][\@firstofone]{%
  4625.   \blx@bibcpstring{#1}{abx@sstr}{#2}}
  4626.  
  4627. \protected\def\blx@bibcpstring#1#2#3{%
  4628.   \blx@begunit
  4629.   \blx@hyphenreset
  4630.   \blx@bibstringsimple
  4631.   \lowercase{\edef\blx@tempa{#3}}%
  4632.   \ifcsundef{#2@\blx@tempa}
  4633.    {\blx@warn@nostring\blx@tempa
  4634.     \blx@endnounit}
  4635.    {#1{\MakeCapital{\csuse{#2@\blx@tempa}}}%
  4636.      \blx@endunit}}
  4637.  
  4638. % [<wrapper>]{<string>}
  4639. \newrobustcmd*{\blx@imc@biblcstring}[2][\@firstofone]{%
  4640.   \blx@biblcstring{#1}{\abx@str}{#2}}
  4641.  
  4642. \newrobustcmd*{\blx@imc@biblclstring}[2][\@firstofone]{%
  4643.   \blx@biblcstring{#1}{abx@lstr}{#2}}
  4644.  
  4645. \newrobustcmd*{\blx@imc@biblcsstring}[2][\@firstofone]{%
  4646.   \blx@biblcstring{#1}{abx@sstr}{#2}}
  4647.  
  4648. \protected\def\blx@biblcstring#1#2#3{%
  4649.   \blx@begunit
  4650.   \blx@hyphenreset
  4651.   \blx@bibstringsimple
  4652.   \lowercase{\edef\blx@tempa{#3}}%
  4653.   \ifcsundef{#2@\blx@tempa}
  4654.    {\blx@warn@nostring\blx@tempa
  4655.     \blx@endnounit}
  4656.    {#1{\MakeLowercase{\csuse{#2@\blx@tempa}}}%
  4657.      \blx@endunit}}
  4658.  
  4659. % [<wrapper>]{<string>}
  4660. \newrobustcmd*{\blx@imc@bibucstring}[2][\@firstofone]{%
  4661.   \blx@bibucstring{#1}{\abx@str}{#2}}
  4662.  
  4663. \newrobustcmd*{\blx@imc@bibuclstring}[2][\@firstofone]{%
  4664.   \blx@bibucstring{#1}{abx@lstr}{#2}}
  4665.  
  4666. \newrobustcmd*{\blx@imc@bibucsstring}[2][\@firstofone]{%
  4667.   \blx@bibucstring{#1}{abx@sstr}{#2}}
  4668.  
  4669. \protected\def\blx@bibucstring#1#2#3{%
  4670.   \blx@begunit
  4671.   \blx@hyphenreset
  4672.   \blx@bibstringsimple
  4673.   \lowercase{\edef\blx@tempa{#3}}%
  4674.   \ifcsundef{#2@\blx@tempa}
  4675.    {\blx@warn@nostring\blx@tempa
  4676.     \blx@endnounit}
  4677.    {#1{\MakeUppercase{\csuse{#2@\blx@tempa}}}%
  4678.      \blx@endunit}}
  4679.  
  4680. % {<string>}
  4681. \def\blx@imc@bibxstring#1{%
  4682.   \blx@bibxstring{\abx@str}{#1}}
  4683.  
  4684. \def\blx@imc@bibxlstring#1{%
  4685.   \blx@bibxstring{abx@lstr}{#1}}
  4686.  
  4687. \def\blx@imc@bibxsstring#1{%
  4688.   \blx@bibxstring{abx@sstr}{#1}}
  4689.  
  4690. \def\blx@bibxstring#1#2{%
  4691.   \ifcsundef{#1@#2}
  4692.    {\protect\blx@warn@nostring{#2}}
  4693.    {\csuse{#1@#2}}}
  4694.  
  4695. % {<string>}{<true>}{<false>}
  4696. \def\blx@imc@ifbibstring#1{%
  4697.   \ifcsundef{\abx@str @\detokenize{#1}}
  4698.    {\@secondoftwo}
  4699.    {\@firstoftwo}}
  4700.  
  4701. \def\blx@imc@ifbibxstring#1{%
  4702.   \blx@xsanitizeafter\ifcsundef{\abx@str @#1}
  4703.    {\@secondoftwo}
  4704.    {\@firstoftwo}}
  4705.  
  4706. % {<field>}{<true>}{<false>}
  4707. \def\blx@imc@iffieldbibstring#1{%
  4708.   \blx@imc@iffieldundef{#1}
  4709.    {\@secondoftwo}
  4710.     {\ifcsundef{\abx@str @\detokenize\expandafter
  4711.                           \expandafter\expandafter{%
  4712.                 \csname abx@field@#1\endcsname}}
  4713.        {\@secondoftwo}
  4714.       {\@firstoftwo}}}
  4715.  
  4716. % {<field>}{<string>}{<true>}{<false>}
  4717. \def\blx@imc@iffieldplusstringbibstring#1#2{%
  4718.   \blx@imc@iffieldundef{#1}
  4719.    {\@secondoftwo}
  4720.     {\ifcsundef{\abx@str @\detokenize\expandafter
  4721.                           \expandafter\expandafter{%
  4722.                 \csname abx@field@#1\endcsname}#2}
  4723.        {\@secondoftwo}
  4724.       {\@firstoftwo}}}
  4725.  
  4726. \blx@regimcs{%
  4727.   \bibstring   \biblstring   \bibsstring
  4728.   \bibxstring  \bibxlstring  \bibxsstring
  4729.   \bibcpstring \bibcplstring \bibcpsstring
  4730.   \biblcstring \biblclstring \biblcsstring
  4731.   \bibucstring \bibuclstring \bibucsstring
  4732.   \ifbibstring \ifbibxstring \iffieldbibstring
  4733.   \iffieldplusstringbibstring}
  4734.  
  4735. \let\blx@hook@uc\relax
  4736. \let\blx@hook@lc\relax
  4737.  
  4738. \AtEndPreamble{%
  4739.   \toggletrue{blx@tempa}%
  4740.   \toggletrue{blx@tempb}%
  4741.   \expandafter\patchcmd\csname MakeUppercase \endcsname
  4742.     {\protected@edef}
  4743.    {\blx@hook@uc\protected@edef}
  4744.    {\togglefalse{blx@tempa}}
  4745.    {}%
  4746.   \expandafter\patchcmd\csname MakeLowercase \endcsname
  4747.     {\protected@edef}
  4748.    {\blx@hook@lc\protected@edef}
  4749.    {\togglefalse{blx@tempb}}
  4750.    {}%
  4751.   \@ifpackageloaded{textcase}
  4752.    {\expandafter\patchcmd\csname MakeUppercase \endcsname
  4753.       {\def\i}
  4754.       {\blx@hook@uc\def\i}
  4755.       {\togglefalse{blx@tempa}}
  4756.       {}%
  4757.      \expandafter\patchcmd\csname MakeLowercase \endcsname
  4758.        {\@uclcnotmath{}}
  4759.       {\@uclcnotmath{\blx@hook@lc}}
  4760.       {\togglefalse{blx@tempb}}
  4761.       {}%
  4762.      \expandafter\patchcmd\csname MakeTextUppercase \endcsname
  4763.        {\def\i}
  4764.       {\blx@hook@uc\def\i}
  4765.       {}
  4766.       {}%
  4767.      \expandafter\patchcmd\csname MakeTextLowercase \endcsname
  4768.        {\@uclcnotmath{}}
  4769.       {\@uclcnotmath{\blx@hook@lc}}
  4770.       {}
  4771.       {}}
  4772.    {}%
  4773.   \iftoggle{blx@tempa}{\blx@err@patch{\string\MakeUppercase}}{}%
  4774.   \iftoggle{blx@tempb}{\blx@err@patch{\string\MakeLowercase}}{}%
  4775. }
  4776.  
  4777. \appto\blx@blxinit{%
  4778.   \def\blx@hook@uc{%
  4779.     \def\bibstring{\blx@imc@bibucstring}%
  4780.     \def\biblstring{\blx@imc@bibuclstring}%
  4781.     \def\bibsstring{\blx@imc@bibucsstring}%
  4782.     \def\biblcstring{\blx@imc@bibucstring}%
  4783.     \def\biblclstring{\blx@imc@bibuclstring}%
  4784.     \def\biblcsstring{\blx@imc@bibucsstring}%
  4785.     \def\bibcpstring{\blx@imc@bibucstring}%
  4786.     \def\bibcplstring{\blx@imc@bibuclstring}%
  4787.     \def\bibcpsstring{\blx@imc@bibucsstring}}%
  4788.   \def\blx@hook@lc{%
  4789.     \def\bibstring{\blx@imc@biblcstring}%
  4790.     \def\biblstring{\blx@imc@biblclstring}%
  4791.     \def\bibsstring{\blx@imc@biblcsstring}%
  4792.     \def\bibucstring{\blx@imc@biblcstring}%
  4793.     \def\bibuclstring{\blx@imc@biblclstring}%
  4794.     \def\bibucsstring{\blx@imc@biblcsstring}%
  4795.     \def\bibcpstring{\blx@imc@biblcstring}%
  4796.     \def\bibcplstring{\blx@imc@biblclstring}%
  4797.     \def\bibcpsstring{\blx@imc@biblcsstring}}}
  4798.  
  4799. \def\abx@dostrings{%
  4800.   \do{bibliography}%
  4801.   \do{references}%
  4802.   \do{shorthands}%
  4803.   \do{editor}%
  4804.   \do{editors}%
  4805.   \do{compiler}%
  4806.   \do{compilers}%
  4807.   \do{redactor}%
  4808.   \do{redactors}%
  4809.   \do{reviser}%
  4810.   \do{revisers}%
  4811.   \do{founder}%
  4812.   \do{founders}%
  4813.   \do{continuator}%
  4814.   \do{continuators}%
  4815.   \do{collaborator}%
  4816.   \do{collaborators}%
  4817.   \do{translator}%
  4818.   \do{translators}%
  4819.   \do{commentator}%
  4820.   \do{commentators}%
  4821.   \do{annotator}%
  4822.   \do{annotators}%
  4823.   \do{commentary}%
  4824.   \do{annotations}%
  4825.   \do{introduction}%
  4826.   \do{foreword}%
  4827.   \do{afterword}%
  4828.   \do{editortr}%
  4829.   \do{editorstr}%
  4830.   \do{editorco}%
  4831.   \do{editorsco}%
  4832.   \do{editoran}%
  4833.   \do{editorsan}%
  4834.   \do{editorin}%
  4835.   \do{editorsin}%
  4836.   \do{editorfo}%
  4837.   \do{editorsfo}%
  4838.   \do{editoraf}%
  4839.   \do{editorsaf}%
  4840.   \do{editortrco}%
  4841.   \do{editorstrco}%
  4842.   \do{editortran}%
  4843.   \do{editorstran}%
  4844.   \do{editortrin}%
  4845.   \do{editorstrin}%
  4846.   \do{editortrfo}%
  4847.   \do{editorstrfo}%
  4848.   \do{editortraf}%
  4849.   \do{editorstraf}%
  4850.   \do{editorcoin}%
  4851.   \do{editorscoin}%
  4852.   \do{editorcofo}%
  4853.   \do{editorscofo}%
  4854.   \do{editorcoaf}%
  4855.   \do{editorscoaf}%
  4856.   \do{editoranin}%
  4857.   \do{editorsanin}%
  4858.   \do{editoranfo}%
  4859.   \do{editorsanfo}%
  4860.   \do{editoranaf}%
  4861.   \do{editorsanaf}%
  4862.   \do{editortrcoin}%
  4863.   \do{editorstrcoin}%
  4864.   \do{editortrcofo}%
  4865.   \do{editorstrcofo}%
  4866.   \do{editortrcoaf}%
  4867.   \do{editorstrcoaf}%
  4868.   \do{editortranin}%
  4869.   \do{editorstranin}%
  4870.   \do{editortranfo}%
  4871.   \do{editorstranfo}%
  4872.   \do{editortranaf}%
  4873.   \do{editorstranaf}%
  4874.   \do{translatorco}%
  4875.   \do{translatorsco}%
  4876.   \do{translatoran}%
  4877.   \do{translatorsan}%
  4878.   \do{translatorin}%
  4879.   \do{translatorsin}%
  4880.   \do{translatorfo}%
  4881.   \do{translatorsfo}%
  4882.   \do{translatoraf}%
  4883.   \do{translatorsaf}%
  4884.   \do{translatorcoin}%
  4885.   \do{translatorscoin}%
  4886.   \do{translatorcofo}%
  4887.   \do{translatorscofo}%
  4888.   \do{translatorcoaf}%
  4889.   \do{translatorscoaf}%
  4890.   \do{translatoranin}%
  4891.   \do{translatorsanin}%
  4892.   \do{translatoranfo}%
  4893.   \do{translatorsanfo}%
  4894.   \do{translatoranaf}%
  4895.   \do{translatorsanaf}%
  4896.   \do{byauthor}%
  4897.   \do{byeditor}%
  4898.   \do{bycompiler}%
  4899.   \do{byredactor}%
  4900.   \do{byreviser}%
  4901.   \do{byreviewer}%
  4902.   \do{byfounder}%
  4903.   \do{bycontinuator}%
  4904.   \do{bycollaborator}%
  4905.   \do{bytranslator}%
  4906.   \do{bycommentator}%
  4907.   \do{byannotator}%
  4908.   \do{withcommentator}%
  4909.   \do{withannotator}%
  4910.   \do{withintroduction}%
  4911.   \do{withforeword}%
  4912.   \do{withafterword}%
  4913.   \do{organizer}%
  4914.   \do{organizers}%
  4915.   \do{byorganizer}%
  4916.   \do{byeditortr}%
  4917.   \do{byeditorco}%
  4918.   \do{byeditoran}%
  4919.   \do{byeditorin}%
  4920.   \do{byeditorfo}%
  4921.   \do{byeditoraf}%
  4922.   \do{byeditortrco}%
  4923.   \do{byeditortran}%
  4924.   \do{byeditortrin}%
  4925.   \do{byeditortrfo}%
  4926.   \do{byeditortraf}%
  4927.   \do{byeditorcoin}%
  4928.   \do{byeditorcofo}%
  4929.   \do{byeditorcoaf}%
  4930.   \do{byeditoranin}%
  4931.   \do{byeditoranfo}%
  4932.   \do{byeditoranaf}%
  4933.   \do{byeditortrcoin}%
  4934.   \do{byeditortrcofo}%
  4935.   \do{byeditortrcoaf}%
  4936.   \do{byeditortranin}%
  4937.   \do{byeditortranfo}%
  4938.   \do{byeditortranaf}%
  4939.   \do{bytranslatorco}%
  4940.   \do{bytranslatoran}%
  4941.   \do{bytranslatorin}%
  4942.   \do{bytranslatorfo}%
  4943.   \do{bytranslatoraf}%
  4944.   \do{bytranslatorcoin}%
  4945.   \do{bytranslatorcofo}%
  4946.   \do{bytranslatorcoaf}%
  4947.   \do{bytranslatoranin}%
  4948.   \do{bytranslatoranfo}%
  4949.   \do{bytranslatoranaf}%
  4950.   \do{and}%
  4951.   \do{andothers}%
  4952.   \do{andmore}%
  4953.   \do{volume}%
  4954.   \do{volumes}%
  4955.   \do{involumes}%
  4956.   \do{part}%
  4957.   \do{jourvol}%
  4958.   \do{jourser}%
  4959.   \do{newseries}%
  4960.   \do{oldseries}%
  4961.   \do{edition}%
  4962.   \do{reprint}%
  4963.   \do{reprintof}%
  4964.   \do{reprintas}%
  4965.   \do{reprintfrom}%
  4966.   \do{reviewof}%
  4967.   \do{translationof}%
  4968.   \do{translationas}%
  4969.   \do{translationfrom}%
  4970.   \do{origpubas}%
  4971.   \do{origpubin}%
  4972.   \do{astitle}%
  4973.   \do{bypublisher}%
  4974.   \do{nodate}%
  4975.   \do{page}%
  4976.   \do{pages}%
  4977.   \do{column}%
  4978.   \do{columns}%
  4979.   \do{line}%
  4980.   \do{lines}%
  4981.   \do{verse}%
  4982.   \do{verses}%
  4983.   \do{section}%
  4984.   \do{sections}%
  4985.   \do{paragraph}%
  4986.   \do{paragraphs}%
  4987.   \do{pagetotal}%
  4988.   \do{pagetotals}%
  4989.   \do{columntotal}%
  4990.   \do{columntotals}%
  4991.   \do{linetotal}%
  4992.   \do{linetotals}%
  4993.   \do{versetotal}%
  4994.   \do{versetotals}%
  4995.   \do{sectiontotal}%
  4996.   \do{sectiontotals}%
  4997.   \do{paragraphtotal}%
  4998.   \do{paragraphtotals}%
  4999.   \do{in}%
  5000.   \do{inseries}%
  5001.   \do{ofseries}%
  5002.   \do{book}%
  5003.   \do{issue}%
  5004.   \do{number}%
  5005.   \do{chapter}%
  5006.   \do{bathesis}%
  5007.   \do{mathesis}%
  5008.   \do{phdthesis}%
  5009.   \do{candthesis}%
  5010.   \do{resreport}%
  5011.   \do{techreport}%
  5012.   \do{software}%
  5013.   \do{datacd}%
  5014.   \do{audiocd}%
  5015.   \do{version}%
  5016.   \do{url}%
  5017.   \do{urlfrom}%
  5018.   \do{urlseen}%
  5019.   \do{file}%
  5020.   \do{inpreparation}%
  5021.   \do{submitted}%
  5022.   \do{inpress}%
  5023.   \do{prepublished}%
  5024.   \do{forthcoming}%
  5025.   \do{library}%
  5026.   \do{abstract}%
  5027.   \do{annotation}%
  5028.   \do{citedas}%
  5029.   \do{seenote}%
  5030.   \do{quotedin}%
  5031.   \do{opcit}%
  5032.   \do{loccit}%
  5033.   \do{ibidem}%
  5034.   \do{idem}%
  5035.   \do{idemsf}%
  5036.   \do{idemsm}%
  5037.   \do{idemsn}%
  5038.   \do{idempf}%
  5039.   \do{idempm}%
  5040.   \do{idempn}%
  5041.   \do{idempp}%
  5042.   \do{confer}%
  5043.   \do{sequens}%
  5044.   \do{sequentes}%
  5045.   \do{passim}%
  5046.   \do{see}%
  5047.   \do{seealso}%
  5048.   \do{backrefpage}%
  5049.   \do{backrefpages}%
  5050.   \do{thiscite}%
  5051.   \do{january}%
  5052.   \do{february}%
  5053.   \do{march}%
  5054.   \do{april}%
  5055.   \do{may}%
  5056.   \do{june}%
  5057.   \do{july}%
  5058.   \do{august}%
  5059.   \do{september}%
  5060.   \do{october}%
  5061.   \do{november}%
  5062.   \do{december}%
  5063.   \do{langamerican}%
  5064.   \do{langbrazilian}%
  5065.   \do{langbulgarian}%
  5066.   \do{langcatalan}%
  5067.   \do{langcroatian}%
  5068.   \do{langczech}%
  5069.   \do{langdanish}%
  5070.   \do{langdutch}%
  5071.   \do{langenglish}%
  5072.   \do{langestonian}%
  5073.   \do{langfinnish}%
  5074.   \do{langfrench}%
  5075.   \do{langgalician}%
  5076.   \do{langgerman}%
  5077.   \do{langgreek}%
  5078.   \do{langhungarian}%
  5079.   \do{langitalian}%
  5080.   \do{langjapanese}%
  5081.   \do{langlatin}%
  5082.   \do{langlatvian}%
  5083.   \do{langnorwegian}%
  5084.   \do{langpolish}%
  5085.   \do{langportuguese}%
  5086.   \do{langrussian}%
  5087.   \do{langslovak}%
  5088.   \do{langslovene}%
  5089.   \do{langspanish}%
  5090.   \do{langswedish}%
  5091.   \do{langukrainian}%
  5092.   \do{fromamerican}%
  5093.   \do{frombrazilian}%
  5094.   \do{frombulgarian}%
  5095.   \do{fromcatalan}%
  5096.   \do{fromcroatian}%
  5097.   \do{fromczech}%
  5098.   \do{fromdanish}%
  5099.   \do{fromdutch}%
  5100.   \do{fromenglish}%
  5101.   \do{fromestonian}%
  5102.   \do{fromfinnish}%
  5103.   \do{fromfrench}%
  5104.   \do{fromgalician}%
  5105.   \do{fromgerman}%
  5106.   \do{fromgreek}%
  5107.   \do{fromhungarian}%
  5108.   \do{fromitalian}%
  5109.   \do{fromjapanese}%
  5110.   \do{fromlatin}%
  5111.   \do{fromlatvian}%
  5112.   \do{fromnorwegian}%
  5113.   \do{frompolish}%
  5114.   \do{fromportuguese}%
  5115.   \do{fromrussian}%
  5116.   \do{fromslovak}%
  5117.   \do{fromslovene}%
  5118.   \do{fromspanish}%
  5119.   \do{fromswedish}%
  5120.   \do{fromukrainian}%
  5121.   \do{countryde}%
  5122.   \do{countryep}%
  5123.   \do{countryeu}%
  5124.   \do{countryfr}%
  5125.   \do{countryuk}%
  5126.   \do{countryus}%
  5127.   \do{patent}%
  5128.   \do{patentde}%
  5129.   \do{patenteu}%
  5130.   \do{patentfr}%
  5131.   \do{patentuk}%
  5132.   \do{patentus}%
  5133.   \do{patreq}%
  5134.   \do{patreqde}%
  5135.   \do{patreqeu}%
  5136.   \do{patreqfr}%
  5137.   \do{patrequk}%
  5138.   \do{patrequs}%
  5139.   \do{commonera}%
  5140.   \do{beforecommonera}%
  5141.   \do{annodomini}%
  5142.   \do{beforechrist}%
  5143.   \do{circa}%
  5144.   \do{spring}%
  5145.   \do{summer}%
  5146.   \do{autumn}%
  5147.   \do{winter}%
  5148.   \do{am}%
  5149.   \do{pm}%
  5150. }
  5151.  
  5152. \newrobustcmd*{\NewBibliographyString}[1]{%
  5153.   \forcsvlist\blx@newstring{#1}}
  5154.  
  5155. \def\blx@newstring#1{%
  5156.   \ifcsundef{KV@blx@lbx@#1}
  5157.    {\gappto\abx@dostrings{\do{#1}}%
  5158.      \csgdef{KV@blx@lbx@#1}##1{\blx@defstring{#1}{##1}}}
  5159.    {}}
  5160.  
  5161. % in *.cbx/bbx/tex: <key> = {<string>},
  5162. % in *.lbx:         <key> = {{<longstring>}{<abbrevstring>}},
  5163. \def\do#1{\define@key{blx@lbx}{#1}{\blx@defstring{#1}{##1}}}
  5164. \abx@dostrings
  5165.  
  5166. % in *.cbx/bbx/tex: (implicit)
  5167. % in *.lbx:         inherit = {<language>},
  5168. \define@key{blx@lbx}{inherit}{%
  5169.   \blx@lbxinput@strings{#1}{}{\blx@err@nolang{#1}}%
  5170.   \csuse{abx@strings@#1}}
  5171.  
  5172. \def\blx@cfg@defstring#1#2{%
  5173.   \csdef{abx@lstr@#1}{#2}%
  5174.   \csdef{abx@sstr@#1}{#2}}
  5175.  
  5176. \def\blx@lbx@defstring#1#2{%
  5177.   \blx@lbx@defstring@i{#1}#2}
  5178. \def\blx@lbx@defstring@i#1#2#3{%
  5179.   \csdef{abx@lstr@#1}{#2}%
  5180.   \csdef{abx@sstr@#1}{#3}}
  5181.  
  5182. % {<language>}
  5183. \def\blx@lbxcheck#1{%
  5184.   \ifcsdef{blx@lng@#1}
  5185.     {\expandafter\expandafter\expandafter\IfFileExists
  5186.      \expandafter\expandafter\expandafter{%
  5187.      \csname blx@lng@#1\endcsname.lbx}
  5188.        {}
  5189.       {\blx@err@nolang{#1}}}
  5190.    {\IfFileExists{#1.lbx}
  5191.       {}
  5192.       {\blx@err@nolang{#1}}}}
  5193.  
  5194. % {<language>}{<definitions>}
  5195. \newrobustcmd*{\DefineBibliographyExtras}[2]{%
  5196.   \blx@lbxcheck{#1}%
  5197.   \csgappto{blx@hook@extras@#1}{%
  5198.     \blx@defbibextras{#1}{#2}}}
  5199. \@onlypreamble\DefineBibliographyExtras
  5200.  
  5201. \newrobustcmd*{\UndefineBibliographyExtras}[2]{%
  5202.   \blx@lbxcheck{#1}%
  5203.   \csgappto{blx@hook@noextras@#1}{%
  5204.     \blx@undefbibextras{#1}{#2}}}
  5205. \@onlypreamble\UndefineBibliographyExtras
  5206.  
  5207. \def\blx@defbibextras#1{\csgappto{abx@extras@#1}}
  5208. \def\blx@undefbibextras#1{\csgappto{abx@noextras@#1}}
  5209.  
  5210. % {<language>}{<language>}
  5211. \def\blx@letbibextras#1#2{%
  5212.   \blx@lbxinput@extras{#2}{}{\blx@err@nolang{#2}}%
  5213.   \global\csletcs{abx@extras@#1}{abx@extras@#2}
  5214.  \global\csletcs{abx@noextras@#1}{abx@noextras@#2}}%
  5215.  
  5216. % {<language>}{<strings>}
  5217. \newrobustcmd*{\DefineBibliographyStrings}[2]{%
  5218.   \blx@lbxcheck{#1}%
  5219.   \csgappto{blx@hook@strings@#1}{%
  5220.     \begingroup
  5221.     \let\blx@defstring\blx@cfg@defstring
  5222.     \blx@defbibstrings{#1}{#2}%
  5223.     \endgroup}}
  5224. \@onlypreamble\DefineBibliographyStrings
  5225.  
  5226. \def\blx@defbibstrings#1#2{%
  5227.   \def\do##1{\csundef{abx@lstr@##1}\csundef{abx@sstr@##1}}%
  5228.   \abx@dostrings
  5229.   \csuse{abx@strings@#1}%
  5230.   \setkeys{blx@lbx}{#2}%
  5231.   \let\do\blx@defbibstrings@i
  5232.   \csxdef{abx@strings@#1}{\abx@dostrings}%
  5233.   \csgappto{abx@strings@#1}{%
  5234.     \ifcsdef{\abx@str @bibliography}
  5235.      {\letcs\bibname{\abx@str @bibliography}}
  5236.      {\let\bibname\@empty}%
  5237.     \ifcsdef{\abx@str @references}
  5238.      {\letcs\refname{\abx@str @references}}
  5239.      {\let\refname\@empty}%
  5240.     \ifcsdef{\abx@str @shorthands}
  5241.      {\letcs\biblistname{\abx@str @shorthands}}
  5242.      {\let\biblistname\@empty}}}
  5243.  
  5244. \def\blx@defbibstrings@i#1{%
  5245.   \ifcsdef{abx@lstr@#1}
  5246.     {\def\expandafter\noexpand\csname abx@lstr@#1\endcsname{%
  5247.        \csexpandonce{abx@lstr@#1}}}
  5248.    {\undef\expandafter\noexpand\csname abx@lstr@#1\endcsname}%
  5249.   \ifcsdef{abx@sstr@#1}
  5250.     {\def\expandafter\noexpand\csname abx@sstr@#1\endcsname{%
  5251.        \csexpandonce{abx@sstr@#1}}}
  5252.    {\undef\expandafter\noexpand\csname abx@sstr@#1\endcsname}}
  5253.  
  5254. % {<language>}{<language>}
  5255. \def\blx@letbibstrings#1#2{%
  5256.   \blx@lbxinput@strings{#2}{}{\blx@err@nolang{#2}}%
  5257.   \global\csletcs{abx@strings@#1}{abx@strings@#2}}%
  5258.  
  5259. % {<language>}{<exceptions>}
  5260. \newrobustcmd*{\DefineHyphenationExceptions}[2]{%
  5261.   \ifcsundef{l@#1}
  5262.    {\blx@warn@nohyph{#1}}
  5263.    {}%
  5264.   \csgappto{blx@hook@hyph@#1}{\blx@hyphexcept{#1}{#2}}}
  5265. \@onlypreamble\DefineHyphenationExceptions
  5266.  
  5267. \def\blx@hyphexcept#1#2{%
  5268.   \ifcsundef{l@#1}
  5269.    {\blx@warn@nohyph{#1}}
  5270.    {\begingroup
  5271.     \language\csname l@#1\endcsname\relax
  5272.     \hyphenation{#2}%
  5273.      \endgroup}}
  5274.  
  5275. % {<mapping suffix>}
  5276. \newrobustcmd*{\DeclareLanguageMappingSuffix}[1]{%
  5277.   \gdef\blx@lng@suff{#1}}
  5278. \@onlypreamble\DeclareLanguageMappingSuffix
  5279. \let\blx@lng@suff\@empty
  5280.  
  5281. % {<language>}{<mapping>}
  5282. \newrobustcmd*{\DeclareLanguageMapping}[2]{%
  5283.   \csgdef{blx@lng@#1}{#2}%
  5284.   \csgdef{blx@lng@explicit@#1}{#2}}
  5285. \@onlypreamble\DeclareLanguageMapping
  5286.  
  5287. % to avoid copying, these commands simply redefine the input handlers and
  5288. % process and postprocess code
  5289. % {<language>}{<success>}{<failure>}
  5290. \def\blx@lbxinput#1{%
  5291.   \csletcs{blx@lbx@input@handler}{blx@lbx@input@handler@once}%
  5292.   \csletcs{blx@lbx@input@process}{blx@lbx@input@process@all}%
  5293.   \csletcs{blx@lbx@input@postprocess}{blx@lbx@input@postprocess@all}%
  5294.   \blx@lbxinput@i{#1}}
  5295.  
  5296. \def\blx@lbxinput@strings#1{%
  5297.   \csletcs{blx@lbx@input@handler}{blx@lbx@input@handler@simple}%
  5298.   \csletcs{blx@lbx@input@process}{blx@lbx@input@process@strings}%
  5299.   \csletcs{blx@lbx@input@postprocess}{blx@lbx@input@postprocess@strings}%
  5300.   \blx@lbxinput@i{#1}}
  5301.  
  5302. \def\blx@lbxinput@extras#1{%
  5303.   \csletcs{blx@lbx@input@handler}{blx@lbx@input@handler@simple}%
  5304.   \csletcs{blx@lbx@input@process}{blx@lbx@input@process@extras}%
  5305.   \csletcs{blx@lbx@input@postprocess}{blx@lbx@input@postprocess@extras}%
  5306.   \blx@lbxinput@i{#1}}
  5307.  
  5308. \def\blx@lbxinput@i#1{%
  5309.   \ifcsundef{blx@nolbxrecurse@#1}
  5310.    {\ifcsdef{blx@lng@explicit@#1}
  5311.       {\global\csletcs{blx@lng@#1}{blx@lng@explicit@#1}}
  5312.       {\ifdefempty\blx@lng@suff
  5313.          {}
  5314.          {\csgdef{blx@lng@#1}{#1\blx@lng@suff}}}}
  5315.    {}%
  5316.   \blx@lbxinput@ii{#1}}
  5317.  
  5318. \def\blx@lbxinput@ii#1{%
  5319.   \ifcsdef{blx@lng@#1}
  5320.     {\expandafter\expandafter\expandafter\blx@lbxinput@iii
  5321.      \expandafter\expandafter\expandafter{%
  5322.        \csname blx@lng@#1\endcsname}{#1}}
  5323.    {\blx@lbxinput@iv{#1}{#1}{language '#1'}}}
  5324.  
  5325. % {<mapping>}{<language>}
  5326. \def\blx@lbxinput@iii#1#2{%
  5327.   \global\csundef{blx@lng@#2}%
  5328.   \IfFileExists{#1.lbx}
  5329.    {\blx@lbxinput@iv{#2}{#1}{language '#2' -> '#1'}}
  5330.    {\ifcsdef{blx@suffmaptried@#2}
  5331.      {}
  5332.       {\blx@warning@noline{%
  5333.           File '#1.lbx' not found!\MessageBreak
  5334.           Ignoring mapping '#2' -> '#1'}%
  5335.        \global\cslet{blx@suffmaptried@#2}\@empty}%
  5336.      \blx@lbxinput@iv{#2}{#2}{language '#2'}}}
  5337.  
  5338. % .lbx files must be read with one of the two following commands,
  5339. % do not use \blx@inputonce. Only the commands here make sure that the file
  5340. % is read as many times as necessary.
  5341. % blx@file@lbx@simple@#1 only blocks the file being added to the file list
  5342. % blx@file@lbx@once@#1 blocks a file from being loaded again by the input-once
  5343. % routine
  5344. % {<file>}{<message>}{<preload>}{<postload>}{<success>}{<failure>}
  5345. \protected\long\def\blx@lbx@input@handler@simple#1#2#3#4#5#6{%
  5346.   \blx@info@noline{Trying to load #2..}%
  5347.   \IfFileExists{#1}
  5348.    {\blx@info@noline{... file '#1' found}%
  5349.      #3\@@input\@filef@und#4#5%
  5350.      \ifcsundef{blx@file@lbx@simple@#1}
  5351.       {\listxadd\blx@list@req@stat{#1}%
  5352.         \@addtofilelist{#1}%
  5353.         \global\cslet{blx@file@lbx@simple@#1}\@empty}
  5354.       {}}
  5355.    {\blx@info@noline{... file '#1' not found}#6}}
  5356.  
  5357. % {<file>}{<message>}{<preload>}{<postload>}{<success>}{<failure>}
  5358. \protected\long\def\blx@lbx@input@handler@once#1#2#3#4#5#6{%
  5359.   \ifcsundef{blx@file@lbx@once@#1}
  5360.    {\blx@info@noline{Trying to load #2..}%
  5361.      \IfFileExists{#1}
  5362.       {\blx@info@noline{... file '#1' found}%
  5363.         #3\@@input\@filef@und#4#5%
  5364.         \ifcsundef{blx@file@lbx@simple@#1}
  5365.          {\listxadd\blx@list@req@stat{#1}%
  5366.            \@addtofilelist{#1}}
  5367.          {}}
  5368.       {\blx@info@noline{... file '#1' not found}#6}%
  5369.      \global\cslet{blx@file@lbx@once@#1}\@empty
  5370.     \global\cslet{blx@file@lbx@simple@#1}\@empty}
  5371.    {#5}}
  5372.  
  5373. \def\blx@lbx@input@process@strings#1{%
  5374.   \global\cslet{abx@strings@#1}\@empty
  5375.   \def\InheritBibliographyStrings{%
  5376.     \blx@letbibstrings{#1}}%
  5377.   \def\DeclareBibliographyStrings##1{%
  5378.     \begingroup
  5379.       \let\blx@defstring\blx@lbx@defstring
  5380.       \blx@defbibstrings{#1}{##1}%
  5381.     \endgroup}}
  5382.  
  5383. \def\blx@lbx@input@process@extras#1{%
  5384.   \global\cslet{abx@extras@#1}\@empty
  5385.  \global\cslet{abx@noextras@#1}\@empty
  5386.  \def\InheritBibliographyExtras{\blx@letbibextras{#1}}%
  5387.   \def\DeclareBibliographyExtras{\blx@defbibextras{#1}}%
  5388.   \def\UndeclareBibliographyExtras{\blx@undefbibextras{#1}}}
  5389.  
  5390. \def\blx@lbx@input@process@all#1{%
  5391.   \blx@lbx@input@process@strings{#1}%
  5392.   \blx@lbx@input@process@extras{#1}%
  5393.   \def\DeclareHyphenationExceptions{\blx@hyphexcept{#1}}}
  5394.  
  5395. \def\blx@lbx@input@postprocess@strings#1{%
  5396.   \csuse{blx@hook@strings@#1}}
  5397.  
  5398. \def\blx@lbx@input@postprocess@extras#1{%
  5399.   \csuse{blx@hook@extras@#1}%
  5400.   \csuse{blx@hook@noextras@#1}}
  5401.  
  5402. \def\blx@lbx@input@postprocess@all#1{%
  5403.   \blx@lbx@input@postprocess@strings{#1}%
  5404.   \blx@lbx@input@postprocess@extras{#1}%
  5405.   \csuse{blx@hook@hyph@#1}}
  5406.  
  5407. % {<language>}{<lbxfile>}{<message>}
  5408. \def\blx@lbxinput@iv#1#2#3{%
  5409.   \begingroup
  5410.     \blx@lbx@input@handler{#2.lbx}{#3}
  5411.      {\blx@maplang{#1}{#1}%
  5412.        \let\InheritBibliographyStrings\@gobble
  5413.        \let\DeclareBibliographyStrings\@gobble
  5414.        \let\InheritBibliographyExtras\@gobble
  5415.        \let\DeclareBibliographyExtras\@gobble
  5416.        \let\UndeclareBibliographyExtras\@gobble
  5417.        \blx@lbx@input@process{#1}%
  5418.        \begingroup
  5419.        \cslet{blx@nolbxrecurse@#1}\@empty
  5420.       \blx@saneccodes
  5421.       \makeatletter}
  5422.      {\endgroup
  5423.       \blx@lbx@input@postprocess{#1}}
  5424.      {\aftergroup\@firstoftwo}
  5425.      {\aftergroup\@secondoftwo}%
  5426.   \endgroup}
  5427.  
  5428. % {<language>}
  5429. \def\blx@langsetup#1{%
  5430.   \blx@lbxinput{#1}
  5431.    {\edef\blx@languagename{#1}}
  5432.    {\blx@warning
  5433.       {Language '#1' not supported.\MessageBreak
  5434.        Using fallback language '\blx@languagename'}%
  5435.      \blx@lbxinput{\blx@languagename}
  5436.       {\blx@maplang{#1}{\blx@languagename}}
  5437.       {\blx@err@nolang{\blx@languagename}}}}
  5438.  
  5439. % auxiliary macros
  5440.  
  5441. % {<field base name>}
  5442. \newrobustcmd*{\mkdaterangeshort}{%
  5443.   \mkdaterangefull{short}}
  5444.  
  5445. \newrobustcmd*{\mkdaterangelong}{%
  5446.   \mkdaterangefull{long}}
  5447.  
  5448. \newrobustcmd*{\mkdaterangeterse}{%
  5449.   \mkdaterangetrunc{short}}
  5450.  
  5451. \newrobustcmd*{\mkdaterangecomp}{%
  5452.   \mkdaterangetrunc{long}}
  5453.  
  5454. \newrobustcmd*{\mkdaterangeshortextra}{%
  5455.   \mkdaterangefullextra{short}}
  5456.  
  5457. \newrobustcmd*{\mkdaterangelongextra}{%
  5458.   \mkdaterangefullextra{long}}
  5459.  
  5460. \newrobustcmd*{\mkdaterangeterseextra}{%
  5461.   \mkdaterangetruncextra{short}}
  5462.  
  5463. \newrobustcmd*{\mkdaterangecompextra}{%
  5464.   \mkdaterangetruncextra{long}}
  5465.  
  5466. % calls to \blx@metadateinfo should be grouped to avoid name clashes
  5467. \def\blx@metadateinfo#1{%
  5468.   \letcs\ifdateera{if#1dateera}%
  5469.   \letcs\ifenddateera{if#1enddateera}%
  5470.   \letcs\ifdatecirca{if#1datecirca}%
  5471.   \letcs\ifenddatecirca{if#1enddatecirca}%
  5472.   \letcs\ifdatejulian{if#1datejulian}%
  5473.   \letcs\ifenddatejulian{if#1enddatejulian}%
  5474.   \letcs\ifdateuncertain{if#1dateuncertain}%
  5475.   \letcs\ifenddateuncertain{if#1enddateuncertain}%
  5476.   \letcs\ifdateunknown{if#1dateunknown}%
  5477.   \letcs\ifenddateunknown{if#1enddateunknown}}
  5478.  
  5479. \expandafter\newrobustcmd\expandafter*\csname mktimerange24h\endcsname{%
  5480.   \mktimerange{24h}}
  5481.  
  5482. \expandafter\newrobustcmd\expandafter*\csname mktimerange12h\endcsname{%
  5483.   \mktimerange{12h}}
  5484.  
  5485. \expandafter\newrobustcmd\expandafter*\csname mktimerange24hcomp\endcsname[1]{%
  5486.   \iffieldundef{#1hour}
  5487.    {}
  5488.    {\ifboolexpr{test {\iffieldundef{#1endhour}}
  5489.                 or
  5490.                 test {\iffieldequalstr{#1endhour}{}}}
  5491.       {\mktimerange{24h}{#1}}
  5492.       {\iffieldsequal{#1hour}{#1endhour}
  5493.           % 14:xx:xx 14:xx:xx
  5494.           {\iffieldsequal{#1minute}{#1endminute}
  5495.              % 14:13:xx 14:13:xx
  5496.              {\toggletrue{blx@seconds}%
  5497.               \printtext[#1time]{%
  5498.                 \csuse{mkbibtime24h}{#1hour}{#1minute}{#1second}{}%
  5499.               \bibtimerangesep
  5500.               \csuse{mkbibtime24h}{}{}{#1endsecond}{}}}
  5501.              % 14:13:xx 14:14:xx
  5502.              {\toggletrue{blx@seconds}%
  5503.               \printtext[#1time]{\csuse{mkbibtime24h}{#1hour}{#1minute}{}{}%
  5504.               \bibtimerangesep
  5505.               \csuse{mkbibtime24h}{}{#1endminute}{}{}}}}
  5506.           % 14:xx:xx 15:xx:xx
  5507.           {\mktimerange{24h}{#1}}}}}
  5508.  
  5509. % {<24h|24hcomp|12h>}{<datetype>}
  5510. \newrobustcmd*{\mktimerange}[2]{%
  5511.   \iffieldundef{#2hour}
  5512.    {\blx@nounit}
  5513.    {\blx@timepre{#2}{}%
  5514.      \printtext[#2time]{\csuse{mkbibtime#1}{#2hour}{#2minute}{#2second}{#2timezone}%
  5515.      \iffieldundef{#2endhour}
  5516.       {}
  5517.       {\blx@timepre{#2}{end}%
  5518.         \iffieldequalstr{#2endhour}{}
  5519.          {\mbox{\bibtimerangesep}}
  5520.          {\bibtimerangesep
  5521.           \csuse{mkbibtime#1}{#2endhour}{#2endminute}{#2endsecond}{#2endtimezone}}}}}}
  5522.  
  5523. % {<datetype>}{''|end}
  5524. \newrobustcmd*{\blx@timepre}[2]{%
  5525.   \iftoggle{blx@timezones}{}
  5526.    {\blx@imc@clearfield{#1#2timezone}}%
  5527.   \iftoggle{blx@seconds}{}
  5528.    {\blx@imc@clearfield{#1#2second}}}
  5529.  
  5530. % {<short|long>}{<datetype>}
  5531. \newrobustcmd*{\mkdaterangefull}[2]{%
  5532.   \begingroup
  5533.     \blx@metadateinfo{#2}%
  5534.     \iffieldundef{#2year}
  5535.      {\blx@nounit}
  5536.       {\printtext[#2date]{%
  5537.          \datecircaprint
  5538.          % Such a season component can only come from an ISO8601 season which replaces
  5539.          % a normal month so if it exists, we know that a normal date print is ruled out
  5540.          \iffieldundef{#2season}
  5541.           {\csuse{mkbibdate#1}{#2year}{#2month}{#2day}%
  5542.             % Optionally print the time after the date
  5543.             \blx@printtime{#2}{}}
  5544.           {\csuse{mkbibseasondate#1}{#2year}{#2season}}%
  5545.          \dateuncertainprint
  5546.          \dateeraprint{#2year}%
  5547.          \iffieldundef{#2endyear}
  5548.           {}
  5549.           {\iffieldequalstr{#2endyear}{}
  5550.              {\mbox{\bibdaterangesep}}
  5551.              {\bibdaterangesep
  5552.               \enddatecircaprint
  5553.               \iffieldundef{#2season}
  5554.                 {\csuse{mkbibdate#1}{#2endyear}{#2endmonth}{#2endday}%
  5555.                   % Optionally print the time after the date
  5556.                   \blx@printtime{#2}{end}}
  5557.                 {\csuse{mkbibseasondate#1}{#2endyear}{#2endseason}}%
  5558.                \enddateuncertainprint
  5559.                \dateeraprint{#2endyear}}}}}%
  5560.   \endgroup}
  5561.  
  5562. \newrobustcmd*{\mkdaterangetrunc}[2]{%
  5563.   \begingroup
  5564.     \blx@metadateinfo{#2}%
  5565.     \iffieldundef{#2year}
  5566.      {\blx@nounit}
  5567.       {\printtext[#2date]{%
  5568.          \datecircaprint
  5569.          % Such a season component can only come from an ISO8601 season which replaces
  5570.          % a normal month so if it exists, we know that a normal date print is ruled out
  5571.          \iffieldundef{#2season}
  5572.           {\ifdateyearsequal{#2}{#2end}
  5573.              {\iffieldsequal{#2month}{#2endmonth}
  5574.                 {\csuse{mkbibdate#1}{}{}{#2day}}
  5575.                 {\csuse{mkbibdate#1}{}{#2month}{#2day}}}
  5576.              {\csuse{mkbibdate#1}{#2year}{#2month}{#2day}%
  5577.                \iffieldsequal{#2dateera}{#2enddateera}{}
  5578.                 {\dateeraprint{#2year}}}}
  5579.           {\ifdateyearsequal{#2}{#2end}
  5580.             {\csuse{mkbibseasondate#1}{}{#2season}}
  5581.             {\csuse{mkbibseasondate#1}{#2year}{#2season}%
  5582.               \iffieldsequal{#2dateera}{#2enddateera}{}
  5583.                {\dateeraprint{#2year}}}}%
  5584.          \dateuncertainprint
  5585.          \iffieldundef{#2endyear}
  5586.           {}
  5587.           {\iffieldequalstr{#2endyear}{}
  5588.              {\mbox{\bibdaterangesep}}
  5589.              {\bibdaterangesep
  5590.               \enddatecircaprint
  5591.               \iffieldundef{#2season}
  5592.                 {\csuse{mkbibdate#1}{#2endyear}{#2endmonth}{#2endday}}
  5593.                 {\csuse{mkbibseasondate#1}{#2endyear}{#2endseason}}%
  5594.                \enddateuncertainprint
  5595.                \dateeraprint{#2endyear}}}}}%
  5596.   \endgroup}
  5597.  
  5598. \newrobustcmd*{\mkdaterangefullextra}[2]{%
  5599.   \begingroup
  5600.     \blx@metadateinfo{#2}%
  5601.     \iffieldundef{#2year}
  5602.      {\blx@nounit}
  5603.       {\printtext[#2date]{%
  5604.          \datecircaprint
  5605.          % Such a season component can only come from an ISO8601 season which replaces
  5606.          % a normal month so if it exists, we know that a normal date print is ruled out
  5607.          \iffieldundef{#2season}
  5608.           {\csuse{mkbibdate#1}{#2year}{#2month}{#2day}%
  5609.             % Optionally print the time after the date
  5610.             \blx@printtime{#2}{}}
  5611.           {\csuse{mkbibseasondate#1}{#2year}{#2season}}%
  5612.          \dateuncertainprint
  5613.          \dateeraprint{#2year}%
  5614.          \iffieldundef{#2endyear}
  5615.           {\printfield{extradate}}
  5616.           {\iffieldequalstr{#2endyear}{}
  5617.              {\printfield{extradate}%
  5618.                \printtext{\mbox{\bibdaterangesep}}}
  5619.               {\printtext{%
  5620.                  \bibdaterangesep
  5621.                  \enddatecircaprint
  5622.                  \iffieldundef{#2season}
  5623.                   {\csuse{mkbibdate#1}{#2endyear}{#2endmonth}{#2endday}%
  5624.                     % Optionally print the time after the date
  5625.                     \blx@printtime{#2}{end}}
  5626.                   {\csuse{mkbibseasondate#1}{#2endyear}{#2endseason}}}%
  5627.                  \printfield{extradate}%
  5628.                  \enddateuncertainprint
  5629.                  \dateeraprint{#2endyear}}}}}%
  5630.   \endgroup}
  5631.  
  5632. \newrobustcmd*{\mkdaterangetruncextra}[2]{%
  5633.   \begingroup
  5634.     \blx@metadateinfo{#2}%
  5635.     \iffieldundef{#2year}
  5636.      {\blx@nounit}
  5637.       {\printtext[#2date]{%
  5638.          \datecircaprint
  5639.          % Such a season component can only come from an ISO8601 season which replaces
  5640.          % a normal month so if it exists, we know that a normal date print is ruled out
  5641.          \iffieldundef{#2season}
  5642.           {\ifdateyearsequal{#2}{#2end}
  5643.              {\iffieldsequal{#2month}{#2endmonth}
  5644.                 {\csuse{mkbibdate#1}{}{}{#2day}}
  5645.                 {\csuse{mkbibdate#1}{}{#2month}{#2day}}}
  5646.              {\csuse{mkbibdate#1}{#2year}{#2month}{#2day}%
  5647.                \iffieldsequal{#2dateera}{#2enddateera}{}
  5648.                 {\dateeraprint{#2year}}}}
  5649.           {\ifdateyearsequal{#2}{#2end}
  5650.             {\csuse{mkbibseasondate#1}{}{#2season}}
  5651.             {\csuse{mkbibseasondate#1}{#2year}{#2season}%
  5652.               \iffieldsequal{#2dateera}{#2enddateera}{}
  5653.                {\dateeraprint{#2year}}}}%
  5654.          \dateuncertainprint
  5655.          \iffieldundef{#2endyear}
  5656.           {\printfield{extradate}}
  5657.           {\iffieldequalstr{#2endyear}{}
  5658.              {\printfield{extradate}%
  5659.                \printtext{\mbox{\bibdaterangesep}}}
  5660.               {\printtext{%
  5661.                  \bibdaterangesep
  5662.                  \enddatecircaprint
  5663.                  \iffieldundef{#2season}
  5664.                   {\csuse{mkbibdate#1}{#2endyear}{#2endmonth}{#2endday}}
  5665.                   {\csuse{mkbibseasondate#1}{#2endyear}{#2endseason}}}%
  5666.                  \printfield{extradate}%
  5667.                  \enddateuncertainprint
  5668.                  \dateeraprint{#2endyear}}}}}%
  5669.   \endgroup}
  5670.  
  5671. \newrobustcmd*{\mkdaterangeyear}[1]{%
  5672.   \blx@imc@clearfield{#1season}%
  5673.   \blx@imc@clearfield{#1month}%
  5674.   \blx@imc@clearfield{#1day}%
  5675.   \blx@imc@clearfield{#1hour}%
  5676.   \blx@imc@clearfield{#1minute}%
  5677.   \blx@imc@clearfield{#1second}%
  5678.   \blx@imc@clearfield{#1timezone}%
  5679.   \blx@imc@clearfield{#1endseason}%
  5680.   \blx@imc@clearfield{#1endmonth}%
  5681.   \blx@imc@clearfield{#1endday}%
  5682.   \blx@imc@clearfield{#1endhour}%
  5683.   \blx@imc@clearfield{#1endminute}%
  5684.   \blx@imc@clearfield{#1endsecond}%
  5685.   \blx@imc@clearfield{#1endtimezone}%
  5686.   \ifdateyearsequal{#1}{#1end}
  5687.    {\blx@imc@clearfield{#1endyear}}
  5688.    {}%
  5689.   \mkdaterangefull{short}{#1}}
  5690.  
  5691. % {<datetype>}
  5692. \newrobustcmd*{\mkdaterangeymd}[1]{%
  5693.   \begingroup
  5694.     \blx@metadateinfo{#1}%
  5695.     \iffieldundef{#1year}
  5696.      {\blx@nounit}
  5697.       {\printtext[#1date]{%
  5698.          \datecircaprint
  5699.          % Such a season component can only come from an  ISO8601 season which replaces
  5700.          % a normal month so if it exists, we know that a normal date print is ruled out
  5701.          \iffieldundef{#1season}
  5702.           {\blx@ymddate{#1}{}%
  5703.             % Optionally print the time after the date
  5704.             \blx@printtime{#1}{}}
  5705.           {\csuse{mkbibseasondateshort}{#1year}{#1season}}%
  5706.          \dateuncertainprint
  5707.          \dateeraprint{#1year}%
  5708.          \iffieldundef{#1endyear}
  5709.           {}
  5710.           {\iffieldequalstr{#1endyear}{}
  5711.              {\mbox{\bibdaterangesep}}
  5712.              {\bibdaterangesep
  5713.               \enddatecircaprint
  5714.               \iffieldundef{#1season}
  5715.                 {\blx@ymddate{#1}{end}%
  5716.                   % Optionally print the time after the date
  5717.                   \blx@printtime{#1}{end}}
  5718.                 {\csuse{mkbibseasondateshort}{#1endyear}{#1endseason}}%
  5719.                \enddateuncertainprint
  5720.                \dateeraprint{#1endyear}}}}}%
  5721.   \endgroup}
  5722.  
  5723. % {<datetype>}
  5724. \newrobustcmd*{\mkdaterangeymdextra}[1]{%
  5725.   \begingroup
  5726.     \blx@metadateinfo{#1}%
  5727.     \iffieldundef{#1year}
  5728.      {\blx@nounit}
  5729.       {\printtext[#1date]{%
  5730.          \datecircaprint
  5731.          % Such a season component can only come from an ISO8601 season which replaces
  5732.          % a normal month so if it exists, we know that a normal date print is ruled out
  5733.          \iffieldundef{#1season}
  5734.           {\blx@ymddate[extradate]{#1}{}%
  5735.             % Optionally print the time after the date
  5736.             \blx@printtime{#1}{}}
  5737.           {\csuse{mkbibseasondateshort}{#1year}{#1season}}%
  5738.          \dateuncertainprint
  5739.          \dateeraprint{#1year}%
  5740.          \iffieldundef{#1endyear}
  5741.           {}
  5742.           {\iffieldequalstr{#1endyear}{}
  5743.              {\mbox{\bibdaterangesep}}
  5744.               {\printtext{%
  5745.                  \bibdaterangesep
  5746.                  \enddatecircaprint
  5747.                  \iffieldundef{#1season}
  5748.                   {\blx@ymddate{#1}{end}%
  5749.                     % Optionally print the time after the date
  5750.                     \blx@printtime{#1}{end}}
  5751.                   {\csuse{mkbibseasondateshort}{#1endyear}{#1endseason}}}%
  5752.                \enddateuncertainprint
  5753.                \dateeraprint{#1endyear}}}}}%
  5754.   \endgroup}
  5755.  
  5756. % [extradate]{<datetype>}{''|end}
  5757. \newrobustcmd*{\blx@ymddate}[3][]{%
  5758.   \dateeraprintpre{#2#3year}%
  5759.   \mkyearzeros{\thefield{#2#3year}}\ifblank{#1}{}{\printfield{#1}}%
  5760.   \iffieldundef{#2#3month}{}{\bibdatesep\mkmonthzeros{\thefield{#2#3month}}}%
  5761.   \iffieldundef{#2#3day}{}{\bibdatesep\mkdayzeros{\thefield{#2#3day}}}}
  5762.  
  5763. \newrobustcmd*{\mkdaterangeyearextra}[1]{%
  5764.   \blx@imc@clearfield{#1season}%
  5765.   \blx@imc@clearfield{#1month}%
  5766.   \blx@imc@clearfield{#1day}%
  5767.   \blx@imc@clearfield{#1hour}%
  5768.   \blx@imc@clearfield{#1minute}%
  5769.   \blx@imc@clearfield{#1second}%
  5770.   \blx@imc@clearfield{#1timezone}%
  5771.   \blx@imc@clearfield{#1endseason}%
  5772.   \blx@imc@clearfield{#1endmonth}%
  5773.   \blx@imc@clearfield{#1endday}%
  5774.   \blx@imc@clearfield{#1endhour}%
  5775.   \blx@imc@clearfield{#1endminute}%
  5776.   \blx@imc@clearfield{#1endsecond}%
  5777.   \blx@imc@clearfield{#1endtimezone}%
  5778.   \ifdateyearsequal{#1}{#1end}
  5779.    {\blx@imc@clearfield{#1endyear}}
  5780.    {}%
  5781.   \mkdaterangefullextra{short}{#1}}
  5782.  
  5783. % {<datetype>}{'' | end}
  5784. \newrobustcmd*{\blx@printtime}[2]{%
  5785.   \ifboolexpr{%
  5786.     togl {blx@#1dateusetime}
  5787.    and
  5788.    not test {\iffieldundef{#1#2hour}}}
  5789.    {\blx@timepre{#1}{#2}%
  5790.      \printtext{\bibdatetimesep}%
  5791.      \printtext[#1time]{\csuse{mkbibtime\csuse{blx@timeformat@#1time}}{#1#2hour}{#1#2minute}{#1#2second}{#1#2timezone}}}
  5792.    {}}
  5793.  
  5794. \newrobustcmd*{\mkdaterangeiso}[1]{%
  5795.   \begingroup
  5796.     \blx@metadateinfo{#1}%
  5797.     \def\bibdatetimesep{T}%
  5798.     \iffieldundef{#1year}
  5799.      {\blx@nounit}
  5800.       {\printtext[#1date]{%
  5801.          \blx@isodate{#1}{}%
  5802.          \ifboolexpr{%
  5803.            togl {blx@#1dateusetime}
  5804.           and
  5805.           not test {\iffieldundef{#1hour}}}
  5806.           {\printtext{\bibdatetimesep}%
  5807.             \blx@isotime{#1}{}}
  5808.           {}%
  5809.          \dateuncertainprint
  5810.          \datecircaprintiso
  5811.          \iffieldundef{#1endyear}
  5812.           {}
  5813.           {\addslash
  5814.            \blx@isodate{#1}{end}%
  5815.             \ifboolexpr{%
  5816.               togl {blx@#1dateusetime}
  5817.              and
  5818.              not test {\iffieldundef{#1endhour}}}
  5819.              {\printtext{\bibdatetimesep}%
  5820.                \blx@isotime{#1}{end}}
  5821.              {}%
  5822.            \enddateuncertainprint
  5823.            \enddatecircaprintiso}}}%
  5824.   \endgroup}
  5825.  
  5826. \newrobustcmd*{\mkdaterangeisoextra}[1]{%
  5827.   \begingroup
  5828.     \blx@metadateinfo{#1}%
  5829.     \def\bibdatetimesep{T}%
  5830.     \iffieldundef{#1year}
  5831.      {\blx@nounit}
  5832.       {\printtext[#1date]{%
  5833.          \blx@isodate[extradate]{#1}{}%
  5834.          \ifboolexpr{%
  5835.            togl {blx@#1dateusetime}
  5836.           and
  5837.           not test {\iffieldundef{#1hour}}}
  5838.           {\printtext{\bibdatetimesep}%
  5839.             \blx@isotime{#1}{}}
  5840.           {}%
  5841.          \dateuncertainprint
  5842.          \datecircaprintiso
  5843.          \iffieldundef{#1endyear}
  5844.           {}
  5845.           {\addslash
  5846.            \blx@isodate{#1}{end}}%
  5847.             \ifboolexpr{%
  5848.               togl {blx@#1dateusetime}
  5849.              and
  5850.              not test {\iffieldundef{#1endhour}}}
  5851.              {\printtext{\bibdatetimesep}%
  5852.                \blx@isotime{#1}{end}}
  5853.              {}%
  5854.             \enddateuncertainprint
  5855.             \enddatecircaprintiso}}%
  5856.   \endgroup}
  5857.  
  5858. % [extradate]{<datetype>}{''|end}
  5859. \newrobustcmd*{\blx@isodate}[3][]{%
  5860.   \dateeraprintpre{#2#3year}%
  5861.   \blx@imc@forcezerosy{\thefield{#2#3year}}\ifblank{#1}{}{\printfield{#1}}%
  5862.   % Such a season component can only come from an ISO8601 season which replaces
  5863.   % a normal month so if it exists, we know that a normal date print is ruled out
  5864.   \iffieldundef{#2#3season}
  5865.    {\iffieldundef{#2#3month}{}{\hyphen\blx@imc@forcezerosmdt{\thefield{#2#3month}}}%
  5866.      \iffieldundef{#2#3day}{}{\hyphen\blx@imc@forcezerosmdt{\thefield{#2#3day}}}}
  5867.    {\hyphen\blx@seasonmap{\thefield{#2#3season}}}}
  5868.  
  5869. \def\blx@seasonmap#1{%
  5870.   \blx@xifstrequal{#1}{spring}{21}
  5871.    {\blx@xifstrequal{#1}{summer}{22}
  5872.      {\blx@xifstrequal{#1}{autumn}{23}
  5873.        {\blx@xifstrequal{#1}{winter}{24}{}}}}}
  5874.  
  5875. \newrobustcmd*{\blx@isotime}[2]{%
  5876.   \blx@imc@forcezerosmdt{\thefield{#1#2hour}}%
  5877.   :\blx@imc@forcezerosmdt{\thefield{#1#2minute}}%
  5878.   :\blx@imc@forcezerosmdt{\thefield{#1#2second}}%
  5879.   \iftoggle{blx@timezones}
  5880.    {\mkbibtimezone{\thefield{#1#2timezone}}}
  5881.    {}}
  5882.  
  5883. % some sane defaults for bibliography extras
  5884. % many of these should be redefined in the .lbx files
  5885. % all .lbx files should have date and time handling, so the fallback values
  5886. % issue a warning to make people aware of the deficiency in their file
  5887. % \mkbibordinal should also only be used if it is defined, so it warns as well
  5888. % times
  5889. \newrobustcmd*{\bibtimesep}{:}
  5890. \newrobustcmd*{\bibtimerangesep}{\textendash}
  5891. \newrobustcmd*{\bibutctimezone}{Z}
  5892. \newrobustcmd*{\bibtimezonesep}{}
  5893. \newrobustcmd*{\bibtzminsep}{\bibtimesep}
  5894. % dates
  5895. \newrobustcmd*{\bibdateuncertain}{?}
  5896. % \textminus is only guaranteed for non-PDFTeX
  5897. \newrobustcmd*{\bibdateeraprefix}{\ifdef\textminus\textminus\textendash}
  5898. \newrobustcmd*{\bibdateeraendprefix}{\,\bibdateeraprefix}
  5899. \newrobustcmd*{\bibdatesep}{\hyphen}
  5900. \newrobustcmd*{\bibdaterangesep}{\bibrangedash}
  5901. % date+times
  5902. \newrobustcmd*{\bibdatetimesep}{\space}
  5903. % ranges
  5904. \newrobustcmd*{\bibrangedash}{\textendash}
  5905. \newrobustcmd*{\bibrangessep}{,\space}
  5906. % formatters
  5907. \newrobustcmd*{\mkbibtimezone}[1]{\blx@xifstrequal{#1}{Z}{\bibutctimezone}{#1}}
  5908. % you should never end up needing the next few definitions
  5909. % but it is safer to do something than just swallow the input
  5910. \newrobustcmd*{\mkbibdatelong}[3]{%
  5911.   \blx@warning@noline{%
  5912.     Using fallback definition for \string\mkbibdatelong.\MessageBreak
  5913.     The command should be defined in the .lbx file.\MessageBreak
  5914.     If you see this message, the .lbx file could not be\MessageBreak
  5915.     loaded, is faulty or does not contain a definition\MessageBreak
  5916.     for \string\mkbibdatelong
  5917.   }%
  5918.   \iffieldundef{#3}
  5919.    {}
  5920.    {\mkbibordinal{\thefield{#3}}%
  5921.      \iffieldundef{#2}{}{\nobreakspace}}%
  5922.   \iffieldundef{#2}
  5923.    {}
  5924.    {\mkbibmonth{\thefield{#2}}%
  5925.      \iffieldundef{#1}{}{\space}}%
  5926.   \iffieldbibstring{#1}
  5927.    {\bibstring{\thefield{#1}}}
  5928.    {\dateeraprintpre{#1}\stripzeros{\thefield{#1}}}}
  5929.  
  5930. \newrobustcmd*{\mkbibdateshort}[3]{%
  5931.   \blx@warning@noline{%
  5932.     Using fallback definition for \string\mkbibdateshort.\MessageBreak
  5933.     The command should be defined in the .lbx file.\MessageBreak
  5934.     If you see this message, the .lbx file could not be\MessageBreak
  5935.     loaded, is faulty or does not contain a definition\MessageBreak
  5936.     for \string\mkbibdateshort
  5937.   }%
  5938.   \iffieldundef{#3}
  5939.    {}
  5940.    {\mkdayzeros{\thefield{#3}}%
  5941.      \iffieldundef{#2}{}{/}}%
  5942.   \iffieldundef{#2}
  5943.    {}
  5944.    {\mkmonthzeros{\thefield{#2}}%
  5945.      \iffieldundef{#1}{}{/}}%
  5946.   \iffieldbibstring{#1}
  5947.    {\bibstring{\thefield{#1}}}
  5948.    {\dateeraprintpre{#1}\mkyearzeros{\thefield{#1}}}}
  5949.  
  5950. \expandafter\newrobustcmd\expandafter*\csname mkbibtime24h\endcsname[4]{%
  5951.   \blx@warning@noline{%
  5952.     Using fallback definition for
  5953.     \expandafter\string\csname mkbibtime24h\endcsname.\MessageBreak
  5954.     The command should be defined in the .lbx file.\MessageBreak
  5955.     If you see this message, the .lbx file could not be\MessageBreak
  5956.     loaded, is faulty or does not contain a definition\MessageBreak
  5957.     for \expandafter\string\csname mkbibtime24h\endcsname
  5958.   }%
  5959.     \iffieldundef{#1}{}
  5960.      {\printtext{\mktimezeros{\thefield{#1}}}\setunit{\bibtimesep}}%
  5961.     \iffieldundef{#2}{}
  5962.      {\printtext{\mktimezeros{\thefield{#2}}}\setunit{\bibtimesep}}%
  5963.     \iffieldundef{#3}{}
  5964.      {\printtext{\mktimezeros{\thefield{#3}}}}%
  5965.     \setunit{}%
  5966.     \iffieldundef{#4}{}
  5967.      {\bibtimezonesep
  5968.       \mkbibtimezone{\thefield{#4}}}}
  5969.  
  5970. \expandafter\newrobustcmd\expandafter*\csname mkbibtime12h\endcsname[4]{%
  5971.   \blx@warning@noline{%
  5972.     Using fallback definition for
  5973.     \expandafter\string\csname mkbibtime12h\endcsname.\MessageBreak
  5974.     The command should be defined in the .lbx file.\MessageBreak
  5975.     If you see this message, the .lbx file could not be\MessageBreak
  5976.     loaded, is faulty or does not contain a definition\MessageBreak
  5977.     for \expandafter\string\csname mkbibtime12h\endcsname
  5978.   }%
  5979.     \stripzeros{\mktimehh{\thefield{#1}}}%
  5980.     \bibtimesep
  5981.     \forcezerosmdt{\thefield{#2}}%
  5982.     \iffieldundef{#3}{}
  5983.      {\bibtimesep
  5984.       \forcezeros{\thefield{#3}}}%
  5985.      \space
  5986.      \ifnumless{\thefield{#1}}{12}
  5987.       {\bibstring{am}}
  5988.       {\bibstring{pm}}%
  5989.     \iffieldundef{#4}{}
  5990.     {\space\bibtimezonesep
  5991.      \parentext{\mkbibtimezone{\thefield{#4}}}}}
  5992.  
  5993. \newrobustcmd*{\mkbibseasondateshort}[2]{%
  5994.   \blx@warning@noline{%
  5995.     Using fallback definition for \string\mkbibseasondateshort.\MessageBreak
  5996.     The command should be defined in the .lbx file.\MessageBreak
  5997.     If you see this message, the .lbx file could not be\MessageBreak
  5998.     loaded, is faulty or does not contain a definition\MessageBreak
  5999.     for \string\mkbibseasondateshort
  6000.   }%
  6001.   \mkbibseason{\thefield{#2}}%
  6002.   \iffieldundef{#1}{}{\space}%
  6003.   \dateeraprintpre{#1}\mkyearzeros{\thefield{#1}}}
  6004.  
  6005. \newrobustcmd*{\mkbibseasondatelong}[2]{%
  6006.   \blx@warning@noline{%
  6007.     Using fallback definition for \string\mkbibseasondatelong.\MessageBreak
  6008.     The command should be defined in the .lbx file.\MessageBreak
  6009.     If you see this message, the .lbx file could not be\MessageBreak
  6010.     loaded, is faulty or does not contain a definition\MessageBreak
  6011.     for \string\mkbibseasondatelong
  6012.   }%
  6013.   \mkbibseason{\thefield{#2}}%
  6014.   \iffieldundef{#1}{}{\space}%
  6015.   \dateeraprintpre{#1}\mkyearzeros{\thefield{#1}}}
  6016.  
  6017. \newrobustcmd*{\finalandcomma}{}
  6018. \newrobustcmd*{\finalandsemicolon}{}
  6019. \newrobustcmd*{\mkbibordinal}[1]{%
  6020.   \blx@warning@noline{%
  6021.     Using fallback definition for \string\mkbibordinal.\MessageBreak
  6022.     The command should be defined in the .lbx file.\MessageBreak
  6023.     If you see this message, the .lbx file could not be\MessageBreak
  6024.     loaded, is faulty or does not contain a definition\MessageBreak
  6025.     for \string\mkbibordinal
  6026.   }%
  6027.   #1%
  6028. }
  6029. \newrobustcmd*{\mkbibmascord}{\mkbibordinal}
  6030. \newrobustcmd*{\mkbibfemord}{\mkbibordinal}
  6031. \newrobustcmd*{\mkbibneutord}{\mkbibordinal}
  6032. % the following is usually not redefined in an .lbx
  6033. \newrobustcmd*{\mkbibseason}[1]{\abx@bibseason{#1}}
  6034. \newrobustcmd*{\mkbibmonth}[1]{%
  6035.   \ifcase0#1\relax
  6036.     \blx@warning@entry{Month out of range or not an integer}%
  6037.   \or\abx@bibmonth{january}%
  6038.   \or\abx@bibmonth{february}%
  6039.   \or\abx@bibmonth{march}%
  6040.   \or\abx@bibmonth{april}%
  6041.   \or\abx@bibmonth{may}%
  6042.   \or\abx@bibmonth{june}%
  6043.   \or\abx@bibmonth{july}%
  6044.   \or\abx@bibmonth{august}%
  6045.   \or\abx@bibmonth{september}%
  6046.   \or\abx@bibmonth{october}%
  6047.   \or\abx@bibmonth{november}%
  6048.   \or\abx@bibmonth{december}%
  6049.   \else
  6050.     \blx@warning@entry{Month out of range}#1%
  6051.   \fi}
  6052.  
  6053. % strip leading zeros and prepend zero for month/day/timeparts
  6054. % Allow for non numeric labelyear values
  6055. \protected\def\blx@imc@forcezerosmdt#1{%
  6056.   \protected@edef\blx@tempa{#1}%
  6057.   \expandafter\blx@imc@forcezerosmdt@i\expandafter{\blx@tempa}}
  6058.  
  6059. \protected\def\blx@imc@forcezerosmdt@i#1{%
  6060.   \notblank{#1}
  6061.    {\blx@imc@ifinteger{#1}
  6062.       {\ifnumless{#1}{10}
  6063.         {0\the\numexpr(#1)\relax}
  6064.         {#1}}
  6065.       {#1}}
  6066.    {#1}}
  6067.  
  6068. % strip leading zeros and prepend zero(s) for year
  6069. % Allow for non numeric labelyear values
  6070. \protected\def\blx@imc@forcezerosy#1{%
  6071.   \protected@edef\blx@tempa{#1}%
  6072.   \expandafter\blx@imc@forcezerosy@i\expandafter{\blx@tempa}}
  6073.  
  6074. \protected\def\blx@imc@forcezerosy@i#1{%
  6075.   \notblank{#1}
  6076.    {\blx@imc@ifinteger{#1}
  6077.       {\ifnumless{#1}{10}% 1-digit year
  6078.           {000\the\numexpr(#1)\relax}
  6079.          {\ifnumless{#1}{100}% 2-digit year
  6080.             {00\the\numexpr(#1)\relax}
  6081.            {\ifnumless{#1}{1000}% 3-digit year
  6082.               {0\the\numexpr(#1)\relax}
  6083.              {#1}}}}
  6084.       {#1}}
  6085.    {#1}}%
  6086.  
  6087. \let\blx@imc@mkyearzeros\blx@imc@forcezerosy
  6088. \let\blx@imc@mkmonthzeros\blx@imc@forcezerosmdt
  6089. \let\blx@imc@mkdayzeros\blx@imc@forcezerosmdt
  6090. \protected\def\blx@imc@stripzeros#1{%
  6091.   \begingroup
  6092.   \setbox\@tempboxa=\hbox\bgroup
  6093.   \aftergroup\endgroup
  6094.   \abx@hook@xsanitize
  6095.   \if0#1\relax
  6096.     \expandafter\@firstoftwo
  6097.   \else
  6098.     \expandafter\@secondoftwo
  6099.   \fi
  6100.   {\@tempcnta#1\relax
  6101.   \expandafter\egroup
  6102.   \number\@tempcnta
  6103.   \@tempcnta#1\relax}
  6104.  {\egroup#1}}
  6105.  
  6106. \let\blx@imc@printlabeldate\@empty
  6107. \let\blx@imc@printlabeltime\@empty
  6108. \let\blx@imc@printlabeldateextra\@empty
  6109.  
  6110. \blx@regimcs{\printlabeldate \printlabeltime \printlabeldateextra
  6111.  \stripzeros \forcezerosy \forcezerosmdt
  6112.  \mkyearzeros \mkmonthzeros \mkdayzeros \mktimezeros}
  6113.  
  6114. % User macro for retrieving currrent language
  6115. \def\currentlang{\blx@languagename}
  6116.  
  6117. % {<language>}{<strings>}
  6118. \def\blx@maplang#1#2{%
  6119.   \csxappto{extras#1}{%
  6120.     \noexpand\blx@resetpunct
  6121.     \expandafter\noexpand\csname abx@extras@#2\endcsname
  6122.     \expandafter\noexpand\csname abx@strings@#2\endcsname}%
  6123.   \csxappto{noextras#1}{%
  6124.     \noexpand\blx@resetpunct
  6125.     \expandafter\noexpand\csname abx@noextras@#2\endcsname}}
  6126.  
  6127. %% babel/polyglossia interface
  6128. \def\blx@beglang{\blx@clearlang\begingroup}
  6129. \def\blx@endlang{\endgroup}
  6130. \let\blx@beglangbib\blx@beglang
  6131. \let\blx@endlangbib\blx@endlang
  6132. \let\blx@beglangcite\blx@beglang
  6133. \let\blx@endlangcite\blx@endlang
  6134. \let\blx@hook@endlang\@empty
  6135. \let\blx@hook@initlang\@empty
  6136. \let\blx@imc@mainlang\@empty
  6137. \def\blx@hyphenreset{%
  6138.   \ifcsundef{l@\blx@languagename}
  6139.    {}
  6140.    {\language\csname l@\blx@languagename\endcsname\relax}%
  6141.   \ifcsundef{\blx@languagename hyphenmins}
  6142.    {\blx@sethyphenmins\tw@\thr@@}
  6143.    {\expandafter\expandafter\expandafter\blx@sethyphenmins
  6144.       \csname\blx@languagename hyphenmins\endcsname}}
  6145. \def\blx@sethyphenmins#1#2{%
  6146.   \lefthyphenmin#1\relax
  6147.   \righthyphenmin#2\relax}
  6148.  
  6149. \begingroup
  6150. \@makeother\#
  6151. \gdef\blx@mkautolangbabel{%
  6152.   \ifundef\bbl@main@language
  6153.     {\blx@error
  6154.      {No default 'babel' language defined}
  6155.      {You must define a default language for 'babel'}}
  6156.    {}%
  6157.   \pretocmd\select@language{\blx@langsetup{#1}}
  6158.     {\ifdef\blx@thelangenv
  6159.        {\def\blx@beglang{%
  6160.           \blx@clearlang
  6161.           \begingroup
  6162.          % Need to override all entries, regardless of if there is a langid
  6163.          % if language=<language> option is given
  6164.          \ifboolexpr { test {\ifdef\abx@field@langid }
  6165.                       or
  6166.                       test {\ifdef\blx@forcelanguagename} }
  6167.             % override local langid if we forced it with
  6168.             % language=<language> option
  6169.             {\ifdef\blx@forcelanguagename
  6170.               {\let\abx@field@langid\blx@forcelanguagename}
  6171.               {}%
  6172.              \let\blx@languagename\abx@field@langid% track global language
  6173.              \ifcsundef{l@\abx@field@langid}
  6174.               {\blx@warn@nohyph{\abx@field@langid}}
  6175.                {\blx@hook@initlang
  6176.                 \def\blx@endlang{%
  6177.                   \blx@hook@endlang
  6178.                   \csname end\blx@thelangenv\endcsname
  6179.                   \endgroup}%
  6180.                 \iftoggle{blx@autolangbib}
  6181.                  {\let\blx@endlangbib\blx@endlang}
  6182.                  {}%
  6183.                 \iftoggle{blx@autolangcite}
  6184.                  {\let\blx@endlangcite\blx@endlang}
  6185.                  {}%
  6186.                 \csname\blx@thelangenv\expandafter\endcsname
  6187.                 \expandafter{\abx@field@langid}}}
  6188.            {}}}
  6189.       {}%
  6190.      \def\blx@langstrings{}%
  6191.      \def\blx@imc@mainlang{\select@language{\bbl@main@language}}%
  6192.      \blx@langsetup\bbl@main@language}
  6193.     {\blx@err@patch{'babel' package}%
  6194.      \blx@mknoautolang}}
  6195.  
  6196. \gdef\blx@mkautolangpoly{%
  6197.   \ifundef\bbl@main@language
  6198.     {\blx@error
  6199.      {No default 'polyglossia' language defined}
  6200.      {You must define a default language for 'polyglossia'}}
  6201.    {}%
  6202.   \edef\blx@saved@underscore@catcode{\the\catcode`\_}%
  6203.   \catcode`\_=11% polyglossia uses "_" as a letter
  6204.   \pretocmd\select@language{\blx@langsetup{#1}}
  6205.     {\ifdef\blx@thelangenv
  6206.        {\def\blx@beglang{%
  6207.           \blx@clearlang
  6208.           \begingroup
  6209.          % Need to override all entries, regardless of if there is a langid
  6210.          % if language=<language> option is given
  6211.          \ifboolexpr { test {\ifdef\abx@field@langid }
  6212.                       or
  6213.                       test {\ifdef\blx@forcelanguagename} }
  6214.             % override local langid if we forced it with
  6215.             % language=<language> option
  6216.             {\ifdef\blx@forcelanguagename
  6217.               {\let\abx@field@langid\blx@forcelanguagename}
  6218.               {}%
  6219.              \let\blx@languagename\abx@field@langid% track global language
  6220.              \ifcsundef{l@\abx@field@langid}
  6221.               {\blx@warn@nohyph{\abx@field@langid}}
  6222.                {\blx@hook@initlang
  6223.                 \def\blx@endlang{%
  6224.                   \blx@hook@endlang
  6225.                   % Polyglossia language envs are \<lang>[]
  6226.                   \ifcsstring{blx@thelangenv}{langname}
  6227.                    {\csname end\abx@field@langid\endcsname}
  6228.                    {\csname end\blx@thelangenv\endcsname}%
  6229.                   \endgroup}%
  6230.                 \iftoggle{blx@autolangbib}
  6231.                  {\let\blx@endlangbib\blx@endlang}
  6232.                  {}%
  6233.                 \iftoggle{blx@autolangcite}
  6234.                  {\let\blx@endlangcite\blx@endlang}
  6235.                  {}%
  6236.                 \ifcsstring{blx@thelangenv}{langname}
  6237.                  {\ifdef\abx@field@langidopts
  6238.                     {\csname\abx@field@langid\expandafter\endcsname\expandafter[\abx@field@langidopts]}
  6239.                     {\csname\abx@field@langid\endcsname}}
  6240.                  {\csname\blx@thelangenv\expandafter\endcsname\expandafter{\abx@field@langid}}%
  6241.                 % These lines are equal to \blx@maplang
  6242.                 \ifcsstring{blx@thelangenv}{hyphenrules}
  6243.                  {}
  6244.                  {\blx@resetpunct
  6245.                   \csuse{abx@extras@\abx@field@langid}%
  6246.                    \csuse{abx@strings@\abx@field@langid}}}}
  6247.            {}}}
  6248.       {}%
  6249.      % polyglossia needs this - it doesn't get the
  6250.      % strings automatically set for some reason
  6251.      \def\blx@langstrings{%
  6252.        \csuse{abx@extras@\languagename}%
  6253.        \csuse{abx@strings@\languagename}}%
  6254.      \def\blx@imc@mainlang{%
  6255.        \select@language{\bbl@main@language}%
  6256.        % These lines are equal to \blx@maplang
  6257.        \blx@resetpunct
  6258.        \csuse{abx@extras@\bbl@main@language}%
  6259.        \csuse{abx@strings@\bbl@main@language}}%
  6260.      \blx@langsetup\bbl@main@language}
  6261.     {\blx@err@patch{'polyglossia' package}%
  6262.      \blx@mknoautolang}%
  6263.   \catcode`\_=\blx@saved@underscore@catcode\relax}
  6264. \endgroup
  6265.  
  6266. \def\blx@mknoautolang{%
  6267.   \blx@lbxinput{\blx@languagename}
  6268.    {}
  6269.    {\blx@err@nolang{\blx@languagename}}}
  6270.  
  6271. \blx@regimcs{\mainlang}
  6272.  
  6273. \newrobustcmd*{\DeclareRedundantLanguages}[2]{%
  6274.   \begingroup
  6275.   \ifblank{#2}
  6276.     {\def\do##1{%
  6277.        \global\csundef{blx@rlm@##1}%
  6278.        \global\csundef{blx@rlm@lang##1}}}
  6279.     {\def\do##1{%
  6280.        \csxdef{blx@rlm@##1}{#2}%
  6281.        \csxdef{blx@rlm@lang##1}{#2}}}%
  6282.   \docsvlist{#1}%
  6283.   \endgroup}
  6284.  
  6285. \def\blx@clearlang{%
  6286.   \iftoggle{blx@clearlang}
  6287.    {\iflistundef{language}
  6288.       {}
  6289.       {\ifnumgreater{\value{language}}{1}
  6290.          {}
  6291.          {\expandafter\blx@clearlang@i\abx@list@language}}}
  6292.    {}}
  6293.  
  6294. \def\blx@clearlang@i#1{%
  6295.   \ifcsdef{blx@rlm@#1}
  6296.     {\expandafter\expandafter\expandafter\forcsvlist
  6297.      \expandafter\expandafter\expandafter\blx@clearlang@ii
  6298.      \expandafter\expandafter\expandafter{%
  6299.        \csname blx@rlm@#1\endcsname}}
  6300.     {}}
  6301.  
  6302. \def\blx@clearlang@ii#1{%
  6303.   \ifdefstring\languagename{#1}
  6304.    {\clearlist{language}}
  6305.    {}}
  6306.  
  6307. %% Biber equivalents to bibtex data interface
  6308.  
  6309. \def\abx@doentrytypes{\dolistloop\blx@datamodel@entrytypes}
  6310.  
  6311. % fields which can be used as labels - we auto-create some macros for these
  6312. \def\abx@dolabelfields{\dolistloop\blx@datamodel@labelfields}
  6313.  
  6314. \def\abx@donames{\dolistloop\blx@datamodel@names}
  6315. \def\abx@donameparts{\expandafter\docsvlist\expandafter{\blx@datamodel@constant@nameparts}}
  6316.  
  6317. \def\abx@dofields{\dolistloop\blx@datamodel@fields}
  6318.  
  6319. \def\abx@dolists{%
  6320.   \dolistloop\blx@datamodel@lists%
  6321.   \do{pageref}}
  6322.  
  6323. % Used to pass regexps to .bcf
  6324. \def\regexp#1{\expandafter\zap@space\detokenize{#1} \@empty}
  6325.  
  6326. % Have to do this otherwise the '~'s in the .bcf strings are not expanded
  6327. % This is done for the .bcf later but since we have to do all the
  6328. % data model things much earlier, have to set this here and reset on finishing
  6329. \let\blx@tsave~
  6330. \let~\space
  6331. % Data model and supporting macros must be loaded early
  6332. \blx@inputonce{blx-dm.def}{biblatex default data model}{}{}{}{}
  6333. \let~\blx@tsave
  6334.  
  6335. % We need to now load any style data model
  6336. % Order of precedence is:
  6337. % <datamodel option>.dbx
  6338. %   <style option>.dbx
  6339. %     <citestyle option>.dbx and <bibstyle option>.dbx
  6340. % This has to be done before the real options processing so we need to
  6341. % pick out just these four options to look at. You can't do this with keyval,
  6342. % you have to use kvoptions. So, pick out these four, pass through all
  6343. % others and delete datamodel option as we don't care about it when we come
  6344. % to really set options below
  6345. \SetupKeyvalOptions{
  6346.  family=blx@opt@eldt,
  6347.  prefix=blx@opt@eldt@}
  6348. \DeclareStringOption{datamodel}
  6349. \DeclareStringOption{style}
  6350. \DeclareStringOption{citestyle}
  6351. \DeclareStringOption{bibstyle}
  6352. \DeclareDefaultOption{}
  6353. \ProcessLocalKeyvalOptions{blx@opt@eldt}
  6354. \ifx\blx@opt@eldt@datamodel\@empty
  6355.  \ifx\blx@opt@eldt@style\@empty
  6356.    \ifx\blx@opt@eldt@citestyle\@empty
  6357.    \else
  6358.      \blx@inputonce{\blx@opt@eldt@citestyle.dbx}{biblatex citestyle data model}{}{}{}{}
  6359.    \fi
  6360.    \ifx\blx@opt@eldt@bibstyle\@empty
  6361.    \else
  6362.      \blx@inputonce{\blx@opt@eldt@bibstyle.dbx}{biblatex bibstyle data model}{}{}{}{}
  6363.    \fi
  6364.  \else
  6365.    \blx@inputonce{\blx@opt@eldt@style.dbx}{biblatex style data model}{}{}{}{}
  6366.  \fi
  6367. \else
  6368.  \blx@inputonce{\blx@opt@eldt@datamodel.dbx}{biblatex style data model}{}{}{}{}
  6369. \fi
  6370. \DisableKeyvalOption[action=undef,local]{blx@opt@eldt}{datamodel}
  6371.  
  6372. % Override with user-defined data model if there is one
  6373. \blx@inputonce{biblatex-dm.cfg}{biblatex custom data model}{}{}{}{}
  6374.  
  6375. % Initialise option datatypes lists
  6376. \global\let\blx@bcf@options@scope@global\@empty
  6377. \global\let\blx@bcf@options@scope@type\@empty
  6378. \global\let\blx@bcf@options@scope@entry\@empty
  6379. \global\let\blx@bcf@options@scope@namelist\@empty
  6380. \global\let\blx@bcf@options@scope@name\@empty
  6381. \global\let\blx@globalopts@datatypes\@empty
  6382. \global\let\blx@typeopts@datatypes\@empty
  6383. \global\let\blx@entryopts@datatypes\@empty
  6384. \global\let\blx@namelistopts@datatypes\@empty
  6385. \global\let\blx@nameopts@datatypes\@empty
  6386. \def\do#1{%
  6387.   \global\cslet{blx@globalopts@#1}\@empty
  6388.  \global\cslet{blx@typeopts@#1}\@empty
  6389.  \global\cslet{blx@entryopts@#1}\@empty
  6390.  \global\cslet{blx@namelistopts@#1}\@empty
  6391.  \global\cslet{blx@nameopts@#1}\@empty}
  6392. \expandafter\expandafter\expandafter\docsvlist\expandafter\expandafter\expandafter{\csname blx@datamodel@constant@optiondatatypes\endcsname}
  6393.  
  6394. % Helper for collecting options and datatypes
  6395. % {<datatype>}{<scope>}{<name>}
  6396. \def\blx@collectopts#1#2#3{%
  6397.   \ifinlistcs{#1}{#2@datatypes}
  6398.    {}
  6399.    {\listcsgadd{#2@datatypes}{#1}}%
  6400.   \ifinlistcs{#3}{#2@#1}
  6401.    {}
  6402.    {\listcsgadd{#2@#1}{#3}}}
  6403.  
  6404. % date, eventdate, urldate etc.
  6405. \def\abx@dodates{\dolistloop\blx@datamodel@dates}
  6406. % year, endyear, month, endmonth etc.
  6407. \def\abx@dodateparts{\expandafter\docsvlist\expandafter{\blx@dateparts}}
  6408.  
  6409. % '', event, url, orig etc.
  6410. \def\do#1{%
  6411.   \blx@stripfromendinto{#1}{date}\blx@datetype
  6412.  \listxadd\blx@datetypes{\blx@datetype}}
  6413. \abx@dodates
  6414. % main date field has an empty prefix (''date) which can't be added to a list
  6415. % and so do it explicity
  6416. % This is one of the few (only?) hard-coded datamodel assumptions but it is
  6417. % very unlikely that anyone would *remove* the main date field in a custom application ...
  6418. \def\abx@dodatetypes{\do{}\dolistloop\blx@datetypes}
  6419.  
  6420. % per-entry inheritance blocking option for biber
  6421. \blx@collectopts{string}{blx@entryopts}{noinherit}
  6422.  
  6423. % useprefix namelist/name scope
  6424. \blx@collectopts{boolean}{blx@namelistopts}{useprefix}% for passing to bcf
  6425. \blx@collectopts{boolean}{blx@nameopts}{useprefix}% for passing to the .bcf
  6426.  
  6427. % nametemplates meta-option entry/namelist/name scope
  6428. \blx@collectopts{string}{blx@entryopts}{nametemplates}
  6429. \blx@collectopts{string}{blx@namelistopts}{nametemplates}% for passing to bcf
  6430. \blx@collectopts{string}{blx@nameopts}{nametemplates}% for passing to the .bcf
  6431.  
  6432. % sortingnamekeytemplate namelist/name scope
  6433. \blx@collectopts{string}{blx@namelistopts}{sortingnamekeytemplatename}% for passing to bcf
  6434. \blx@collectopts{string}{blx@nameopts}{sortingnamekeytemplatename}% for passing to the .bcf
  6435.  
  6436. % uniquenametemplate namelist/name scope
  6437. \blx@collectopts{string}{blx@namelistopts}{uniquenametemplatename}% for passing to bcf
  6438. \blx@collectopts{string}{blx@nameopts}{uniquenametemplatename}% for passing to the .bcf
  6439.  
  6440. % labelalphanametemplate namelist/name scope
  6441. \blx@collectopts{string}{blx@namelistopts}{labelalphanametemplatename}% for passing to bcf
  6442. \blx@collectopts{string}{blx@nameopts}{labelalphanametemplatename}% for passing to the .bcf
  6443.  
  6444. % Misc globalopts
  6445. \blx@collectopts{xml}{blx@globalopts}{datamodel}% for passing to the .bcf
  6446. \blx@collectopts{string}{blx@globalopts}{controlversion}% for passing to the .bcf
  6447.  
  6448. \newcommand*{\labelalphaothers}{+}
  6449. \newcommand*{\sortalphaothers}{\labelalphaothers}
  6450. \blx@collectopts{string}{blx@globalopts}{alphaothers}% for passing to the .bcf
  6451. \blx@collectopts{string}{blx@typeopts}{alphaothers}% for passing to the .bcf
  6452. \blx@collectopts{string}{blx@globalopts}{sortalphaothers}% for passing to the .bcf
  6453. \blx@collectopts{string}{blx@typeopts}{sortalphaothers}% for passing to the .bcf
  6454.  
  6455. % The Declare*Option macros are for options which need to be visible
  6456. % to biblatex. For options which only biber needs to see, they can be
  6457. % passed to the .bcf directly using \blx@collectopts
  6458. % [<datatype>]{<key>}[<value>]{<code>}
  6459. \newrobustcmd*{\DeclareBibliographyOption}[2][]{%
  6460.   \ifblank{#1}
  6461.    {\def\blx@tempa{boolean}}
  6462.    {\ifcsundef{blx@globalopts@#1}
  6463.       {\blx@warn@badoptdt{#1}%
  6464.         \def\blx@tempa{boolean}}
  6465.       {\def\blx@tempa{#1}}}%
  6466.   \expandafter\blx@collectopts\expandafter{\blx@tempa}{blx@globalopts}{#2}%
  6467.   \@ifnextchar[%]
  6468.     {\blx@defbibopt{#2}}
  6469.    {\blx@defbibopt{#2}[]}}
  6470.  
  6471. \long\def\blx@defbibopt#1[#2]#3{%
  6472.   \ifcsundef{KV@blx@opt@ldt@#1}
  6473.    {\ifcsundef{KV@blx@opt@pre@#1}
  6474.       {\ifblank{#2}
  6475.          {\define@key{blx@opt@pre}{#1}{#3}}
  6476.          {\define@key{blx@opt@pre}{#1}[#2]{#3}}}
  6477.       {\blx@err@optdef{#1}}}
  6478.    {\blx@err@optdef{#1}}}
  6479.  
  6480. % [<datatype>]{<key>}[<value>]{<code>}
  6481. \newrobustcmd*{\DeclareTypeOption}[2][]{%
  6482.   \ifblank{#1}
  6483.    {\def\blx@tempa{boolean}}
  6484.    {\ifcsundef{blx@typeopts@#1}
  6485.       {\blx@warn@badoptdt{#1}%
  6486.         \def\blx@tempa{boolean}}
  6487.       {\def\blx@tempa{#1}}}%
  6488.     \expandafter\blx@collectopts\expandafter{\blx@tempa}{blx@typeopts}{#2}%
  6489.   \@ifnextchar[%]
  6490.     {\blx@deftypeopt{#2}}
  6491.    {\blx@deftypeopt{#2}[]}}
  6492.  
  6493. \long\def\blx@deftypeopt#1[#2]#3{%
  6494.   \ifcsundef{KV@blx@opt@typ@#1}
  6495.    {\ifblank{#2}
  6496.       {\define@key{blx@opt@typ}{#1}{#3}}
  6497.       {\define@key{blx@opt@typ}{#1}[#2]{#3}}}
  6498.    {\blx@err@optdef{#1}}}
  6499.  
  6500. % [<datatype>]{<key>}[<value>]{<code>}
  6501. \newrobustcmd*{\DeclareEntryOption}[2][]{%
  6502.   \ifblank{#1}
  6503.    {\def\blx@tempa{boolean}}
  6504.    {\ifcsundef{blx@entryopts@#1}
  6505.       {\blx@warn@badoptdt{#1}%
  6506.         \def\blx@tempa{boolean}}
  6507.       {\def\blx@tempa{#1}}}%
  6508.     \expandafter\blx@collectopts\expandafter{\blx@tempa}{blx@entryopts}{#2}%
  6509.   \@ifnextchar[%]
  6510.     {\blx@defentryopt{#2}}
  6511.    {\blx@defentryopt{#2}[]}}
  6512.  
  6513. \long\def\blx@defentryopt#1[#2]#3{%
  6514.   \ifcsundef{KV@blx@opt@ent@#1}
  6515.    {\ifblank{#2}
  6516.       {\define@key{blx@opt@ent}{#1}{#3}}
  6517.       {\define@key{blx@opt@ent}{#1}[#2]{#3}}}
  6518.    {\blx@err@optdef{#1}}}
  6519.  
  6520. % Sanity check on date field names - they *must* end in 'date' to make things easier/possible later
  6521. \def\do#1{%
  6522.   \blx@ifstrendswith{#1}{date}
  6523.    {}
  6524.    {\blx@error
  6525.       {Invalid date field name '#1'}
  6526.       {Date fields in the datemodel must end in the string 'date' but '#1' doesn't}}}
  6527. \abx@dodates
  6528.  
  6529. % date meta-information option fallbacks
  6530. \def\do#1{%
  6531.   \cslet{#1datecircaprint}\@empty
  6532.  \cslet{#1enddatecircaprint}\@empty
  6533.  \cslet{#1datecircaprintiso}\@empty
  6534.  \cslet{#1enddatecircaprintiso}\@empty
  6535.  \cslet{#1dateuncertainprint}\@empty
  6536.  \cslet{#1enddateuncertainprint}\@empty
  6537.  \cslet{#1dateeraprint}\@gobble
  6538.  \cslet{#1dateeraprintpre}\@gobble
  6539.  \csdef{if#1dateera}##1{\@secondoftwo}%
  6540.   \csdef{if#1enddateera}##1{\@secondoftwo}%
  6541.   \cslet{if#1datecirca}\@secondoftwo
  6542.  \cslet{if#1enddatecirca}\@secondoftwo
  6543.  \cslet{if#1datejulian}\@secondoftwo
  6544.  \cslet{if#1enddatejulian}\@secondoftwo
  6545.  \cslet{if#1dateuncertain}\@secondoftwo
  6546.  \cslet{if#1enddateuncertain}\@secondoftwo
  6547.  \cslet{if#1dateunknown}\@secondoftwo
  6548.  \cslet{if#1enddateunknown}\@secondoftwo}
  6549. \abx@dodatetypes
  6550. \do{labeldate}
  6551.  
  6552. % These are internal fields/booleans which are not part of the data model but
  6553. % which need to be dealt with along with data model fields in places
  6554. \def\do#1{%
  6555.   \listxadd\blx@datemetafields{#1dateera}%
  6556.   \listxadd\blx@datemetafields{#1enddateera}%
  6557.   \listxadd\blx@datemetafields{#1dateunspecified}}
  6558. \abx@dodatetypes
  6559.  
  6560. \def\do#1{%
  6561.   \listxadd\blx@datemetabooleans{#1datecirca}%
  6562.   \listxadd\blx@datemetabooleans{#1enddatecirca}%
  6563.   \listxadd\blx@datemetabooleans{#1datejulian}%
  6564.   \listxadd\blx@datemetabooleans{#1enddatejulian}%
  6565.   \listxadd\blx@datemetabooleans{#1dateuncertain}%
  6566.   \listxadd\blx@datemetabooleans{#1enddateuncertain}%
  6567.   \listxadd\blx@datemetabooleans{#1dateunknown}%
  6568.   \listxadd\blx@datemetabooleans{#1enddateunknown}}
  6569. \abx@dodatetypes
  6570.  
  6571. \def\do#1{%
  6572.   \listxadd\blx@namepartmetafields{#1namehash}%
  6573.   \listxadd\blx@namepartmetafields{#1fullhash}%
  6574.   \listxadd\blx@namepartmetafields{#1bibnamehash}}
  6575. \abx@donameparts
  6576.  
  6577. \def\do#1{%
  6578.   \listxadd\blx@labeldatepartfields{label#1}}
  6579. \abx@dodateparts
  6580.  
  6581. \def\abx@dointernalfields{%
  6582.   \do{clonesourcekey}%
  6583.   \do{labeldate}%
  6584.   \do{labeldatesource}%
  6585.   \do{labeldateera}%
  6586.   \do{labelenddateera}%
  6587.   \do{labelyear}%
  6588.   \do{labelendyear}%
  6589.   \do{labelmonth}%
  6590.   \do{labelendmonth}%
  6591.   \do{labelday}%
  6592.   \do{labelendday}%
  6593.   \do{labelhour}%
  6594.   \do{labelendhour}%
  6595.   \do{labelminute}%
  6596.   \do{labelendminute}%
  6597.   \do{labelsecond}%
  6598.   \do{labelendsecond}%
  6599.   \do{labeltimezone}%
  6600.   \do{labelendtimezone}%
  6601.   \do{labelseason}%
  6602.   \do{labelendseason}%
  6603.   \do{entrykey}%
  6604.   \do{entryset}%
  6605.   \do{entrysetcount}%
  6606.   \do{entrytype}%
  6607.   \do{extraalpha}%
  6608.   \do{extraname}%
  6609.   \do{extratitle}%
  6610.   \do{extratitleyear}%
  6611.   \do{extradate}%
  6612.   \do{fullhash}%
  6613.   \do{labelalpha}%
  6614.   \do{labelnumber}%
  6615.   \do{labelprefix}%
  6616.   \do{labeltitleyear}%
  6617.   \do{localnumber}%
  6618.   \do{namehash}%
  6619.   \do{bibnamehash}%
  6620.   \do{options}%
  6621.   \do{sortinit}%
  6622.   \do{sortinithash}%
  6623.   \dolistloop\blx@datemetafields
  6624.   \dolistloop\blx@namepartmetafields
  6625.   \dolistloop\blx@labeldatepartfields}
  6626.  
  6627. \def\abx@dobooleans{%
  6628.   \do{crossrefsource}%
  6629.   \do{xrefsource}%
  6630.   \do{singletitle}%
  6631.   \do{uniquetitle}%
  6632.   \do{uniquebaretitle}%
  6633.   \do{uniquework}%
  6634.   \do{uniqueprimaryauthor}%
  6635.   \do{nocite}%
  6636.   \dolistloop\blx@datemetabooleans}
  6637.  
  6638. % Date datatype fields
  6639. \def\do#1{%
  6640.   \protected\csdef{blx@imc@print#1date}{}%
  6641.   \protected\csdef{blx@imc@print#1dateextra}{}%
  6642.   \protected\csdef{blx@imc@print#1time}{}}
  6643. \abx@dodatetypes
  6644.  
  6645. % \blx@regimcs doesn't work in do-lists nicely so use internal macro it calls
  6646. \def\do#1{%
  6647.   \xappto\blx@blxinit{\csletcs{print#1date}{blx@imc@print#1date}}%
  6648.   \xappto\blx@blxinit{\csletcs{print#1time}{blx@imc@print#1time}}%
  6649.   \xappto\blx@blxinit{\csletcs{print#1dateextra}{blx@imc@print#1dateextra}}}
  6650. \abx@dodatetypes
  6651.  
  6652. % Set up circa, julian and uncertain date internals
  6653. \def\blx@makeifdatemeta@bools@i#1#2{%
  6654.   \appto\blx@blxinit{%
  6655.     \blx@makeifdatemeta@bools{#1}{#2}}}
  6656.  
  6657. \def\blx@makeifdatemeta@bools#1#2{%
  6658.   \csdef{if#1date#2}{\iftoggle{abx@bool@#1date#2}}%
  6659.   \csdef{if#1enddate#2}{\iftoggle{abx@bool@#1enddate#2}}%
  6660.   \appto\blx@TE@hook{%
  6661.     \csdef{if#1date#2}{\blx@TE{\iftoggle{abx@bool@#1date#2}}}%
  6662.     \csdef{if#1enddate#2}{\blx@TE{\iftoggle{abx@bool@#1enddate#2}}}}}
  6663.  
  6664. % Set up date era internals
  6665. \def\blx@makeifdatemeta@fields@i#1{%
  6666.   \appto\blx@blxinit{%
  6667.     \blx@makeifdatemeta@fields{#1}}}
  6668.  
  6669. \def\blx@makeifdatemeta@fields#1{%
  6670.   \csdef{if#1dateera}##1{\ifcsstring{abx@field@#1dateera}{##1}}%
  6671.   \csdef{if#1enddateera}##1{\ifcsstring{abx@field@#1enddateera}{##1}}%
  6672.   \appto\blx@TE@hook{%
  6673.     \csdef{if#1dateera}##1{\blx@TE{\ifcsstring{abx@field@#1dateera}{##1}}}%
  6674.     \csdef{if#1enddateera}##1{\blx@TE{\ifcsstring{abx@field@#1enddateera}{##1}}}}}
  6675.  
  6676. % Create date meta information boolean tests
  6677. \def\do#1{%
  6678.   \blx@makeifdatemeta@bools@i{#1}{circa}%
  6679.   \blx@makeifdatemeta@bools@i{#1}{julian}%
  6680.   \blx@makeifdatemeta@bools@i{#1}{uncertain}%
  6681.   \blx@makeifdatemeta@bools@i{#1}{unknown}}
  6682. \abx@dodatetypes
  6683.  
  6684. % Create date meta information field tests
  6685. \def\do#1{%
  6686.   \blx@makeifdatemeta@fields@i{#1}}
  6687. \abx@dodatetypes
  6688.  
  6689. % Resolve date meta information tests and print routines for labeldate
  6690. % We have to test here, in each \def, whether the labeldatesource
  6691. % is a real date field or not. If it's not, then we don't want to use
  6692. % any of the meta-information and so make the conditionals always return false
  6693. % This can't be neater by testing for the \abx@field@labeldatesource value
  6694. % earlier because its not available until the tests are in scope.
  6695. \appto\blx@blxinit{%
  6696.    \ifdefstring\blx@dateera{astronomical}
  6697.      {\protected\def\dateeraprintpre#1{%
  6698.         \iffieldnum{#1}
  6699.          {\begingroup
  6700.           \let\blx@tempa\@empty
  6701.           \blx@ifstrendswith{#1}{endyear}
  6702.             {\blx@stripfromendinto{#1}{endyear}\blx@datetype
  6703.              \def\blx@tempa{end}}
  6704.             {\blx@stripfromendinto{#1}{year}\blx@datetype}%
  6705.            \csuse{if\blx@datetype\blx@tempa dateera}{bce}
  6706.             {\ifnumless{0-\thefield{#1}}{0}
  6707.               {\printtext{\csuse{bibdateera\blx@tempa prefix}}}
  6708.               {}}
  6709.             {}%
  6710.            \endgroup}
  6711.           {}}}
  6712.      {\protected\def\dateeraprint#1{%
  6713.         \iffieldnum{#1}
  6714.          {\begingroup
  6715.           \let\blx@tempa\@empty
  6716.           \blx@ifstrendswith{#1}{endyear}
  6717.             {\blx@stripfromendinto{#1}{endyear}\blx@datetype
  6718.              \def\blx@tempa{end}}
  6719.             {\blx@stripfromendinto{#1}{year}\blx@datetype}%
  6720.            \csuse{if\blx@datetype\blx@tempa dateera}{bce}
  6721.             {\ifnum\numexpr0-\thefield{#1}\relax<\blx@dateeraauto
  6722.                 % \midsentence is to suppress automatic capitalisation
  6723.                 \printtext{\printdelim{dateeradelim}\midsentence\bibstring{\blx@dateera@bce}}\relax
  6724.              \fi}
  6725.             {\ifnumless{\thefield{#1}}\blx@dateeraauto
  6726.               {\printtext{\printdelim{dateeradelim}\midsentence\bibstring{\blx@dateera@ce}}}
  6727.               {}}%
  6728.            \endgroup}
  6729.           {}}}%
  6730.   \iftoggle{blx@labeldateparts}
  6731.     {\def\iflabeldateera#1{% start era
  6732.        \xifinlist{\abx@field@labeldatesource date}\blx@datamodel@dates
  6733.         {\ifcsstring{abx@field@\abx@field@labeldatesource dateera}{#1}}
  6734.         {\@secondoftwo}}%
  6735.      \appto\blx@TE@hook{\def\iflabeldateera#1{%
  6736.        \xifinlist{\abx@field@labeldatesource date}\blx@datamodel@dates
  6737.         {\blx@TE{\ifcsstring{abx@field@\abx@field@labeldatesource dateera}{#1}}}
  6738.         {\@secondoftwo}}}%
  6739.      % end era
  6740.      \def\iflabelenddateera#1{%
  6741.        \xifinlist{\abx@field@labeldatesource date}\blx@datamodel@dates
  6742.         {\ifcsstring{abx@field@\abx@field@labeldatesource enddateera}{#1}}
  6743.         {\@secondoftwo}}%
  6744.      \appto\blx@TE@hook{\def\iflabelenddateera#1{%
  6745.        \xifinlist{\abx@field@labeldatesource date}\blx@datamodel@dates
  6746.         {\blx@TE{\ifcsstring{abx@field@\abx@field@labeldatesource enddateera}{#1}}}
  6747.         {\@secondoftwo}}}%
  6748.      % start circa
  6749.      \def\iflabeldatecirca{%
  6750.        \xifinlist{\abx@field@labeldatesource date}\blx@datamodel@dates
  6751.         {\iftoggle{abx@bool@\abx@field@labeldatesource datecirca}}
  6752.         {\@secondoftwo}}%
  6753.      \appto\blx@TE@hook{\def\iflabeldatecirca{%
  6754.        \xifinlist{\abx@field@labeldatesource date}\blx@datamodel@dates
  6755.         {\blx@TE{\iftoggle{abx@bool@\abx@field@labeldatesource datecirca}}}
  6756.         {\@secondoftwo}}}%
  6757.      % end circa
  6758.      \def\iflabelenddatecirca{%
  6759.        \xifinlist{\abx@field@labeldatesource date}\blx@datamodel@dates
  6760.         {\iftoggle{abx@bool@\abx@field@labeldatesource enddatecirca}}
  6761.         {\@secondoftwo}}%
  6762.      \appto\blx@TE@hook{\def\iflabelenddatecirca{%
  6763.        \xifinlist{\abx@field@labeldatesource date}\blx@datamodel@dates
  6764.         {\blx@TE{\iftoggle{abx@bool@\abx@field@labeldatesource enddatecirca}}}
  6765.         {\@secondoftwo}}}%
  6766.      % start julian
  6767.      \def\iflabeldatejulian{%
  6768.        \xifinlist{\abx@field@labeldatesource date}\blx@datamodel@dates
  6769.         {\iftoggle{abx@bool@\abx@field@labeldatesource datejulian}}
  6770.         {\@secondoftwo}}%
  6771.      \appto\blx@TE@hook{\def\iflabeldatejulian{%
  6772.        \xifinlist{\abx@field@labeldatesource date}\blx@datamodel@dates
  6773.         {\blx@TE{\iftoggle{abx@bool@\abx@field@labeldatesource datejulian}}}
  6774.         {\@secondoftwo}}}%
  6775.      % end julian
  6776.      \def\iflabelenddatejulian{%
  6777.        \xifinlist{\abx@field@labeldatesource date}\blx@datamodel@dates
  6778.         {\iftoggle{abx@bool@\abx@field@labeldatesource enddatejulian}}
  6779.         {\@secondoftwo}}%
  6780.      \appto\blx@TE@hook{\def\iflabelenddatejulian{%
  6781.        \xifinlist{\abx@field@labeldatesource date}\blx@datamodel@dates
  6782.         {\blx@TE{\iftoggle{abx@bool@\abx@field@labeldatesource enddatejulian}}}
  6783.         {\@secondoftwo}}}%
  6784.      % start uncertain
  6785.      \def\iflabeldateuncertain{%
  6786.        \xifinlist{\abx@field@labeldatesource date}\blx@datamodel@dates
  6787.         {\iftoggle{abx@bool@\abx@field@labeldatesource dateuncertain}}
  6788.         {\@secondoftwo}}%
  6789.      \appto\blx@TE@hook{\def\iflabeldateuncertain{%
  6790.        \xifinlist{\abx@field@labeldatesource date}\blx@datamodel@dates
  6791.         {\blx@TE{\iftoggle{abx@bool@\abx@field@labeldatesource dateuncertain}}}
  6792.         {\@secondoftwo}}}%
  6793.      % end uncertain
  6794.      \def\iflabelenddateuncertain{%
  6795.        \xifinlist{\abx@field@labeldatesource date}\blx@datamodel@dates
  6796.         {\iftoggle{abx@bool@\abx@field@labeldatesource enddateuncertain}}
  6797.         {\@secondoftwo}}%
  6798.      \appto\blx@TE@hook{\def\iflabelenddateuncertain{%
  6799.        \xifinlist{\abx@field@labeldatesource date}\blx@datamodel@dates
  6800.         {\blx@TE{\iftoggle{abx@bool@\abx@field@labeldatesource enddateuncertain}}}
  6801.         {\@secondoftwo}}}}%
  6802.   {}}
  6803.  
  6804. % Name toggles like \ifauthor etc. need to be dynamically created for all
  6805. % name datatypes in the data model and we have to do this here after the
  6806. % datamodel is available. Need to be careful about expansions here as these
  6807. % go into hooks to be executed later
  6808.  
  6809. % toggle to say if we have set any <name>inits to true. Used for conflict
  6810. % tests with uniquename settings (see \AtEndPreamble below)
  6811. \newtoggle{abx@bool@xinits}
  6812. % define <name>inits options and tests (terseinits is global for all initials)
  6813. \def\do#1{%
  6814.   \newtoggle{abx@bool@#1inits}%
  6815.   \appto\blx@blxinit{%
  6816.     \csdef{if#1inits}{\iftoggle{abx@bool@#1inits}}%
  6817.     \appto\blx@TE@hook{%
  6818.       \csdef{if#1inits}{\blx@TE{\iftoggle{abx@bool@#1inits}}}}}%
  6819.   \DeclareBibliographyOption[boolean]{#1inits}[true]{%
  6820.     \settoggle{abx@bool@#1inits}{##1}}}
  6821. \abx@donameparts
  6822.  
  6823. \def\do#1{%
  6824.   % Define use<name> options scope for biber
  6825.   \blx@collectopts{boolean}{blx@globalopts}{use#1}%
  6826.   \blx@collectopts{boolean}{blx@typeopts}{use#1}%
  6827.   \blx@collectopts{boolean}{blx@entryopts}{use#1}%
  6828.   % Define name toggles
  6829.   \newtoggle{blx@use#1}\toggletrue{blx@use#1}%
  6830.   % Define tests
  6831.   \appto\blx@blxinit{%
  6832.     \csdef{ifuse#1}{\iftoggle{blx@use#1}}%
  6833.     \appto\blx@TE@hook{%
  6834.       \csdef{ifuse#1}{\blx@TE{\iftoggle{blx@use#1}}}}}}
  6835. \abx@donames
  6836.  
  6837. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  6838.  
  6839. % Since these are bare counters which define \the<string>, save any current values
  6840. % (memoir, titling, koma etc. have a \theauthor macro, for example) and restore at
  6841. % end of package
  6842. \def\do#1{%
  6843.   \csletcs{blx@compat@the#1}{the#1}%
  6844.   \newcounter{#1}%
  6845.   \newcounter{saved#1}%
  6846.   \appto\abx@dobooleans{\do{more#1}}}
  6847.  
  6848. \abx@donames
  6849. \abx@dornames
  6850. \abx@dolists
  6851. %\abx@dorlists
  6852.  
  6853. \AtEndOfPackage{%
  6854.   \def\do#1{\csletcs{the#1}{blx@compat@the#1}}%
  6855.   \abx@donames
  6856.   \abx@dornames
  6857.   \abx@dolists}
  6858.  
  6859. \def\do#1{\newtoggle{abx@bool@#1}}
  6860. \abx@dobooleans
  6861.  
  6862. \def\do#1{\expandafter\newlength\expandafter{\csname #1width\endcsname}}
  6863. \abx@dolabelfields
  6864.  
  6865. \newlength{\locallabelnumberwidth}
  6866. \newlength{\locallabelalphawidth}
  6867. \def\do#1{\expandafter\newlength\expandafter{\csname local#1width\endcsname}}
  6868. \abx@dolabelfields
  6869.  
  6870. \protected\def\blx@resetdata{%
  6871.   \let\blx@saved@do\do
  6872.   \let\do\blx@imc@clearname
  6873.   \abx@donames
  6874.   \let\do\blx@imc@clearlist
  6875.   \abx@dolists
  6876.   \let\do\blx@imc@clearfield
  6877.   \abx@dofields
  6878.   \abx@dointernalfields
  6879.   \ifundef\abx@annotation@defined
  6880.     {}
  6881.    {\def\do##1{\csundef{abx@annotation@##1}}%
  6882.      \dolistloop\abx@annotation@defined}%
  6883.   \let\abx@annotation@defined\@empty
  6884.   \def\do##1{\togglefalse{abx@bool@##1}}%
  6885.   \abx@dobooleans
  6886.   \let\do\blx@saved@do
  6887.   \c@citecounter\z@
  6888.   \iftoggle{blx@bibliography}
  6889.    {\c@maxnames\blx@maxbibnames\relax
  6890.     \c@minnames\blx@minbibnames\relax}
  6891.    {\c@maxnames\blx@maxcitenames\relax
  6892.     \c@minnames\blx@mincitenames\relax}%
  6893.   \c@maxitems\blx@maxitems\relax
  6894.   \c@minitems\blx@minitems\relax}
  6895.  
  6896. \protected\def\blx@saveentry{%
  6897.   \let\blx@saved@do\do
  6898.   \let\do\blx@savename
  6899.   \abx@donames
  6900.   \let\do\blx@saverelname
  6901.   \dolistloop\abx@dorelnames
  6902.   \let\do\blx@savelist
  6903.   \abx@dolists
  6904.   \let\do\blx@saverellist
  6905.   \dolistloop\abx@dorellists
  6906.   \let\do\blx@savefield
  6907.   \abx@dofields
  6908.   \abx@dointernalfields
  6909.   \let\do\blx@saverelfield
  6910.   \dolistloop\abx@dorelfields
  6911.   \ifundef\abx@savedannotation@defined
  6912.     {}
  6913.    {\def\do##1{\csundef{abx@annotation@\blx@saveannotations@makesaved##1}}%
  6914.      \dolistloop\abx@savedannotation@defined}%
  6915.   \let\abx@savedannotation@defined\@empty
  6916.   \ifundef\abx@annotation@defined
  6917.     {}
  6918.    {\let\do\blx@saveannotations
  6919.     \dolistloop\abx@annotation@defined}%
  6920.   \let\abx@savedannotation@defined\abx@annotation@defined
  6921.   \let\do\blx@savebool
  6922.   \abx@dobooleans
  6923.   \let\do\blx@savedatetype
  6924.   \abx@dodatetypes
  6925.   \do{label}%
  6926.   \c@savedcitecounter\c@citecounter
  6927.   \let\do\blx@saved@do}
  6928.  
  6929. \protected\def\blx@savename#1{%
  6930.   \csletcs{etb@tgl@abx@bool@moresaved#1}{etb@tgl@abx@bool@more#1}%
  6931.   \csletcs{abx@name@saved#1}{abx@name@#1}%
  6932.   \csname c@saved#1\endcsname\csname c@#1\endcsname}
  6933.  
  6934. % override with name saved from \clearfield for related processing
  6935. \protected\def\blx@saverelname#1{%
  6936.   \csletcs{etb@tgl@abx@bool@moresaved#1}{etb@tgl@abx@bool@morerelsaved#1}%
  6937.   \csletcs{abx@name@saved#1}{abx@name@relsaved#1}%
  6938.   \csname c@saved#1\endcsname\csname c@relsaved#1\endcsname}
  6939.  
  6940. \protected\def\blx@savelist#1{%
  6941.   \csletcs{etb@tgl@abx@bool@moresaved#1}{etb@tgl@abx@bool@more#1}%
  6942.   \csletcs{abx@list@saved#1}{abx@list@#1}%
  6943.   \csname c@saved#1\endcsname\csname c@#1\endcsname}
  6944.  
  6945. % override with list saved from \clearfield for related processing
  6946. \protected\def\blx@saverellist#1{%
  6947.   \csletcs{etb@tgl@abx@bool@moresaved#1}{etb@tgl@abx@bool@morerelsaved#1}%
  6948.   \csletcs{abx@list@saved#1}{abx@list@relsaved#1}%
  6949.   \csname c@saved#1\endcsname\csname c@relsaved#1\endcsname}
  6950.  
  6951. \protected\def\blx@savefield#1{%
  6952.   \csletcs{abx@field@saved#1}{abx@field@#1}}
  6953.  
  6954. % override with field saved from \clearfield for related processing
  6955. \protected\def\blx@saverelfield#1{%
  6956.   \csletcs{abx@field@saved@#1}{abx@field@relsaved#1}}
  6957.  
  6958. \protected\def\blx@savebool#1{%
  6959.   \csletcs{etb@tgl@abx@bool@saved#1}{etb@tgl@abx@bool@#1}}
  6960.  
  6961. \protected\def\blx@savedatetype#1{%
  6962.   \csletcs{blx@dateformat@saved#1date}{blx@dateformat@#1date}%
  6963.   \protected\csedef{blx@imc@printsaved#1date}{%
  6964.     \noexpand\csuse{mkdaterange\csuse{blx@dateformat@saved#1date}}
  6965.      {saved#1}}%
  6966.   \protected\csedef{blx@imc@printsaved#1dateextra}{%
  6967.     \begingroup
  6968.       % extradate is hard-coded in date macros, so reset it temporarily
  6969.       \csletcs{abx@field@extradate}{abx@field@savedextradate}%
  6970.       \noexpand\csuse{mkdaterange\csuse{blx@dateformat@saved#1date}extra}
  6971.        {saved#1}%
  6972.     \endgroup}%
  6973.   \csletcs{blx@timeformat@saved#1time}{blx@timeformat@#1time}%
  6974.   \protected\csedef{blx@imc@printsaved#1time}{%
  6975.     \noexpand\csuse{mktimerange\csuse{blx@timeformat@saved#1time}}
  6976.      {saved#1}}%
  6977.   \csletcs{etb@tgl@blx@saved#1dateusetime}{etb@tgl@blx@#1dateusetime}%
  6978.   % the datemetabooleans are here again for labeldate
  6979.   \blx@savebool{#1datecirca}%
  6980.   \blx@savebool{#1enddatecirca}%
  6981.   \blx@savebool{#1datejulian}%
  6982.   \blx@savebool{#1enddatejulian}%
  6983.   \blx@savebool{#1dateuncertain}%
  6984.   \blx@savebool{#1enddateuncertain}%
  6985.   \blx@savebool{#1dateunknown}%
  6986.   \blx@savebool{#1enddateunknown}%
  6987.   \blx@makeifdatemeta@bools{saved#1}{circa}%
  6988.   \blx@makeifdatemeta@bools{saved#1}{julian}%
  6989.   \blx@makeifdatemeta@bools{saved#1}{uncertain}%
  6990.   \blx@makeifdatemeta@bools{saved#1}{unknown}%
  6991.   \blx@makeifdatemeta@fields{saved#1}%
  6992.   \csletcs{printsaved#1date}{blx@imc@printsaved#1date}%
  6993.   \csletcs{printsaved#1time}{blx@imc@printsaved#1time}%
  6994.   \csletcs{printsaved#1dateextra}{blx@imc@printsaved#1dateextra}}
  6995.  
  6996. \def\blx@saveannotations@makesaved#1@#2{#1@saved#2}
  6997. \protected\def\blx@saveannotations#1{%
  6998.   \csletcs{abx@annotation@\blx@saveannotations@makesaved#1}{abx@annotation@#1}}
  6999.  
  7000. % {<code>}
  7001. \protected\long\def\blx@bbl@preamble#1{%
  7002.   \gappto\abx@preamble{#1}}
  7003.  
  7004. % {<message>}
  7005. \protected\def\blx@bbl@warn#1{%
  7006.   \begingroup
  7007.   \def\item{\MessageBreak-\space}%
  7008.   \def\break{\MessageBreak\space\space}%
  7009.   \edef\blx@tempa{%
  7010.     Biber reported the following issues%
  7011.     \ifdef\abx@field@entrykey
  7012.       {\MessageBreak with '\abx@field@entrykey'}
  7013.      {}%
  7014.     :#1}%
  7015.   \blx@warning@noline{\blx@tempa}%
  7016.   \endgroup}
  7017.  
  7018. % {<field>}{<code>}
  7019. \newrobustcmd{\DeclareFieldInputHandler}[2]{%
  7020.   \ifblank{#2}
  7021.    {\csundef{blx@fih@#1}}
  7022.    {\long\csdef{blx@fih@#1}##1{#2}}}
  7023. \@onlypreamble\DeclareFieldInputHandler
  7024.  
  7025. % {<list>}{<code>}
  7026. \newrobustcmd*{\DeclareListInputHandler}[2]{%
  7027.   \ifblank{#2}
  7028.    {\csundef{blx@lih@#1}}
  7029.    {\csdef{blx@lih@#1}##1{#2}}}
  7030. \@onlypreamble\DeclareListInputHandler
  7031.  
  7032. % {<name>}{<code>}
  7033. \newrobustcmd*{\DeclareNameInputHandler}[2]{%
  7034.   \ifblank{#2}
  7035.    {\csundef{blx@nih@#1}}
  7036.    {\csdef{blx@nih@#1}##1{#2}}}
  7037. \@onlypreamble\DeclareNameInputHandler
  7038.  
  7039. % {<entrykey>}{<refsection>}{<field>}{<refcontext>}{<value>}
  7040. \long\def\blx@bbl@addentryfield#1#2#3#4#5{%
  7041.   \csxappto{blx@data@#2@#4@#1}{%
  7042.     \def\expandafter\noexpand\csname abx@field@#3\endcsname{#5}}}
  7043.  
  7044. % {<rangefield>}{<value>}
  7045. \protected\def\blx@bbl@rangedef#1#2{%
  7046.   \csxappto\blx@bbl@data{%
  7047.     \def\expandafter\noexpand\csname abx@range@#1\endcsname{#2}}}
  7048.  
  7049. % {<field>}{<value>}
  7050. \long\def\blx@bbl@addfield#1#2{%
  7051.   \csxappto\blx@bbl@data{%
  7052.     \def\expandafter\noexpand\csname abx@field@#1\endcsname{#2}}}
  7053.  
  7054. \protected\long\def\blx@bbl@fielddef#1#2{%
  7055.   \def\NewValue{#2}%
  7056.   \ifcsdef{blx@fih@#1}
  7057.    {\csname blx@fih@#1\endcsname{#2}%
  7058.      \ifdefvoid\NewValue}
  7059.     {\@secondoftwo}
  7060.       {}
  7061.       {\blx@bbl@addfield{#1}{\expandonce\NewValue}}}
  7062.  
  7063. \protected\long\def\blx@bbl@fieldedef#1#2{%
  7064.   \edef\NewValue{#2}%
  7065.   \ifcsdef{blx@fih@#1}
  7066.    {\csname blx@fih@#1\expandafter
  7067.     \endcsname\expandafter{\NewValue}%
  7068.      \ifdefvoid\NewValue}
  7069.     {\@secondoftwo}
  7070.       {}
  7071.       {\blx@bbl@addfield{#1}{\NewValue}}}
  7072.  
  7073. \protected\long\def\blx@bbl@stringdef#1#2{%
  7074.   \begingroup
  7075.   \edef\blx@tempa{\endgroup
  7076.    \blx@bbl@fielddef{#1}{\detokenize{#2}}}%
  7077.   \blx@tempa}
  7078.  
  7079. % Verbatim lists
  7080. % {<list>}{<listcount>}
  7081. \protected\def\blx@bbl@verbldef#1#2{%
  7082.   \begingroup
  7083.   \let\lverb\blx@bbl@verbladd
  7084.   \def\blx@tempa{#1}%
  7085.   \def\blx@tempb{#2}%
  7086.   \let\blx@tempc\@empty
  7087.   \let\NewValue\@empty}
  7088.  
  7089. \protected\def\blx@bbl@verblend{%
  7090.   \expandafter\blx@bbl@listdef\expandafter{\expandafter\blx@tempa\expandafter}\expandafter{\expandafter\blx@tempb\expandafter}\expandafter{\blx@tempc}%
  7091.   \endgroup}
  7092.  
  7093. \protected\def\blx@bbl@verbladd{%
  7094.   \begingroup
  7095.   \let\do\@makeother
  7096.   \dospecials
  7097.   \catcode\endlinechar=12\relax
  7098.   \blx@bbl@verbladd@i}
  7099.  
  7100. % Verbatim fields
  7101. % {<field>}
  7102. \protected\def\blx@bbl@verbdef#1{%
  7103.   \begingroup
  7104.   \let\verb\blx@bbl@verbadd
  7105.   \def\blx@tempa{#1}%
  7106.   \let\NewValue\@empty}
  7107.  
  7108. \protected\def\blx@bbl@verbend{%
  7109.   \ifcsdef{blx@fih@\blx@tempa}
  7110.    {\csname blx@fih@\blx@tempa\expandafter
  7111.     \endcsname\expandafter{\NewValue}%
  7112.      \ifdefvoid\NewValue}
  7113.     {\@secondoftwo}
  7114.       {}
  7115.       {\blx@bbl@addfield{\blx@tempa}{\NewValue}}%
  7116.   \endgroup}
  7117.  
  7118. \protected\def\blx@bbl@verbadd{%
  7119.   \begingroup
  7120.   \let\do\@makeother
  7121.   \dospecials
  7122.   \catcode\endlinechar=12\relax
  7123.   \blx@bbl@verbadd@i}
  7124.  
  7125. % {<scope>}{<field>}{<name>}{<itemcount>}{<part>}{<isliteral>}{<value>}
  7126. \protected\def\blx@bbl@annotationdef#1#2#3#4#5#6#7{%
  7127.   \ifstrequal{#1}{field}
  7128.      {\csxappto\blx@bbl@data{%
  7129.         \listadd\noexpand\abx@annotation@defined{field@#2@#3}}%
  7130.       \ifstrequal{#6}{1}
  7131.         {\csgappto\blx@bbl@data{%
  7132.            \csdef{abx@annotation@literal@field@#2@#3}{#7}}}
  7133.         {\csxappto\blx@bbl@data{%
  7134.            \def\do####1{\listcsadd{abx@annotation@field@#2@#3}{####1}}%
  7135.            \docsvlist{#7}}}}
  7136.     {}%
  7137.   \ifstrequal{#1}{item}
  7138.      {\csxappto\blx@bbl@data{%
  7139.         \listadd\noexpand\abx@annotation@defined{item@#2@#3@#4}}%
  7140.       \ifstrequal{#6}{1}
  7141.         {\csgappto\blx@bbl@data{%
  7142.            \csdef{abx@annotation@literal@item@#2@#3@#4}{#7}}}
  7143.         {\csxappto\blx@bbl@data{%
  7144.            \def\do####1{\listcsadd{abx@annotation@item@#2@#3@#4}{####1}}%
  7145.            \docsvlist{#7}}}}
  7146.     {}%
  7147.   \ifstrequal{#1}{part}
  7148.      {\csxappto\blx@bbl@data{%
  7149.         \listadd\noexpand\abx@annotation@defined{part@#2@#3@#4@#5}}%
  7150.       \ifstrequal{#6}{1}
  7151.         {\csgappto\blx@bbl@data{%
  7152.            \csdef{abx@annotation@literal@part@#2@#3@#4@#5}{#7}}}
  7153.         {\csxappto\blx@bbl@data{%
  7154.           \def\do####1{\listcsadd{abx@annotation@part@#2@#3@#4@#5}{####1}}%
  7155.           \docsvlist{#7}}}}
  7156.     {}}
  7157.  
  7158. % [<field>][<annotationname>]
  7159. \def\blx@imc@getfieldannotation{%
  7160.   \let\blx@tempa\@empty
  7161.   \ifdefvoid\currentfield{}{\let\blx@tempa\currentfield}%
  7162.   \ifdefvoid\currentlist{}{\let\blx@tempa\currentlist}%
  7163.   \ifdefvoid\currentname{}{\let\blx@tempa\currentname}%
  7164.   \@ifnextchar[%]
  7165.    {\blx@imc@getfieldannotation@i}
  7166.   {\blx@imc@getfieldannotation@i[\blx@tempa]}}
  7167.  
  7168. \def\blx@imc@getfieldannotation@i[#1]{%
  7169.  \ifstrempty{#1}
  7170.   {\blx@imc@getfieldannotation@i[\blx@tempa]}
  7171.    {\@ifnextchar[%]
  7172.       {\blx@imc@getfieldannotation@ii{#1}}
  7173.      {\blx@imc@getfieldannotation@ii{#1}[default]}}}
  7174.  
  7175. \def\blx@imc@getfieldannotation@ii#1[#2]{%
  7176.   \def\blx@tempb{#1}%
  7177.   \blx@resolve@annotation@label{\blx@tempb}%
  7178.   \ifcsdef{abx@annotation@literal@field@\blx@tempb @#2}
  7179.    {\csuse{abx@annotation@literal@field@\blx@tempb @#2}}
  7180.    {}}
  7181.  
  7182. % [<field>][<annotationname>][<item>]
  7183. \def\blx@imc@getitemannotation{%
  7184.   \let\blx@tempa\@empty
  7185.   \ifdefvoid\currentfield{}{\let\blx@tempa\currentfield}%
  7186.   \ifdefvoid\currentlist{}{\let\blx@tempa\currentlist}%
  7187.   \ifdefvoid\currentname{}{\let\blx@tempa\currentname}%
  7188.   \@ifnextchar[%]
  7189.    {\blx@imc@getitemannotation@i}
  7190.   {\blx@imc@getitemannotation@i[\blx@tempa]}}
  7191.  
  7192. \def\blx@imc@getitemannotation@i[#1]{%
  7193.   \ifstrempty{#1}
  7194.    {\blx@imc@getitemannotation@i[\blx@tempa]}
  7195.     {\@ifnextchar[%]
  7196.       {\blx@imc@getitemannotation@ii{#1}}
  7197.      {\blx@imc@getitemannotation@ii{#1}[default]}}}
  7198.  
  7199. \def\blx@imc@getitemannotation@ii#1[#2]{%
  7200.   \ifstrempty{#2}
  7201.    {\def\blx@tempb{default}}
  7202.    {\def\blx@tempb{#2}}%
  7203.   \@ifnextchar[%]
  7204.     {\blx@imc@getitemannotation@iii{#1}{\blx@tempb}}
  7205.    {\blx@imc@getitemannotation@iii{#1}{\blx@tempb}[\the\value{listcount}]}}
  7206.  
  7207. \def\blx@imc@getitemannotation@iii#1#2[#3]{%
  7208.   \def\blx@tempc{#1}%
  7209.   \blx@resolve@annotation@label{\blx@tempc}%
  7210.   \ifcsdef{abx@annotation@literal@item@\blx@tempc @#2@#3}
  7211.    {\csuse{abx@annotation@literal@item@\blx@tempc @#2@#3}}
  7212.    {}}
  7213.  
  7214. % [<field>][<annotationname>][<item>]{<part>}
  7215. \def\blx@imc@getpartannotation{%
  7216.   \let\blx@tempa\@empty
  7217.   \ifdefvoid\currentfield{}{\let\blx@tempa\currentfield}%
  7218.   \ifdefvoid\currentlist{}{\let\blx@tempa\currentlist}%
  7219.   \ifdefvoid\currentname{}{\let\blx@tempa\currentname}%
  7220.   \@ifnextchar[%]
  7221.     {\blx@imc@getpartannotation@i}
  7222.    {\blx@imc@getpartannotation@i[\blx@tempa]}}
  7223.  
  7224. \def\blx@imc@getpartannotation@i[#1]{%
  7225.   \ifstrempty{#1}
  7226.    {\blx@imc@getpartannotation@i[\blx@tempa]}
  7227.     {\@ifnextchar[%]
  7228.       {\blx@imc@getpartannotation@ii{#1}}
  7229.      {\blx@imc@getpartannotation@ii{#1}[default]}}}
  7230.  
  7231. \def\blx@imc@getpartannotation@ii#1[#2]{%
  7232.  \ifstrempty{#2}
  7233.   {\def\blx@tempb{default}}
  7234.   {\def\blx@tempb{#2}}%
  7235.   \@ifnextchar[%]
  7236.     {\blx@imc@getpartannotation@iii{#1}{\blx@tempb}}
  7237.    {\blx@imc@getpartannotation@iii{#1}{\blx@tempb}[\the\value{listcount}]}}
  7238.  
  7239. \def\blx@imc@getpartannotation@iii#1#2[#3]#4{%
  7240.   \ifstrempty{#3}
  7241.    {\def\blx@tempc{\the\value{listcount}}}
  7242.    {\def\blx@tempc{#3}}%
  7243.   \def\blx@tempd{#1}%
  7244.   \blx@resolve@annotation@label{\blx@tempd}%
  7245.   \ifcsdef{abx@annotation@literal@part@\blx@tempd @#2@\blx@tempc @#4}
  7246.    {\csuse{abx@annotation@literal@part@\blx@tempd @#2@\blx@tempc @#4}}
  7247.    {}}
  7248.  
  7249. % [<field>][<annotationname>]{<annotation>}
  7250. \def\blx@imc@iffieldannotation{%
  7251.   \let\blx@tempa\@empty
  7252.   \ifdefvoid\currentfield{}{\let\blx@tempa\currentfield}%
  7253.   \ifdefvoid\currentlist{}{\let\blx@tempa\currentlist}%
  7254.   \ifdefvoid\currentname{}{\let\blx@tempa\currentname}%
  7255.  \@ifnextchar[%]
  7256.     {\blx@imc@iffieldannotation@i}
  7257.    {\blx@imc@iffieldannotation@i[\blx@tempa]}}
  7258.  
  7259. \def\blx@imc@iffieldannotation@i[#1]{%
  7260.   \ifstrempty{#1}
  7261.    {\blx@imc@iffieldannotation@i[\blx@tempa]}
  7262.     {\@ifnextchar[%]
  7263.       {\blx@imc@iffieldannotation@ii{#1}}
  7264.      {\blx@imc@iffieldannotation@ii{#1}[default]}}}
  7265.  
  7266. \def\blx@imc@iffieldannotation@ii#1[#2]#3{%
  7267.   \ifstrempty{#2}
  7268.    {\def\blx@tempb{default}}
  7269.    {\def\blx@tempb{#2}}%
  7270.   \def\blx@tempc{#1}%
  7271.   \blx@resolve@annotation@label{\blx@tempc}%
  7272.   \ifinlistcs{#3}{abx@annotation@field@\blx@tempc @\blx@tempb}}
  7273.  
  7274. % [<field>][<annotationname>][<item>]{<annotation>}
  7275. \def\blx@imc@ifitemannotation{%
  7276.   \let\blx@tempa\@empty
  7277.   \ifdefvoid\currentfield{}{\let\blx@tempa\currentfield}%
  7278.   \ifdefvoid\currentlist{}{\let\blx@tempa\currentlist}%
  7279.   \ifdefvoid\currentname{}{\let\blx@tempa\currentname}%
  7280.    \@ifnextchar[%]
  7281.     {\blx@imc@ifitemannotation@i}
  7282.    {\blx@imc@ifitemannotation@i[\blx@tempa]}}
  7283.  
  7284. \def\blx@imc@ifitemannotation@i[#1]{%
  7285.   \ifstrempty{#1}
  7286.    {\blx@imc@ifitemannotation@i[\blx@tempa]}
  7287.     {\@ifnextchar[%]
  7288.       {\blx@imc@ifitemannotation@ii{#1}}
  7289.      {\blx@imc@ifitemannotation@ii{#1}[default]}}}
  7290.  
  7291. \def\blx@imc@ifitemannotation@ii#1[#2]{%
  7292.   \ifstrempty{#2}
  7293.    {\def\blx@tempb{default}}
  7294.    {\def\blx@tempb{#2}}%
  7295.   \@ifnextchar[%]
  7296.     {\blx@imc@ifitemannotation@iii{#1}{\blx@tempb}}
  7297.    {\blx@imc@ifitemannotation@iii{#1}{\blx@tempb}[\the\value{listcount}]}}
  7298.  
  7299. \def\blx@imc@ifitemannotation@iii#1#2[#3]#4{%
  7300.   \def\blx@tempc{#1}%
  7301.   \blx@resolve@annotation@label{\blx@tempc}%
  7302.   \ifinlistcs{#4}{abx@annotation@item@\blx@tempc @#2@#3}}
  7303.  
  7304. % [<field>][<annotationname>][<item>]{<part>}{<annotation>}
  7305. \def\blx@imc@ifpartannotation{%
  7306.   \let\blx@tempa\@empty
  7307.   \ifdefvoid\currentfield{}{\let\blx@tempa\currentfield}%
  7308.   \ifdefvoid\currentlist{}{\let\blx@tempa\currentlist}%
  7309.   \ifdefvoid\currentname{}{\let\blx@tempa\currentname}%
  7310.   \@ifnextchar[%]
  7311.     {\blx@imc@ifpartannotation@i}
  7312.    {\blx@imc@ifpartannotation@i[\blx@tempa]}}
  7313.  
  7314. \def\blx@imc@ifpartannotation@i[#1]{%
  7315.   \ifstrempty{#1}
  7316.    {\blx@imc@ifpartannotation@i[\blx@tempa]}
  7317.     {\@ifnextchar[%]
  7318.       {\blx@imc@ifpartannotation@ii{#1}}
  7319.      {\blx@imc@ifpartannotation@ii{#1}[default]}}}
  7320.  
  7321. \def\blx@imc@ifpartannotation@ii#1[#2]{%
  7322.  \ifstrempty{#2}
  7323.   {\def\blx@tempb{default}}
  7324.   {\def\blx@tempb{#2}}%
  7325.   \@ifnextchar[%]
  7326.     {\blx@imc@ifpartannotation@iii{#1}{\blx@tempb}}
  7327.    {\blx@imc@ifpartannotation@iii{#1}{\blx@tempb}[\the\value{listcount}]}}
  7328.  
  7329. \def\blx@imc@ifpartannotation@iii#1#2[#3]#4#5{%
  7330.   \ifstrempty{#3}
  7331.    {\def\blx@tempc{\the\value{listcount}}}
  7332.    {\def\blx@tempc{#3}}%
  7333.   \def\blx@tempd{#1}%
  7334.   \blx@resolve@annotation@label{\blx@tempd}%
  7335.   \ifinlistcs{#5}{abx@annotation@part@\blx@tempd @#2@\blx@tempc @#4}}
  7336.  
  7337. % [<field>][<annotationname>]
  7338. \def\blx@imc@hasfieldannotation{%
  7339.   \let\blx@tempa\@empty
  7340.   \ifdefvoid\currentfield{}{\let\blx@tempa\currentfield}%
  7341.   \ifdefvoid\currentlist{}{\let\blx@tempa\currentlist}%
  7342.   \ifdefvoid\currentname{}{\let\blx@tempa\currentname}%
  7343.  \@ifnextchar[%]
  7344.     {\blx@imc@hasfieldannotation@i}
  7345.    {\blx@imc@hasfieldannotation@i[\blx@tempa]}}
  7346.  
  7347. \def\blx@imc@hasfieldannotation@i[#1]{%
  7348.   \ifstrempty{#1}
  7349.    {\blx@imc@hasfieldannotation@i[\blx@tempa]}
  7350.     {\@ifnextchar[%]
  7351.       {\blx@imc@hasfieldannotation@ii{#1}}
  7352.      {\blx@imc@hasfieldannotation@ii{#1}[default]}}}
  7353.  
  7354. \def\blx@imc@hasfieldannotation@ii#1[#2]{%
  7355.   \ifstrempty{#2}
  7356.    {\def\blx@tempb{default}}
  7357.    {\def\blx@tempb{#2}}%
  7358.   \def\blx@tempc{#1}%
  7359.   \blx@resolve@annotation@label{\blx@tempc}%
  7360.   \ifcsdef{abx@annotation@literal@field@\blx@tempc @\blx@tempb}}
  7361.  
  7362. % [<field>][<annotationname>][<item>]
  7363. \def\blx@imc@hasitemannotation{%
  7364.   \let\blx@tempa\@empty
  7365.   \ifdefvoid\currentfield{}{\let\blx@tempa\currentfield}%
  7366.   \ifdefvoid\currentlist{}{\let\blx@tempa\currentlist}%
  7367.   \ifdefvoid\currentname{}{\let\blx@tempa\currentname}%
  7368.    \@ifnextchar[%]
  7369.     {\blx@imc@hasitemannotation@i}
  7370.    {\blx@imc@hasitemannotation@i[\blx@tempa]}}
  7371.  
  7372. \def\blx@imc@hasitemannotation@i[#1]{%
  7373.   \ifstrempty{#1}
  7374.    {\blx@imc@hasitemannotation@i[\blx@tempa]}
  7375.     {\@ifnextchar[%]
  7376.       {\blx@imc@hasitemannotation@ii{#1}}
  7377.      {\blx@imc@hasitemannotation@ii{#1}[default]}}}
  7378.  
  7379. \def\blx@imc@hasitemannotation@ii#1[#2]{%
  7380.   \ifstrempty{#2}
  7381.    {\def\blx@tempb{default}}
  7382.    {\def\blx@tempb{#2}}%
  7383.   \@ifnextchar[%]
  7384.     {\blx@imc@hasitemannotation@iii{#1}{\blx@tempb}}
  7385.    {\blx@imc@hasitemannotation@iii{#1}{\blx@tempb}[\the\value{listcount}]}}
  7386.  
  7387. \def\blx@imc@hasitemannotation@iii#1#2[#3]{%
  7388.   \def\blx@tempc{#1}%
  7389.   \blx@resolve@annotation@label{\blx@tempc}%
  7390.   \ifcsdef{abx@annotation@literal@item@\blx@tempc @#2@#3}}
  7391.  
  7392. % [<field>][<annotationname>][<item>]{<part>}
  7393. \def\blx@imc@haspartannotation{%
  7394.   \let\blx@tempa\@empty
  7395.   \ifdefvoid\currentfield{}{\let\blx@tempa\currentfield}%
  7396.   \ifdefvoid\currentlist{}{\let\blx@tempa\currentlist}%
  7397.   \ifdefvoid\currentname{}{\let\blx@tempa\currentname}%
  7398.   \@ifnextchar[%]
  7399.     {\blx@imc@haspartannotation@i}
  7400.    {\blx@imc@haspartannotation@i[\blx@tempa]}}
  7401.  
  7402. \def\blx@imc@haspartannotation@i[#1]{%
  7403.   \ifstrempty{#1}
  7404.    {\blx@imc@haspartannotation@i[\blx@tempa]}
  7405.     {\@ifnextchar[%]
  7406.       {\blx@imc@haspartannotation@ii{#1}}
  7407.      {\blx@imc@haspartannotation@ii{#1}[default]}}}
  7408.  
  7409. \def\blx@imc@haspartannotation@ii#1[#2]{%
  7410.  \ifstrempty{#2}
  7411.   {\def\blx@tempb{default}}
  7412.   {\def\blx@tempb{#2}}%
  7413.   \@ifnextchar[%]
  7414.     {\blx@imc@haspartannotation@iii{#1}{\blx@tempb}}
  7415.    {\blx@imc@haspartannotation@iii{#1}{\blx@tempb}[\the\value{listcount}]}}
  7416.  
  7417. \def\blx@imc@haspartannotation@iii#1#2[#3]#4{%
  7418.   \ifstrempty{#3}
  7419.    {\def\blx@tempc{\the\value{listcount}}}
  7420.    {\def\blx@tempc{#3}}%
  7421.   \def\blx@tempd{#1}%
  7422.   \blx@resolve@annotation@label{\blx@tempd}%
  7423.   \ifcsdef{abx@annotation@literal@part@\blx@tempd @#2@\blx@tempc @#4}}
  7424.  
  7425. % labeldatesource has a slightly different format than other <field>sources
  7426. % that's one reason for a dedicated command, the other being that this command
  7427. % is probably only used in contexts where \currentfield is not defined, so
  7428. % the <datetype> argument is always required
  7429. % [<annotationname>]{<datetype>}{<annotation>}
  7430. \newcommand*{\blx@imc@ifdateannotation}[3][]{%
  7431.   \ifblank{#1}
  7432.    {\def\blx@tempa{default}}
  7433.    {\def\blx@tempa{#1}}%
  7434.   \def\blx@tempb{#2}%
  7435.   \ifcsundef{abx@field@\blx@tempb source}
  7436.    {}%
  7437.     {\letcs\blx@tempa{abx@field@\blx@tempb source}%
  7438.      \edef\blx@tempb{\blx@tempb date}}%
  7439.   \ifinlistcs{#3}{abx@annotation@field@\blx@tempb @\blx@tempa}}
  7440.  
  7441. % [<annotationname>]{<datetype>}
  7442. \newcommand*{\blx@imc@hasdateannotation}[2][]{%
  7443.   \ifblank{#1}
  7444.    {\def\blx@tempa{default}}
  7445.    {\def\blx@tempa{#1}}%
  7446.   \def\blx@tempb{#2}%
  7447.   \ifcsundef{abx@field@\blx@tempb source}
  7448.    {}%
  7449.     {\letcs\blx@tempa{abx@field@\blx@tempb source}%
  7450.      \edef\blx@tempb{\blx@tempb date}}%
  7451.   \ifboolexpr { test {\ifcsdef{abx@annotation@field@\blx@tempb @\blx@tempa}}
  7452.                or
  7453.                test {\ifcsdef{abx@annotation@literal@field@\blx@tempb @\blx@tempa}} }}
  7454.  
  7455. % [<annotationname>]{<datetype>}
  7456. \newcommand*{\blx@imc@getdateannotation}[2][]{%
  7457.   \ifblank{#1}
  7458.    {\def\blx@tempa{default}}
  7459.    {\def\blx@tempa{#1}}%
  7460.   \def\blx@tempb{#1}%
  7461.   \ifcsundef{abx@field@\blx@tempb source}
  7462.    {}%
  7463.     {\letcs\blx@tempb{abx@field@\blx@tempb source}%
  7464.      \edef\blx@tempb{\blx@tempb date}}%
  7465.   \ifcsdef{abx@annotation@literal@field@\blx@tempb @\blx@tempa}
  7466.    {\csuse{abx@annotation@literal@field@\blx@tempb @\blx@tempa}}
  7467.    {}}
  7468.  
  7469. \blx@regimcs{\iffieldannotation \ifitemannotation \ifpartannotation
  7470.  \ifdateannotation \getfieldannotation \getitemannotation \getpartannotation
  7471.  \getdateannotation \hasfieldannotation \hasitemannotation \haspartannotation
  7472.  \hasdateannotation}
  7473.  
  7474. % {<fieldname>}
  7475. \def\blx@resolve@annotation@label#1{%
  7476.   \ifcsundef{abx@field@#1source}
  7477.    {}%
  7478.     {\letcs\blx@tempa{abx@field@#1source}}}
  7479.  
  7480. \begingroup
  7481. \catcode`\<=12
  7482. \catcode`\>=12
  7483. \uccode`\<=`\ %
  7484. \uccode`\>=\endlinechar
  7485. \uppercase{\gdef\blx@bbl@verbadd@i<#1>}{%
  7486.   \endgroup
  7487.   \edef\NewValue{\NewValue\detokenize{#1}}}
  7488. \uppercase{\gdef\blx@bbl@verbladd@i<#1>}{%
  7489.   \endgroup
  7490.   \eappto\blx@tempc{{\detokenize{#1}}}}%
  7491. \endgroup
  7492.  
  7493. % {<counter>}{<value>}
  7494. \protected\long\def\blx@bbl@cntdef#1#2{%
  7495.   \csxappto\blx@bbl@data{%
  7496.     \csname c@#1\endcsname#2\relax}}
  7497.  
  7498. % {<boolean>}
  7499. \protected\def\blx@bbl@booltrue#1{%
  7500.   \csgappto\blx@bbl@data{%
  7501.     \toggletrue{abx@bool@#1}}}
  7502.  
  7503. \protected\def\blx@bbl@boolfalse#1{%
  7504.   \csgappto\blx@bbl@data{%
  7505.     \togglefalse{abx@bool@#1}}}
  7506.  
  7507. % {<list>}{<itemcount>}{<value>}
  7508. \protected\def\blx@bbl@listdef#1#2#3{%
  7509.   \def\NewCount{#2}%
  7510.   \def\NewValue{#3}%
  7511.   \ifcsdef{blx@lih@#1}
  7512.    {\csname blx@lih@#1\endcsname{#3}%
  7513.      \ifdefvoid\NewValue}
  7514.     {\@secondoftwo}
  7515.       {}
  7516.        {\csxappto\blx@bbl@data{%
  7517.           \csname c@#1\endcsname\NewCount\relax
  7518.           \def\expandafter\noexpand\csname abx@list@#1\endcsname
  7519.           {\expandonce\NewValue}}}}
  7520.  
  7521. % {<name>}{<itemcount>}{<nameoptions>}{<value>}
  7522. \protected\def\blx@bbl@namedef#1#2#3#4{%
  7523.   \def\NewCount{#2}%
  7524.   \def\NewOption{#3}%
  7525.   \def\NewValue{#4}%
  7526.   \ifcsdef{blx@nih@#1}
  7527.    {\csname blx@nih@#1\endcsname{#4}%
  7528.      \ifdefvoid\NewValue}
  7529.     {\@secondoftwo}
  7530.       {}
  7531.        {\csxappto\blx@bbl@data{%
  7532.           \csname c@#1\endcsname\NewCount\relax
  7533.           \def\expandafter\noexpand\csname abx@name@#1\endcsname
  7534.           {{\expandonce\NewOption}{\expandonce\NewValue}}}}}
  7535.  
  7536. % blx@setp@<rs>@<sp> = map of set parent <sp> in a refsection <rs> to csv
  7537. %                      of set children
  7538. % blx@seti@<rs>@<sc> = position of set child <sc> in entry set in
  7539. %                      refsection <rs>
  7540. % blx@setc@<rs>@<sc> = map of set child <sc> in refsection <rs> to set parent
  7541.  
  7542. % {<entrykey>,...}
  7543. \protected\def\blx@bbl@set#1{%
  7544.   \blx@bbl@fieldedef{entryset}{\detokenize{#1}}%
  7545.   \csxdef{blx@setp@\the\c@refsection @\abx@field@entrykey}{\detokenize{#1}}%
  7546.   \begingroup
  7547.   \blx@tempcnta\z@
  7548.   \expandafter\forcsvlist
  7549.   \expandafter\blx@bbl@set@i
  7550.   \expandafter{\detokenize{#1}}%
  7551.   \endgroup}
  7552.  
  7553. \def\blx@bbl@set@i#1{%
  7554.   \advance\blx@tempcnta\@ne
  7555.   \csxdef{blx@seti@\the\c@refsection @#1}{\the\blx@tempcnta}}
  7556.  
  7557. % {<entrykey>}
  7558. \protected\def\blx@bbl@inset#1{%
  7559.   \toggletrue{blx@setonly}%
  7560.   \blx@bbl@fieldedef{entryset}{\detokenize{#1}}%
  7561.   \csxdef{blx@setc@\the\c@refsection @\abx@field@entrykey}{\detokenize{#1}}}
  7562.  
  7563. % {<entrykey>}
  7564. \protected\def\blx@bbl@xref#1{}% No-op to avoid an error with BibTeX .bbl
  7565.  
  7566. % {<keyword>,...}
  7567. \protected\def\blx@bbl@keyw#1{%
  7568.   \forcsvlist{\blx@addkeyword{\abx@field@entrykey}}{#1}%
  7569.   \blx@bbl@fielddef{keywords}{#1}}
  7570.  
  7571. \def\blx@addkeyword#1#2{%
  7572.   \listcsxadd{blx@keyw@\the\c@refsection @\detokenize{#2}}{#1}}
  7573.  
  7574. % {<options>}
  7575. \protected\long\def\blx@bbl@options#1{%
  7576.   \begingroup
  7577.   \let\blx@tempa\@empty
  7578.   \forcsvlist\blx@bbl@options@i{#1}%
  7579.   \edef\blx@tempa{%
  7580.     \endgroup
  7581.     \ifx\blx@tempa\@empty
  7582.     \else
  7583.       \def\noexpand\abx@field@options{\expandonce\blx@tempa}%
  7584.     \fi}%
  7585.   \blx@tempa}
  7586.  
  7587. \long\def\blx@bbl@options@i#1{\blx@bbl@options@ii#1==&}
  7588.  
  7589. \long\def\blx@bbl@options@ii#1=#2=#3&{%
  7590.   \ifcsundef{KV@blx@opt@ent@#1}
  7591.     {\blx@warning@noline{%
  7592.        Ignoring undefined option '#1'\MessageBreak
  7593.        at entry '\abx@field@entrykey'}}
  7594.     {\eappto\blx@tempa{%
  7595.        \ifx\blx@tempa\@empty\else,\fi
  7596.        \unexpanded{#1}\ifblank{#2}{}{=\unexpanded{#2}}}}}
  7597.  
  7598. \def\blx@ifdata#1{%
  7599.   \ifcsdef{blx@data@\the\c@refsection @\blx@refcontext@context @#1}}
  7600. \let\blx@imc@ifentryinbib\blx@ifdata
  7601.  
  7602. \def\blx@getdata#1{%
  7603.   \csuse{blx@data@\the\c@refsection @\blx@refcontext@context @#1}%
  7604.   \blx@adjustyears
  7605.   \blx@getlabeldata
  7606.   \blx@aliasfields
  7607.   \blx@setcitecounter}
  7608.  
  7609. \def\blx@adjustyears{%
  7610.   % All dates by default are output from biber in astronomical era with a year 0
  7611.   % So, if we are ouputting BCE/BC era, we need to adjust the years by +1
  7612.   \def\do##1{%
  7613.     \ifdefstring\blx@dateera{astronomical}
  7614.      {}
  7615.      {\ifcsdef{abx@field@##1year}
  7616.        {\csuse{if##1dateera}{bce}
  7617.          {\csedef{abx@field@##1year}{\number\numexpr\csuse{abx@field@##1year}+1}}
  7618.          {}}
  7619.        {}%
  7620.        \ifcsdef{abx@field@##1endyear}
  7621.         {\csuse{if##1enddateera}{bce}
  7622.           {\csedef{abx@field@##1endyear}{\number\numexpr\csuse{abx@field@##1endyear}+1}}
  7623.           {}}
  7624.         {}}%
  7625.       {}}%
  7626.   \abx@dodatetypes}
  7627.  
  7628. \def\blx@getlabeldata{%
  7629.   % Here we resolve label* bib fields to their real fields. In fact, currently biber resolves
  7630.   % the label* fields too, as it needs to do this to generate various internal
  7631.   % counters for tracking things like singletitle etc. internally. However, it does not output
  7632.   % the resolved values to the .bbl. It is conceptually neater to have just the calculated label*
  7633.   % source field in the .bbl and let biblatex resolve the label* field using the label*source
  7634.   % fields. However, currently there is no way/need to vary the label* resolution to pick up a
  7635.   % different target field in biblatex and so practically, this resolution is being done twice,
  7636.   % once by biber, once by biblatex. It is possible in the future that it would be useful to
  7637.   % to change the resolution of the label* fields dynamically in a style/document and so this
  7638.   % biblatex-side resolution remains.
  7639.   %
  7640.   % An unanswered question is whether such dynamic resolution causes problems due to the fact
  7641.   % that biber uses the label* field to generate counters internally and changing the
  7642.   % label* field resolution in biblatex would occur after such counters have been used to
  7643.   % generate the .bbl
  7644.   % This could all be removed from biblatex if necessary and biber could output all resolved
  7645.   % label* fields to the .bbl but then it potentially removes control of such things from
  7646.   % macros
  7647.   %
  7648.   % fields
  7649.   \def\do##1{%
  7650.     \ifcsundef{abx@field@##1source}
  7651.      {}%
  7652.       {\csletcs{abx@field@##1}{abx@field@\csuse{abx@field@##1source}}}}%
  7653.   \dolistloop\abx@rfields%
  7654.   % names
  7655.   \def\do##1{%
  7656.     \ifcsundef{abx@field@##1source}
  7657.     {}
  7658.     {\csname c@##1\expandafter\endcsname\expandafter\the\csname c@\csuse{abx@field@##1source}\endcsname
  7659.      \csletcs{abx@name@##1}{abx@name@\csuse{abx@field@##1source}}}}%
  7660.   \dolistloop\abx@rnames%
  7661.   % Resolve labeldate
  7662.   % Note that here we can't refer to labelyear as this is where we create it, hence the
  7663.   % complications in constructing test names etc.
  7664.   % This also shows why biber shouldn't resolve labeldate fields as we have to add
  7665.   % circa/uncertain/era etc. information to them and that has to be done here.
  7666.   \ifundef\abx@field@labeldatesource
  7667.     {}
  7668.    {\ifcsundef{abx@field@\abx@field@labeldatesource year}
  7669.        % \DeclareLabeldate resolved to a literal/localisation string or a non-date field
  7670.        % in which case we only set labelyear.
  7671.        {\ifcsundef{abx@field@\abx@field@labeldatesource}
  7672.          % \DeclareLabeldate resolved to a literal/localisation string
  7673.          {\edef\abx@field@labelyear{\abx@field@labeldatesource}}
  7674.          % \DeclareLabeldate resolved to a non-date field.  Not safe to \edef because
  7675.          % such contents could contain arbitrary macros, unlike ETDF sourced labeldatesource values
  7676.          {\letcs\abx@field@labelyear{abx@field@\abx@field@labeldatesource}}}
  7677.        % \DeclareLabeldate resolved to a date field name prefix like '', 'event', 'url'
  7678.        % or 'orig'
  7679.        {% labeldateera/labelenddateera
  7680.         \ifcsdef{abx@field@\abx@field@labeldatesource dateera}
  7681.          {\edef\abx@field@labeldateera{\csuse{abx@field@\abx@field@labeldatesource dateera}}}
  7682.          {}%
  7683.         \ifcsdef{abx@field@\abx@field@labeldatesource enddateera}
  7684.          {\edef\abx@field@labelenddateera{\csuse{abx@field@\abx@field@labeldatesource enddateera}}}
  7685.          {}%
  7686.         % labelyear/labelendyear
  7687.         \ifcsdef{abx@field@\abx@field@labeldatesource year}
  7688.          {\edef\abx@field@labelyear{\csuse{abx@field@\abx@field@labeldatesource year}}}
  7689.          {}%
  7690.         \ifcsdef{abx@field@\abx@field@labeldatesource endyear}
  7691.          {\edef\abx@field@labelendyear{\csuse{abx@field@\abx@field@labeldatesource endyear}}}
  7692.          {}%
  7693.         % labelmonth
  7694.         \ifcsdef{abx@field@\abx@field@labeldatesource month}
  7695.          {\edef\abx@field@labelmonth{\csuse{abx@field@\abx@field@labeldatesource month}}}
  7696.          {}%
  7697.         \ifcsdef{abx@field@\abx@field@labeldatesource endmonth}
  7698.          {\edef\abx@field@labelendmonth{\csuse{abx@field@\abx@field@labeldatesource endmonth}}}
  7699.          {}%
  7700.         % labelday/labelendday
  7701.         \ifcsdef{abx@field@\abx@field@labeldatesource day}
  7702.          {\edef\abx@field@labelday{\csuse{abx@field@\abx@field@labeldatesource day}}}
  7703.          {}%
  7704.         \ifcsdef{abx@field@\abx@field@labeldatesource endday}
  7705.          {\edef\abx@field@labelendday{\csuse{abx@field@\abx@field@labeldatesource endday}}}
  7706.          {}%
  7707.         % labelhour/labelendhour
  7708.         \ifcsdef{abx@field@\abx@field@labeldatesource hour}
  7709.          {\edef\abx@field@labelhour{\csuse{abx@field@\abx@field@labeldatesource hour}}}
  7710.          {}%
  7711.         \ifcsdef{abx@field@\abx@field@labeldatesource endhour}
  7712.          {\edef\abx@field@labelendhour{\csuse{abx@field@\abx@field@labeldatesource endhour}}}
  7713.          {}%
  7714.         % labelminute/labelendminute
  7715.         \ifcsdef{abx@field@\abx@field@labeldatesource minute}
  7716.          {\edef\abx@field@labelminute{\csuse{abx@field@\abx@field@labeldatesource minute}}}
  7717.          {}%
  7718.         \ifcsdef{abx@field@\abx@field@labeldatesource endminute}
  7719.          {\edef\abx@field@labelendminute{\csuse{abx@field@\abx@field@labeldatesource endminute}}}
  7720.          {}%
  7721.         % labelsecond/labelendsecond
  7722.         \ifcsdef{abx@field@\abx@field@labeldatesource second}
  7723.          {\edef\abx@field@labelsecond{\csuse{abx@field@\abx@field@labeldatesource second}}}
  7724.          {}%
  7725.         \ifcsdef{abx@field@\abx@field@labeldatesource endsecond}
  7726.          {\edef\abx@field@labelendsecond{\csuse{abx@field@\abx@field@labeldatesource endsecond}}}
  7727.          {}%
  7728.         % labeltimezone/labelendtimezone
  7729.         \ifcsdef{abx@field@\abx@field@labeldatesource timezone}
  7730.          {\edef\abx@field@labeltimezone{\csuse{abx@field@\abx@field@labeldatesource timezone}}}
  7731.          {}%
  7732.         \ifcsdef{abx@field@\abx@field@labeldatesource endtimezone}
  7733.          {\edef\abx@field@labelendtimezone{\csuse{abx@field@\abx@field@labeldatesource endtimezone}}}
  7734.          {}%
  7735.         % labelseason/labelendseason
  7736.         \ifcsdef{abx@field@\abx@field@labeldatesource season}
  7737.          {\edef\abx@field@labelseason{\csuse{abx@field@\abx@field@labeldatesource season}}}
  7738.          {}%
  7739.         \ifcsdef{abx@field@\abx@field@labeldatesource endseason}
  7740.          {\edef\abx@field@labelendseason{\csuse{abx@field@\abx@field@labeldatesource endseason}}}
  7741.          {}%
  7742.         % labeldateunspecified
  7743.         \ifcsdef{abx@field@\abx@field@labeldatesource dateunspecified}
  7744.          {\csletcs{abx@field@labeldateunspecified}{abx@field@\abx@field@labeldatesource dateunspecified}}
  7745.          {}%
  7746.         % labeldatecirca/labelenddatecirca
  7747.         \ifcsdef{etb@tgl@abx@bool@\abx@field@labeldatesource datecirca}
  7748.          {\csletcs{etb@tgl@abx@bool@labeldatecirca}{etb@tgl@abx@bool@\abx@field@labeldatesource datecirca}}
  7749.          {}%
  7750.         \ifcsdef{etb@tgl@abx@bool@\abx@field@labeldatesource enddatecirca}
  7751.          {\csletcs{etb@tgl@abx@bool@labelenddatecirca}{etb@tgl@abx@bool@\abx@field@labeldatesource enddatecirca}}
  7752.          {}%
  7753.         % labeldatejulian/labelenddatejulian
  7754.         \ifcsdef{etb@tgl@abx@bool@\abx@field@labeldatesource datejulian}
  7755.          {\csletcs{etb@tgl@abx@bool@labeldatejulian}{etb@tgl@abx@bool@\abx@field@labeldatesource datejulian}}
  7756.          {}%
  7757.         \ifcsdef{etb@tgl@abx@bool@\abx@field@labeldatesource enddatejulian}
  7758.          {\csletcs{etb@tgl@abx@bool@labelenddatejulian}{etb@tgl@abx@bool@\abx@field@labeldatesource enddatejulian}}
  7759.          {}%
  7760.         % labeldateuncertain/labelenddateuncertain
  7761.         \ifcsdef{etb@tgl@abx@bool@\abx@field@labeldatesource dateuncertain}
  7762.          {\csletcs{etb@tgl@abx@bool@labeldateuncertain}{etb@tgl@abx@bool@\abx@field@labeldatesource dateuncertain}}
  7763.          {}%
  7764.         \ifcsdef{etb@tgl@abx@bool@\abx@field@labeldatesource enddateuncertain}
  7765.          {\csletcs{etb@tgl@abx@bool@labelenddateuncertain}{etb@tgl@abx@bool@\abx@field@labeldatesource enddateuncertain}}
  7766.          {}%
  7767.         % labeldateunknown/labelenddateunknown
  7768.         \ifcsdef{etb@tgl@abx@bool@\abx@field@labeldatesource dateunknown}
  7769.          {\csletcs{etb@tgl@abx@bool@labeldateunknown}{etb@tgl@abx@bool@\abx@field@labeldatesource dateunknown}}
  7770.          {}%
  7771.         \ifcsdef{etb@tgl@abx@bool@\abx@field@labeldatesource enddateunknown}
  7772.          {\csletcs{etb@tgl@abx@bool@labelenddateunknown}{etb@tgl@abx@bool@\abx@field@labeldatesource enddateunknown}}
  7773.          {}}}}
  7774.  
  7775. % This gets the entry data for a citation
  7776. \def\blx@getdata@cite#1{%
  7777.   \blx@getdata{#1}%
  7778.   % Inject the relevant set parent fields like labelnumber/labelprefix into child
  7779.   \ifcsdef{blx@setc@\the\c@refsection @#1}
  7780.    {\blx@ifdata{#1}
  7781.       {\def\abx@field@childentrykey{#1}%LEGACY(<3.8)
  7782.         \edef\abx@field@childentrytype{\abx@field@entrytype}%LEGACY(<3.8)
  7783.         \begingroup
  7784.         \expandafter\expandafter\expandafter\blx@getdata\expandafter\expandafter\expandafter{%
  7785.           \csname blx@setc@\the\c@refsection @#1\endcsname}%
  7786.         \let\blx@tempa\@empty
  7787.         % Inject labelnumber if it exists
  7788.         \ifdef\abx@field@labelnumber
  7789.           {\appto\blx@tempa{\def\noexpand\abx@field@labelnumber{\abx@field@labelnumber}}}
  7790.          {}%
  7791.         % Inject labelprefix if it exists
  7792.         \ifdef\abx@field@labelprefix
  7793.           {\appto\blx@tempa{\def\noexpand\abx@field@labelprefix{\abx@field@labelprefix}}}
  7794.          {}%
  7795.         % Inject labelalpha if it exists
  7796.         \ifdef\abx@field@labelalpha
  7797.           {\appto\blx@tempa{\def\noexpand\abx@field@labelalpha{\abx@field@labelalpha}}}
  7798.          {}%
  7799.         % Inject extraalpha if it exists
  7800.         \ifdef\abx@field@extraalpha
  7801.           {\appto\blx@tempa{\def\noexpand\abx@field@extraalpha{\abx@field@extraalpha}}}
  7802.          {}%
  7803.         % Perform the injection
  7804.         \edef\blx@tempb{\endgroup\blx@tempa}%
  7805.         \blx@tempb}
  7806.        {}}
  7807.    {}%
  7808.   \ifcsdef{blx@seti@\the\c@refsection @#1}
  7809.    {\letcs\abx@field@entrysetcount{blx@seti@\the\c@refsection @#1}}
  7810.    {}}
  7811.  
  7812. \def\blx@execute{%
  7813.   \blx@imc@thefield{execute}}
  7814.  
  7815. \def\blx@setoptions@entry{%
  7816.   \blx@imc@iffieldundef{options}
  7817.    {}
  7818.    {\begingroup
  7819.     \edef\blx@tempa{\endgroup
  7820.       \noexpand\setkeys{blx@opt@ent}{\abx@field@options}}%
  7821.      \blx@tempa
  7822.      \blx@checkoptions@entry}}
  7823.  
  7824. \def\blx@setoptions@type#1{%
  7825.   \ifcsdef{blx@opts@type@#1}
  7826.    {\begingroup
  7827.     \edef\blx@tempa{\endgroup
  7828.       \noexpand\setkeys{blx@opt@typ}{\csuse{blx@opts@type@#1}}}%
  7829.      \blx@tempa}
  7830.     {}}
  7831.  
  7832. \def\blx@checkoptions@global{}
  7833. \def\blx@checkoptions@type{}
  7834. \def\blx@checkoptions@entry{}
  7835.  
  7836. \def\blx@entrysetcount{%
  7837.   \ifdef\abx@field@entrykey
  7838.     {\ifcsdef{blx@seti@\the\c@refsection @\abx@field@entrykey}
  7839.        {\letcs\abx@field@entrysetcount{%
  7840.           blx@seti@\the\c@refsection @\abx@field@entrykey}}
  7841.        {}}
  7842.    {}}
  7843.  
  7844. % {<section>}
  7845. \def\blx@bbl@refsection#1{%
  7846.   \begingroup
  7847.   \c@refsection#1\relax}
  7848.  
  7849. \def\blx@bbl@endrefsection{%
  7850.   \iftoggle{blx@addset}
  7851.    {\blx@addset
  7852.     \global\togglefalse{blx@addset}}
  7853.    {}%
  7854.   \endgroup}
  7855.  
  7856. % {<entrykey>}
  7857. \protected\def\blx@bbl@missing#1{%
  7858.   \listcsxadd{blx@miss@\the\c@refsection}{\detokenize{#1}}%
  7859.   \blx@warning@noline{%
  7860.     The following entry could not be found\MessageBreak
  7861.     in the database%
  7862.     \ifnumgreater\c@refsection\z@
  7863.       { (refsection \the\c@refsection)}
  7864.      {}:\MessageBreak
  7865.    \detokenize{#1}\MessageBreak
  7866.    Please verify the spelling and rerun\MessageBreak
  7867.    LaTeX afterwards}}
  7868.  
  7869. % We create an alias resolving macro and also a list of aliases
  7870. % which we need to add to the .bcf. We need to resolve the aliases
  7871. % for internal use but we always want the aliases themselves in the .bcf
  7872. % so that biber can correctly use and resolve them too.
  7873. \protected\def\blx@bbl@keyalias#1#2{%
  7874.   \csgdef{blx@keyalias@\the\c@refsection @#1}{\detokenize{#2}}%
  7875.   \listcsgadd{blx@keyaliases@\the\c@refsection}{#1}}
  7876.  
  7877. % blx@dlist@list@<section>@<refcontext> - a list of list items in a refcontext in a
  7878. %                                     section (for tracking bibliography lists,
  7879. %                                     obeys skipbiblist)
  7880. % blx@dlist@entry@<section>@<list> - a list of normal entries in a list in a
  7881. %                                      section (for tracking bibliographies,
  7882. %                                      obeys skipbib)
  7883. % blx@dlist@centry@<section>@<list> - a list of normal entries in a list in a
  7884. %                                       section (for tracking citations,
  7885. %                                       obeys skipbib). Same as @entry@ but
  7886. %                                       with added set children
  7887.  
  7888. % {<entrykey>}{<entrytype>}{<options>}
  7889. \protected\def\blx@bbl@entry#1#2#3{%
  7890.   \begingroup
  7891.   \edef\abx@field@entrykey{\detokenize{#1}}%
  7892.   \blx@setoptions@type{#2}%
  7893.   \blx@bbl@options{#3}%
  7894.   \blx@setoptions@entry
  7895.   \edef\blx@bbl@data{blx@data@\the\c@refsection @\blx@dlist@name @\abx@field@entrykey}%
  7896.   \blx@bbl@addfield{entrykey}{\abx@field@entrykey}%
  7897.   \listxadd\blx@entries{\abx@field@entrykey}%
  7898.   \blx@bbl@addfield{entrytype}{#2}%
  7899.   \csuse\blx@bbl@data
  7900.   \blx@imc@iffieldundef{options}
  7901.    {}
  7902.    {\blx@bbl@fieldedef{options}{\expandonce\abx@field@options}}}
  7903.  
  7904. \protected\def\blx@bbl@endentry{%
  7905.   \csuse\blx@bbl@data
  7906.   \ifcsundef{blx@pref@\the\c@refsection @\abx@field@entrykey}
  7907.    {}
  7908.    {\blx@addpageref{\abx@field@entrykey}}%
  7909.   \nottoggle{blx@setonly}
  7910.    {}
  7911.    {\global\toggletrue{blx@addset}%
  7912.      \toggletrue{blx@skipbib}%
  7913.      \toggletrue{blx@skipbiblist}%
  7914.      \toggletrue{blx@skiplab}}%
  7915.   \nottoggle{blx@skipbib}
  7916.    {\expandafter\ifstrequal\expandafter{\blx@dlist@type}{entry}
  7917.       {\listcsxadd{blx@dlist@entry@\the\c@refsection @\blx@dlist@name}{\abx@field@entrykey}%
  7918.         \listcsxadd{blx@dlist@centry@\the\c@refsection @\blx@dlist@name}{\abx@field@entrykey}%
  7919.         \listcsxadd{blx@type@\the\c@refsection @\abx@field@entrytype}{\abx@field@entrykey}%
  7920.         \ifdef\abx@field@entrysubtype
  7921.           {\listcsxadd{blx@subt@\the\c@refsection @\abx@field@entrysubtype}{\abx@field@entrykey}}
  7922.          {}}
  7923.       {}}%
  7924.     {}%
  7925.   \nottoggle{blx@skipbiblist}
  7926.    {\expandafter\ifstrequal\expandafter{\blx@dlist@type}{list}
  7927.      {\blx@bbl@labelfields
  7928.        \listcsxadd{blx@dlist@\blx@dlist@type @\the\c@refsection @\blx@dlist@name}{\abx@field@entrykey}}
  7929.      {}}%
  7930.     {}%
  7931.   \nottoggle{blx@skiplab}
  7932.    {\iftoggle{blx@labelnumber}
  7933.       {\blx@bbl@labelnumber}
  7934.       {}%
  7935.      \iftoggle{blx@labelalpha}
  7936.       {\blx@bbl@labelalpha}
  7937.       {}%
  7938.      \iftoggle{blx@labeltitle}
  7939.       {\blx@bbl@labeltitle}
  7940.       {}%
  7941.      \iftoggle{blx@labeltitleyear}
  7942.       {\blx@bbl@labeltitleyear}
  7943.       {}%
  7944.      \iftoggle{blx@labeldateparts}
  7945.       {\blx@bbl@labeldate}
  7946.       {}%
  7947.      \blx@bbl@labelname}
  7948.     {}%
  7949.   \blx@bbl@titles
  7950.   \blx@bbl@hooks
  7951.   \endgroup}
  7952.  
  7953. % This, at the end of the .bbl, puts any set parent children into the
  7954. % current context sort list of citations (a separate list *@centry@* to the
  7955. % bibliography *@entry@* which doesn't want the children adding if they weren't
  7956. % cited) as this is needed for the subentry citing
  7957. % when sortcites is enabled as for sortcites, the current context sorting list
  7958. % is used and the parent set of a subentry is not necessarily
  7959. % available in the current context sortlist.
  7960. \def\blx@addset{%
  7961.   \begingroup
  7962.   \ifcsdef{blx@dlist@centry@\the\c@refsection @\blx@refcontext@context}
  7963.    {\letcs\blx@tempa{blx@dlist@centry@\the\c@refsection @\blx@refcontext@context}%
  7964.      \global\cslet{blx@dlist@centry@\the\c@refsection @\blx@refcontext@context}\@empty
  7965.     \forlistloop\blx@addset@i\blx@tempa}
  7966.    {\blx@warning@noline{Sorting template has changed}}%
  7967.   \endgroup}
  7968.  
  7969. \def\blx@addset@i#1{%
  7970.   \listcsgadd{blx@dlist@centry@\the\c@refsection @\blx@refcontext@context}{#1}%
  7971.   \ifcsdef{blx@setp@\the\c@refsection @#1}
  7972.     {\expandafter\expandafter\expandafter\forcsvlist
  7973.      \expandafter\expandafter\expandafter\blx@addset@ii
  7974.      \expandafter\expandafter\expandafter{%
  7975.        \csname blx@setp@\the\c@refsection @#1\endcsname}}
  7976.     {}}
  7977.  
  7978. \def\blx@addset@ii#1{%
  7979.   \listcsgadd{blx@dlist@centry@\the\c@refsection @\blx@refcontext@context}{#1}}
  7980.  
  7981. % {<csname>}{<field>/<format>}{<field>}
  7982. \def\abx@flfw@getfieldformat#1#2#3{%
  7983.   \blx@getformat\abx@tmp@theformat{ffd}{#2}{#3}%
  7984.   \csletcs{#1}{abx@tmp@theformat}}
  7985.  
  7986. \def\blx@labelwidth@resetlocal{%
  7987.   \locallabelnumberwidth0pt\relax
  7988.   \locallabelalphawidth0pt\relax
  7989.   \def\do##1{%
  7990.     \csname local##1width\endcsname0pt\relax}%
  7991.   \abx@dolabelfields}
  7992.  
  7993. \def\blx@labelwidth@settolocal{%
  7994.   \labelnumberwidth\locallabelnumberwidth
  7995.   \labelalphawidth\locallabelalphawidth
  7996.   \def\do##1{%
  7997.     \csname ##1width\endcsname\csname local##1width\endcsname}%
  7998.   \abx@dolabelfields}
  7999.  
  8000. \def\blx@locallabelwidth#1{%
  8001.   \blx@labelwidth@resetlocal
  8002.   \let\blx@do\blx@lengthitem
  8003.   \let\blx@done\relax
  8004.   \blx@listloop{#1}%
  8005.   \blx@labelwidth@settolocal}
  8006.  
  8007. % {<prefix for labelwidth fields>}
  8008. \def\blx@bbl@labelnumberwidth@numeric#1{%
  8009.   \abx@flfw@getfieldformat{abx@flfw@labelnumberwidth}{labelnumberwidth}{}%
  8010.   \abx@flfw@getfieldformat{abx@flfw@labelprefix}{labelprefix}{}%
  8011.   \abx@flfw@getfieldformat{abx@flfw@labelnumber}{labelnumber}{}%
  8012.     \iftoggle{blx@defernumbers}
  8013.      {\ifundef\abx@field@localnumber
  8014.        {\numdef\abx@field@localnumber{0}}%
  8015.         {}}
  8016.       {\ifundef\abx@field@localnumber
  8017.          {\edef\abx@field@localnumber{%
  8018.             \csuse{blx@labelnumber@\the\c@refsection}}}
  8019.          {}}%
  8020.   \blx@setlabwidth{\csname #1labelnumberwidth\endcsname}{%
  8021.     \csuse{abx@flfw@labelnumberwidth}{%
  8022.       \ifdef\abx@field@labelprefix
  8023.         {\csuse{abx@flfw@labelprefix}{\abx@field@labelprefix}}
  8024.        {}%
  8025.       \csuse{abx@flfw@labelnumber}{\abx@field@localnumber}}}}
  8026.  
  8027. \def\blx@bbl@labelnumberwidth@shorthand#1{%
  8028.   \abx@flfw@getfieldformat{abx@flfw@labelnumberwidth}{labelnumberwidth}{}%
  8029.   \abx@flfw@getfieldformat{abx@flfw@labelnumber}{labelnumber}{}%
  8030.   \blx@setlabwidth{\csname #1labelnumberwidth\endcsname}{%
  8031.     \csuse{abx@flfw@labelnumberwidth}{%
  8032.       \csuse{abx@flfw@labelnumber}{\abx@field@shorthand}}}}
  8033.  
  8034. \def\blx@bbl@locallabelnumberwidth{%
  8035.   \ifdefempty\abx@field@localnumber
  8036.     {}
  8037.    {\ifundef\abx@field@shorthand
  8038.       {\blx@bbl@labelnumberwidth@numeric{local}}
  8039.       {\blx@bbl@labelnumberwidth@shorthand{local}}}}
  8040.  
  8041. % {<prefix for labelwidth fields>}
  8042. \def\blx@bbl@labelalphawidth#1{%
  8043.   \abx@flfw@getfieldformat{abx@flfw@labelalphawidth}{labelalphawidth}{}%
  8044.   \abx@flfw@getfieldformat{abx@flfw@labelprefix}{labelprefix}{}%
  8045.   \abx@flfw@getfieldformat{abx@flfw@labelalpha}{labelalpha}{}%
  8046.   \abx@flfw@getfieldformat{abx@flfw@extraalpha}{extraalpha}{}%
  8047.   \blx@setlabwidth{\csname #1labelalphawidth\endcsname}{%
  8048.     \csuse{abx@flfw@labelalphawidth}{%
  8049.       \ifdef\abx@field@labelprefix
  8050.         {\csuse{abx@flfw@labelprefix}{\abx@field@labelprefix}}
  8051.        {}%
  8052.       \csuse{abx@flfw@labelalpha}{\abx@field@labelalpha}%
  8053.       \ifundef\abx@field@extraalpha
  8054.         {}
  8055.        {\csuse{abx@flfw@extraalpha}{\abx@field@extraalpha}}}}}
  8056.  
  8057. \def\blx@bbl@locallabelalphawidth{%
  8058.   \ifundef\abx@field@labelalpha
  8059.     {}
  8060.    {\blx@bbl@labelalphawidth{local}}}
  8061.  
  8062. \def\blx@bbl@locallabelfields{\blx@bbl@labelfields@i{local}}
  8063.  
  8064. \def\blx@bbl@labelfields{\blx@bbl@labelfields@i{}}
  8065.  
  8066. % {<prefix for labelwidth fields>}
  8067. \def\blx@bbl@labelfields@i#1{%
  8068.   \def\do##1{%
  8069.     \ifcsundef{abx@field@##1}
  8070.      {}
  8071.      {\abx@flfw@getfieldformat{abx@flfw@##1width}{##1width}{##1}%
  8072.        \blx@setlabwidth{\csname #1##1width\endcsname}{%
  8073.          \csuse{abx@flfw@##1width}{\csname abx@field@##1\endcsname}}}}%
  8074.   \abx@dolabelfields}
  8075.  
  8076. \def\blx@bbl@labelnumber{%
  8077.   % Used at endentry, when reading .bbl
  8078.   % only do this for the global sorting list otherwise we increment
  8079.   % the labelnumbers for each sortlist
  8080.   \ifdefempty\abx@field@localnumber
  8081.     {}% only if omitnumbers=true
  8082.     {\ifundef\abx@field@shorthand
  8083.      {\iftoggle{blx@defernumbers}
  8084.         % only if defernumbers=true, we have to define localnumber to
  8085.         % something to stop labelnumberwidth def complaining on first
  8086.         % post-backend run since there will be nothing in the .aux yet
  8087.         % for defernums localnumbers. On the second post-backend run,
  8088.         % it will have a value correct for generating labelnumberwidth
  8089.         % We also have to define a dummy value for labelnumber here for
  8090.         % first post-backend runs otherwise references to labelnumber
  8091.         % in cite styles like numeric-comp will die.
  8092.         {\ifundef\abx@field@localnumber
  8093.          {\numdef\abx@field@localnumber{0}%
  8094.            \blx@bbl@fielddef{labelnumber}{0}}%
  8095.           {}}
  8096.        {\csnumgdef{blx@labelnumber@\the\c@refsection}{%
  8097.             \csuse{blx@labelnumber@\the\c@refsection}+1}%
  8098.           \edef\abx@field@localnumber{%
  8099.             \csuse{blx@labelnumber@\the\c@refsection}}%
  8100.           \blx@bbl@fieldedef{labelnumber}{\abx@field@localnumber}}%
  8101.         \iftoggle{blx@skipbib}
  8102.          {}
  8103.          {\blx@bbl@labelnumberwidth@numeric{}}}
  8104.      {\csgappto\blx@bbl@data{\let\abx@field@labelnumber\abx@field@shorthand}%
  8105.         \iftoggle{blx@skipbib}
  8106.          {}
  8107.          {\blx@bbl@labelnumberwidth@shorthand{}}}}}
  8108.  
  8109. \def\blx@bbl@labelalpha{%
  8110.    \ifundef\abx@field@labelalpha
  8111.      {}
  8112.     {\ifundef\abx@field@extraalpha
  8113.        {}
  8114.        {\ifnum\abx@field@extraalpha>\c@maxextraalpha
  8115.           \global\c@maxextraalpha\abx@field@extraalpha\relax
  8116.         \fi}%
  8117.       \iftoggle{blx@skipbib}
  8118.        {}
  8119.        {\blx@bbl@labelalphawidth{}}}}
  8120.  
  8121. \def\blx@bbl@labeltitle{%
  8122.   \ifundef\abx@field@extratitle
  8123.     {}
  8124.    {\ifnum\abx@field@extratitle>\c@maxextratitle
  8125.       \global\c@maxextratitle\abx@field@extratitle\relax
  8126.     \fi}}
  8127.  
  8128. \def\blx@bbl@labeltitleyear{%
  8129.   \ifundef\abx@field@extratitleyear
  8130.     {}
  8131.    {\ifnum\abx@field@extratitleyear>\c@maxextratitleyear
  8132.       \global\c@maxextratitleyear\abx@field@extratitleyear\relax
  8133.     \fi}}
  8134.  
  8135. \def\blx@bbl@labelname{%
  8136.   \ifundef\abx@field@extraname
  8137.     {}
  8138.    {\ifnum\abx@field@extraname>\c@maxextraname
  8139.       \global\c@maxextraname\abx@field@extraname\relax
  8140.     \fi}}
  8141.  
  8142. \def\blx@bbl@labeldate{%
  8143.   \ifundef\abx@field@extradate
  8144.     {}
  8145.    {\ifnum\abx@field@extradate>\c@maxextradate
  8146.       \global\c@maxextradate\abx@field@extradate\relax
  8147.     \fi}}
  8148.  
  8149. \def\blx@bbl@titles{%
  8150.   \ifundef\abx@field@indextitle
  8151.     {\csgappto\blx@bbl@data{%
  8152.        \let\abx@field@indextitle\abx@field@title}}
  8153.     {}%
  8154.   \ifundef\abx@field@indexsorttitle
  8155.     {\csgappto\blx@bbl@data{%
  8156.        \let\abx@field@indexsorttitle\abx@field@indextitle}}
  8157.     {}}
  8158.  
  8159. \def\blx@bbl@hooks{%
  8160.   \ifcsundef{blx@hook@bblitem@*}
  8161.    {\ifcsundef{blx@hook@bblitem@\abx@field@entrytype}
  8162.       {}
  8163.       {\csuse\blx@bbl@data
  8164.        \csuse{blx@hook@bblitem@\abx@field@entrytype}}}
  8165.    {\csuse\blx@bbl@data
  8166.     \csuse{blx@hook@bblitem@*}%
  8167.      \csuse{blx@hook@bblitem@\abx@field@entrytype}}}
  8168.  
  8169. \newrobustcmd*{\AtDataInput}[1][*]{\csgappto{blx@hook@bblitem@#1}}
  8170. \@onlypreamble\AtDataInput
  8171.  
  8172. \def\blx@setlabwidth#1#2{%
  8173.   \begingroup
  8174.   \settowidth{\@tempdima}{\bibfont#2}%
  8175.   \ifnum\@tempdima>#1%
  8176.     \global#1\@tempdima
  8177.   \fi
  8178.   \endgroup}
  8179.  
  8180. \def\blx@bblstart{%
  8181.   \let\preamble\blx@bbl@preamble
  8182.   \let\warn\blx@bbl@thewarn
  8183.   \let\refsection\blx@bbl@refsection
  8184.   \let\endrefsection\blx@bbl@endrefsection
  8185.   \let\entry\blx@bbl@entry
  8186.   \let\endentry\blx@bbl@endentry
  8187.   \let\missing\blx@bbl@missing
  8188.   \let\keyalias\blx@bbl@keyalias
  8189.   \let\datalist\blx@bbl@dlist
  8190.   \let\enddatalist\blx@bbl@enddlist
  8191.   \let\set\blx@bbl@set
  8192.   \let\inset\blx@bbl@inset
  8193.   \let\xref\blx@bbl@xref % A No-op for Biber
  8194.   \let\keyw\blx@bbl@keyw
  8195.   \let\name\blx@bbl@namedef
  8196.   \let\list\blx@bbl@listdef
  8197.   \let\field\blx@bbl@fielddef
  8198.   \let\range\blx@bbl@rangedef
  8199.   \let\strng\blx@bbl@stringdef
  8200.   \let\cnt\blx@bbl@cntdef
  8201.   \let\true\blx@bbl@booltrue
  8202.   \let\false\blx@bbl@boolfalse
  8203.   \let\verb\blx@bbl@verbdef
  8204.   \let\endverb\blx@bbl@verbend
  8205.   \let\lverb\blx@bbl@verbldef
  8206.   \let\endlverb\blx@bbl@verblend
  8207.   \let\annotation\blx@bbl@annotationdef}
  8208.  
  8209. \def\blx@bblend{%
  8210.   % Special warning for defernumbers when a citation cannot be found
  8211.   \iftoggle{blx@defernumbers}
  8212.    {\def\do##1{\ifinlist{##1}\blx@entries
  8213.                 {}
  8214.                  {\blx@warning@noline{%
  8215.                      citation '##1' was not found at all in the .bbl, bibliography labels cannot be generated, please correct the citation}}}%
  8216.      \dolistloop\blx@lastcites}
  8217.     {}}
  8218.  
  8219. % {<entrykey>}
  8220. % Get the saved information on which citations were mentioned last run
  8221. \protected\def\abx@aux@cite#1{%
  8222.   \listxadd\blx@lastcites{\detokenize{#1}}}
  8223.  
  8224. % {<refcontext>}
  8225. % Get the saved information on which refcontexts were mentioned last run
  8226. \protected\def\abx@aux@refcontext#1{%
  8227.   \listxadd\blx@lastrefcontexts{\detokenize{#1}}}
  8228.  
  8229. % {<sortingtemplatename>}
  8230. % Get the saved information on which shorthand sorting templates were mentioned last run
  8231. \protected\def\abx@aux@biblist#1{%
  8232.   \listgadd\blx@lastbiblists{#1}}
  8233.  
  8234. % Here we mustn't change the checksum if we used localnumbers from the
  8235. % .aux file as this means that deferred numbering is
  8236. % complete. Otherwise we get in an endless rerun loop because the
  8237. % checksum due to number changes is always different.
  8238. \AtEndDocument{%
  8239.   \def\abx@aux@number#1#2#3#4#5{%
  8240.     \ifblank{#5}
  8241.      {}
  8242.      {\nottoggle{blx@localnumber}
  8243.         {\blx@addchecksum{#1}{#5}}
  8244.         {}}}}
  8245.  
  8246. \AtEndDocument{%
  8247.   % Here we run some tests to decide if we need to issue re-run
  8248.   % messages in certain circumstances. In general, if we add/remove
  8249.   % any citations or add/remove any sorting templates, we need to re-run
  8250.   % biber. Also, if we have to re-run biber, we need to defer writing
  8251.   % the defernumbers .aux information because it will not yet be correct.
  8252.  
  8253.   % Test to see if we *removed* any citations since last run
  8254.   % (adding citations is dealt with naturally in \blx@citation@entry)
  8255.   % If so, give a rerun biber message. This also sets the
  8256.   % rerun biber toggle so defernums doesn't consume the localnumbers
  8257.   % in the .aux but instead, re-writes them, which is what we need.
  8258.   \begingroup
  8259.   \def\do#1{\ifinlist{#1}\blx@cites{}{\blx@logreq@active{}}\relax}%
  8260.   \dolistloop\blx@lastcites
  8261.   % Special case - if we are using sortingtemplate "none" anywhere, then changes
  8262.   % in citation order matter and we need to re-run biber. So a special test
  8263.   % to see if the cites from last run are identical in order. We have
  8264.   % already tested for more or less cites between runs by now, we are
  8265.   % testing here for exactly the same cites by treating the cite and
  8266.   % lastcite lists as strings and comparing them. This doesn't apply
  8267.   % to biblist sortingtemplates as nobody wants to sort biblists with
  8268.   % "none", since it makes no sense
  8269.   \ifinlist{none}\blx@sortingtemplatenames
  8270.    {\ifdefstrequal{\blx@cites}{\blx@lastcites}
  8271.      {}
  8272.      {\blx@logreq@active{}}}
  8273.    {}%
  8274.   % Test if we removed any mention of a reference context since last run
  8275.   % If we did, we need to re-run biber
  8276.   \def\do#1{\ifinlist{#1}\blx@refcontexts{}{\blx@logreq@active{}}\relax}%
  8277.   \dolistloop\blx@lastrefcontexts
  8278.   % Test if we added any mention of a reference context since last run
  8279.   % If we did, we need to re-run biber
  8280.   \def\do#1{\ifinlist{#1}\blx@lastrefcontexts{}{\blx@logreq@active{}}\relax}%
  8281.   \dolistloop\blx@refcontexts
  8282.   % Test if we removed any mention of a biblist since last run.
  8283.   % If we did, we need to re-run biber
  8284.   \def\do#1{\ifinlist{#1}\blx@biblists{}{\blx@logreq@active{}}\relax}%
  8285.   \dolistloop\blx@lastbiblists
  8286.   % Test to see if we added any mention of a biblist since last run.
  8287.   % If we did, we need to re-run biber
  8288.   \def\do#1{\ifinlist{#1}\blx@lastbiblists{}{\blx@logreq@active{}}\relax}%
  8289.   \dolistloop\blx@biblists
  8290.   % If we have to run biber or latex again and we are using defernumbers,
  8291.   % don't write the localnumber information to the .aux file yet as we will
  8292.   % potentially have to regenerate sorting order first in biber
  8293.   \iftoggle{blx@defernumbers}
  8294.    {\iftoggle{blx@runbiber}
  8295.      {}
  8296.      {\def\do#1{\blx@auxwrite\@mainaux{}{#1}}
  8297.       \dolistloop\blx@localnumaux}}
  8298.    {}%
  8299.   \endgroup}
  8300.  
  8301. % {<instcount>}{<entrykey>}{<refsection>}{<refcontext>}{<labelnumber>}
  8302. \protected\def\blx@aux@number#1#2#3#4#5{%
  8303.   \blx@bbl@addentryfield{\detokenize{#2}}{#3}{localnumber}{#4}{#5}%
  8304.   \blx@bbl@addentryfield{\detokenize{#2}}{#3}{labelnumber}{#4}{#5}%
  8305.   \global\toggletrue{blx@localnumber}%
  8306.   \ifblank{#5}
  8307.    {}
  8308.    {\csgdef{blx@labelnumber@#3}{#5}}}
  8309.  
  8310. % Called as part of bib output for an entry
  8311. % Only used when defernumbers=true
  8312. \def\blx@addlabelnumber{%
  8313.   \begingroup
  8314.   \nottoggle{blx@skiplab}
  8315.    {\iftoggle{blx@labelnumber}
  8316.        {\ifundef\abx@field@shorthand
  8317.          % Need to know if we set any localnumber from .aux file, not
  8318.          % just current item. Otherwise, we may just write new
  8319.          % localnumbers but not existing ones
  8320.          % Also, don't want to regenerate localnumber for any key in a
  8321.          % refsection which we've already seen because this has the nasty
  8322.          % side-effect of incrementing the localnum counter
  8323.          {\ifboolexpr { not togl {blx@localnumber}
  8324.                        and
  8325.                        not test {\ifcsdef{blx@defer@\the\c@refsection @\blx@refcontext@context @\abx@field@entrykey}} }
  8326.            {\iftoggle{blx@omitnumbers}
  8327.               {\let\abx@field@localnumber\@empty}
  8328.               {\csnumgdef{blx@labelnumber@\the\c@refsection}{%
  8329.                   \csuse{blx@labelnumber@\the\c@refsection}+1}%
  8330.                 \edef\abx@field@localnumber{%
  8331.                   \csuse{blx@labelnumber@\the\c@refsection}}%
  8332.                 \blx@bbl@addentryfield{\abx@field@entrykey}{\the\c@refsection}%
  8333.                     {localnumber}{\blx@refcontext@context}{\abx@field@localnumber}}}
  8334.            {}%
  8335.           % If localnumbers were already in the .aux, add them
  8336.           % again from the .aux. This prevents some cycling
  8337.           % problems where pagebreaks change after localnumber
  8338.           % settles down and then we need another run which then
  8339.           % regenerates localnumber requiring another run but then
  8340.           % the pagebreaks change back again ... etc.
  8341.           \ifcsundef{blx@defer@\the\c@refsection @\blx@refcontext@context @\abx@field@entrykey}
  8342.            {\ifundef\abx@field@localnumber
  8343.               {}
  8344.                 {\listxadd\blx@localnumaux{%
  8345.                    \string\abx@aux@number%
  8346.                      {\the\c@instcount}%
  8347.                      {\abx@field@entrykey}%
  8348.                      {\the\c@refsection}%
  8349.                      {\blx@refcontext@context}%
  8350.                      {\abx@field@localnumber}}%
  8351.                    % record that we have already generated and output localnum
  8352.                    % for this key in this refsection/refcontext
  8353.                    \global\cslet{blx@defer@\the\c@refsection @\blx@refcontext@context @\abx@field@entrykey}\@empty}}
  8354.           {}}
  8355.         {}}%
  8356.        {}}
  8357.    {}%
  8358.   \endgroup}
  8359.  
  8360. % {<datalistname>}
  8361. \def\blx@bbl@dlist[#1]#2{%
  8362.   \begingroup
  8363.   \def\blx@dlist@type{#1}%
  8364.   \def\blx@dlist@name{#2}}
  8365.  
  8366. \def\blx@bbl@enddlist{%
  8367.   \csnumgdef{blx@labelnumber@\the\c@refsection}{0}%
  8368.   \endgroup}
  8369.  
  8370. \def\blx@addpageref#1{%
  8371.   \begingroup
  8372.   \blx@tempcnta\z@
  8373.   \let\blx@tempa\@empty
  8374.   \def\do##1{%
  8375.     \appto\blx@tempa{{##1}}%
  8376.     \advance\blx@tempcnta\@ne}%
  8377.   \dolistcsloop{blx@pref@\the\c@refsection @#1}%
  8378.   \edef\blx@tempa{\endgroup\noexpand\blx@bbl@listdef
  8379.    {pageref}{\the\blx@tempcnta}{\blx@tempa}}%
  8380.   \blx@tempa}
  8381.  
  8382. %% Data input
  8383. \def\blx@bblinput{%
  8384.   \begingroup
  8385.   \blx@info@noline{Trying to load bibliographic data..}%
  8386.   \blx@blxinit
  8387.   \blx@bblfile
  8388.   \endgroup}
  8389.  
  8390. \def\blx@bblfile{%
  8391.   \blx@secinit
  8392.   \begingroup
  8393.   \blx@bblstart
  8394.   \blx@ifsigned{\jobname}{bbl}
  8395.    {\InputIfFileExists{\jobname.bbl}
  8396.       {\blx@info@noline{... file '\jobname.bbl' found}%
  8397.         \global\toggletrue{blx@bbldone}}
  8398.       {\blx@info@noline{... file '\jobname.bbl' not found}%
  8399.         \typeout{No file \jobname.bbl.}}}
  8400.    {}%
  8401.   \blx@bblend
  8402.   \endgroup
  8403.   % global sorting as this is called at BeginDocument
  8404.   \csnumgdef{blx@labelnumber@\the\c@refsection}{0}}
  8405.  
  8406. %% Bibliography
  8407.  
  8408. % {<name>}{<start code>}[<end code>]{<item code>}
  8409. \newrobustcmd*{\defbibenvironment}[4]{%
  8410.   \long\csdef{blx@env@#1}{#2}%
  8411.   \long\csdef{blx@endenv@#1}{#3}%
  8412.   \long\csdef{blx@item@#1}{#4}}
  8413.  
  8414. \defbibenvironment{bibliography}
  8415.  {\list{}{%
  8416.      \leftmargin\bibhang
  8417.      \itemindent-\leftmargin
  8418.      \itemsep\bibitemsep
  8419.      \parsep\bibparsep}}
  8420.   {\endlist}
  8421.  {\item}
  8422.  
  8423. \def\do#1{%
  8424.   \defbibenvironment{#1}
  8425.   {\list{\thefield{#1}}{%
  8426.        \labelwidth\csname #1width\endcsname
  8427.        \labelsep\biblabelsep
  8428.        \leftmargin\labelwidth
  8429.        \advance\leftmargin\labelsep
  8430.        \itemsep\bibitemsep
  8431.        \parsep\bibparsep
  8432.        \def\makelabel####1{####1\hss}}}
  8433.    {\endlist}
  8434.    {\item}}
  8435. \abx@dolabelfields
  8436.  
  8437. % {<name>}[<default>]{<code>}
  8438. \newrobustcmd*{\defbibheading}[1]{%
  8439.   \@ifnextchar[%]
  8440.     {\blx@defbibheading{blx@head@#1}}
  8441.    {\blx@defbibheading{blx@head@#1}[\bibname]}}
  8442.  
  8443. \def\blx@defbibheading#1[#2]{%
  8444.   \csundef{#1}%
  8445.   \expandafter\newcommand\csname#1\endcsname[1][#2]}
  8446.  
  8447. % {<name>}{<text>}
  8448. \newrobustcmd*{\defbibnote}[1]{%
  8449.   \long\csdef{blx@note@#1}}
  8450.  
  8451. % {<name>}{<code>}
  8452. \newrobustcmd*{\defbibfilter}[2]{%
  8453.   \begingroup
  8454.   \def\blx@flt@error{\csname blx@flt@errortrue\endcsname}%
  8455.   \let\not\blx@flt@not \let\NOT\not
  8456.   \let\and\blx@flt@and \let\AND\and
  8457.   \let\or\blx@flt@or   \let\OR\or
  8458.   \letcs\({blx@flt@(}  \letcs\){blx@flt@)}%
  8459.   \def\section##1{\blx@flt@error}%
  8460.   \def\segment##1{segment=##1}%
  8461.   \def\type##1{type=##1}%
  8462.   \def\subtype##1{subtype=##1}%
  8463.   \def\keyword##1{keyword={##1}}%
  8464.   \def\category##1{category={##1}}%
  8465.   \edef\blx@tempa{\noexpand\blx@defbibfilter{#2}}%
  8466.   \ifdef\blx@flt@errortrue
  8467.     {\blx@err@filter}
  8468.    {\let\the\relax
  8469.     \let\blx@flt@item\relax
  8470.     \edef\blx@tempa{\blx@tempa}%
  8471.      \ifdef\blx@flt@errortrue
  8472.        {\blx@err@filter}
  8473.       {\csxdef{blx@filter@#1}{\blx@tempa}}}%
  8474.   \endgroup}
  8475.  
  8476. \def\blx@defbibfilter#1{%
  8477.   \blx@defbibfilter@i#1 &}
  8478. \def\blx@defbibfilter@i#1 #2&{%
  8479.   \blx@defbibfilter@ii#1==&%
  8480.   \ifblank{#2}{}{\blx@defbibfilter@i#2 &}}
  8481. \def\blx@defbibfilter@ii#1=#2=#3&{%
  8482.   \ifblank{#2}
  8483.    {\ifblank{#1}
  8484.       {}
  8485.       {\ifcsdef{blx@flt@#1}
  8486.          {\csname blx@flt@#1\endcsname}
  8487.          {\blx@flt@error}}}
  8488.    {\ifcsdef{blx@flt@#1}
  8489.       {\csname blx@flt@#1\endcsname{\detokenize{#2}}}
  8490.       {\blx@flt@error}}}
  8491.  
  8492. \def\blx@flt@and{ and }
  8493. \def\blx@flt@or{ or }
  8494. \def\blx@flt@not{ not }
  8495. \csdef{blx@flt@(}{ ( }
  8496. \csdef{blx@flt@)}{ ) }
  8497. \def\blx@flt@segment#1{%
  8498.   test {\xifinlistcs\blx@flt@item{blx@segm@\the\c@refsection @#1}}}
  8499. \def\blx@flt@type#1{%
  8500.   test {\xifinlistcs\blx@flt@item{blx@type@\the\c@refsection @#1}}}
  8501. \def\blx@flt@subtype#1{%
  8502.   test {\xifinlistcs\blx@flt@item{blx@subt@\the\c@refsection @#1}}}
  8503. \def\blx@flt@keyword#1{%
  8504.   test {\xifinlistcs\blx@flt@item{blx@keyw@\the\c@refsection @#1}}}
  8505. \def\blx@flt@category#1{%
  8506.   test {\xifinlistcs\blx@flt@item{blx@catg@#1}}}
  8507.  
  8508. % {<name>}{<code>}
  8509. \newrobustcmd*{\defbibcheck}[2]{%
  8510.   \csdef{blx@bibcheck@#1}{%
  8511.     \togglefalse{blx@skipentry}%
  8512.     \def\skipentry{\toggletrue{blx@skipentry}}%
  8513.     #2\undef\skipentry}}
  8514.  
  8515. % options
  8516. % We need a 2-pass structure for options in \printbibliography and
  8517. % \printbiblist because the section has to be set before any
  8518. % other options and this partly determines which list to use for later filtering
  8519. \define@key{blx@bib1}{segment}{}
  8520. \define@key{blx@bib1}{type}{}
  8521. \define@key{blx@bib1}{nottype}{}
  8522. \define@key{blx@bib1}{subtype}{}
  8523. \define@key{blx@bib1}{notsubtype}{}
  8524. \define@key{blx@bib1}{keyword}{}
  8525. \define@key{blx@bib1}{notkeyword}{}
  8526. \define@key{blx@bib1}{category}{}
  8527. \define@key{blx@bib1}{notcategory}{}
  8528. \define@key{blx@bib1}{filter}{}
  8529. \define@key{blx@bib1}{check}{}
  8530. \define@key{blx@bib1}{heading}{}
  8531. \define@key{blx@bib1}{env}{}
  8532. \define@key{blx@bib1}{title}{}
  8533. \define@key{blx@bib1}{prenote}{}
  8534. \define@key{blx@bib1}{postnote}{}
  8535. \define@key{blx@bib1}{omitnumbers}[]{}
  8536. % Here we are using the first pass to see if there is an explicit setting for resetnumbers
  8537. % If there isn't we will use the default behaviour where if there is a labelprefix,
  8538. % resetnumbers will default to "true"
  8539. \define@key{blx@bib1}{resetnumbers}[true]{%
  8540.   \toggletrue{blx@resetnumsexplicit}}
  8541.  
  8542. \define@key{blx@bib2}{section}{}
  8543. \define@key{blx@bib2}{sorting}{}
  8544.  
  8545. \define@key{blx@biblist1}{segment}{}
  8546. \define@key{blx@biblist1}{type}{}
  8547. \define@key{blx@biblist1}{nottype}{}
  8548. \define@key{blx@biblist1}{subtype}{}
  8549. \define@key{blx@biblist1}{notsubtype}{}
  8550. \define@key{blx@biblist1}{keyword}{}
  8551. \define@key{blx@biblist1}{notkeyword}{}
  8552. \define@key{blx@biblist1}{category}{}
  8553. \define@key{blx@biblist1}{notcategory}{}
  8554. \define@key{blx@biblist1}{filter}{}
  8555. \define@key{blx@biblist1}{check}{}
  8556. \define@key{blx@biblist1}{heading}{}
  8557. \define@key{blx@biblist1}{env}{}
  8558. \define@key{blx@biblist1}{title}{}
  8559. \define@key{blx@biblist1}{prenote}{}
  8560. \define@key{blx@biblist1}{postnote}{}
  8561.  
  8562. \define@key{blx@biblist2}{section}{}
  8563. \define@key{blx@biblist2}{sorting}{}
  8564.  
  8565. \define@key{blx@bib1}{section}{%
  8566.   \ifcsundef{blx@sections@#1}
  8567.    {\blx@err@nosec{#1}}
  8568.    {\c@refsection#1\relax
  8569.     \def\blx@tempe{#1}}}
  8570.  
  8571. \define@key{blx@biblist1}{section}{%
  8572.   \ifcsundef{blx@sections@#1}
  8573.    {\blx@err@nosec{#1}}
  8574.    {\c@refsection#1\relax
  8575.     \def\blx@tempe{#1}}}
  8576.  
  8577. \define@key{blx@bbg}{section}{%
  8578.   \ifcsundef{blx@sections@#1}
  8579.    {\blx@err@nosec{#1}}
  8580.    {\c@refsection#1\relax}}
  8581.  
  8582. \define@key{blx@bbc}{section}{%
  8583.   \ifcsundef{blx@sections@#1}
  8584.    {\blx@err@nosec{#1}}
  8585.    {\c@refsection#1\relax}}
  8586.  
  8587. \define@key{blx@bib2}{segment}{\blx@key@segment{#1}}
  8588. \define@key{blx@biblist2}{segment}{\blx@key@segment{#1}}
  8589.  
  8590. \def\blx@key@segment#1{%
  8591.   \ifcsundef{blx@segm@\the\c@refsection @#1}
  8592.    {\blx@warning{Segment '#1' not found in section '\the\c@refsection'}}
  8593.    {\c@refsegment#1\relax
  8594.     \blx@printbibchecks
  8595.     \blx@filter\blx@tempa{blx@segm@\the\c@refsection @#1}}}
  8596.  
  8597. \define@key{blx@bib2}{type}{\blx@key@type{#1}}
  8598. \define@key{blx@biblist2}{type}{\blx@key@type{#1}}
  8599.  
  8600. \def\blx@key@type#1{%
  8601.   \ifcsundef{blx@type@\the\c@refsection @#1}
  8602.    {\blx@warning{Type '#1' not found}%
  8603.      \let\blx@tempa\@empty}
  8604.     {\blx@printbibchecks
  8605.     \iftoggle{blx@tempb}
  8606.       {\togglefalse{blx@tempb}%
  8607.         \blx@filter\blx@tempa{blx@type@\the\c@refsection @#1}}
  8608.       {\let\blx@tempa\@empty
  8609.        \blx@error
  8610.          {'type' used multiple times}
  8611.          {When passing multiple filter options, each entry\MessageBreak
  8612.           must satisfy all conditions (AND conjunction),\MessageBreak
  8613.           hence some options may not be used twice.\MessageBreak
  8614.           Use 'filter' and '\string\defbibfilter' with OR conjunctions}}}}
  8615.  
  8616. \define@key{blx@bib2}{nottype}{\blx@key@nottype{#1}}
  8617. \define@key{blx@biblist2}{nottype}{\blx@key@nottype{#1}}
  8618.  
  8619. \def\blx@key@nottype#1{%
  8620.   \ifcsundef{blx@type@\the\c@refsection @#1}
  8621.    {}
  8622.    {\blx@printbibchecks
  8623.     \blx@notfilter\blx@tempa{blx@type@\the\c@refsection @#1}}}
  8624.  
  8625. \define@key{blx@bib2}{subtype}{\blx@key@subtype{#1}}
  8626. \define@key{blx@biblist2}{subtype}{\blx@key@subtype{#1}}
  8627.  
  8628. \def\blx@key@subtype#1{%
  8629.   \ifcsundef{blx@subt@\the\c@refsection @#1}
  8630.    {\blx@warning{Subtype '#1' not found}%
  8631.      \let\blx@tempa\@empty}
  8632.     {\blx@printbibchecks
  8633.     \iftoggle{blx@tempb}
  8634.       {\togglefalse{blx@tempb}%
  8635.         \blx@filter\blx@tempa{blx@subt@\the\c@refsection @#1}}
  8636.       {\let\blx@tempa\@empty
  8637.        \blx@error
  8638.          {'subtype' used multiple times}
  8639.          {When passing multiple filter options, each entry\MessageBreak
  8640.           must satisfy all conditions (AND conjunction),\MessageBreak
  8641.           hence some options may not be used twice.\MessageBreak
  8642.           Use 'filter' and '\string\defbibfilter' with OR conjunctions}}}}
  8643.  
  8644. \define@key{blx@bib2}{notsubtype}{\blx@key@notsubtype{#1}}
  8645. \define@key{blx@biblist2}{notsubtype}{\blx@key@notsubtype{#1}}
  8646.  
  8647. \def\blx@key@notsubtype#1{%
  8648.   \ifcsundef{blx@subt@\the\c@refsection @#1}
  8649.    {}
  8650.    {\blx@printbibchecks
  8651.     \blx@notfilter\blx@tempa{blx@subt@\the\c@refsection @#1}}}
  8652.  
  8653. \define@key{blx@bib2}{keyword}{\blx@key@keyword{#1}}
  8654. \define@key{blx@biblist2}{keyword}{\blx@key@keyword{#1}}
  8655.  
  8656. \def\blx@key@keyword#1{%
  8657.   \ifcsundef{blx@keyw@\the\c@refsection @\detokenize{#1}}
  8658.    {\blx@warning{Keyword '\detokenize{#1}' not found}%
  8659.      \let\blx@tempa\@empty}
  8660.     {\blx@printbibchecks
  8661.     \blx@filter\blx@tempa{blx@keyw@\the\c@refsection @\detokenize{#1}}}}
  8662.  
  8663. \define@key{blx@bib2}{notkeyword}{\blx@key@notkeyword{#1}}
  8664. \define@key{blx@biblist2}{notkeyword}{\blx@key@notkeyword{#1}}
  8665.  
  8666. \def\blx@key@notkeyword#1{%
  8667.   \ifcsundef{blx@keyw@\the\c@refsection @\detokenize{#1}}
  8668.    {}
  8669.    {\blx@printbibchecks
  8670.     \blx@notfilter\blx@tempa{blx@keyw@\the\c@refsection @\detokenize{#1}}}}
  8671.  
  8672. \define@key{blx@bib2}{category}{\blx@key@category{#1}}
  8673. \define@key{blx@biblist2}{category}{\blx@key@category{#1}}
  8674.  
  8675. \def\blx@key@category#1{%
  8676.   \ifcsundef{blx@catg@\detokenize{#1}}
  8677.    {\blx@warning{Category '\detokenize{#1}' not found}%
  8678.      \let\blx@tempa\@empty}
  8679.     {\blx@printbibchecks
  8680.     \blx@filter\blx@tempa{blx@catg@\detokenize{#1}}}}
  8681.  
  8682. \define@key{blx@bib2}{notcategory}{\blx@key@notcategory{#1}}
  8683. \define@key{blx@biblist2}{notcategory}{\blx@key@notcategory{#1}}
  8684.  
  8685. \def\blx@key@notcategory#1{%
  8686.   \ifcsundef{blx@catg@#1}
  8687.    {}
  8688.    {\blx@printbibchecks
  8689.     \blx@notfilter\blx@tempa{blx@catg@#1}}}
  8690.  
  8691. \define@key{blx@bib2}{filter}{\blx@key@filter{#1}}
  8692. \define@key{blx@biblist2}{filter}{\blx@key@filter{#1}}
  8693.  
  8694. \def\blx@key@filter#1{%
  8695.   \ifcsdef{blx@filter@#1}
  8696.    {\blx@printbibchecks
  8697.     \blx@bibfilter\blx@tempa{blx@filter@#1}}
  8698.    {\let\blx@tempa\@empty
  8699.     \blx@error
  8700.       {Filter '#1' not found}
  8701.       {The filter '#1' could not be found.\MessageBreak
  8702.        Use \string\defbibfilter\space to define it}}}
  8703.  
  8704. \define@key{blx@bib2}{check}{\blx@key@bibcheck{#1}}
  8705. \define@key{blx@biblist2}{check}{\blx@key@bibcheck{#1}}
  8706.  
  8707. \def\blx@key@bibcheck#1{%
  8708.   \ifcsdef{blx@bibcheck@#1}
  8709.    {\letcs\blx@bibcheck{blx@bibcheck@#1}}
  8710.    {\let\blx@tempa\@empty
  8711.     \blx@error
  8712.       {Check '#1' not found}
  8713.       {The check '#1' could not be found.\MessageBreak
  8714.        Use \string\defbibcheck\space to define it}}}
  8715.  
  8716. \define@key{blx@bhd}{heading}{\blx@key@heading{#1}}
  8717. \define@key{blx@bib2}{heading}{\blx@key@heading{#1}}
  8718. \define@key{blx@biblist2}{heading}{\blx@key@heading{#1}}
  8719. \define@key{blx@bbs}{heading}{\blx@key@heading{#1}}
  8720. \define@key{blx@bbg}{heading}{\blx@key@heading{#1}}
  8721.  
  8722. \def\blx@key@heading#1{%
  8723.   \ifcsundef{blx@head@#1}
  8724.     {\blx@error
  8725.        {Heading '#1' not found}
  8726.        {The heading '#1' could not be found.\MessageBreak
  8727.         Use \string\defbibheading\space to define it}}
  8728.     {\def\blx@theheading{#1}}}
  8729.  
  8730. \define@key{blx@bib2}{env}{\blx@key@env{#1}}
  8731. \define@key{blx@biblist2}{env}{\blx@key@env{#1}}
  8732. \define@key{blx@bbs}{env}{\blx@key@env{#1}}
  8733. \define@key{blx@bbg}{env}{\blx@key@env{#1}}
  8734. \define@key{blx@bbc}{env}{\blx@key@env{#1}}
  8735.  
  8736. \def\blx@key@env#1{%
  8737.   \ifcsundef{blx@env@#1}
  8738.     {\blx@error
  8739.        {Environment '#1' not found}
  8740.        {The environment '#1' could not be found.\MessageBreak
  8741.         Use \string\defbibenvironment\space to define it}}
  8742.     {\def\blx@theenv{#1}}}
  8743.  
  8744. \define@key{blx@bhd}{title}{\def\blx@thetitle{#1}}
  8745. \define@key{blx@bib2}{title}{\def\blx@thetitle{#1}}
  8746. \define@key{blx@biblist2}{title}{\def\blx@thetitle{#1}}
  8747.  
  8748. \define@key{blx@bib2}{prenote}{\blx@key@prenote{#1}}
  8749. \define@key{blx@biblist2}{prenote}{\blx@key@prenote{#1}}
  8750. \define@key{blx@bbs}{prenote}{\blx@key@prenote{#1}}
  8751. \define@key{blx@bbg}{prenote}{\blx@key@prenote{#1}}
  8752. \define@key{blx@bbc}{prenote}{\blx@key@prenote{#1}}
  8753. \def\blx@key@prenote#1{%
  8754.   \ifcsundef{blx@note@#1}
  8755.     {\blx@error
  8756.        {Note '#1' not found}
  8757.        {The note '#1' could not be found.\MessageBreak
  8758.         Use \string\defbibnote\space to define it}}
  8759.     {\def\blx@theprenote{#1}}}
  8760.  
  8761. \define@key{blx@bib2}{postnote}{\blx@key@postnote{#1}}
  8762. \define@key{blx@biblist2}{postnote}{\blx@key@postnote{#1}}
  8763. \define@key{blx@bbs}{postnote}{\blx@key@postnote{#1}}
  8764. \define@key{blx@bbg}{postnote}{\blx@key@postnote{#1}}
  8765. \define@key{blx@bbc}{postnote}{\blx@key@postnote{#1}}
  8766.  
  8767. \def\blx@key@postnote#1{%
  8768.   \ifcsundef{blx@note@#1}
  8769.     {\blx@error
  8770.        {Note '#1' not found}
  8771.        {The note '#1' could not be found.\MessageBreak
  8772.         Use \string\defbibnote\space to define it}}
  8773.     {\def\blx@thepostnote{#1}}}
  8774.  
  8775. \define@key{blx@bib1}{locallabelwidth}[]{}
  8776. \define@key{blx@biblist1}{locallabelwidth}[]{}
  8777. \define@key{blx@bib2}{locallabelwidth}[true]{\blx@key@locallabelwidth{#1}}
  8778. \define@key{blx@biblist2}{locallabelwidth}[true]{\blx@key@locallabelwidth{#1}}
  8779.  
  8780. \def\blx@key@locallabelwidth#1{%
  8781.   \ifstrequal{#1}{true}
  8782.    {\def\abx@locallabelwidth{\blx@locallabelwidth}}
  8783.    {\let\abx@locallabelwidth\@gobble}}
  8784.  
  8785. \define@key{blx@bib2}{resetnumbers}[true]{%
  8786.   \iftoggle{blx@defernumbers}
  8787.    {\ifstrequal{#1}{true}
  8788.       {\csnumdef{blx@labelnumber@\the\c@refsection}{0}}
  8789.       {\ifstrequal{#1}{false}
  8790.         {}
  8791.         {\csnumdef{blx@labelnumber@\the\c@refsection}{#1-1}}}}
  8792.     {\blx@warning{%
  8793.        Option 'resetnumbers' requires 'defernumbers=true'.\MessageBreak
  8794.        Ignoring 'resetnumbers=true'}}}
  8795.  
  8796. \define@key{blx@bib2}{omitnumbers}[true]{%
  8797.   \ifstrequal{#1}{true}
  8798.    {\iftoggle{blx@defernumbers}
  8799.       {\toggletrue{blx@omitnumbers}}
  8800.        {\blx@warning{%
  8801.           Option 'omitnumbers' requires 'defernumbers=true'.\MessageBreak
  8802.           Ignoring 'omitnumbers=true'}}}
  8803.     {}}
  8804.  
  8805. % [<options>]
  8806. \newrobustcmd*{\printbibheading}{%
  8807.   \begingroup
  8808.   \edef\on@line{\on@line}%
  8809.   \@ifnextchar[%]
  8810.     {\blx@printbibheading}
  8811.    {\blx@printbibheading[]}}
  8812.  
  8813. \def\blx@printbibheading[#1]{%
  8814.   \def\blx@theheading{bibliography}%
  8815.   \let\blx@thetitle\@empty
  8816.   \blx@safe@actives
  8817.   \setkeys{blx@bhd}{#1}%
  8818.   \blx@rest@actives
  8819.   \blx@langstrings
  8820.   \blx@bibheading\blx@theheading\blx@thetitle
  8821.   \endgroup}
  8822.  
  8823. % We use this to determine whether an explicit value for resetnumbers is passed to
  8824. % \printbibliography, if not, then we use the default behaviour where a labelprefix forces
  8825. % a reset. It is useful that we have a 2-pass structure for \printbibliography keys anyway.
  8826. \newtoggle{blx@resetnumsexplicit}
  8827.  
  8828. % [<options>]
  8829. \newrobustcmd*{\printbibliography}{%
  8830.   \begingroup
  8831.   \delimcontext{bib}%
  8832.   \edef\on@line{\on@line}%
  8833.   \@ifnextchar[%]
  8834.     {\blx@printbibliography}
  8835.    {\blx@printbibliography[]}}
  8836.  
  8837. \def\blx@printbibliography[#1]{%
  8838.   \toggletrue{blx@tempa}%
  8839.   \toggletrue{blx@tempb}%
  8840.   \def\blx@theheading{bibliography}%
  8841.   \def\blx@theenv{bibliography}%
  8842.   \let\blx@theprenote\@empty
  8843.   \let\blx@thepostnote\@empty
  8844.   \let\blx@thetitle\@empty
  8845.   % defaults
  8846.   \let\blx@tempa\@empty% before there is a .bbl, this must not be undef
  8847.   \edef\blx@tempe{\the\c@refsection}% default refsection is current
  8848.   \blx@safe@actives
  8849.   \togglefalse{blx@resetnumsexplicit}%
  8850.   \setkeys{blx@bib1}{#1}% First pass options keys - section and resetnumbers
  8851.   % Is there a user-specified option for resetnumbers? If so, this overrides the default
  8852.   % "labelprefix implies resetnumbers" behaviour
  8853.   \iftoggle{blx@resetnumsexplicit}
  8854.    {}
  8855.    {\ifdefempty\blx@refcontext@labelprefix
  8856.      {}
  8857.      {\setkeys{blx@bib2}{resetnumbers}}}%
  8858.   \blx@rest@actives
  8859.   \ifcsvoid{blx@dlist@entry@\blx@tempe @\blx@refcontext@context}
  8860.    {}
  8861.    {\letcs\blx@tempa{blx@dlist@entry@\blx@tempe @\blx@refcontext@context}}%
  8862.   \blx@safe@actives
  8863.   % Must reset omitnumbers as it's a global macro and if we don't, any
  8864.   % \printbibliography following one with this set will inherit any
  8865.   % previous "true" value
  8866.   \togglefalse{blx@omitnumbers}%
  8867.   \setkeys{blx@bib2}{#1}% ... now we have correct \blx@tempa, set rest of options
  8868.   \blx@rest@actives
  8869.   % Add datalist to list of seen datalists to prevent duplicates
  8870.   \xifinlist{\blx@refcontext@context @\blx@tempe @entry}\blx@dlistnames
  8871.    {}
  8872.    {\listxadd\blx@dlistnames{\blx@refcontext@context @\blx@tempe @entry}%
  8873.      \csxappto{blx@dlists}{%
  8874.        \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}}{}}}%
  8875.   \ifdefvoid\blx@tempa
  8876.     {\blx@warn@bibempty\endgroup}
  8877.    {\blx@bibliography\blx@tempa}}
  8878.  
  8879. % [<options>]
  8880. \newrobustcmd*{\bibbysection}{%
  8881.   \begingroup
  8882.   \delimcontext{bib}%
  8883.   \ifnum\blx@maxsection=\z@
  8884.     \blx@warning{No reference sections found}%
  8885.   \fi
  8886.   \edef\on@line{\on@line}%
  8887.   \@ifnextchar[%]
  8888.     {\blx@bibbysection}
  8889.    {\blx@bibbysection[]}}
  8890.  
  8891. \def\blx@bibbysection[#1]{%
  8892.   \def\blx@theheading{bibliography}%
  8893.   \def\blx@theenv{bibliography}%
  8894.   \let\blx@theprenote\@empty
  8895.   \let\blx@thepostnote\@empty
  8896.   \let\blx@thetitle\@empty
  8897.   \c@refsection\z@
  8898.   \blx@safe@actives
  8899.   \setkeys{blx@bbs}{#1}%
  8900.   \blx@rest@actives
  8901.   \togglefalse{blx@tempa}%
  8902.   \blx@refsections}
  8903.  
  8904. \def\blx@refsections{%
  8905.   \ifcsvoid{blx@dlist@entry@\the\c@refsection @\blx@refcontext@context}
  8906.    {}
  8907.    {\toggletrue{blx@tempa}%
  8908.      \begingroup
  8909.      \expandafter\blx@bibliography\csname blx@dlist@entry@\the\c@refsection @\blx@refcontext@context\endcsname}%
  8910.   \ifnum\c@refsection<\blx@maxsection
  8911.     \advance\c@refsection\@ne
  8912.     \expandafter\blx@refsections
  8913.   \else
  8914.     \iftoggle{blx@tempa}{}{\blx@warn@bibempty}%
  8915.     \endgroup
  8916.   \fi}
  8917.  
  8918. % [<options>]
  8919. \newrobustcmd*{\bibbysegment}{%
  8920.   \begingroup
  8921.   \delimcontext{bib}%
  8922.   \edef\on@line{\on@line}%
  8923.   \ifnum\csname blx@maxsegment@\the\c@refsection\endcsname=\z@
  8924.     \blx@warning{No reference segments found}%
  8925.   \fi
  8926.   \@ifnextchar[%]
  8927.     {\blx@bibbysegment}
  8928.    {\blx@bibbysegment[]}}
  8929.  
  8930. \def\blx@bibbysegment[#1]{%
  8931.   \def\blx@theheading{bibliography}%
  8932.   \def\blx@theenv{bibliography}%
  8933.   \let\blx@theprenote\@empty
  8934.   \let\blx@thepostnote\@empty
  8935.   \let\blx@thetitle\@empty
  8936.   \c@refsegment\@ne
  8937.   \blx@safe@actives
  8938.   \setkeys{blx@bbg}{#1}%
  8939.   \blx@rest@actives
  8940.   \togglefalse{blx@tempa}%
  8941.   \blx@refsegments}
  8942.  
  8943. \def\blx@refsegments{%
  8944.   \ifcsvoid{blx@segm@\the\c@refsection @\the\c@refsegment}
  8945.    {}
  8946.    {\toggletrue{blx@tempa}%
  8947.      \begingroup
  8948.      \let\blx@tempa\@empty
  8949.      \ifcsvoid{blx@dlist@entry@\the\c@refsection @\blx@refcontext@context}
  8950.       {}
  8951.       {\letcs\blx@tempa{blx@dlist@entry@\the\c@refsection @\blx@refcontext@context}}%
  8952.      \blx@filter\blx@tempa{blx@segm@\the\c@refsection @\the\c@refsegment}%
  8953.      \blx@bibliography\blx@tempa}%
  8954.   \ifnum\c@refsegment<\csname blx@maxsegment@\the\c@refsection\endcsname
  8955.     \advance\c@refsegment\@ne
  8956.     \expandafter\blx@refsegments
  8957.   \else
  8958.     \iftoggle{blx@tempa}{}{\blx@warn@bibempty}%
  8959.     \endgroup
  8960.   \fi}
  8961.  
  8962. % [<options>]
  8963. \newrobustcmd*{\bibbycategory}{%
  8964.   \begingroup
  8965.   \delimcontext{bib}%
  8966.   \edef\on@line{\on@line}%
  8967.   \ifx\blx@categories\@empty
  8968.     \blx@warning{No categories found}%
  8969.   \fi
  8970.   \@ifnextchar[%]
  8971.     {\blx@bibbycategory}
  8972.    {\blx@bibbycategory[]}}
  8973.  
  8974. \def\blx@bibbycategory[#1]{%
  8975.   \def\blx@theheading{bibliography}%
  8976.   \def\blx@theenv{bibliography}%
  8977.   \let\blx@theprenote\@empty
  8978.   \let\blx@thepostnote\@empty
  8979.   \let\blx@thetitle\@empty
  8980.   \c@refsection\z@
  8981.   \blx@safe@actives
  8982.   \setkeys{blx@bbc}{#1}%
  8983.   \blx@rest@actives
  8984.   \togglefalse{blx@tempa}%
  8985.   \forlistloop\blx@bibcategory\blx@categories
  8986.   \blx@endbibcategory}
  8987.  
  8988. \def\blx@bibcategory#1{%
  8989.   \ifcsvoid{blx@catg@#1}
  8990.    {}
  8991.    {\toggletrue{blx@tempa}%
  8992.      \begingroup
  8993.      \blx@key@heading{#1}%
  8994.      \let\blx@tempa\@empty
  8995.      \ifcsvoid{blx@dlist@entry@\the\c@refsection @\blx@refcontext@context}
  8996.       {}
  8997.       {\letcs\blx@tempa{blx@dlist@entry@\the\c@refsection @\blx@refcontext@context}}%
  8998.      \blx@filter\blx@tempa{blx@catg@#1}%
  8999.      \blx@bibliography\blx@tempa}}%
  9000.  
  9001. \def\blx@endbibcategory{%
  9002.   \iftoggle{blx@tempa}{}{\blx@warn@bibempty}%
  9003.   \endgroup}
  9004.  
  9005. % {<entrykey>,...}
  9006. \def\blx@bibliography#1{%
  9007.   \blx@langstrings
  9008.   \blx@bibheading\blx@theheading\blx@thetitle
  9009.   \blx@bibnote\blx@theprenote
  9010.   \begingroup
  9011.   \blx@bibinit
  9012.   \let\@noitemerr\@empty
  9013.   \let\blx@noitem\blx@warn@bibempty
  9014.   \ifnum\bibinitsep=\z@
  9015.     \let\blx@initsep\relax
  9016.   \fi
  9017.   \ifnum\bibnamesep=\z@
  9018.     \let\blx@namesep\relax
  9019.   \fi
  9020.   \abx@locallabelwidth{#1}%
  9021.   \csuse{blx@env@\blx@theenv}%
  9022.   \csuse{blx@hook@bibinit}%
  9023.   \csuse{blx@hook@bibinit@next}%
  9024.   \let\blx@do\blx@bibitem
  9025.   \let\blx@done\blx@endbibliography
  9026.   \blx@listloop{#1}}
  9027.  
  9028. \def\blx@endbibliography{%
  9029.   \csuse{blx@endenv@\blx@theenv}%
  9030.   \blx@noitem
  9031.   \endgroup
  9032.   \blx@bibnote\blx@thepostnote
  9033.   \endgroup}
  9034.  
  9035. \def\blx@bibheading#1#2{%
  9036.   \begingroup
  9037.   \edef\blx@tempa{\endgroup
  9038.    \noexpand\blx@bibheading@i{\expandonce#1}{\expandonce#2}}%
  9039.   \blx@tempa}
  9040.  
  9041. \def\blx@bibheading@i#1#2{%
  9042.   \let\newrefsection\relax
  9043.   \let\newrefsegment\relax
  9044.   \ifblank{#2}
  9045.    {\csuse{blx@head@#1}}
  9046.    {\csuse{blx@head@#1}[#2]}%
  9047.   \let\newrefsection\blx@newrefsection
  9048.   \let\newrefsegment\blx@newrefsegment}
  9049.  
  9050. \def\blx@bibnote#1{%
  9051.   \ifdefempty#1
  9052.     {}
  9053.    {\begingroup
  9054.     \let\newrefsection\relax
  9055.     \let\newrefsegment\relax
  9056.     \noindent
  9057.     \csuse{blx@note@#1}\par\nobreak
  9058.     \endgroup}}
  9059.  
  9060. \def\blx@bibinit{%
  9061.   \iftoggle{blx@citation}
  9062.    {}
  9063.    {\toggletrue{blx@bibliography}}%
  9064.   \blx@blxinit
  9065.   \blx@resetdata
  9066.   \csuse{blx@hook@bbxinit}%
  9067.   \bibsetup\bibfont
  9068.   \blx@setsfcodes
  9069.   \csuse{blx@bibsetup}}
  9070.  
  9071. % {<entrykey>}
  9072. \def\blx@lengthitem#1{%
  9073.   \blx@ifdata{#1}
  9074.    {\begingroup
  9075.     \blx@getdata{#1}%
  9076.      \blx@bibcheck
  9077.      \iftoggle{blx@skipentry}{}{%
  9078.        \iftoggle{blx@labelnumber}
  9079.         {\blx@bbl@locallabelnumberwidth}
  9080.         {}%
  9081.        \iftoggle{blx@labelalpha}
  9082.         {\blx@bbl@locallabelalphawidth}
  9083.         {}%
  9084.        \nottoggle{blx@skipbiblist}
  9085.         {\blx@bbl@locallabelfields}
  9086.         {}}%
  9087.      \endgroup}
  9088.     {}}
  9089.  
  9090. % {<entrykey>}
  9091. % output a bib item, this is why \blx@thelabelnumber is here so that
  9092. % labelnumber is deferred if defernumbers=true
  9093. \def\blx@bibitem#1{%
  9094.   \blx@ifdata{#1}
  9095.    {\begingroup
  9096.     \blx@getdata{#1}%
  9097.      \blx@bibcheck
  9098.      \iftoggle{blx@skipentry}{}{%
  9099.        \blx@setdefaultrefcontext{#1}%
  9100.        \global\let\blx@noitem\@empty
  9101.        \blx@setoptions@type\abx@field@entrytype
  9102.        \blx@setoptions@entry
  9103.        \blx@thelabelnumber
  9104.        \addtocounter{instcount}\@ne
  9105.       \csuse{blx@item@\blx@theenv}\relax
  9106.       \blx@initsep
  9107.       \blx@namesep
  9108.       \csuse{blx@hook@bibitem}%
  9109.        \blx@execute
  9110.        \blx@initunit
  9111.        \blx@anchor
  9112.        \blx@beglangbib
  9113.        \bibsentence
  9114.        \blx@pagetracker
  9115.        \blx@driver\abx@field@entrytype
  9116.        \blx@postpunct
  9117.        \blx@endlangbib}%
  9118.      \endgroup}
  9119.     {}}
  9120.  
  9121. \let\blx@bibcheck\relax
  9122.  
  9123. \def\blx@edef@refcontext#1{%
  9124.   \edef\blx@refcontext@context{#1}%
  9125.   \expandafter\edef\expandafter\blx@refcontext@context\expandafter{%
  9126.     \expandafter\detokenize\expandafter{\blx@refcontext@context}}}
  9127.  
  9128. \def\blx@xdef@refcontext#1{%
  9129.   \edef\blx@refcontext@context{#1}%
  9130.   \expandafter\xdef\expandafter\blx@refcontext@context\expandafter{%
  9131.     \expandafter\detokenize\expandafter{\blx@refcontext@context}}}
  9132.  
  9133.  
  9134. % This sets and saves to the .aux the default refcontext for an entry. The
  9135. % default refcontext for an entry is the refcontext of the last
  9136. % bibliography in the refsection in which it is actually printed. This
  9137. % allows citations to default to selecting data from the correct
  9138. % bibliography list in standard cases where entries are not listed in
  9139. % multiple bibliographies
  9140. \def\blx@setdefaultrefcontext#1{%
  9141.   \ifbool{refcontextdefaults}
  9142.    {\blx@rerun@latex}%
  9143.     {}%
  9144.   \ifinlistcs{#1}{blx@defaultrefcontexts@\the\c@refsection}
  9145.    {}
  9146.    {\listcsgadd{blx@defaultrefcontexts@\the\c@refsection}{#1}}%
  9147.   \csxdef{blx@assignedrefcontextbib@\the\c@refsection @#1}{\blx@refcontext@context}}
  9148. % <refsection><key><refcontext>
  9149. \def\abx@aux@defaultrefcontext#1#2#3{%
  9150.   \global\boolfalse{refcontextdefaults}%
  9151.   \csxdef{blx@assignedrefcontextbib@#1@#2}{\detokenize{#3}}}
  9152. \def\abx@aux@refcontextdefaultsdone{%
  9153.   \global\boolfalse{refcontextdefaults}}
  9154.  
  9155. \AtEndDocument{%
  9156.   % write the .aux to say we don't need to re-run to consume refcontext defaults
  9157.   \ifbool{refcontextdefaults}
  9158.    {}
  9159.    {\blx@auxwrite\@mainaux{}{\string\abx@aux@refcontextdefaultsdone}}%
  9160.   % always add default refcontext declarations to .aux after biber run
  9161.   \iftoggle{blx@bbldone}
  9162.     {\def\do#1{%
  9163.        \begingroup
  9164.        \def\do##1{%
  9165.          \blx@auxwrite\@mainaux{}{\string\abx@aux@defaultrefcontext{#1}{##1}{\csuse{blx@assignedrefcontextbib@#1@##1}}}}%
  9166.        \dolistcsloop{blx@defaultrefcontexts@#1}%
  9167.        \endgroup}
  9168.      \dolistloop\blx@allrefsections}
  9169.     {}}
  9170.  
  9171. \def\blx@initsep{%
  9172.   \blx@imc@iffieldundef{sortinithash}
  9173.    {}
  9174.    {\ifnum\c@instcount>\@ne
  9175.       \blx@imc@iffieldequals{sortinithash}\blx@previnithash
  9176.         {}
  9177.         {\addvspace{\bibinitsep}}%
  9178.      \fi
  9179.      \global\let\blx@previnithash\abx@field@sortinithash}}
  9180.  
  9181. \def\blx@namesep{%
  9182.   \ifnum\c@instcount>\@ne
  9183.     \blx@imc@iffieldequals{fullhash}\blx@prevhash
  9184.      {}
  9185.      {\addvspace{\bibnamesep}}%
  9186.   \fi
  9187.   \global\let\blx@prevhash\abx@field@fullhash}
  9188.  
  9189. \newrobustcmd*{\AtBeginBibliography}{\gappto\blx@hook@bibinit}
  9190. \newrobustcmd*{\AtEveryBibitem}{\gappto\blx@hook@bibitem}
  9191. \@onlypreamble\AtBeginBibliography
  9192. \@onlypreamble\AtEveryBibitem
  9193.  
  9194. \def\blx@imc@UseBibitemHook{\csuse{blx@hook@bibitem}}
  9195.  
  9196. \blx@regimcs{\UseBibitemHook}
  9197.  
  9198. \newrobustcmd*{\AtNextBibliography}{%
  9199.   \ifundef\blx@hook@bibinit@next
  9200.     {\gdef\blx@hook@bibinit@next{\global\undef\blx@hook@bibinit@next}}
  9201.    {}%
  9202.   \gappto\blx@hook@bibinit@next}
  9203.  
  9204. % page tracker
  9205. \def\blx@pagetracker@context{%
  9206.   \blx@leavevmode
  9207.   \ifbool{@filesw}
  9208.    {\ifbool{pagetracker}
  9209.       {\protected@write\@mainaux{}{%
  9210.           \iftoggle{blx@footnote}
  9211.            {\string\abx@aux@fnpage}
  9212.            {\string\abx@aux@page}%
  9213.           {\the\c@instcount}{\noexpand\the\c@page}}}
  9214.       {}}
  9215.    {}}
  9216.  
  9217. % {<instcount>}{<page>}
  9218. \protected\def\blx@aux@page#1#2{%
  9219.   \csgdef{blx@page@#1}{#2}%
  9220.   \blx@addpagesum{#1}{#2}}
  9221. \protected\def\blx@aux@spread#1#2{%
  9222.   \ifodd#2\relax
  9223.     \csxdef{blx@page@#1}{\number\numexpr#2-1}%
  9224.   \else
  9225.     \csgdef{blx@page@#1}{#2}%
  9226.   \fi
  9227.   \blx@addpagesum{#1}{#2}}
  9228.  
  9229. \protected\def\blx@aux@fnpage#1#2{%
  9230.   \csgdef{blx@fnpage@#1}{#2}%
  9231.   \blx@addpagesum{#1}{#2}}
  9232. \protected\def\blx@aux@fnspread#1#2{%
  9233.   \ifodd#2\relax
  9234.     \csxdef{blx@fnpage@#1}{\number\numexpr#2-1}%
  9235.   \else
  9236.     \csgdef{blx@fnpage@#1}{#2}%
  9237.   \fi
  9238.   \blx@addpagesum{#1}{#2}}
  9239.  
  9240. \AtEndDocument{%
  9241.   \def\abx@aux@page#1#2{\blx@addpagesum{#1}{#2}}%
  9242.   \def\abx@aux@fnpage#1#2{\blx@addpagesum{#1}{#2}}}
  9243.  
  9244. % hyperref interface
  9245. \appto\blx@mkhyperref{%
  9246.   \let\blx@anchors\@empty
  9247.   \ifundef\hyper@natanchorstart
  9248.     {\protected\def\blx@anchor{%
  9249.        \xifinlist{\the\c@refsection @\abx@field@entrykey}{\blx@anchors}
  9250.         {}
  9251.         {\listxadd\blx@anchors{\the\c@refsection @\abx@field@entrykey}%
  9252.           \hypertarget{cite.\the\c@refsection @\abx@field@entrykey}{}}}}
  9253.     {\protected\def\blx@anchor{%
  9254.        \xifinlist{\the\c@refsection @\abx@field@entrykey}{\blx@anchors}
  9255.         {}
  9256.         {\listxadd\blx@anchors{\the\c@refsection @\abx@field@entrykey}%
  9257.           \hyper@natanchorstart{\the\c@refsection @\abx@field@entrykey}%
  9258.           \hyper@natanchorend}}}}
  9259.  
  9260. \appto\blx@mknohyperref{\let\blx@anchor\relax}
  9261.  
  9262. \define@key{blx@biblist2}{driver}{\blx@key@driver{#1}}
  9263. \define@key{blx@biblist1}{driver}{}
  9264.  
  9265. \def\blx@key@driver#1{%
  9266.   \def\blx@thebiblistdriver{#1}}
  9267.  
  9268. % Custom bibliography list
  9269. % [<otions>]{biblistname}
  9270. \newrobustcmd*{\printbiblist}[2][]{%
  9271.   \begingroup
  9272.   \delimcontext{biblist}%
  9273.   \edef\on@line{\on@line}%
  9274.   \toggletrue{blx@tempa}%
  9275.   \toggletrue{blx@tempb}%
  9276.   \def\blx@theheading{biblist}% default to biblist heading
  9277.   \def\blx@theenv{#2}% default to list name
  9278.   \def\blx@thebiblist{#2}%
  9279.   \def\blx@thebiblistdriver{#2}%
  9280.   \def\blx@thebiblistfilter{#2}%
  9281.   \let\blx@theprenote\@empty
  9282.   \let\blx@thepostnote\@empty
  9283.   \let\blx@thetitle\@empty
  9284.   % defaults
  9285.   \let\blx@tempa\@empty% before there is a .bbl, this must not be undef
  9286.   % default sorting template and template name for list is same name as list
  9287.   % name, then current context if not found
  9288.   \edef\blx@tempc{%
  9289.     \ifcsdef{blx@sortingtemplate@#2}
  9290.      {#2}
  9291.      {\blx@refcontext@sortingtemplatename}}%
  9292.     % locally define this since we want to fetch data from the datalist named
  9293.     % after the list we are printing rather than the data in refcontext list
  9294.     % Note that the name must be unique so we prepend "#2:" because the combination of
  9295.     % options might not generate a unique name since sortschemename has a fallback to the
  9296.     % refcontext scheme if there is no sortscheme named after the list
  9297.     \blx@edef@refcontext{#2:\blx@tempc/\blx@refcontext@sortingnamekeytemplatename/\blx@refcontext@labelprefix/\blx@refcontext@uniquenametemplatename/\blx@refcontext@labelalphanametemplatename}%
  9298.   \xifinlist\blx@tempc\blx@sortingtemplatenames
  9299.     {}
  9300.    {\listxadd\blx@sortingtemplatenames\blx@tempc}%
  9301.   \let\blx@printbibchecks\relax
  9302.   \edef\blx@tempe{\the\c@refsection}% default refsection is current
  9303.   \blx@safe@actives
  9304.   \blx@printbibchecks
  9305.   % Add the sortingtemplate to the list of sortingtemplates for this biblist
  9306.   % so we can compare on next run
  9307.   \xifinlist\blx@tempc\blx@biblists
  9308.     {}
  9309.    {\listxadd\blx@biblists\blx@tempc
  9310.     \blx@auxwrite\@mainaux{}{\string\abx@aux@biblist{\blx@tempc}}}%
  9311.   \setkeys{blx@biblist1}{#1}% Set section only, if present ...
  9312.   \blx@rest@actives
  9313.   \ifcsvoid{blx@dlist@list@\blx@tempe @\blx@refcontext@context}
  9314.    {}
  9315.    {\letcs\blx@tempa{blx@dlist@list@\blx@tempe @\blx@refcontext@context}}%
  9316.   \blx@safe@actives
  9317.   \setkeys{blx@biblist2}{#1}% ... now we have correct \blx@tempa, set rest of options
  9318.   \ifundef\blx@bibcheck
  9319.     {\ifcsdef{blx@bibcheck@#2}
  9320.      {\letcs\blx@bibcheck{blx@bibcheck@#2}}
  9321.      {}}
  9322.    {}%
  9323.   \blx@rest@actives
  9324.   % Add datalist to list of seen datalists to prevent duplicates
  9325.   \xifinlist{\blx@refcontext@context @\blx@tempe @list}\blx@dlistnames
  9326.    {}
  9327.    {\listxadd\blx@dlistnames{\blx@refcontext@context @\blx@tempe @list}%
  9328.      \xappto\blx@dlists{%
  9329.        \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}}}}%
  9330.   \ifdefvoid\blx@tempa
  9331.     {\blx@warn@biblistempty{#2}\endgroup}
  9332.    {\blx@biblist\blx@tempa}}
  9333.  
  9334. \def\blx@printbibchecks{%
  9335.   \togglefalse{blx@tempa}%
  9336.   \iftoggle{blx@defernumbers}
  9337.    {\global\let\blx@printbibchecks\relax}
  9338.    {\iftoggle{blx@labelnumber}
  9339.       {}
  9340.       {\global\let\blx@printbibchecks\relax}}}
  9341.  
  9342. % {<entrykey>,...}
  9343. \def\blx@biblist#1{%
  9344.   \if@twocolumn
  9345.     \@restonecoltrue\onecolumn
  9346.   \else
  9347.     \@restonecolfalse
  9348.   \fi
  9349.   \blx@langstrings
  9350.   \blx@bibheading\blx@theheading\blx@thetitle
  9351.   \blx@bibnote\blx@theprenote
  9352.   \begingroup
  9353.   \blx@bibinit
  9354.   \let\@noitemerr\@empty
  9355.   \def\blx@noitem{\blx@warn@biblistempty{\blx@thebiblist}}%
  9356.   \abx@locallabelwidth{#1}%
  9357.   \csuse{blx@env@\blx@theenv}%
  9358.   \csuse{blx@hook@biblistinit@\blx@thebiblist}%
  9359.   \let\blx@do\blx@biblistitem
  9360.   \let\blx@done\blx@endbiblist
  9361.   \blx@listloop{#1}}
  9362.  
  9363. \def\blx@endbiblist{%
  9364.   \csuse{blx@endenv@\blx@theenv}%
  9365.   \blx@noitem
  9366.   \endgroup
  9367.   \blx@bibnote\blx@thepostnote
  9368.   \endgroup
  9369.   \if@restonecol\twocolumn\fi}
  9370.  
  9371. % {<biblistname>}
  9372. \newrobustcmd*{\AtBeginBiblist}[1]{\csgappto{blx@hook@biblistinit@#1}}
  9373. \newrobustcmd*{\AtEveryBiblistitem}[1]{\csgappto{blx@hook@biblistitem@#1}}
  9374. \@onlypreamble\AtBeginBiblist
  9375. \@onlypreamble\AtEveryBiblistitem
  9376.  
  9377. % {<entrykey>}
  9378. \def\blx@biblistitem#1{%
  9379.   \blx@ifdata{#1}
  9380.    {\begingroup
  9381.     \blx@getdata{#1}%
  9382.      \blx@bibcheck
  9383.      \iftoggle{blx@skipentry}{}{%
  9384.        \blx@setdefaultrefcontext{#1}%
  9385.        \global\let\blx@noitem\@empty
  9386.        \blx@setoptions@type\abx@field@entrytype
  9387.        \blx@setoptions@entry
  9388.        \addtocounter{instcount}\@ne
  9389.       \csuse{blx@item@\blx@theenv}\relax
  9390.       \csuse{blx@hook@biblistitem@\blx@thebiblist}%
  9391.        \blx@execute
  9392.        \blx@initunit
  9393.        \blx@beglangbib
  9394.        \bibsentence
  9395.        \blx@pagetracker
  9396.        \blx@driver{\blx@thebiblistdriver}%
  9397.        \blx@postpunct
  9398.        \blx@endlangbib}%
  9399.      \endgroup}
  9400.     {}}
  9401.  
  9402. % Just a default in case .bbx doesn't define it. standard.bbx defines
  9403. % it to print a complete entry, like the bibliography.
  9404. \DeclareBibliographyDriver{shorthand}{%
  9405.   \iffieldundef{shorttitle}
  9406.    {\printfield{title}}
  9407.    {\printfield{shorttitle}}}
  9408.  
  9409. % Reference contexts
  9410. \newcommand*{\DeclareRefcontext}[2]{%
  9411.   \csgdef{blx@refcontext@name@#1}{#2}}
  9412. \@onlypreamble\DeclareRefcontext
  9413.  
  9414. \def\newrefcontext{%
  9415.   \endrefcontext
  9416.   \refcontext}
  9417.  
  9418. % Backwards compat for older \refcontext[] format
  9419. \def\refcontext{%
  9420.   \@ifnextchar[%]
  9421.     {\refcontext@i}
  9422.    {\refcontext@i[]}}
  9423.  
  9424. \def\refcontext@i[#1]{%
  9425.   \@ifnextchar\bgroup
  9426.     {\refcontext@ii[#1]}
  9427.    {\refcontext@ii[#1]{}}}
  9428.  
  9429. \newcommand*{\refcontext@ii}[2][]{%
  9430.   \iftoggle{blx@refcontext}
  9431.    {\blx@err@nestenv{refcontext}%
  9432.      \endrefcontext}
  9433.     {\toggletrue{blx@refcontext}%
  9434.      % Set refcontext from named refcontext, if given
  9435.      \ifblank{#2}
  9436.       {}
  9437.       {\edef\z{\noexpand\setkeys{blx@refcontext}{\csuse{blx@refcontext@name@#2}}}\z}%
  9438.      % Override with explicit refcontext keyvals, if given
  9439.      \setkeys{blx@refcontext}{#1}%
  9440.      % Add the sortingtemplate to the list of sortingtemplates so we can track
  9441.      % special cases like sorting=none which need cite order change detection
  9442.      \xifinlist\blx@refcontext@sortingtemplatename\blx@sortingtemplatenames
  9443.        {}
  9444.       {\listxadd\blx@sortingtemplatenames\blx@refcontext@sortingtemplatename}%
  9445.      \blx@xdef@refcontext{\blx@refcontext@sortingtemplatename/\blx@refcontext@sortingnamekeytemplatename/\blx@refcontext@labelprefix/\blx@refcontext@uniquenametemplatename/\blx@refcontext@labelalphanametemplatename}%
  9446.      % Add the refcontext to the list of refcontexts so we can compare on next run
  9447.      \xifinlist\blx@refcontext@context\blx@refcontexts
  9448.        {}
  9449.       {\listxadd\blx@refcontexts\blx@refcontext@context
  9450.        \blx@auxwrite\@mainaux{}{\string\abx@aux@refcontext{\blx@refcontext@context}}}%
  9451.      \ifcsundef{blx@sortingtemplate@\blx@refcontext@sortingtemplatename}
  9452.       {\blx@err@invopt{sorting=\blx@refcontext@sortingtemplatename}{}}
  9453.       {}%
  9454.      \ifcsundef{blx@sortingnamekeytemplate@\blx@refcontext@sortingnamekeytemplatename}
  9455.       {\blx@err@invopt{sortingnamekeytemplate=\blx@refcontext@sortingnamekeytemplatename}{}}
  9456.       {}%
  9457.      \ifcsundef{blx@uniquenametemplate@\blx@refcontext@uniquenametemplatename}
  9458.       {\blx@err@invopt{uniquenametemplate=\blx@refcontext@uniquenametemplatename}{}}
  9459.       {}%
  9460.      \ifcsundef{blx@labelalphanametemplate@\blx@refcontext@labelalphanametemplatename}
  9461.       {\blx@err@invopt{labelalphanametemplate=\blx@refcontext@labelalphanametemplatename}{}}
  9462.       {}}}
  9463.  
  9464. % Reset to global sorting etc. when we leave a ref context (since they can't be nested)
  9465. \protected\def\endrefcontext{%
  9466.   \togglefalse{blx@refcontext}%
  9467.   \global\let\blx@refcontext@labelprefix\@empty
  9468.   \global\let\blx@refcontext@labelprefix@real\@empty
  9469.   \xdef\blx@refcontext@sortingtemplatename{\blx@sorting}%
  9470.   \gdef\blx@refcontext@sortingnamekeytemplatename{global}%
  9471.   \gdef\blx@refcontext@uniquenametemplatename{global}%
  9472.   \gdef\blx@refcontext@labelalphanametemplatename{global}%
  9473.   \blx@xdef@refcontext{\blx@refcontext@sortingtemplatename/\blx@refcontext@sortingnamekeytemplatename//\blx@refcontext@uniquenametemplatename/\blx@refcontext@labelalphanametemplatename}}
  9474.  
  9475. % Meta option to set all name template options
  9476. \define@key{blx@refcontext}{nametemplates}{%
  9477.   \gdef\blx@refcontext@sortingnamekeytemplatename{#1}%
  9478.   \gdef\blx@refcontext@uniquenametemplatename{#1}%
  9479.   \gdef\blx@refcontext@labelalphanametemplatename{#1}}
  9480.  
  9481. \define@key{blx@refcontext}{sorting}{\gdef\blx@refcontext@sortingtemplatename{#1}}
  9482. \define@key{blx@refcontext}{sortingnamekeytemplatename}{\gdef\blx@refcontext@sortingnamekeytemplatename{#1}}
  9483. \define@key{blx@refcontext}{uniquenametemplatename}{\gdef\blx@refcontext@uniquenametemplatename{#1}}
  9484. \define@key{blx@refcontext}{labelalphanametemplatename}{\gdef\blx@refcontext@labelalphanametemplatename{#1}}
  9485.  
  9486. % labelprefix cannot be used as is because it is used to construct the internal
  9487. % refcontext name which is referenced/expanded a lot all over the place. So,
  9488. % we hash the given input and use the safe hash as internal name.
  9489. % But that is not enough since the MD5 hash function expands the argument all
  9490. % the way and so unexpandable content like \dag breaks.
  9491. % Unexpandable content should be protected with \detokenize.
  9492. \define@key{blx@refcontext}{labelprefix}{%
  9493.   \xdef\blx@refcontext@labelprefix{\blx@mdfivesum{#1}}%
  9494.   \gdef\blx@refcontext@labelprefix@real{#1}%
  9495.   \iftoggle{blx@defernumbers}
  9496.    {}%
  9497.     {\iftoggle{blx@labelnumber}
  9498.        {\blx@warning{%
  9499.           Option 'labelprefix' requires global\MessageBreak
  9500.           'defernumbers=true'}}
  9501.        {}}}
  9502.  
  9503. % [refcontext keys]{<keyword1>,<keyword2>,...}
  9504. \newcommand*{\assignrefcontextkeyws}{%
  9505.   \@ifstar
  9506.     {\blx@assignrefcontextkeyws[*]}
  9507.    {\blx@assignrefcontextkeyws[]}}
  9508.  
  9509. \def\blx@assignrefcontextkeyws[#1][#2]#3{%
  9510.   \edef\blx@tempa{\blx@sorting}%
  9511.   \def\blx@tempb{global}%
  9512.   \let\blx@tempc\@empty%
  9513.   \def\blx@tempd{global}%
  9514.   \def\blx@tempe{global}%
  9515.   \setkeys{blx@assignrefcontext}{#2}%
  9516.   \def\do##1{%
  9517.     \listxadd\blx@assignedrefcontextkeywlist{##1}%
  9518.     \csxdef{blx@assignedrefcontextkeyws#1@\the\c@refsection @##1}%
  9519.       {\blx@tempa/\blx@tempb/\blx@tempc/\blx@tempd/\blx@tempe}}%
  9520.   \docsvlist{#3}}
  9521.  
  9522. % [refcontext keys]{<category1>,<category2>,...}
  9523. \newcommand*{\assignrefcontextcats}{%
  9524.   \@ifstar
  9525.     {\blx@assignrefcontextcats[*]}
  9526.    {\blx@assignrefcontextcats[]}}
  9527.  
  9528. \def\blx@assignrefcontextcats[#1][#2]#3{%
  9529.   \edef\blx@tempa{\blx@sorting}%
  9530.   \def\blx@tempb{global}%
  9531.   \let\blx@tempc\@empty%
  9532.   \def\blx@tempd{global}%
  9533.   \def\blx@tempe{global}%
  9534.   \setkeys{blx@assignrefcontext}{#2}%
  9535.   \def\do##1{%
  9536.     \listxadd\blx@assignedrefcontextcatlist{##1}%
  9537.     \csxdef{blx@assignedrefcontextcats#1@\the\c@refsection @##1}%
  9538.       {\blx@tempa/\blx@tempb/\blx@tempc/\blx@tempd/\blx@tempe}}%
  9539.   \docsvlist{#3}}
  9540.  
  9541. % [refcontext keys]{<entrykey1>,<entrykey2>,...}
  9542. \newcommand*{\assignrefcontextentries}{%
  9543.   \@ifstar
  9544.     {\blx@assignrefcontextentries[*]}
  9545.    {\blx@assignrefcontextentries[]}}
  9546.  
  9547. \def\blx@assignrefcontextentries[#1][#2]#3{%
  9548.   \edef\blx@tempa{\blx@sorting}%
  9549.   \def\blx@tempb{global}%
  9550.   \let\blx@tempc\@empty%
  9551.   \def\blx@tempd{global}%
  9552.   \def\blx@tempe{global}%
  9553.   \setkeys{blx@assignrefcontext}{#2}%
  9554.   \def\do##1{%
  9555.     \csxdef{blx@assignedrefcontextkeys#1@\the\c@refsection @##1}%
  9556.       {\blx@tempa/\blx@tempb/\blx@tempc/\blx@tempd/\blx@tempe}}%
  9557.   \docsvlist{#3}}
  9558.  
  9559. % Meta option to set all name template options
  9560. \define@key{blx@assignrefcontext}{nametemplates}{%
  9561.   \def\blx@tempb{#1}%
  9562.   \def\blx@tempd{#1}%
  9563.   \def\blx@tempe{#1}}
  9564.  
  9565. \define@key{blx@assignrefcontext}{sorting}{\def\blx@tempa{#1}}
  9566. \define@key{blx@assignrefcontext}{sortingnamekeytemplatename}{\def\blx@tempb{#1}}
  9567. \define@key{blx@assignrefcontext}{labelprefix}{%
  9568.   \edef\blx@tempc{\blx@mdfivesum{#1}}}
  9569. \define@key{blx@assignrefcontext}{uniquenametemplatename}{\def\blx@tempd{#1}}
  9570. \define@key{blx@assignrefcontext}{labelalphanametemplatename}{\def\blx@tempe{#1}}
  9571.  
  9572. % Reference sections
  9573. \newrobustcmd*{\newrefsection}{%
  9574.   \endrefcontext
  9575.   \ifnum\c@refsection>\z@
  9576.     \endrefsection
  9577.   \fi
  9578.   \refsection}
  9579. \let\blx@newrefsection\newrefsection
  9580.  
  9581. \newrobustcmd*{\refsection}{%
  9582.   \begingroup
  9583.   \edef\on@line{\on@line}%
  9584.   \ifnum\c@refsection>\z@
  9585.     \blx@err@nestenv{refsection}%
  9586.     \blx@endrefsection
  9587.   \fi
  9588.   \ifnum\c@refsegment>\z@
  9589.     \blx@err@nestenv{refsection}%
  9590.     \blx@endrefsegment
  9591.   \fi
  9592.   \@ifnextchar[%]
  9593.     {\blx@refsection}
  9594.    {\blx@refsection[]}}
  9595.  
  9596. \def\blx@refsection{%
  9597.   \begingroup
  9598.   \blx@hook@fileverb
  9599.   \blx@refsection@i}
  9600.  
  9601. \def\blx@refsection@i[#1]{%
  9602.   \endgroup
  9603.   \global\advance\blx@maxsection\@ne
  9604.   \global\c@refsection\blx@maxsection
  9605.   \xifinlist{\the\c@refsection}\blx@allrefsections
  9606.    {}
  9607.    {\listxadd\blx@allrefsections{\the\c@refsection}}%
  9608.   \ifcsdef{blx@defaultrefcontexts@\the\c@refsection}
  9609.    {}
  9610.    {\global\cslet{blx@defaultrefcontexts@\the\c@refsection}\@empty}%
  9611.   \expandafter\newcount\csname blx@maxsegment@\the\c@refsection\endcsname
  9612.   \expandafter\newcount\csname blx@sectionciteorder@\the\c@refsection\endcsname
  9613.   \blx@inf@refsec
  9614.   \blx@secinit
  9615.   \if@filesw
  9616.     \blx@auxwrite\@mainaux{}{%
  9617.       \string\abx@aux@refsection{\the\c@refsection}{\the\c@page}}%
  9618.     \ifblank{#1}
  9619.      {}
  9620.       {\let\blx@bibfiles\@empty
  9621.        % globals should be first as it might contain macros needed for others
  9622.        \forlistloop{\listadd\blx@bibfiles}\blx@bibfiles@global}%
  9623.        \blx@xsanitizeafter{\forcsvlist\blx@refsection@addfile}{#1}%
  9624.     \blx@refsection@ii
  9625.   \fi
  9626.   \blx@info{Setting label 'refsection:\the\c@refsection'}%
  9627.   \label{refsection:\the\c@refsection}%
  9628.   \endgroup}
  9629.  
  9630. \def\blx@refsection@addfile#1{%
  9631.   \ifcsdef{blx@res@labl@#1}
  9632.    {\blx@refsection@addfile@i{\csuse{blx@res@labl@#1}}}
  9633.    {\blx@refsection@addfile@i{#1}}}
  9634.  
  9635. \def\blx@refsection@addfile@i#1{%
  9636.   \ifcsdef{blx@res@loca@#1}
  9637.    {\listeadd\blx@bibfiles{#1}}
  9638.    {\listeadd\blx@bibfiles{\blx@stripbib{#1}\detokenize{.bib}}}}
  9639.  
  9640. \def\blx@refsection@ii{%
  9641.   \blx@regbibfiles\jobname\blx@bibfiles
  9642.   \begingroup
  9643.   \let\blx@tempa\@empty
  9644.   \blx@bibdata\blx@tempa\blx@bibfiles
  9645.   \blx@auxwrite\blx@bcfout
  9646.     {\let\do\blx@datasource}
  9647.    {\blx@xml@endsection\blx@nl
  9648.     \blx@xml@comment{SECTION \the\c@refsection}%
  9649.      \blx@xml@bibdata{\the\c@refsection}{\blx@tempa}%
  9650.      \blx@xml@section{\the\c@refsection}}%
  9651.   \endgroup}
  9652.  
  9653. \protected\def\endrefsection{%
  9654.   \endrefcontext
  9655.   \blx@endrefsection
  9656.   \blx@inf@refsec}
  9657.  
  9658. \def\blx@endrefsection{%
  9659.   \blx@endrefsegment
  9660.   % make sure we always output aliases to the .bcf otherwise after their
  9661.   % first resolution by biber, they will be invisible to subsequent biber
  9662.   % runs since biblatex will resolve the \keyalias{} macro to the main
  9663.   % entry key, biber won't put \keyalias{}in the .bbl on subsequent runs
  9664.   % and biblatex will report a missing citekey
  9665.   \def\do##1{%
  9666.     % Make sure this counter exists. Sometimes it might not when using, e.g:
  9667.     % refsection=chapter and \includeonly to put in the chapters or when
  9668.     % inserting citations into table of contents
  9669.     \ifcscounter{blx@sectionciteorder@\the\c@refsection}
  9670.      {}
  9671.      {\expandafter\newcount\csname blx@sectionciteorder@\the\c@refsection\endcsname}%
  9672.     \global\advance\csname blx@sectionciteorder@\the\c@refsection\endcsname\@ne
  9673.     \blx@auxwrite\blx@bcfout{}{\blx@xml@citekey{##1}{}{\expandafter\the\csname blx@sectionciteorder@\the\c@refsection\endcsname}}}%
  9674.   \dolistcsloop{blx@keyaliases@\the\c@refsection}%
  9675.   \ifnum\c@refsection>\z@
  9676.     \blx@auxwrite\blx@bcfout{}{%
  9677.       \blx@xml@endsection\blx@nl
  9678.       \blx@xml@comment{SECTION 0 (cont.)}%
  9679.       \blx@xml@section{0}}%
  9680.   \fi
  9681.   \global\c@refsection\z@}
  9682.  
  9683. \AtEndDocument{%
  9684.   \endrefcontext
  9685.   \blx@endrefsection
  9686.   \def\abx@aux@refsection#1#2{\blx@addchecksum{#1}{#2}}}
  9687.  
  9688. \protected\def\abx@aux@refsection#1#2{%
  9689.   \ifnum#1>\blx@maxsection
  9690.     \global\blx@maxsection#1\relax
  9691.   \fi
  9692.   \blx@addchecksum{#1}{#2}}
  9693.  
  9694. % Reference segments
  9695. \newrobustcmd*{\newrefsegment}{%
  9696.   \ifnum\c@refsegment>\z@
  9697.     \blx@endrefsegment
  9698.   \fi
  9699.   \refsegment}
  9700. \let\blx@newrefsegment\newrefsegment
  9701.  
  9702. \newrobustcmd*{\refsegment}{%
  9703.   \ifnum\c@refsegment>\z@
  9704.     \blx@err@nestenv{refsegment}%
  9705.     \blx@endrefsegment
  9706.   \fi
  9707.   \global\advance\csname blx@maxsegment@\the\c@refsection\endcsname\@ne
  9708.   \global\c@refsegment\csname blx@maxsegment@\the\c@refsection\endcsname
  9709.   \blx@inf@refseg
  9710.   \blx@info{Setting label 'refsegment:\the\c@refsection\the\c@refsegment'}%
  9711.   \label{refsegment:\the\c@refsection\the\c@refsegment}%
  9712.   \ifcsundef{blx@segm@\the\c@refsection @\the\c@refsegment}
  9713.    {\global\cslet{blx@segm@\the\c@refsection @\the\c@refsegment}\@empty}
  9714.    {}}
  9715.  
  9716. \protected\def\endrefsegment{%
  9717.   \blx@endrefsegment
  9718.   \blx@inf@refseg}
  9719.  
  9720. \def\blx@endrefsegment{%
  9721.   \global\c@refsegment\z@}
  9722.  
  9723. % Reference section/segment auto-reset
  9724. % we are prepending to the commands so that the resets happen before
  9725. % the part title is typeset otherwise \cites in there could be "ibid"
  9726. % which makes no sense
  9727. \def\blx@refpatch@part#1{%
  9728.     \ifundef\part
  9729.       {\blx@err@nodocdiv{part}}
  9730.      {\toggletrue{blx@tempa}%
  9731.        \def\do##1{%
  9732.          \pretocmd##1{#1}
  9733.           {\togglefalse{blx@tempa}\listbreak}
  9734.           {}}%
  9735.        \docsvlist{%
  9736.          \H@old@part,%    hyperref
  9737.          \NR@part,%       nameref
  9738.          \@part}%         latex/koma-script/memoir
  9739.        \iftoggle{blx@tempa}
  9740.         {\blx@err@patch{\string\@part}}
  9741.         {}%
  9742.        \let\do\noexpand}}
  9743.  
  9744. \def\blx@refpatch@chapter#1{%
  9745.   \ifundef\chapter
  9746.     {\blx@err@nodocdiv{chapter}}
  9747.     {% the \ifcsundef{KOMAClassName} should be redundant, but you never know
  9748.      \ifboolexpr{test {\ifcsundef{KOMAClassName}}
  9749.                 or test {\ifcsundef{startsection@secnumdepth}}}
  9750.       {\pretocmd\@makechapterhead{#1}
  9751.          {}
  9752.          {\blx@err@patch{\string\@makechapterhead}}
  9753.        \pretocmd\@makeschapterhead{#1}
  9754.          {}
  9755.          {\blx@err@patch{\string\@makeschapterhead}}}
  9756.        {% <- new KOMA >= 3.26 defines \startsection@secnumdepth
  9757.         \At@startsection{\ifnumequal{\startsection@secnumdepth}{0}{#1}{}}}}}
  9758.  
  9759. \def\blx@refpatch@sect#1{%
  9760.   \ifcsundef{#1}
  9761.    {\blx@err@nodocdiv{#1}\@gobbletwo}
  9762.     {% the \ifcsundef{KOMAClassName} should be redundant, but you never know
  9763.      \ifboolexpr{test {\ifcsundef{KOMAClassName}}
  9764.                 or test {\ifcsundef{startsection@secnumdepth}}}
  9765.       {\blx@refpatch@sect@i}
  9766.       {\blx@refpatch@sect@koma}}}
  9767.  
  9768. % KOMA >= 3.26 defines \startsection@secnumdepth to check the sectioning level,
  9769. % so we can now use \At@startsection
  9770. \def\blx@refpatch@sect@koma#1#2{%
  9771.   \At@startsection{\ifnumequal{\startsection@secnumdepth}{#2}{#1}{}}}
  9772.  
  9773. \edef\blx@refpatch@sect@i#1#2{%
  9774.   \def\noexpand\do##1{%
  9775.     \pretocmd##1%
  9776.       {\noexpand\blx@refpatch@sect@ii{#1}{#2}{\string#2}}
  9777.      {\togglefalse{blx@tempa}\noexpand\listbreak}
  9778.      {}}%
  9779.   \noexpand\blx@refpatch@sect@iii}
  9780.  
  9781. \def\blx@refpatch@sect@ii#1#2#3{%
  9782.   \ifnumequal{#2}{#3}{#1}{}}
  9783.  
  9784. \def\blx@refpatch@sect@iii{%
  9785.   \toggletrue{blx@tempa}%
  9786.   \docsvlist{%       order does matter:
  9787.     \H@old@sectm@m,% memoir+hyperref (what a mess...)
  9788.     \M@sect,%        memoir
  9789.     \H@old@sect,%    hyperref
  9790.     \NR@sect,%       nameref
  9791.     \scr@sect,%      koma-script 3.x
  9792.     \scr@startsection,%  bad hack for koma 3.15 <= v <= 3.25
  9793.     \@startsection}%         latex
  9794.   \iftoggle{blx@tempa}
  9795.    {\blx@err@patch{\string\@sect}}
  9796.    {}%
  9797.   \let\do\noexpand}
  9798.  
  9799. % Bibliography categories
  9800.  
  9801. \let\blx@categories\@empty
  9802.  
  9803. % {<category>}
  9804. \newrobustcmd*{\DeclareBibliographyCategory}[1]{%
  9805.   \ifcsundef{blx@catg@#1}
  9806.    {\global\cslet{blx@catg@#1}\@empty
  9807.     \listgadd\blx@categories{#1}}
  9808.    {\blx@error
  9809.       {Category '#1' already declared}
  9810.       {The bibliography category '#1'\MessageBreak
  9811.        has already been declared}}}
  9812. \@onlypreamble\DeclareBibliographyCategory
  9813.  
  9814. % {<category>}{<entrykey>,...}
  9815. \newrobustcmd*{\addtocategory}[2]{%
  9816.   \ifcsundef{blx@catg@#1}
  9817.    {\blx@error
  9818.       {Category '#1' not declared}
  9819.       {Use \string\DeclareBibliographyCategory\space to declare}}
  9820.     {\AfterPreamble{%
  9821.        \blx@xsanitizeafter{\forcsvlist{\blx@addtocategory{#1}}}{#2}}}}
  9822.  
  9823. % {<category>}{<entrykey>,...}
  9824. \def\blx@addtocategory#1#2{%
  9825.   % If we are adding a set member to a category, make sure we also add the
  9826.   % set parent if it is cited. If it is cited, we should be using the set
  9827.   % parent in the category, not the set child member. blx@setc@... will
  9828.   % only exist if the set parent is also cited as it is only defined when a
  9829.   % member contains \inset which only happens when the set parent is cited.
  9830.   \ifcsdef{blx@setc@\the\c@refsection @#2}
  9831.    {\blx@auxwrite\@mainaux{}{\string\abx@aux@category{#1}{\csuse{blx@setc@\the\c@refsection @#2}}}%
  9832.      \abx@aux@category{#1}{\csuse{blx@setc@\the\c@refsection @#2}}}
  9833.    {}%
  9834.   \blx@auxwrite\@mainaux{}{\string\abx@aux@category{#1}{#2}}%
  9835.   \abx@aux@category{#1}{#2}}
  9836.  
  9837. % {<category>}{<entrykey>,...}
  9838. \protected\def\abx@aux@category#1#2{%
  9839.   \xifinlistcs{\detokenize{#2}}{blx@catg@#1}
  9840.    {}
  9841.    {\listcsxadd{blx@catg@#1}{\detokenize{#2}}}}
  9842.  
  9843. \AtEndDocument{\let\abx@aux@category\@gobbletwo}
  9844.  
  9845. % [<options>]{<resource>,...}
  9846. \renewrobustcmd*{\bibliography}[1]{%
  9847.   \begingroup
  9848.   \def\blx@tempa{file}%
  9849.   \def\blx@tempb{bibtex}%
  9850.   \def\blx@tempc{local}%
  9851.   \undef\blx@tempd
  9852.   \let\blx@tempe\@empty
  9853.   \blx@xsanitizeafter{\forcsvlist\blx@addbib@legacy}{#1}%
  9854.   \endgroup}
  9855. \@onlypreamble\bibliography
  9856.  
  9857. \def\blx@addbib@legacy#1{%
  9858.   \begingroup
  9859.   \edef\blx@tempa{\endgroup
  9860.    \noexpand\blx@addbib@resource{\blx@stripbib{#1}\detokenize{.bib}}}%
  9861.   \blx@tempa}
  9862.  
  9863. \def\blx@stripbib#1{%
  9864.   \expandafter\blx@stripbib@i\detokenize{#1.bib}&}
  9865. \edef\blx@stripbib@i{%
  9866.   \def\noexpand\blx@stripbib@i##1\detokenize{.bib}##2&}
  9867. \blx@stripbib@i{#1}
  9868.  
  9869. % [<options>]{<resource>,...}
  9870. \newrobustcmd*{\addbibresource}{%
  9871.   \blx@addbib\blx@addbib@resource}
  9872. \@onlypreamble\addbibresource
  9873.  
  9874. \newrobustcmd*{\addglobalbib}{%
  9875.   \blx@addbib\blx@addbib@global}
  9876. \@onlypreamble\addglobalbib
  9877.  
  9878. \newrobustcmd*{\addsectionbib}{%
  9879.   \blx@addbib\blx@addbib@register}
  9880. \@onlypreamble\addsectionbib
  9881.  
  9882. \def\blx@addbib#1{%
  9883.   \@ifnextchar[%]
  9884.     {\blx@addbib@i{#1}}
  9885.    {\blx@addbib@i{#1}[]}}
  9886.  
  9887. \def\blx@addbib@i#1[#2]{%
  9888.   \begingroup
  9889.   \blx@hook@fileverb
  9890.   \blx@addbib@ii{#1}{#2}}
  9891.  
  9892. \def\blx@addbib@ii#1#2#3{%
  9893.   \endgroup
  9894.   \begingroup
  9895.   \def\blx@tempa{file}%
  9896.   \def\blx@tempb{bibtex}%
  9897.   \def\blx@tempc{local}%
  9898.   \undef\blx@tempd
  9899.   \let\blx@tempe\@empty
  9900.   \setkeys{blx@addbib}{#2}%
  9901.   \blx@xsanitizeafter{#1}{#3}%
  9902.   \endgroup}
  9903.  
  9904. \def\blx@hook@fileverb{%
  9905.   \let\do\@makeother
  9906.   \dospecials
  9907.   \catcode`\\=\z@
  9908.   \catcode`\{=\@ne
  9909.  \catcode`\}=\tw@}
  9910.  
  9911. \define@key{blx@addbib}{type}{\def\blx@tempa{#1}}
  9912. \define@key{blx@addbib}{datatype}{\def\blx@tempb{#1}}
  9913. \define@key{blx@addbib}{location}{\def\blx@tempc{#1}}
  9914. \define@key{blx@addbib}{label}{\edef\blx@tempd{\detokenize{#1}}}
  9915. \define@key{blx@addbib}{bibencoding}{\def\blx@tempe{#1}}
  9916.  
  9917. % \blx@res@type@<resource>      resource -> type
  9918. % \blx@res@data@<resource>      resource -> datatype
  9919. % \blx@res@loca@<resource>      resource -> datatype
  9920. % \blx@res@labl@<resource>      label    -> resource
  9921.  
  9922. \def\blx@addbib@register#1{%
  9923.   \csxdef{blx@res@type@#1}{\blx@tempa}%
  9924.   \csxdef{blx@res@data@#1}{\blx@tempb}%
  9925.   \csxdef{blx@res@loca@#1}{\blx@tempc}%
  9926.   \csxdef{blx@res@bibencoding@#1}{\blx@tempe}%
  9927.   \ifdef\blx@tempd
  9928.     {\csxdef{blx@res@labl@\blx@tempd}{#1}}
  9929.    {}}
  9930.  
  9931. \def\blx@addbib@resource#1{%
  9932.   \blx@addbib@register{#1}%
  9933.   \listgadd\blx@bibfiles{#1}%
  9934.   \blx@regbibfile\jobname{#1}}
  9935.  
  9936. \def\blx@addbib@global#1{%
  9937.   \blx@addbib@resource{#1}%
  9938.   \listgadd\blx@bibfiles@global{#1}}
  9939.  
  9940. \let\blx@bibfiles\@empty
  9941. \let\blx@bibfiles@global\@empty
  9942.  
  9943. \def\blx@bibdata#1#2{%
  9944.   \forlistloop{\blx@bibdata@i{#1}}#2}
  9945. \def\blx@bibdata@i#1#2{%
  9946.   \blx@xmlsanitizeafter{\blx@bibdata@ii{#1}{#2}}{#2}}
  9947. \def\blx@bibdata@ii#1#2#3{%
  9948.   \eappto#1{%
  9949.     \blx@xml@datasource
  9950.       {\ifcsdef{blx@res@type@#2}
  9951.         {\csuse{blx@res@type@#2}}
  9952.         {file}}
  9953.      {\ifcsdef{blx@res@data@#2}
  9954.        {\csuse{blx@res@data@#2}}
  9955.        {bibtex}}
  9956.      {\ifcsvoid{blx@res@bibencoding@#2}
  9957.        {}
  9958.        { encoding="\csuse{blx@res@bibencoding@#2}"}}
  9959.      {#3}}}
  9960.  
  9961. %% Citations
  9962.  
  9963. \newrobustcmd*{\AtEveryCite}{\gappto\blx@hook@cite}
  9964. \newrobustcmd*{\AtEveryCitekey}{\gappto\blx@hook@citekey}
  9965. \newrobustcmd*{\AtEveryMultiCite}{\gappto\blx@hook@mcite}
  9966. \@onlypreamble\AtEveryCite
  9967. \@onlypreamble\AtEveryCitekey
  9968. \@onlypreamble\AtEveryMultiCite
  9969.  
  9970. \newrobustcmd*{\AtEachCitekey}{%
  9971.   \iftoggle{blx@citation}{\appto\blx@hook@citekey}{\@gobble}}
  9972.  
  9973. \def\blx@imc@UseEveryCiteHook{\csuse{blx@hook@cite}}
  9974. \def\blx@imc@UseEveryCitekeyHook{\csuse{blx@hook@citekey}}
  9975. \def\blx@imc@UseEveryMultiCiteHook{\csuse{blx@hook@mcite}}
  9976.  
  9977. \newrobustcmd*{\AtNextCite}{%
  9978.   \ifundef\blx@hook@cite@next
  9979.     {\gdef\blx@hook@cite@next{\global\undef\blx@hook@cite@next}}
  9980.    {}%
  9981.   \gappto\blx@hook@cite@next}
  9982.  
  9983. \newrobustcmd*{\AtNextCitekey}{%
  9984.   \ifundef\blx@hook@citekey@next
  9985.     {\gdef\blx@hook@citekey@next{\global\undef\blx@hook@citekey@next}}
  9986.    {}%
  9987.   \gappto\blx@hook@citekey@next}
  9988.  
  9989. \newrobustcmd*{\AtNextMultiCite}{%
  9990.   \ifundef\blx@hook@mcite@next
  9991.     {\gdef\blx@hook@mcite@next{\global\undef\blx@hook@mcite@next}}
  9992.    {}%
  9993.   \gappto\blx@hook@mcite@next}
  9994.  
  9995. \def\blx@imc@UseNextCiteHook{\csuse{blx@hook@cite@next}}
  9996. \def\blx@imc@UseNextCitekeyHook{\csuse{blx@hook@citekey@next}}
  9997. \def\blx@imc@UseNextMultiCiteHook{\csuse{blx@hook@mcite@next}}
  9998.  
  9999. \def\blx@imc@DeferNextCitekeyHook{\undef\blx@hook@citekey@next}
  10000.  
  10001. \blx@regimcs{%
  10002.   \UseEveryCiteHook \UseEveryCitekeyHook \UseEveryMultiCiteHook
  10003.   \UseNextCiteHook \UseNextCitekeyHook \UseNextMultiCiteHook
  10004.   \DeferNextCitekeyHook}
  10005.  
  10006. % {<style>}
  10007.  
  10008. \newrobustcmd*{\RequireCitationStyle}[1]{%
  10009.   \blx@inputonce{#1.cbx}{citation style '#1'}{}{}{}
  10010.    {\blx@error
  10011.       {Style '#1' not found}
  10012.       {The citation style '#1' could not be found}}}
  10013. \@onlypreamble\RequireCitationStyle
  10014.  
  10015. % {<code>}
  10016.  
  10017. \newrobustcmd*{\InitializeCitationStyle}{\appto\blx@hook@cbxinit}
  10018. \@onlypreamble\InitializeCitationStyle
  10019.  
  10020. % {<code>}
  10021.  
  10022. \newrobustcmd*{\OnManualCitation}{\appto\blx@hook@mancite}
  10023. \@onlypreamble\OnManualCitation
  10024.  
  10025. \newrobustcmd*{\mancite}{%
  10026.   \csuse{blx@hook@mancite}%
  10027.   \blx@ibidreset
  10028.   \blx@idemreset
  10029.   \blx@opcitreset
  10030.   \blx@loccitreset}
  10031.  
  10032. % {<entrykey>}{<message>}
  10033. % Wrapper to track cite keys which are \nocited
  10034. \def\blx@nocitation#1#2{%
  10035.   \ifinlist{#1}\blx@nocites
  10036.    {}
  10037.    {\listgadd\blx@nocites{#1}}%
  10038.   \blx@citation@i{#1}{#2}}
  10039.  
  10040. % {<entrykey>}{<message>}
  10041. % Just a wrapper to suppress citation tracking in toc/lof etc.
  10042. \def\blx@citation#1#2{%
  10043.   \ifinlist{#1}\blx@directcites
  10044.    {}
  10045.    {\listgadd\blx@directcites{#1}}%
  10046.   \blx@citation@i{#1}{#2}}
  10047.  
  10048. \def\blx@citation@i#1#2{%
  10049.   \ifbool{citerequest}
  10050.    {\blx@citation@entry{#1}{#2}}
  10051.    {}}
  10052.  
  10053. \def\blx@citation@entry#1#2{%
  10054.   \blx@bibreq{#1}%
  10055.   \ifinlist{#1}\blx@cites
  10056.    {}
  10057.    {\listgadd{\blx@cites}{#1}%
  10058.      \blx@auxwrite\@mainaux{}{\string\abx@aux@cite{#1}}}%
  10059.   \ifinlistcs{#1}{blx@segm@\the\c@refsection @\the\c@refsegment}
  10060.    {}
  10061.    {\listcsgadd{blx@segm@\the\c@refsection @\the\c@refsegment}{#1}}%
  10062.   \blx@auxwrite\@mainaux{}{\string\abx@aux@segm{\the\c@refsection}{\the\c@refsegment}{\detokenize{#1}}}%
  10063.   \blx@ifdata{#1}
  10064.    {}
  10065.    {\ifcsdef{blx@miss@\the\c@refsection}
  10066.       {\ifinlistcs{#1}{blx@miss@\the\c@refsection}
  10067.          {}
  10068.          {\blx@logreq@active{#2{#1}}}}
  10069.       {\blx@logreq@active{#2{#1}}}}}
  10070.  
  10071. \protected\def\abx@aux@segm#1#2#3{%
  10072.   \listcsxadd{blx@segm@#1@#2}{\detokenize{#3}}}
  10073.  
  10074. \def\blx@nocitation@all{%
  10075.   \ifinlist{*}\blx@nocites
  10076.    {}
  10077.    {\listgadd\blx@nocites{*}}%
  10078.   \blx@citation@all}
  10079.  
  10080. \def\blx@citation@all{%
  10081.   \ifbool{citerequest}
  10082.    {\blx@bibreq{*}%
  10083.      \global\csletcs
  10084.        {blx@segm@\the\c@refsection @\the\c@refsegment}
  10085.       {blx@dlist@entry@\the\c@refsection @\blx@refcontext@context}%
  10086.       \ifcsvoid{blx@dlist@entry@\the\c@refsection @\blx@refcontext@context}
  10087.       {\blx@logreq@active{}}
  10088.       {}}
  10089.    {}}
  10090.  
  10091. \protected\def\blx@bibreq#1{%
  10092.   \begingroup
  10093.   \blx@xmlsanitizeafter{\def\blx@tempa}{#1}%
  10094.   \let\blx@tempb\@empty
  10095.   % Only output as \nocited if a key wasn't also directly \cite'd
  10096.   % Since citekey output is sequential as cites are read, the .bcf might contain
  10097.   % duplicate keys with differring nocite attributes if \nocite{X} and \cite{X} both occur
  10098.   % but biber deals with this and priorities \cites
  10099.   \ifboolexpr{test {\ifinlist{#1}\blx@nocites}
  10100.              and
  10101.              not test {\ifinlist{#1}\blx@directcites}}
  10102.    {\def\blx@tempb{ nocite="1"}}
  10103.    {}%
  10104.   % citeall is always order "0" - this makes no real difference as biber
  10105.   % ignores all other citekeys in the section if citeall is present
  10106.   \ifstrequal{*}{#1}
  10107.    {\blx@auxwrite\blx@bcfout{}{\blx@xml@citekey{\blx@tempa}{\blx@tempb}{0}}}
  10108.    {\blx@auxwrite\blx@bcfout{}{\blx@xml@citekey{\blx@tempa}{\blx@tempb}{\expandafter\the\csname blx@sectionciteorder@\the\c@refsection\endcsname}}}%
  10109.   \endgroup}
  10110.  
  10111. % {<set>}{<key1,key2,key3>}
  10112.  
  10113. \newrobustcmd*{\defbibentryset}[2]{%
  10114.   \@bsphack
  10115.   \begingroup
  10116.   \blx@xsanitizeafter{\def\blx@tempa}{#1}%
  10117.   \let\blx@tempb\@empty
  10118.   \let\blx@tempc\@empty
  10119.   \blx@xsanitizeafter{\forcsvlist\blx@defentryset@add}{#2}%
  10120.   \ifcsdef{blx@set@\the\c@refsection @\blx@tempa}
  10121.    {\expandafter\ifdefequal
  10122.       \csname blx@set@\the\c@refsection @\blx@tempa\endcsname
  10123.       \blx@tempb
  10124.       {}
  10125.       {\blx@error
  10126.          {Conflicting definitions of '\blx@tempa'}
  10127.           {The entry set '\blx@tempa' been defined before.\MessageBreak
  10128.            old: \blx@tempa\space = %
  10129.            \csuse{blx@set@\the\c@refsection @\blx@tempa}\MessageBreak
  10130.           new: \blx@tempa\space = \blx@tempb\MessageBreak
  10131.           I'm ignoring the new definition}}}
  10132.    {\global\cslet{blx@set@\the\c@refsection @\blx@tempa}\blx@tempb
  10133.      \edef\blx@tempa{%
  10134.        \AfterPreamble{\blx@setreq{\blx@tempa}{\blx@tempb}}}%
  10135.      \blx@tempa}%
  10136.   \endgroup
  10137.   \@esphack}
  10138.  
  10139. \def\blx@defentryset@add#1{%
  10140.   \edef\blx@tempb{\blx@tempb\blx@tempc#1}%
  10141.   \def\blx@tempc{,}}
  10142.  
  10143. \protected\def\blx@setreq#1#2{%
  10144.   \begingroup
  10145.   \blx@xmlsanitizeafter{\def\blx@tempa}{#1}%
  10146.   \blx@xmlsanitizeafter{\def\blx@tempb}{#2}%
  10147.   \blx@auxwrite\blx@bcfout{}{\blx@xml@citeset{\blx@tempa}{\blx@tempb}}%
  10148.   \endgroup}
  10149.  
  10150. % {<entrykey>,...}
  10151. \protected\def\blx@citeloop#1{%
  10152.   \expandafter\blx@citeloop@i\expandafter{\detokenize{#1}}}
  10153. \protected\def\blx@citeloop@i#1{%
  10154.   \begingroup
  10155.   % This must be here and not after \blx@citeadd as this changes the refcontext
  10156.   \letcs\blx@tempb{blx@dlist@centry@\the\c@refsection @\blx@refcontext@context}%
  10157.   \ifundef\blx@tempb
  10158.     {\let\blx@tempb\@empty}
  10159.    {}%
  10160.   % Make sure this counter exists. Sometimes it might not when using, e.g:
  10161.   % refsection=chapter and \includeonly to put in the chapters or when
  10162.   % inserting citations into table of contents
  10163.   \ifcscounter{blx@sectionciteorder@\the\c@refsection}
  10164.    {}
  10165.    {\expandafter\newcount\csname blx@sectionciteorder@\the\c@refsection\endcsname}%
  10166.   \global\advance\csname blx@sectionciteorder@\the\c@refsection\endcsname\@ne
  10167.   \blx@tempcnta\z@
  10168.   \blx@tempcntb\z@
  10169.   \let\blx@tempa\@empty
  10170.   \forcsvlist\blx@citeadd{#1}% adds to \blx@tempa
  10171.   \blx@thenotecheck
  10172.   \ifnum\blx@tempcnta>\z@
  10173.     \ifnum\blx@tempcntb>\z@
  10174.       \multicitedelim
  10175.     \fi
  10176.   \else
  10177.     \blx@postpunct@saved
  10178.   \fi
  10179.   % \blx@tempb is a sorted list of all cites, \blx@tempa is the list of cites to
  10180.   % sort using this list
  10181.   \blx@thecitesort
  10182.   \edef\blx@tempa{\endgroup
  10183.    \c@citecount\z@
  10184.    \c@citetotal\the\blx@tempcnta\relax
  10185.    \noexpand\ifnum\c@overallcitetotal=0
  10186.      \c@overallcitetotal\c@citetotal
  10187.    \noexpand\fi
  10188.    \unexpanded{\forlistloop\blx@citeprint}{\blx@tempb}}%
  10189.   \blx@tempa}
  10190.  
  10191. \def\blx@notecheck{%
  10192.   \ifnum\blx@tempcnta>\@ne
  10193.     \blx@warning{%
  10194.       Package option 'sortcites' enabled.\MessageBreak
  10195.       Verify postnote placement}%
  10196.   \fi}
  10197.  
  10198. \def\blx@citesort{%
  10199.   \ifnum\blx@tempcnta>\@ne
  10200.     \blx@filtercitesort\blx@tempb{blx@tempa}%
  10201.   \else
  10202.     \blx@citenosort
  10203.   \fi}
  10204.  
  10205. \def\blx@citenosort{%
  10206.   \let\blx@tempb\blx@tempa}
  10207.  
  10208. \def\abx@missing@entry#1{%
  10209.   \abx@missing{#1}}
  10210.  
  10211. % {<entrykey>}
  10212. \def\blx@citeadd#1{%
  10213.   \ifcsdef{blx@keyalias@\the\c@refsection @#1}
  10214.    {\edef\blx@realkey{\csuse{blx@keyalias@\the\c@refsection @#1}}}
  10215.    {\def\blx@realkey{#1}}%
  10216.   \expandafter\blx@getrefcontext\expandafter{\blx@realkey}% needed for \ifdata
  10217.   \expandafter\blx@citation\expandafter{\blx@realkey}\blx@msg@cundefon
  10218.  \expandafter\blx@ifdata\expandafter{\blx@realkey}
  10219.    {\advance\blx@tempcnta\@ne
  10220.     \listeadd\blx@tempa{\blx@realkey}}
  10221.    {\ifnum\blx@tempcntb>\z@\multicitedelim\fi
  10222.     \expandafter\abx@missing@entry\expandafter{\blx@realkey}%
  10223.      \advance\blx@tempcntb\@ne}}
  10224.  
  10225. % set default refcontext for one citation key
  10226. % and then override with data from auto-assign \assignrefcontext* macros, if any
  10227. % <entrykey>
  10228. \def\blx@getrefcontext#1{%
  10229.   % Save refcontext for restoration at end of \citeprint
  10230.   \let\blx@refcontext@context@saved\blx@refcontext@context
  10231.   % Get the default refcontext
  10232.   % If there was one due to appearance in a bib/biblist, use it
  10233.   % otherwise fall back on global refcontext. This can happen for cites
  10234.   % made (a bit strangely but some styles do this) inside a biblist
  10235.   % which never appear in any printed bib/biblist and therefore have no default
  10236.   % refcontext defined
  10237.   \ifcsdef{blx@assignedrefcontextbib@\the\c@refsection @#1}
  10238.    {\letcs\blx@refcontext@context{blx@assignedrefcontextbib@\the\c@refsection @#1}}
  10239.    {\blx@edef@refcontext{\blx@sorting/global//global/global}}%
  10240.   % assignment via keyword list
  10241.   \ifdef\blx@assignedrefcontextkeywlist
  10242.     {\def\do##1{%
  10243.        \blx@imc@ifentrykeyword{#1}{##1}
  10244.          {% weak version
  10245.           \ifboolexpr{test {\ifcsdef{blx@assignedrefcontextkeyws*@\the\c@refsection @##1}}
  10246.                      and
  10247.                      not togl {blx@refcontext}}% inside explicit non-global refcontext
  10248.             {\letcs\blx@refcontext@context{blx@assignedrefcontextkeyws*@\the\c@refsection @##1}}
  10249.            {}%
  10250.           % strong version
  10251.           \ifcsdef{blx@assignedrefcontextkeyws@\the\c@refsection @##1}
  10252.            {\letcs\blx@refcontext@context{blx@assignedrefcontextkeyws@\the\c@refsection @##1}}
  10253.            {}}
  10254.         {}}%
  10255.      \dolistloop\blx@assignedrefcontextkeywlist}
  10256.     {}%
  10257.   % assignment via category
  10258.   \ifdef\blx@assignedrefcontextcatlist
  10259.     {\def\do##1{%
  10260.        \blx@imc@ifentrycategory{#1}{##1}
  10261.          {% weak version
  10262.           \ifboolexpr{test {\ifcsdef{blx@assignedrefcontextcats*@\the\c@refsection @##1}}
  10263.                      and
  10264.                      not togl {blx@refcontext}}% inside explicit non-global refcontext
  10265.             {\letcs\blx@refcontext@context{blx@assignedrefcontextcats*@\the\c@refsection @##1}}
  10266.            {}%
  10267.           % strong version
  10268.           \ifcsdef{blx@assignedrefcontextcats@\the\c@refsection @##1}
  10269.            {\letcs\blx@refcontext@context{blx@assignedrefcontextcats@\the\c@refsection @##1}}
  10270.            {}}
  10271.         {}}%
  10272.      \dolistloop\blx@assignedrefcontextcatlist}
  10273.     {}%
  10274.   % assignment via entrykeys
  10275.   % weak version
  10276.   \nottoggle{blx@refcontext}
  10277.    {\ifcsdef{blx@assignedrefcontextkeys*@\the\c@refsection @*}
  10278.       {\letcs\blx@refcontext@context{blx@assignedrefcontextkeys*@\the\c@refsection @*}}
  10279.       {\ifcsdef{blx@assignedrefcontextkeys*@\the\c@refsection @#1}
  10280.         {\letcs\blx@refcontext@context{blx@assignedrefcontextkeys*@\the\c@refsection @#1}}
  10281.         {}}}
  10282.    {}%
  10283.   % strong version
  10284.   \ifcsdef{blx@assignedrefcontextkeys@\the\c@refsection @*}
  10285.    {\letcs\blx@refcontext@context{blx@assignedrefcontextkeys@\the\c@refsection @*}}
  10286.    {\ifcsdef{blx@assignedrefcontextkeys@\the\c@refsection @#1}
  10287.      {\letcs\blx@refcontext@context{blx@assignedrefcontextkeys@\the\c@refsection @#1}}
  10288.      {}}}
  10289.  
  10290. % {<entrykey>}
  10291. \protected\def\blx@citeprint#1{%
  10292.   \blx@getrefcontext{#1}%
  10293.   \advance\c@citecount\@ne
  10294.   \advance\c@overallcitecount\@ne
  10295.   \addtocounter{instcount}\@ne
  10296.  \ifnum\c@citecount=\@ne
  10297.    \blx@getdata@cite{#1}%
  10298.     \blx@precode
  10299.     \ifnum\c@citetotal>\@ne
  10300.       \blx@resetdata
  10301.     \fi
  10302.   \else
  10303.     \blx@dlimcode
  10304.   \fi
  10305.   \begingroup
  10306.   \ifnum\c@citetotal>\@ne
  10307.     \blx@getdata@cite{#1}%
  10308.   \fi
  10309.   \blx@entrysetcount
  10310.   \blx@setoptions@type\abx@field@entrytype
  10311.   \blx@setoptions@entry
  10312.   \blx@backref{#1}%
  10313.   \blx@pagetracker
  10314.   \csuse{blx@hook@citekey}%
  10315.   \csuse{blx@hook@citekey@next}%
  10316.   \blx@beglangcite
  10317.   \blx@execute
  10318.   \blx@loopcode
  10319.   \blx@citecounter
  10320.   \blx@citetracker
  10321.   \blx@ibidtracker
  10322.   \blx@idemtracker
  10323.   \blx@opcittracker
  10324.   \blx@loccittracker
  10325.   \ifnum\c@citecount=\c@citetotal
  10326.     \def\blx@thecheckpunct{\blx@err@nestcite\@gobble}%
  10327.     \blx@postcode
  10328.     \blx@postpunct@saved
  10329.   \fi
  10330.   \blx@endlangcite
  10331.   \endgroup
  10332.   \let\blx@refcontext@context\blx@refcontext@context@saved}
  10333.  
  10334. % cite counter
  10335. \def\blx@citecounter@global{%
  10336.   \ifbool{@filesw}
  10337.    {\ifbool{citetracker}
  10338.        {\immediate\write\@mainaux{%
  10339.           \string\abx@aux@count
  10340.           {\the\c@refsection}{\abx@field@entrykey}}}
  10341.       {}}
  10342.    {}}
  10343.  
  10344. \def\blx@citecounter@context{%
  10345.   \ifbool{@filesw}
  10346.    {\ifbool{citetracker}
  10347.        {\immediate\write\@mainaux{%
  10348.           \iftoggle{blx@footnote}
  10349.            {\string\abx@aux@fncount}
  10350.            {\string\abx@aux@count}%
  10351.           {\the\c@refsection}{\abx@field@entrykey}}}
  10352.       {}}
  10353.    {}}
  10354.  
  10355. % {<refsection>}{<entrykey>}
  10356. % set maxcitecounter as well, note that we also define a maxcitecounter across
  10357. % all refsections, but that does not have a high-level interface
  10358. \protected\def\blx@aux@count#1#2{%
  10359.   \csnumgdef{blx@count@#1@\detokenize{#2}}{%
  10360.     \csuse{blx@count@#1@\detokenize{#2}}+1}%
  10361.   \ifnumgreater{\csuse{blx@count@#1@\detokenize{#2}}}{%
  10362.       0\csuse{blx@maxcitecounter@#1}}
  10363.    {\csnumgdef{blx@maxcitecounter@#1}{%
  10364.        \csuse{blx@count@#1@\detokenize{#2}}}}
  10365.    {}%
  10366.   \ifnumgreater{\csuse{blx@count@#1@\detokenize{#2}}}{%
  10367.       0\csuse{blx@maxcitecounter}}
  10368.    {\csnumgdef{blx@maxcitecounter}{%
  10369.        \csuse{blx@count@#1@\detokenize{#2}}}}
  10370.    {}}
  10371.  
  10372. \protected\def\blx@aux@fncount#1#2{%
  10373.   \csnumgdef{blx@fncount@#1@\detokenize{#2}}{%
  10374.     \csuse{blx@fncount@#1@\detokenize{#2}}+1}%
  10375.   \ifnumgreater{\csuse{blx@fncount@#1@\detokenize{#2}}}{%
  10376.       0\csuse{blx@maxfncitecounter@#1}}
  10377.    {\csnumgdef{blx@maxfncitecounter@#1}{%
  10378.        \csuse{blx@fncount@#1@\detokenize{#2}}}}
  10379.    {}%
  10380.   \ifnumgreater{\csuse{blx@fncount@#1@\detokenize{#2}}}{%
  10381.       0\csuse{blx@maxfncitecounter}}
  10382.    {\csnumgdef{blx@maxfncitecounter}{%
  10383.        \csuse{blx@fncount@#1@\detokenize{#2}}}}
  10384.    {}}
  10385.  
  10386. \let\abx@aux@count\@gobbletwo
  10387. \let\abx@aux@fncount\@gobbletwo
  10388.  
  10389. \AtEndDocument{%
  10390.   \let\abx@aux@count\@gobbletwo
  10391.   \let\abx@aux@fncount\@gobbletwo}
  10392.  
  10393. \protected\def\blx@setcitecounter@global{%
  10394.   \c@citecounter0%
  10395.     \csuse{blx@count@\the\c@refsection @\abx@field@entrykey}%
  10396.   \relax
  10397.   \c@maxcitecounter0%
  10398.     \csuse{blx@maxcitecounter@\the\c@refsection}%
  10399.   \relax}
  10400.  
  10401. \protected\def\blx@setcitecounter@context{%
  10402.   \c@citecounter0%
  10403.     \iftoggle{blx@footnote}
  10404.      {\csuse{blx@fncount@\the\c@refsection @\abx@field@entrykey}}
  10405.      {\csuse{blx@count@\the\c@refsection @\abx@field@entrykey}}%
  10406.   \relax
  10407.   \c@maxcitecounter0%
  10408.     \iftoggle{blx@footnote}
  10409.      {\csuse{blx@maxfncitecounter@\the\c@refsection}}
  10410.      {\csuse{blx@maxcitecounter@\the\c@refsection}}%
  10411.   \relax}
  10412.  
  10413. % cite tracker
  10414. \def\blx@citetracker@global{%
  10415.   \ifbool{citetracker}
  10416.    {\xifinlistcs\abx@field@entrykey{blx@bsee@\the\c@refsection}
  10417.       {}
  10418.       {\listcsxadd{blx@bsee@\the\c@refsection}\abx@field@entrykey}}
  10419.    {}}
  10420.  
  10421. \def\blx@citetracker@context{%
  10422.   \ifbool{citetracker}
  10423.    {\iftoggle{blx@footnote}
  10424.       {\xifinlistcs\abx@field@entrykey{blx@fsee@\the\c@refsection}
  10425.          {}
  10426.          {\listcsxadd{blx@fsee@\the\c@refsection}\abx@field@entrykey}}
  10427.       {\xifinlistcs\abx@field@entrykey{blx@bsee@\the\c@refsection}
  10428.          {}
  10429.          {\listcsxadd{blx@bsee@\the\c@refsection}\abx@field@entrykey}}}
  10430.    {}}
  10431.  
  10432. \protected\appto\abx@savetrackers{%
  10433.   \global\csletcs{blx@saved@bsee@\the\c@refsection}{blx@bsee@\the\c@refsection}%
  10434.   \global\csletcs{blx@saved@fsee@\the\c@refsection}{blx@fsee@\the\c@refsection}}
  10435.  
  10436. \protected\appto\abx@resttrackers{%
  10437.   \global\csletcs{blx@bsee@\the\c@refsection}{blx@saved@bsee@\the\c@refsection}%
  10438.   \global\csletcs{blx@fsee@\the\c@refsection}{blx@saved@fsee@\the\c@refsection}}
  10439.  
  10440. \protected\appto\abx@cleartrackers{%
  10441.   \global\cslet{blx@saved@bsee@\the\c@refsection}\@empty
  10442.  \global\cslet{blx@saved@fsee@\the\c@refsection}\@empty}
  10443.  
  10444. % ibidem tracker
  10445. \def\blx@ibidtracker@global{%
  10446.   \ifbool{citetracker}
  10447.    {\global\let\blx@lastkey@text\abx@field@entrykey}
  10448.    {}}
  10449.  
  10450. \def\blx@ibidtracker@context{%
  10451.   \ifbool{citetracker}
  10452.    {\iftoggle{blx@footnote}
  10453.       {\global\let\blx@lastkey@foot\abx@field@entrykey}
  10454.       {\global\let\blx@lastkey@text\abx@field@entrykey}}
  10455.    {}}
  10456.  
  10457. \def\blx@ibidtracker@strict{%
  10458.   \blx@ifcitesingle
  10459.     {\blx@ibidtracker@global}
  10460.    {\blx@ibidreset@global}}%
  10461.  
  10462. \def\blx@ibidtracker@constrict{%
  10463.   \blx@ifcitesingle
  10464.     {\blx@mpfnsave
  10465.     \blx@ibidtracker@context}
  10466.    {\blx@ibidreset@context}}%
  10467.  
  10468. \def\blx@ibidreset@force{%
  10469.   \global\undef\blx@lastkey@text
  10470.   \global\undef\blx@lastkey@foot
  10471.   \blx@mpfnreset}
  10472.  
  10473. \def\blx@ibidreset@global{%
  10474.   \global\undef\blx@lastkey@text}
  10475.  
  10476. \def\blx@ibidreset@context{%
  10477.   \iftoggle{blx@footnote}
  10478.    {\blx@mpfnreset
  10479.     \global\undef\blx@lastkey@foot}
  10480.    {\global\undef\blx@lastkey@text}}
  10481.  
  10482. \protected\appto\abx@savetrackers{%
  10483.   \global\let\blx@saved@lastkey@text\blx@lastkey@text
  10484.   \global\let\blx@saved@lastkey@foot\blx@lastkey@foot}
  10485.  
  10486. \protected\appto\abx@resttrackers{%
  10487.   \global\let\blx@lastkey@text\blx@saved@lastkey@text
  10488.   \global\let\blx@lastkey@foot\blx@saved@lastkey@foot}
  10489.  
  10490. \protected\appto\abx@cleartrackers{%
  10491.   \global\undef\blx@saved@lastkey@text
  10492.   \global\undef\blx@saved@lastkey@foot}
  10493.  
  10494. % idem tracker
  10495. \def\blx@idemtracker@global{%
  10496.   \ifbool{citetracker}
  10497.    {\global\let\blx@lasthash@text\abx@field@fullhash}
  10498.    {}}
  10499.  
  10500. \def\blx@idemtracker@context{%
  10501.   \ifbool{citetracker}
  10502.    {\iftoggle{blx@footnote}
  10503.       {\global\let\blx@lasthash@foot\abx@field@fullhash}
  10504.       {\global\let\blx@lasthash@text\abx@field@fullhash}}
  10505.    {}}
  10506.  
  10507. \let\blx@idemtracker@strict\blx@idemtracker@global
  10508.  
  10509. \def\blx@idemtracker@constrict{%
  10510.   \blx@mpfnsave
  10511.   \blx@idemtracker@context}
  10512.  
  10513. \def\blx@idemreset@force{%
  10514.   \global\undef\blx@lasthash@text
  10515.   \global\undef\blx@lasthash@foot
  10516.   \blx@mpfnreset}
  10517.  
  10518. \def\blx@idemreset@global{%
  10519.   \global\undef\blx@lasthash@text}
  10520.  
  10521. \def\blx@idemreset@context{%
  10522.   \iftoggle{blx@footnote}
  10523.    {\blx@mpfnreset
  10524.     \global\undef\blx@lasthash@foot}
  10525.    {\global\undef\blx@lasthash@text}}
  10526.  
  10527. \protected\appto\abx@savetrackers{%
  10528.   \global\let\blx@saved@lasthash@text\blx@lasthash@text
  10529.   \global\let\blx@saved@lasthash@text\blx@lasthash@text}
  10530.  
  10531. \protected\appto\abx@resttrackers{%
  10532.   \global\let\blx@lasthash@text\blx@saved@lasthash@text
  10533.   \global\let\blx@lasthash@text\blx@saved@lasthash@text}
  10534.  
  10535. \protected\appto\abx@cleartrackers{%
  10536.   \global\undef\blx@saved@lasthash@text
  10537.   \global\undef\blx@saved@lasthash@foot}
  10538.  
  10539. % opcit tracker
  10540. \def\blx@opcittracker@global{%
  10541.   \ifbool{citetracker}
  10542.    {\blx@opcit@tracker{text}}
  10543.    {}}
  10544.  
  10545. \def\blx@opcittracker@context{%
  10546.   \ifbool{citetracker}
  10547.    {\iftoggle{blx@footnote}
  10548.       {\blx@opcit@tracker{foot}}
  10549.       {\blx@opcit@tracker{text}}}
  10550.    {}}
  10551.  
  10552. \def\blx@opcittracker@strict{%
  10553.   \blx@ifcitesingle
  10554.     {\blx@opcittracker@global}
  10555.    {\blx@opcitreset@global}}%
  10556.  
  10557. \def\blx@opcittracker@constrict{%
  10558.   \blx@ifcitesingle
  10559.     {\blx@mpfnsave
  10560.     \blx@opcittracker@context}
  10561.    {\blx@opcitreset@context}}%
  10562.  
  10563. \def\blx@opcit@tracker#1{%
  10564.   \blx@imc@iffieldundef{namehash}
  10565.    {}
  10566.    {\global\cslet{blx@lastkey@#1@\abx@field@namehash}\abx@field@entrykey
  10567.     \xifinlistcs\abx@field@namehash{blx@trackhash@#1}
  10568.       {}
  10569.       {\listcsxadd{blx@trackhash@#1}\abx@field@namehash}}}
  10570.  
  10571. \def\blx@opcit@reset#1{%
  10572.   \begingroup
  10573.   \def\do##1{\global\csundef{blx@lastkey@#1@##1}}%
  10574.   \dolistcsloop{blx@trackhash@#1}%
  10575.   \global\cslet{blx@trackhash@#1}\@empty
  10576.  \endgroup}
  10577.  
  10578. \def\blx@opcitreset@force{%
  10579.   \blx@opcit@reset{text}%
  10580.   \blx@opcit@reset{foot}%
  10581.   \blx@mpfnreset}
  10582.  
  10583. \def\blx@opcitreset@global{%
  10584.   \blx@opcit@reset{text}}
  10585.  
  10586. \def\blx@opcitreset@context{%
  10587.   \iftoggle{blx@footnote}
  10588.    {\blx@opcit@reset{foot}%
  10589.      \blx@mpfnreset}
  10590.     {\blx@opcit@reset{text}}}
  10591.  
  10592. \let\blx@trackhash@text\@empty
  10593. \let\blx@trackhash@foot\@empty
  10594.  
  10595. \protected\appto\abx@savetrackers{%
  10596.   \begingroup
  10597.   \def\do#1{\global\csletcs{blx@saved@lastkey@text@#1}{blx@lastkey@text@#1}}%
  10598.   \dolistloop\blx@trackhash@text
  10599.   \global\let\blx@saved@trackhash@text\blx@trackhash@text
  10600.   \def\do#1{\global\csletcs{blx@saved@lastkey@foot@#1}{blx@lastkey@foot@#1}}%
  10601.   \dolistloop\blx@trackhash@foot
  10602.   \global\let\blx@saved@trackhash@foot\blx@trackhash@foot
  10603.   \endgroup}
  10604.  
  10605. \protected\appto\abx@resttrackers{%
  10606.   \begingroup
  10607.   \blx@opcit@reset{text}%
  10608.   \global\let\blx@trackhash@text\blx@saved@trackhash@text
  10609.   \def\do#1{\global\csletcs{blx@lastkey@text@#1}{blx@saved@lastkey@text@#1}}%
  10610.   \dolistloop\blx@trackhash@text
  10611.   \blx@opcit@reset{foot}%
  10612.   \global\let\blx@trackhash@foot\blx@saved@trackhash@foot
  10613.   \def\do#1{\global\csletcs{blx@lastkey@foot@#1}{blx@saved@lastkey@foot@#1}}%
  10614.   \dolistloop\blx@trackhash@foot
  10615.   \endgroup}
  10616.  
  10617. \protected\appto\abx@cleartrackers{%
  10618.   \begingroup
  10619.   \def\do#1{\global\csundef{blx@saved@lastkey@text@#1}}%
  10620.   \dolistloop\blx@saved@trackhash@text
  10621.   \global\undef\blx@saved@trackhash@text
  10622.   \def\do#1{\global\csundef{blx@saved@lastkey@foot@#1}}%
  10623.   \dolistloop\blx@saved@trackhash@foot
  10624.   \global\undef\blx@saved@trackhash@foot
  10625.   \endgroup}
  10626.  
  10627. % loccit tracker
  10628. \def\blx@loccittracker@global{%
  10629.   \ifbool{citetracker}
  10630.    {\blx@loccit@tracker{text}}
  10631.    {}}
  10632.  
  10633. \def\blx@loccittracker@context{%
  10634.   \ifbool{citetracker}
  10635.    {\iftoggle{blx@footnote}
  10636.       {\blx@loccit@tracker{foot}}
  10637.       {\blx@loccit@tracker{text}}}
  10638.    {}}
  10639.  
  10640. \def\blx@loccittracker@strict{%
  10641.   \ifbool{citetracker}
  10642.    {\blx@loccit@stricttracker{text}}
  10643.    {}}
  10644.  
  10645. \def\blx@loccittracker@constrict{%
  10646.   \ifbool{citetracker}
  10647.    {\iftoggle{blx@footnote}
  10648.       {\blx@mpfnsave
  10649.        \blx@loccit@stricttracker{foot}}
  10650.       {\blx@loccit@stricttracker{text}}}
  10651.    {}}
  10652.  
  10653. \def\blx@loccit@tracker#1{%
  10654.   \global\csundef{blx@lastnote@#1@\abx@field@entrykey}%
  10655.   \blx@imc@iffieldundef{postnote}
  10656.    {}
  10657.    {\global\cslet{blx@lastnote@#1@\abx@field@entrykey}\abx@field@postnote
  10658.     \xifinlistcs\abx@field@entrykey{blx@trackkeys@#1}
  10659.       {}
  10660.       {\listcsxadd{blx@trackkeys@#1}\abx@field@entrykey}}}
  10661.  
  10662. \def\blx@loccit@stricttracker#1{%
  10663.   \global\csundef{blx@lastnote@#1@\abx@field@entrykey}%
  10664.   \blx@imc@iffieldundef{postnote}
  10665.    {}
  10666.    {\blx@ifcitesingle
  10667.       {\expandafter\blx@imc@ifpages
  10668.        \expandafter{\abx@field@postnote}
  10669.          {\global\cslet{blx@lastnote@#1@\abx@field@entrykey}\abx@field@postnote
  10670.           \xifinlistcs\abx@field@entrykey{blx@trackkeys@#1}
  10671.             {}
  10672.             {\listcsxadd{blx@trackkeys@#1}\abx@field@entrykey}}
  10673.          {}}
  10674.       {}}}
  10675.  
  10676. \def\blx@loccit@reset#1{%
  10677.   \begingroup
  10678.   \def\do##1{\global\csundef{blx@lastnote@#1@##1}}%
  10679.   \dolistcsloop{blx@trackkeys@#1}%
  10680.   \global\cslet{blx@trackkeys@#1}\@empty
  10681.  \endgroup}
  10682.  
  10683. \def\blx@loccitreset@force{%
  10684.   \blx@loccit@reset{text}%
  10685.   \blx@loccit@reset{foot}%
  10686.   \blx@mpfnreset}
  10687.  
  10688. \def\blx@loccitreset@global{%
  10689.   \blx@loccit@reset{text}}
  10690.  
  10691. \def\blx@loccitreset@context{%
  10692.   \iftoggle{blx@footnote}
  10693.    {\blx@loccit@reset{foot}%
  10694.      \blx@mpfnreset}
  10695.     {\blx@loccit@reset{text}}}
  10696.  
  10697. \let\blx@trackkeys@text\@empty
  10698. \let\blx@trackkeys@foot\@empty
  10699.  
  10700. \protected\appto\abx@savetrackers{%
  10701.   \begingroup
  10702.   \def\do#1{\global\csletcs{blx@saved@lastnote@text@#1}{blx@lastnote@text@#1}}%
  10703.   \dolistloop\blx@trackkeys@text
  10704.   \global\let\blx@saved@trackkeys@text\blx@trackkeys@text
  10705.   \def\do#1{\global\csletcs{blx@saved@lastnote@foot@#1}{blx@lastnote@foot@#1}}%
  10706.   \dolistloop\blx@trackkeys@foot
  10707.   \global\let\blx@saved@trackkeys@foot\blx@trackkeys@foot
  10708.   \endgroup}
  10709.  
  10710. \protected\appto\abx@resttrackers{%
  10711.   \begingroup
  10712.   \blx@loccit@reset{text}%
  10713.   \global\let\blx@trackkeys@text\blx@saved@trackkeys@text
  10714.   \def\do#1{\global\csletcs{blx@lastnote@text@#1}{blx@saved@lastnote@text@#1}}%
  10715.   \dolistloop\blx@trackkeys@text
  10716.   \blx@loccit@reset{foot}%
  10717.   \global\let\blx@trackkeys@foot\blx@saved@trackkeys@foot
  10718.   \def\do#1{\global\csletcs{blx@lastnote@foot@#1}{blx@saved@lastnote@foot@#1}}%
  10719.   \dolistloop\blx@trackkeys@foot
  10720.   \endgroup}
  10721.  
  10722. \protected\appto\abx@cleartrackers{%
  10723.   \begingroup
  10724.   \def\do#1{\global\csundef{blx@saved@lastnote@text@#1}}%
  10725.   \dolistloop\blx@saved@trackkeys@text
  10726.   \global\undef\blx@saved@trackkeys@text
  10727.   \def\do#1{\global\csundef{blx@saved@lastnote@foot@#1}}%
  10728.   \dolistloop\blx@saved@trackkeys@foot
  10729.   \global\undef\blx@saved@trackkeys@foot
  10730.   \endgroup}
  10731.  
  10732. \def\blx@addbackref#1{%
  10733.   \ifcsdef{blx@setp@\the\c@refsection @#1}
  10734.    {\ifcase\blx@backrefsetstyle
  10735.       \blx@addbackref@i{#1}%
  10736.      \or
  10737.        \blx@addbackref@ii{setp}{#1}%
  10738.      \or
  10739.        \blx@addbackref@i{#1}%
  10740.      \or
  10741.        \blx@addbackref@i{#1}%
  10742.      \or
  10743.        \blx@addbackref@i{#1}%
  10744.        \blx@addbackref@ii{setp}{#1}%
  10745.      \or
  10746.        \blx@addbackref@i{#1}%
  10747.        \blx@addbackref@ii{setp}{#1}%
  10748.      \fi}
  10749.     {\ifcsdef{blx@setc@\the\c@refsection @#1}
  10750.       {\ifcase\blx@backrefsetstyle
  10751.          \blx@addbackref@ii{setc}{#1}%
  10752.         \or
  10753.           \blx@addbackref@i{#1}%
  10754.         \or
  10755.           \blx@addbackref@i{#1}%
  10756.         \or
  10757.           \blx@addbackref@i{#1}%
  10758.           \blx@addbackref@ii{setc}{#1}%
  10759.         \or
  10760.           \blx@addbackref@i{#1}%
  10761.         \or
  10762.           \blx@addbackref@i{#1}%
  10763.           \blx@addbackref@ii{setc}{#1}%
  10764.         \fi}
  10765.        {\blx@addbackref@i{#1}}}}
  10766.  
  10767. \def\blx@addbackref@i#1{%
  10768.   \ifbacktracker
  10769.     \blx@leavevmode
  10770.     \if@filesw
  10771.       \protected@write\@mainaux{}{\string\abx@aux@backref
  10772.        {\the\c@instcount}{#1}{\the\c@refsection}%
  10773.         {\thepage}{\noexpand\the\c@page}}%
  10774.     \fi
  10775.   \fi}
  10776.  
  10777. \def\blx@addbackref@ii#1#2{%
  10778.   \expandafter\expandafter\expandafter\forcsvlist
  10779.   \expandafter\expandafter\expandafter\blx@addbackref@i
  10780.   \expandafter\expandafter\expandafter{%
  10781.     \csname blx@#1@\the\c@refsection @#2\endcsname}}
  10782.  
  10783. % {<instcount>}{<entrykey>}{<refsection>}{<page>}{<page int>}
  10784. \protected\def\blx@aux@backref#1#2#3#4#5{%
  10785.   \ifcsundef{blx@pref@#3@\detokenize{#2}}
  10786.    {\global\cslet{blx@pref@#3@\detokenize{#2}}\@empty
  10787.     \expandafter\blx@onlypreamble\csname blx@pref@#3@\detokenize{#2}\endcsname}
  10788.    {}%
  10789.   \ifinlistcs{#4}{blx@pref@#3@\detokenize{#2}}
  10790.    {}
  10791.    {\listcsgadd{blx@pref@#3@\detokenize{#2}}{#4}}%
  10792.   \blx@addpagesum{#1}{#5}}
  10793.  
  10794. \AtEndDocument{%
  10795.   \def\abx@aux@backref#1#2#3#4#5{\blx@addpagesum{#1}{#5}}}
  10796.  
  10797. % {<true>}{<false>}
  10798. \def\blx@ifcitesingle{%
  10799.   \ifnum\c@citetotal=\@ne
  10800.     \expandafter\@firstoftwo
  10801.   \else
  10802.     \expandafter\@secondoftwo
  10803.   \fi}
  10804.  
  10805. %  hyperref interface
  10806. \appto\blx@mkhyperref{%
  10807.   \protected\def\blx@imc@bibhyperref{%
  10808.     \@ifnextchar[%]
  10809.       {\blx@bibhyperref}
  10810.      {\blx@bibhyperref[\abx@field@entrykey]}}%
  10811.   \ifundef\hyper@natanchorstart
  10812.     {\long\def\blx@bibhyperref[#1]#2{%
  10813.        \blx@sfsave\hyperlink{cite.\the\c@refsection @#1}{\blx@sfrest
  10814.          #2%
  10815.        \blx@sfsave}\blx@sfrest}%
  10816.      \protected\long\def\blx@imc@bibhyperlink#1#2{%
  10817.        \blx@sfsave\hyperlink{cite.\the\c@refsection:#1}{\blx@sfrest
  10818.          #2%
  10819.        \blx@sfsave}\blx@sfrest}%
  10820.      \protected\long\def\blx@imc@bibhypertarget#1#2{%
  10821.        \blx@sfsave\hypertarget{cite.\the\c@refsection:#1}{\blx@sfrest
  10822.          #2%
  10823.        \blx@sfsave}\blx@sfrest}}%
  10824.     {\long\def\blx@bibhyperref[#1]#2{%
  10825.        \blx@sfsave\hyper@natlinkstart{\the\c@refsection @#1}\blx@sfrest
  10826.        #2%
  10827.        \blx@sfsave\hyper@natlinkend\blx@sfrest}%
  10828.      \protected\long\def\blx@imc@bibhyperlink#1#2{%
  10829.        \blx@sfsave\hyper@natlinkstart{\the\c@refsection:#1}\blx@sfrest
  10830.        #2%
  10831.        \blx@sfsave\hyper@natlinkend\blx@sfrest}%
  10832.      \protected\long\def\blx@imc@bibhypertarget#1#2{%
  10833.        \blx@sfsave\hyper@natanchorstart{\the\c@refsection:#1}\blx@sfrest
  10834.        #2%
  10835.        \blx@sfsave\hyper@natanchorend\blx@sfrest}}
  10836.   \let\blx@imc@ifhyperref\@firstoftwo
  10837.   \def\blx@sf{\spacefactor}%
  10838.   \def\blx@sfsave{%
  10839.     \blx@leavevmode
  10840.     \numgdef\blx@sf{\spacefactor}}%
  10841.   \def\blx@sfrest{%
  10842.     \ifhmode\spacefactor\blx@sf\relax\fi
  10843.     \gdef\blx@sf{\spacefactor}}}
  10844.  
  10845. \appto\blx@mknohyperref{%
  10846.   \protected\def\blx@imc@bibhyperref{\@ifnextchar[\blx@nohyperref\@firstofone}%
  10847.   \def\blx@nohyperref[#1]#2{#2}%
  10848.   \let\blx@imc@bibhyperlink\@secondoftwo
  10849.   \let\blx@imc@bibhypertarget\@secondoftwo
  10850.   \let\blx@imc@ifhyperref\@secondoftwo}
  10851.  
  10852. \blx@regimcs{%
  10853.   \bibhyperref \bibhyperlink \bibhypertarget \ifhyperref}
  10854.  
  10855. % {<entrykey>,...}
  10856. \protected\def\nocite#{\blx@nocite}
  10857.  
  10858. \def\blx@nocite#1{%
  10859.   \@bsphack
  10860.   \AfterPreamble{%
  10861.     \iftoggle{blx@bibliography}
  10862.      {}
  10863.      {\ifstrequal{*}{#1}
  10864.        {\blx@nocitation@all}
  10865.        {\blx@xsanitizeafter{\forcsvlist\blx@nocite@do}{#1}}}}%
  10866.   \@esphack}
  10867.  
  10868. \def\blx@nocite@do#1{%
  10869.     % Make sure this counter exists. Sometimes it might not when using, e.g:
  10870.     % refsection=chapter and \includeonly to put in the chapters or when
  10871.     % inserting citations into table of contents
  10872.     \ifcscounter{blx@sectionciteorder@\the\c@refsection}
  10873.      {}
  10874.      {\expandafter\newcount\csname blx@sectionciteorder@\the\c@refsection\endcsname}%
  10875.   \global\advance\csname blx@sectionciteorder@\the\c@refsection\endcsname\@ne
  10876.   \blx@nocitation{#1}\blx@msg@cundef}
  10877.  
  10878. % {<macro>}[<arg1>][<arg2>]{<arg3>}
  10879. % => <macro>{<arg1>}{<arg2>}{<arg3>}
  10880. \protected\def\blx@citeargs#1{%
  10881.   \@ifnextchar[%]
  10882.     {\blx@citeargs@i{#1}}
  10883.    {\blx@citeargs@iii{#1{}{}}}}
  10884. \long\def\blx@citeargs@i#1[#2]{%
  10885.   \@ifnextchar[%]
  10886.     {\blx@citeargs@ii{#1{#2}}}
  10887.    {\blx@citeargs@iii{#1{}{#2}}}}
  10888. \long\def\blx@citeargs@ii#1[#2]{%
  10889.   \blx@citeargs@iii{#1{#2}}}
  10890. \long\def\blx@citeargs@iii#1#2{%
  10891.   \blx@xsanitizeafter{#1}{#2}}
  10892.  
  10893. % {<macro>}(<arg1>)(<arg2>)
  10894. % => <macro>{<arg1>}{<arg2>}
  10895. \protected\def\blx@multiargs#1{%
  10896.   \@ifnextchar(%)
  10897.     {\blx@multiargs@i{#1}}
  10898.    {#1{}{}}}
  10899. \long\def\blx@multiargs@i#1(#2){%
  10900.   \@ifnextchar(%)
  10901.     {\blx@multiargs@ii{#1{#2}}}
  10902.    {#1{}{#2}}}
  10903. \long\def\blx@multiargs@ii#1(#2){#1{#2}}
  10904.  
  10905. % {<macro>}[<arg1>][<arg2>]{<arg3>}<punct>
  10906. % => <macro>{<arg1>}{<arg2>}{<arg3>}{<punctcmd>}
  10907. \protected\def\blx@citepunct#1{%
  10908.   \blx@citeargs{\blx@citepunct@i{#1}}}
  10909. \long\def\blx@citepunct@i#1#2#3#4{%
  10910.   \blx@thecheckpunct{#1{#2}{#3}{#4}}}
  10911.  
  10912. % {<csname>}[<arg1>][<arg2>]{arg3}[arg4]{arg5}<punct>
  10913. % => <macro>{<arg1>}{<arg2>}{<arg3>}{<arg4>}{arg5}{<punctcmd>}
  10914. \protected\def\blx@citexpunct#1{%
  10915.   \blx@citeargs{\blx@citexpunct@i{#1}}}
  10916. \long\def\blx@citexpunct@i#1#2#3#4{%
  10917.   \@ifnextchar[%]
  10918.     {\blx@citexpunct@ii{#1}{{#2}{#3}{#4}}}
  10919.    {\blx@citexpunct@ii{#1}{{#2}{#3}{#4}}[#1]}}
  10920. \long\def\blx@citexpunct@ii#1#2[#3]#4{%
  10921.   \blx@thecheckpunct{\blxcitecmd{#1}#2{#3}{#4}}}
  10922.  
  10923. % {<code>}<punct> => <code>{<punctcmd>}
  10924. \long\def\blx@checkpunct#1{%
  10925.   \begingroup
  10926.   \def\blx@tempa{\endgroup#1}%
  10927.   \futurelet\blx@tempb\blx@checkpunct@i}
  10928. \def\blx@checkpunct@i{%
  10929.   \expandafter\blx@checkpunct@ii\blx@autopunct&}
  10930. \def\blx@checkpunct@ii#1{%
  10931.   \ifx#1&%
  10932.     \expandafter\blx@checkpunct@iii
  10933.   \fi
  10934.   \ifx#1\blx@tempb
  10935.     \expandafter\blx@checkpunct@iv
  10936.   \fi
  10937.   \blx@checkpunct@ii}
  10938. \def\blx@checkpunct@iii#1\blx@checkpunct@ii{%
  10939.   \global\undef\abx@field@postpunct
  10940.   \blx@tempa{\blx@postpunct}}
  10941. \def\blx@checkpunct@iv#1\blx@checkpunct@ii#2&#3{%
  10942.   \gdef\abx@field@postpunct{#3}%
  10943.   \edef\blx@tempa{%
  10944.     \expandonce\blx@tempa{%
  10945.     \ifcsdef{blx@pm@\detokenize{#3}}
  10946.      {\csname blx@imc@add\csname blx@pm@\detokenize{#3}\endcsname
  10947.       \endcsname}
  10948.      {\noexpand#3}}}%
  10949.   \blx@tempa}
  10950.  
  10951. \long\def\blx@nocheckpunct#1{#1{}}
  10952.  
  10953. \protected\def\blx@citeinit{%
  10954.   \iftoggle{blx@bibliography}
  10955.    {}
  10956.    {\toggletrue{blx@citation}}%
  10957.   \blx@blxinit
  10958.   \blx@langstrings
  10959.   \citesetup
  10960.   \blx@setsfcodes
  10961.   \blx@postpunct@agroup
  10962.   \blx@resetdata
  10963.   \blx@leavevmode
  10964.   \csuse{blx@hook@cite}%
  10965.   \csuse{blx@hook@cite@next}%
  10966.   \let\blx@citeinit\blx@resetdata}
  10967.  
  10968. \protected\def\blx@citecmdinit{%
  10969.   \blx@leavevmode@cite
  10970.   \iftoggle{blx@bibliography}
  10971.    {}
  10972.    {\blx@initunit}}
  10973.  
  10974. % *{<command>}[<wrapper>]{<precode>}{<loopcode>}{<delimcode>}{<postcode>}
  10975. \newrobustcmd*{\DeclareCiteCommand}{%
  10976.   \@ifstar{\blx@defcitecmd*}{\blx@defcitecmd{}}}
  10977.  
  10978. \def\blx@defcitecmd#1#2{%
  10979.   \begingroup
  10980.   \escapechar\m@ne
  10981.   \edef\blx@tempa{\endgroup
  10982.    \noexpand\blx@defcitecmd@i{#1}{\string#2}}%
  10983.   \blx@tempa}
  10984.  
  10985. \def\blx@defcitecmd@i#1#2{%
  10986.   \blx@checkcitecmd{#2}{#1}%
  10987.   \protected\csdef{#2}{%
  10988.     \blx@citecmdinit
  10989.     \@ifstar
  10990.       {\blx@citepunct{\blxcitecmd{#2*}}}
  10991.      {\blx@citepunct{\blxcitecmd{#2}}}}%
  10992.   \@ifnextchar[%]
  10993.     {\blx@defcitecmd@iii{#2#1}}
  10994.    {\blx@defcitecmd@ii{#2#1}}}
  10995.  
  10996. \long\def\blx@defcitecmd@ii#1{%
  10997.   \csundef{blx@defcite@wrapper@#1}%
  10998.   \blx@defcitecmd@iv{#1}%
  10999.   \blx@defcitecmd@v{#1}}
  11000.  
  11001. \long\def\blx@defcitecmd@iii#1[#2]{%
  11002.   \csdef{blx@defcite@wrapper@#1}{#2}%
  11003.   \blx@defcitecmd@iv{#1}%
  11004.   \blx@defcitecmd@v{#1}}
  11005.  
  11006. \long\def\blx@defcitecmd@iv#1{%
  11007.   \protected\long\csedef{blx@cite@#1}##1##2##3##4{%
  11008.     \ifboolexpe{test {\ifcsundef{blx@defcite@wrapper@#1}}
  11009.                and
  11010.                (test {\ifcsundef{blx@citepunct@#1}}
  11011.                 or
  11012.                 test {\ifcsequal{blx@citepunct@#1}{blx@citepunctid@pos@c}})}
  11013.      {}
  11014.      {\begingroup
  11015.       \blx@citeinit}%
  11016.     \ifcsequal{blx@citepunct@#1}{blx@citepunctid@pos@l}
  11017.      {\noexpand\unspace##4}
  11018.      {}%
  11019.     \ifcsequal{blx@citepunct@#1}{blx@citepunctid@pos@f}
  11020.      {\noexpand\iftoggle{blx@footnote}{}{\unspace##4}}
  11021.      {}%
  11022.     \ifcsundef{blx@defcite@wrapper@#1}
  11023.      {\blxciteicmd{#1}{##1}{##2}{##3}{%
  11024.          \ifcsundef{blx@citepunct@#1}{##4}{}%
  11025.          \ifcsequal{blx@citepunct@#1}{blx@citepunctid@pos@c}{##4}{}}}
  11026.      {\csexpandonce{blx@defcite@wrapper@#1}{%
  11027.          \blxciteicmd{#1}{##1}{##2}{##3}{%
  11028.            \ifcsequal{blx@citepunct@#1}{blx@citepunctid@pos@c}{##4}{}}}%
  11029.        \ifcsundef{blx@citepunct@#1}{##4}{}}%
  11030.     \ifcsequal{blx@citepunct@#1}{blx@citepunctid@pos@r}{##4}{}%
  11031.     \ifcsequal{blx@citepunct@#1}{blx@citepunctid@pos@f}
  11032.      {\noexpand\iftoggle{blx@footnote}{##4}{}}
  11033.      {}%
  11034.     \ifboolexpe{test {\ifcsundef{blx@defcite@wrapper@#1}}
  11035.                and
  11036.                (test {\ifcsundef{blx@citepunct@#1}}
  11037.                 or
  11038.                 test {\ifcsequal{blx@citepunct@#1}{blx@citepunctid@pos@c}})}
  11039.      {}
  11040.      {\endgroup}}}
  11041.  
  11042. \long\def\blx@defcitecmd@v#1#2#3#4#5{%
  11043.   \protected\long\csdef{blx@citei@#1}##1##2##3##4{%
  11044.     \ifblank{##1}
  11045.      {}
  11046.      {\def\abx@field@prenote{##1}}%
  11047.     \ifblank{##2}
  11048.      {\let\blx@thenotecheck\relax}
  11049.      {\def\abx@field@postnote{##2}}%
  11050.     \def\blx@precode{\delimcontext{#1}#2}%
  11051.     \def\blx@loopcode{#3}%
  11052.     \def\blx@dlimcode{#4}%
  11053.     \def\blx@postcode{#5}%
  11054.     \def\blx@postpunct@saved{##4}%
  11055.     \edef\blx@smugglecode{%
  11056.       \unless\ifnum\c@overallcitetotal=\z@
  11057.         \noexpand\blx@smuggle@counter
  11058.           \noexpand\c@overallcitecount
  11059.       \fi}%
  11060.     \blx@citeloop{##3}%
  11061.     \blx@smugglecode
  11062.     \endgroup}}
  11063.  
  11064. % Leave the value of a counter outside a group
  11065. \def\blx@smuggle@counter#1\endgroup{%
  11066.   \expandafter\endgroup\expandafter#1\the#1\relax}
  11067.  
  11068. % {<type>}{<name>}{*}
  11069. \def\blx@checkcitecmd#1#2{%
  11070.   \ifblank{#2}
  11071.    {\ifcsdef{blx@cite@#1}
  11072.       {\blx@info{Redefining '\@backslashchar#1'}}
  11073.       {\ifcsundef{#1}
  11074.          {}
  11075.          {\blx@warning@noline{Redefining '\@backslashchar#1'}}}%
  11076.      \ifcsdef{blx@cite@#1*}
  11077.       {}
  11078.       {\csedef{blx@cite@#1*}{%
  11079.           \expandafter\noexpand\csname blx@cite@#1\endcsname}%
  11080.         \csedef{blx@citei@#1*}{%
  11081.           \expandafter\noexpand\csname blx@citei@#1\endcsname}}}
  11082.     {\ifcsdef{blx@cite@#1}
  11083.       {}
  11084.       {\csdef{blx@cite@#1}{\blx@err@citecmd{#1}}%
  11085.         \csdef{blx@citei@#1}{\blx@err@citecmd{#1}}}}}
  11086.  
  11087. % {<name>}{prenote}{postnote}{citekey}{punct}
  11088. \newrobustcmd*{\blxcitecmd}[1]{%
  11089.   \ifcsundef{blx@cite@#1}
  11090.    {\blx@err@citecmd{#1}}
  11091.    {\csuse{blx@cite@#1}}}
  11092.  
  11093. \newrobustcmd*{\blxciteicmd}[1]{%
  11094.   \begingroup
  11095.   \blx@citeinit
  11096.   \ifcsundef{blx@citei@#1}
  11097.    {\blx@err@citecmd{#1}}
  11098.    {\csuse{blx@citei@#1}}}
  11099.  
  11100. % {<multicitecount>}{<name>}{prenote}{postnote}{citekey}{punct}
  11101. \protected\def\blxmciteicmd#1{%
  11102.   \c@multicitecount#1\relax
  11103.   \blxciteicmd}
  11104.  
  11105. % {<multicitetotal>}{<multiprenote>}{<multipostnote>}
  11106. \protected\def\blxmcites#1#2#3{%
  11107.   \begingroup
  11108.   \blx@citeinit
  11109.   \c@multicitecount\z@
  11110.   \c@multicitetotal#1\relax
  11111.   \ifnum\c@multicitetotal>\@ne
  11112.     \let\blx@ifcitesingle\@secondoftwo
  11113.   \fi
  11114.   \csuse{blx@hook@mcite}%
  11115.   \csuse{blx@hook@mcite@next}%
  11116.   \ifblank{#2}%
  11117.     {}
  11118.    {\def\abx@field@multiprenote{#2}}%
  11119.   \ifblank{#3}%
  11120.     {}
  11121.    {\def\abx@field@multipostnote{#3}}%
  11122.   \usebibmacro{multiprenote}}
  11123.  
  11124. \protected\def\blxendmcites{%
  11125.   \usebibmacro{multipostnote}%
  11126.   \endgroup}
  11127.  
  11128. % {<command>}[<wrapper>]{<cite>}{<delimiter>}
  11129. \newrobustcmd{\DeclareMultiCiteCommand}[1]{%
  11130.   \ifundef#1%
  11131.     {}
  11132.    {\blx@info{Redefining '\string#1'}}%
  11133.   \@ifnextchar[%]
  11134.     {\blx@defmcitecmd{#1}}
  11135.    {\blx@defmcitecmd{#1}[\@firstofone]}}
  11136.  
  11137. \def\blx@defmcitecmd#1[#2]#3#4{%
  11138.   \begingroup
  11139.   \escapechar\m@ne
  11140.   \edef\blx@tempa{\endgroup
  11141.     \protected\def\noexpand#1{%
  11142.       \blx@citecmdinit
  11143.       \noexpand\@ifstar
  11144.         {\expandafter\noexpand
  11145.          \csname blx@mcite@\string#1\endcsname*%
  11146.          \expandafter\noexpand
  11147.          \csname blx@mcitei@\string#1\endcsname}
  11148.         {\expandafter\noexpand
  11149.         \csname blx@mcite@\string#1\endcsname{}%
  11150.          \expandafter\noexpand
  11151.          \csname blx@mcitei@\string#1\endcsname}}%
  11152.     \protected\csdef{blx@mcite@\string#1}####1####2{%
  11153.       \begingroup
  11154.       \blx@citeinit
  11155.       \noexpand\blx@multicite
  11156.         ####2%
  11157.         {\unexpanded{#2}}%
  11158.         {\string#3####1}%
  11159.         {\unexpanded{#4}}}%
  11160.     \protected\long\csdef{blx@mcitei@\string#1}}%
  11161.   \blx@tempa##1##2##3{##1{##2}##3\endgroup}}
  11162.  
  11163. % {<command>}{<wrapper>}{<citecmd>}{<delimiter>} =>
  11164. %  <init><command>{<wrapper>}{<cites>}{<punct>}
  11165. \def\blx@multicite#1#2#3#4{%
  11166.   \begingroup
  11167.   \csuse{blx@hook@mcite@before}%
  11168.   \def\blx@tempa{#1}%
  11169.   \def\blx@tempb{#2}%
  11170.   \def\blx@tempc{#3}%
  11171.   \def\blx@tempd{#4}%
  11172.   \c@multicitetotal\z@
  11173.   \blx@multiargs\blx@multicite@i}
  11174.  
  11175. \def\blx@multicite@i#1#2{%
  11176.   \ifblank{#1}%
  11177.     {\let\abx@field@multiprenote\@empty}%
  11178.     {\def\abx@field@multiprenote{#1}}%
  11179.   \ifblank{#2}%
  11180.     {\let\abx@field@multipostnote\@empty}%
  11181.     {\def\abx@field@multipostnote{#2}}%
  11182.   \let\blx@tempe\@empty
  11183.   \let\blx@tempf\@empty
  11184.   \togglefalse{blx@tempa}%
  11185.   \blx@multiparse}
  11186.  
  11187. \iftrue
  11188. % Option 1:
  11189. % Use \blx@citeloop to handle the sorting and compression of citations here.
  11190. % I disable \blx@thenotecheck, \multicitedelim, and \blx@postpunct@saved to
  11191. %   avoid premature output. Then I use \blx@tempcntc (a and b are already used
  11192. %   internally by \blx@citeloop) to keep track of the number of citations,
  11193. %   increasing it with \blx@citeprint, which would otherwise print each
  11194. %   citation. The only global assignment in \blx@citeloop is reversed later.
  11195. %   Finally smuggle \blx@tempcntc one level to add it to \c@overallcitetotal
  11196. % Pros: Concise code (I guess). No need to make an almost exact copy of an
  11197. %   already working code.
  11198. % Cons: Might have unpredicted effects due to the misuse of the macro (I didn't
  11199. %   find any, though, but I'm good at missing obvious problems :).
  11200. \def\blx@multicite@add#1#2#3{%
  11201.   \togglefalse{blx@tempa}%
  11202.   \advance\c@multicitetotal\@ne
  11203.   \begingroup
  11204.     \let\blx@thenotecheck\@empty
  11205.     \let\multicitedelim\@empty
  11206.     \let\blx@postpunct@saved\@empty
  11207.     \blx@tempcntc\z@
  11208.     \def\blx@citeprint##1{\advance\blx@tempcntc\@ne}%
  11209.     \blx@citeloop{#3}% (mis)using to sort the citations
  11210.     \global\advance\csname blx@sectionciteorder@\the\c@refsection\endcsname\m@ne% Undoing global things
  11211.     \blx@smuggle@counter\blx@tempcntc
  11212.   \endgroup
  11213.   \advance\c@overallcitetotal\blx@tempcntc
  11214.   \eappto\blx@tempe{%
  11215.     \expandonce\blx@tempf
  11216.     \blxmciteicmd{\the\c@multicitetotal}%
  11217.     {\expandonce\blx@tempc}\unexpanded{{#1}{#2}{#3}}{}}%
  11218.   \let\blx@tempf\blx@tempd
  11219.   \blx@multiparse}
  11220. \else
  11221. % Option 2:
  11222. % Copy \blx@citeloop and remove unnecessary code for the sorting/compressing
  11223. %   step. Use the counted number of citations (\blx@tempcnta) to \advance the
  11224. %   \c@overallcitetotal and smuggle the \c@overallcitetotal outside of the group.
  11225. % Pros: Does not mess with the citation loop code (supposedly), and can possibly
  11226. %   be optimized.
  11227. % Cons: Code (sort of) duplication.
  11228. \def\blx@multicite@add#1#2#3{%
  11229.   \togglefalse{blx@tempa}%
  11230.   \advance\c@multicitetotal\@ne
  11231.   \begingroup
  11232.     \blx@overallcitecount@loop{#3}%
  11233.     \advance\c@overallcitetotal\blx@tempcnta
  11234.     \blx@smuggle@counter\c@overallcitetotal
  11235.   \endgroup
  11236.   \eappto\blx@tempe{%
  11237.     \expandonce\blx@tempf
  11238.     \blxmciteicmd{\the\c@multicitetotal}%
  11239.     {\expandonce\blx@tempc}\unexpanded{{#1}{#2}{#3}}{}}%
  11240.   \let\blx@tempf\blx@tempd
  11241.   \blx@multiparse}
  11242.  
  11243. % {<entrykey>,...}
  11244. \protected\def\blx@overallcitecount@loop#1{%
  11245.   \expandafter\blx@overallcitecount@loop@i\expandafter{\detokenize{#1}}}
  11246. \protected\def\blx@overallcitecount@loop@i#1{%
  11247.   \begingroup
  11248.   % This must be here and not after \blx@citeadd as this changes the refcontext
  11249.   \letcs\blx@tempb{blx@dlist@centry@\the\c@refsection @\blx@refcontext@context}%
  11250.   \ifundef\blx@tempb
  11251.     {\let\blx@tempb\@empty}
  11252.    {}%
  11253.   % Make sure this counter exists. Sometimes it might not when using, e.g:
  11254.   % refsection=chapter and \includeonly to put in the chapters or when
  11255.   % inserting citations into table of contents
  11256.   \ifcscounter{blx@sectionciteorder@\the\c@refsection}
  11257.    {}
  11258.    {\expandafter\newcount\csname blx@sectionciteorder@\the\c@refsection\endcsname}%
  11259.   % \global% Remove global but keep the \advance (though I have no idea what this counter does)
  11260.   \advance\csname blx@sectionciteorder@\the\c@refsection\endcsname\@ne
  11261.   \blx@tempcnta\z@
  11262.   \blx@tempcntb\z@
  11263.   \let\blx@tempa\@empty
  11264.   \forcsvlist\blx@citeadd{#1}% adds to \blx@tempa
  11265.   % \blx@thenotecheck % Unnecessary/unwated code here
  11266.   % \ifnum\blx@tempcnta>\z@
  11267.   %   \ifnum\blx@tempcntb>\z@
  11268.   %     \multicitedelim
  11269.   %   \fi
  11270.   % \else
  11271.   %   \blx@postpunct@saved
  11272.   % \fi
  11273.   % \blx@tempb is a sorted list of all cites, \blx@tempa is the list of cites to
  11274.   % sort using this list
  11275.   \blx@thecitesort
  11276.   \blx@smuggle@counter\blx@tempcnta
  11277.   \endgroup}
  11278. \fi
  11279.  
  11280. \def\blx@multicite@end#1{%
  11281.   \edef\blx@tempa{\endgroup
  11282.    \c@overallcitetotal\the\c@overallcitetotal\relax
  11283.    \expandonce\blx@tempa
  11284.      {\expandonce\blx@tempb}%
  11285.       {\blxmcites
  11286.         {\the\c@multicitetotal}%
  11287.          {\expandonce\abx@field@multiprenote}%
  11288.          {\expandonce\abx@field@multipostnote}%
  11289.        \expandonce\blx@tempe
  11290.        \blxendmcites}%
  11291.       {#1}%
  11292.     \iftoggle{blx@tempa}{\relax\space}{}}%
  11293.   \blx@tempa}
  11294.  
  11295. \def\blx@multiparse{%
  11296.   \futurelet\@let@token\blx@multiparse@i}
  11297.  
  11298. \def\blx@multiparse@i{%
  11299.   \ifx\@let@token\relax
  11300.     \blx@multiparse@ii{\blx@multicite@end{}}%
  11301.   \fi
  11302.   \ifx\@let@token[%]
  11303.     \blx@multiparse@ii{\blx@citeargs\blx@multicite@add}%
  11304.   \fi
  11305.   \ifx\@let@token\bgroup
  11306.     \blx@multiparse@ii{\blx@citeargs\blx@multicite@add}%
  11307.   \fi
  11308.   \ifx\@let@token\@sptoken
  11309.     \blx@multiparse@ii\blx@multiparse@iii
  11310.   \fi
  11311.   \iftrue
  11312.     \iftoggle{blx@tempa}
  11313.      {\blx@multiparse@ii{\blx@multicite@end{}}}
  11314.      {\blx@multiparse@ii{\blx@thecheckpunct\blx@multicite@end}}%
  11315.   \fi
  11316.   &}
  11317.  
  11318. \def\blx@multiparse@ii#1#2&{\fi#1}
  11319. \csdef{blx@multiparse@iii} {\toggletrue{blx@tempa}\blx@multiparse}
  11320.  
  11321. % {<name>}[l|i|r]{<cite>}{<multicite>}
  11322. \newrobustcmd*{\DeclareAutoCiteCommand}[1]{%
  11323.   \ifcsundef{blx@acite@#1}
  11324.    {}
  11325.    {\blx@info{Redefining autocite command '#1'}}%
  11326.   \@ifnextchar[%]
  11327.     {\blx@defautocmd@i{#1}}
  11328.    {\blx@defautocmd@i{#1}[r]}}
  11329.  
  11330. \def\blx@defautocmd@i#1[#2]#3#4{%
  11331.   \begingroup
  11332.   \escapechar\m@ne
  11333.   \edef\blx@tempa{\endgroup
  11334.    \noexpand\blx@defautocmd@ii{#1}{#2}%
  11335.       {\string#3}{\string#4}}%
  11336.   \blx@tempa}
  11337.  
  11338. \def\blx@defautocmd@ii#1#2#3#4{%
  11339.   \protected\csedef{blx@acite@#1}{%
  11340.     \blx@citecmdinit
  11341.     \noexpand\@ifstar
  11342.       {\blx@citepunct{\expandafter\noexpand
  11343.       \csname blx@acitei@#1\endcsname*}}
  11344.      {\blx@citepunct{\expandafter\noexpand
  11345.       \csname blx@acitei@#1\endcsname{}}}}%
  11346.   \protected\csedef{blx@acitei@#1}##1##2##3##4##5{%
  11347.     \begingroup
  11348.     \blx@citeinit
  11349.     \if l#2\noexpand\unspace##5\fi
  11350.     \if f#2\noexpand\iftoggle{blx@footnote}{}{\unspace##5}\fi
  11351.    \blxcitecmd{#3##1}{##2}{##3}{##4}{}%
  11352.     \if r#2##5\fi
  11353.     \if f#2\noexpand\iftoggle{blx@footnote}{##5}{}\fi
  11354.    \endgroup}%
  11355.   \protected\csedef{blx@macite@#1}{%
  11356.     \blx@citecmdinit
  11357.     \noexpand\@ifstar
  11358.       {\expandafter\noexpand
  11359.        \csname blx@macitei@#1\endcsname*%
  11360.        \expandafter\noexpand
  11361.        \csname blx@maciteii@#1\endcsname}
  11362.       {\expandafter\noexpand
  11363.       \csname blx@macitei@#1\endcsname{}%
  11364.        \expandafter\noexpand
  11365.        \csname blx@maciteii@#1\endcsname}}%
  11366.   \csedef{blx@macitei@#1}{\csname blx@mcite@#4\endcsname}%
  11367.   \protected\csedef{blx@maciteii@#1}##1##2##3{%
  11368.     \if l#2\noexpand\unspace##3\fi
  11369.     \if f#2\noexpand\iftoggle{blx@footnote}{}{\unspace##3}\fi
  11370.    ##1{##2}%
  11371.     \if r#2##3\fi
  11372.     \if f#2\noexpand\iftoggle{blx@footnote}{##3}{}\fi
  11373.    \endgroup}}
  11374.  
  11375. % {<characters>}
  11376. \newrobustcmd*{\DeclareAutoPunctuation}[1]{%
  11377.   \ifblank{#1}
  11378.    {\let\blx@thecheckpunct\blx@nocheckpunct}
  11379.    {\let\blx@thecheckpunct\blx@checkpunct
  11380.     \def\blx@autopunct{#1}}}
  11381.  
  11382. % {<command>}{<pos marker>}
  11383. % pos markers are:
  11384. %   l: move punctuation before the command (i.e. left of it)
  11385. %   r: leave punctuation after the command (i.e. to the right)
  11386. %   f: like l in normal text, like r in footnotes
  11387. %   c: pass on to the cite command,
  11388. %      the punctuation will eventually end up as field 'postpunct'
  11389. %   d: discard the punctuation
  11390. %   o (or any other value): restores the old standard behaviour
  11391. %      r for wrapped citation commands,
  11392. %      c for unwrapped ones
  11393. \newrobustcmd*{\DeclareCitePunctuationPosition}[2]{%
  11394.   \begingroup
  11395.   \escapechar\m@ne
  11396.   \edef\blx@tempa{\endgroup
  11397.    \noexpand\blx@defcitepunctpos@i{\string#1}{#2}}%
  11398.   \blx@tempa}
  11399.  
  11400. \def\blx@citepunctid@pos@l{l}
  11401. \def\blx@citepunctid@pos@r{r}
  11402. \def\blx@citepunctid@pos@f{f}
  11403. \def\blx@citepunctid@pos@c{c}
  11404. \def\blx@citepunctid@pos@d{d}
  11405.  
  11406. \def\blx@defcitepunctpos@i#1#2{%
  11407.   \ifcsundef{blx@citepunctid@pos@#2}
  11408.    {\csundef{blx@citepunct@#1}}
  11409.    {\csletcs{blx@citepunct@#1}{blx@citepunctid@pos@#2}}%
  11410.   \blx@defcitecmd@iv{#1}}
  11411.  
  11412. \AfterEndPreamble{% babel
  11413.   \begingroup
  11414.   \makeatletter
  11415.   \endlinechar\m@ne
  11416.   \scantokens\expandafter{%
  11417.     \expandafter\gdef
  11418.     \expandafter\blx@autopunct
  11419.     \expandafter{\blx@autopunct}}%
  11420.   \endgroup}
  11421.  
  11422. % [<prenote>][<postnote>]{<entrykey>,...}[<format>]{<namelist>}<punct>
  11423. \newrobustcmd*{\citename}{\blx@citexpunct{citename}}
  11424. \long\csdef{blx@cite@citename}#1#2#3#4#5#6{%
  11425.   \begingroup
  11426.   \blx@citecmdinit
  11427.   \blx@citeinit
  11428.   \ifblank{#1}
  11429.    {}
  11430.    {\def\abx@field@prenote{#1}}%
  11431.   \ifblank{#2}
  11432.    {\let\blx@thenotecheck\relax}
  11433.    {\def\abx@field@postnote{#2}}%
  11434.   \def\blx@precode{\usebibmacro{prenote}}%
  11435.   \def\blx@loopcode{%
  11436.     \ifnameundef{#5}
  11437.      {\blx@warning@entry{'#5' undefined or not a name list}%
  11438.        \abx@missing{#5}}
  11439.      {\printnames[#4]{#5}}}%
  11440.   \def\blx@dlimcode{\multicitedelim}%
  11441.   \def\blx@postpunct@saved{#6}%
  11442.   \ifblank{#2}
  11443.    {\let\blx@postcode\@empty}
  11444.    {\def\blx@postcode{\usebibmacro{postnote}}}%
  11445.   \boolfalse{citetracker}%
  11446.   \boolfalse{pagetracker}%
  11447.   \blx@citeloop{#3}%
  11448.   \endgroup}
  11449.  
  11450. % [<prenote>][<postnote>]{<entrykey>,...}[<format>]{<list>}<punct>
  11451. \newrobustcmd*{\citelist}{\blx@citexpunct{citelist}}
  11452. \long\csdef{blx@cite@citelist}#1#2#3#4#5#6{%
  11453.   \begingroup
  11454.   \blx@citecmdinit
  11455.   \blx@citeinit
  11456.   \ifblank{#1}
  11457.    {}
  11458.    {\def\abx@field@prenote{#1}}%
  11459.   \ifblank{#2}
  11460.    {\let\blx@thenotecheck\relax}
  11461.    {\def\abx@field@postnote{#2}}%
  11462.   \def\blx@precode{\usebibmacro{prenote}}%
  11463.   \def\blx@loopcode{%
  11464.     \iflistundef{#5}
  11465.      {\blx@warning@entry{'#5' undefined or not a literal list}%
  11466.        \abx@missing{#5}}
  11467.      {\printlist[#4]{#5}}}%
  11468.   \def\blx@dlimcode{\multicitedelim}%
  11469.   \def\blx@postpunct@saved{#6}%
  11470.   \ifblank{#2}
  11471.    {\let\blx@postcode\@empty}
  11472.    {\def\blx@postcode{\usebibmacro{postnote}}}%
  11473.   \boolfalse{citetracker}%
  11474.   \boolfalse{pagetracker}%
  11475.   \blx@citeloop{#3}%
  11476.   \endgroup}
  11477.  
  11478. % [<prenote>][<postnote>]{<entrykey>,...}[<format>]{<field>}<punct>
  11479.  
  11480. \newrobustcmd*{\citefield}{\blx@citexpunct{citefield}}
  11481. \long\csdef{blx@cite@citefield}#1#2#3#4#5#6{%
  11482.   \begingroup
  11483.   \blx@citecmdinit
  11484.   \blx@citeinit
  11485.   \ifblank{#1}
  11486.    {}
  11487.    {\def\abx@field@prenote{#1}}%
  11488.   \ifblank{#2}
  11489.    {\let\blx@thenotecheck\relax}
  11490.    {\def\abx@field@postnote{#2}}%
  11491.   \def\blx@precode{\usebibmacro{prenote}}%
  11492.   \def\blx@loopcode{%
  11493.     \iffieldundef{#5}
  11494.      {\blx@warning@entry{'#5' undefined or not a field}%
  11495.        \abx@missing{#5}}
  11496.      {\printfield[#4]{#5}}}%
  11497.   \def\blx@dlimcode{\multicitedelim}%
  11498.   \def\blx@postpunct@saved{#6}%
  11499.   \ifblank{#2}
  11500.    {\let\blx@postcode\@empty}
  11501.    {\def\blx@postcode{\usebibmacro{postnote}}}%
  11502.   \boolfalse{citetracker}%
  11503.   \boolfalse{pagetracker}%
  11504.   \blx@citeloop{#3}%
  11505.   \endgroup}
  11506.  
  11507. \renewrobustcmd*{\cite}{\blx@err@citecmd\cite}
  11508. \let\blx@cite@cite\relax
  11509. \newrobustcmd*{\parencite}{\blx@warn@citecmd\parencite\cite}
  11510. \let\blx@cite@parencite\relax
  11511. \newrobustcmd*{\footcite}{\blx@warn@citecmd\footcite\cite}
  11512. \let\blx@cite@footcite\relax
  11513. \newrobustcmd*{\footcitetext}{\blx@warn@citecmd\footcitetext\cite}
  11514. \let\blx@cite@footcitetext\relax
  11515. \newrobustcmd*{\smartcite}{\blx@warn@citecmd\smartcite\cite}
  11516. \let\blx@cite@smartcite\relax
  11517. \newrobustcmd*{\textcite}{\blx@warn@citecmd\textcite\cite}
  11518. \let\blx@cite@textcite\relax
  11519. \newrobustcmd*{\supercite}{\blx@warn@citecmd\supercite\cite}
  11520. \let\blx@cite@supercite\relax
  11521.  
  11522. %% ifthen interface
  11523.  
  11524. \def\blx@TE#1#2{%
  11525.   \TE@throw
  11526.   \unexpanded{%
  11527.     \iftrue\@nameuse{fi}%
  11528.     #1{\@nameuse{iftrue}}{\@nameuse{iffalse}}}#2}
  11529.  
  11530. \def\blx@xTE#1#2{%
  11531.   \TE@throw
  11532.   \unexpanded{\iftrue\@nameuse{fi}}%
  11533.   #1\unexpanded{{\@nameuse{iftrue}}{\@nameuse{iffalse}}}#2}
  11534.  
  11535. \let\blx@TE@hook\@empty
  11536.  
  11537. \appto\blx@blxinit{%
  11538.   \appto\blx@TE@hook{%
  11539.     \def\ifhyperref{\blx@TE\blx@imc@ifhyperref}%
  11540.     \def\ifmorenames{\blx@TE\blx@imc@ifmorenames}%
  11541.     \def\ifmoreitems{\blx@TE\blx@imc@ifmoreitems}%
  11542.     \def\iffirstcitekey{\blx@TE\blx@imc@iffirstcitekey}%
  11543.     \def\iflastcitekey{\blx@TE\blx@imc@iflastcitekey}%
  11544.     \def\ifciteseen{\blx@TE\blx@imc@ifciteseen}%
  11545.     \def\ifentryseen{\blx@TE\blx@imc@ifentryseen}%
  11546.     \def\ifentryinbib{\blx@TE\blx@imc@ifentryinbib}%
  11547.     \def\ifciteibid{\blx@TE\blx@imc@ifciteibid}%
  11548.     \def\ifciteidem{\blx@TE\blx@imc@ifciteidem}%
  11549.     \def\ifopcit{\blx@TE\blx@imc@ifopcit}%
  11550.     \def\ifloccit{\blx@TE\blx@imc@ifloccit}%
  11551.     \def\ifsamepage{\blx@TE\blx@imc@ifsamepage}%
  11552.     \def\iffirstonpage{\blx@TE\blx@imc@iffirstonpage}%
  11553.     \def\ifcurrentfield#1{\blx@TE{\blx@imc@ifcurrentfield{#1}}}%
  11554.     \def\ifcurrentlist#1{\blx@TE{\blx@imc@ifcurrentlist{#1}}}%
  11555.     \def\ifcurrentname#1{\blx@TE{\blx@imc@ifcurrentname{#1}}}%
  11556.     \def\ifentrytype#1{\blx@TE{\blx@imc@ifentrytype{#1}}}%
  11557.     \def\iffieldequalcs#1#2{\blx@TE{\blx@imc@iffieldequalcs{#1}{#2}}}%
  11558.     \def\iffieldequals#1#2{\blx@TE{\blx@imc@iffieldequals{#1}{#2}}}%
  11559.     \def\iffieldequalstr#1#2{\blx@TE{\blx@imc@iffieldequalstr{#1}{#2}}}%
  11560.     \def\iffieldsequal#1#2{\blx@TE{\blx@imc@iffieldsequal{#1}{#2}}}%
  11561.     \def\ifbibmacroundef#1{\blx@TE{\blx@imc@ifbibmacroundef{#1}}}%
  11562.     \def\iffieldundef#1{\blx@TE{\blx@imc@iffieldundef{#1}}}%
  11563.     \def\ifnameequalcs#1#2{\blx@TE{\blx@imc@ifnameequalcs{#1}{#2}}}%
  11564.     \def\ifnameequals#1#2{\blx@TE{\blx@imc@ifnameequals{#1}{#2}}}%
  11565.     \def\ifnamesequal#1#2{\blx@TE{\blx@imc@ifnamesequal{#1}{#2}}}%
  11566.     \def\ifnameundef#1{\blx@TE{\blx@imc@ifnameundef{#1}}}%
  11567.     \def\ifcategory#1{\blx@TE{\blx@imc@ifcategory{#1}}}%
  11568.     \def\ifkeyword#1{\blx@TE{\blx@imc@ifkeyword{#1}}}%
  11569.     \def\ifentrycategory#1#2{\blx@TE{\blx@imc@ifentrycategory{#1}{#2}}}%
  11570.     \def\ifentrykeyword#1#2{\blx@TE{\blx@imc@ifentrykeyword{#1}{#2}}}%
  11571.     \def\ifcapital{\blx@TE\blx@imc@ifcapital}%
  11572.     \def\ifinteger#1{\blx@TE{\blx@imc@ifinteger{#1}}}%
  11573.     \def\iffieldint#1{\blx@TE{\blx@imc@iffieldint{#1}}}%
  11574.     \def\ifnumeral#1{\blx@TE{\blx@imc@ifnumeral{#1}}}%
  11575.     \def\ifnumerals#1{\blx@TE{\blx@imc@ifnumerals{#1}}}%
  11576.     \def\ifpages#1{\blx@TE{\blx@imc@ifpages{#1}}}%
  11577.     \def\iffieldnum#1{\blx@TE{\blx@imc@iffieldnum{#1}}}%
  11578.     \def\iffieldnums#1{\blx@TE{\blx@imc@iffieldnums{#1}}}%
  11579.     \def\iffieldpages#1{\blx@TE{\blx@imc@iffieldpages{#1}}}%
  11580.     \def\ifbibstring#1{\blx@TE{\blx@imc@ifbibstring{#1}}}%
  11581.     \def\iffieldbibstring#1{\blx@TE{\blx@imc@iffieldbibstring{#1}}}%
  11582.     \def\ifnatbibmode{\blx@TE{\iftoggle{blx@natbib}}}%
  11583.     \def\ifcitation{\blx@TE{\iftoggle{blx@citation}}}%
  11584.     \def\ifbibliography{\blx@TE{\iftoggle{blx@bibliography}}}%
  11585.     \def\ifciteindex{\blx@TE{\iftoggle{blx@citeindex}}}%
  11586.     \def\ifbibindex{\blx@TE{\iftoggle{blx@bibindex}}}%
  11587.     \def\iffootnote{\blx@TE{\iftoggle{blx@footnote}}}%
  11588.     \def\ifuseprefix{\blx@TE{\iftoggle{blx@useprefix}}}%
  11589.     \def\ifterseinits{\blx@TE{\iftoggle{blx@terseinits}}}%
  11590.     \def\ifsingletitle{\blx@TE{\iftoggle{abx@bool@singletitle}}}%
  11591.     \def\ifnocite{\blx@TE{\iftoggle{abx@bool@nocite}}}%
  11592.     \def\ifuniquetitle{\blx@TE{\iftoggle{abx@bool@uniquetitle}}}%
  11593.     \def\ifuniquebaretitle{\blx@TE{\iftoggle{abx@bool@uniquebaretitle}}}%
  11594.     \def\ifuniquework{\blx@TE{\iftoggle{abx@bool@uniquework}}}%
  11595.     \def\ifuniqueprimaryauthor{\blx@TE{\iftoggle{abx@bool@uniqueprimaryauthor}}}%
  11596.     \def\ifandothers#1{\blx@TE{\iftoggle{abx@bool@more#1}}}%
  11597.     \def\iflabeldateisdate{\blx@TE\blx@imc@iflabeldateisdate}%
  11598.     \def\ifdatehasyearonlyprecision#1{%
  11599.       \blx@TE{\blx@imc@ifdatehasyearonlyprecision{#1}}}%
  11600.     \def\ifdatehastime#1{\blx@TE{\blx@imc@ifdatehastime{#1}}}%
  11601.     \def\ifdateshavedifferentprecision#1#2{%
  11602.       \blx@TE{\blx@imc@ifdateshavedifferentprecision{#1}{#2}}}%
  11603.     \def\ifdateyearsequal#1#2{%
  11604.       \blx@TE{\blx@imc@ifdateyearsequal{#1}{#2}}}}}
  11605.  
  11606. % {<listmacro>}{<filtercsname>} => matches in <listmacro>
  11607. \protected\def\blx@bibfilter#1#2{%
  11608.   \begingroup
  11609.   \edef\blx@do##1{%
  11610.     \def\noexpand\blx@flt@item{##1}%
  11611.     \ifboolexpr{\csexpandonce{#2}}%
  11612.       {\listadd\noexpand\blx@tempa{##1}}%
  11613.       {}}%
  11614.   \let\blx@done\relax
  11615.   \edef\blx@tempa{%
  11616.     \let\noexpand\blx@tempa\noexpand\@empty
  11617.     \blx@listloop{#1}}%
  11618.   \blx@tempa
  11619.   \edef\blx@tempa{\endgroup
  11620.    \def\noexpand#1{\blx@tempa}}%
  11621.   \blx@tempa}
  11622.  
  11623. %% Auxiliary macros
  11624. \newrobustcmd*{\mkbibquote}{\blx@enquote}
  11625. \protected\def\blx@imc@mkbibquote{%
  11626.   \blx@ifuspunct\blx@usquote\blx@enquote}
  11627.  
  11628. \def\blx@usquote{%
  11629.   \ifnum\@quotelevel>\z@
  11630.     \expandafter\blx@usiquote
  11631.   \else
  11632.     \expandafter\blx@usoquote
  11633.   \fi}
  11634.  
  11635. \long\def\blx@usoquote#1{%
  11636.   \begingroup
  11637.   \blx@initoquote
  11638.   \blx@textooquote#1%
  11639.   \futurelet\@let@token\blx@usoquote@i}
  11640.  
  11641. \def\blx@usoquote@i{%
  11642.   \blx@usqcheck
  11643.     {\ifx\blx@postpunct\@empty\else\blx@dopostpunct\fi
  11644.     \blx@textcoquote\endgroup}
  11645.    {\blx@setpostpunct\blx@textcoquote\endgroup}}
  11646.  
  11647. \long\def\blx@usiquote#1{%
  11648.   \begingroup
  11649.   \blx@initiquote
  11650.   \blx@textoiquote#1%
  11651.   \futurelet\@let@token\blx@usiquote@i}
  11652.  
  11653. \def\blx@usiquote@i{%
  11654.   \blx@usqcheck
  11655.     {\blx@textciquote\endgroup}
  11656.    {\blx@setpostpunct\blx@textciquote\endgroup}}
  11657.  
  11658. \long\def\blx@usqcheck#1#2{%
  11659.   \def\blx@tempa{#1}%
  11660.   \def\blx@tempb{#2}%
  11661.   \ifx\@let@token\space
  11662.     \blx@usqcheck@i\blx@tempa
  11663.   \fi
  11664.   \ifx\@let@token\@sptoken
  11665.     \blx@usqcheck@i\blx@tempa
  11666.   \fi
  11667.   \if\noexpand\@let@token\relax
  11668.     \expandafter\blx@usqcheck@iv
  11669.   \fi
  11670.   \expandafter\blx@usqcheck@ii\blx@quotepunct\relax&}
  11671.  
  11672. \long\def\blx@usqcheck@i#1#2&{\fi#1}
  11673.  
  11674. \long\def\blx@usqcheck@ii#1{%
  11675.   \if\noexpand#1\relax
  11676.     \blx@usqcheck@i\blx@tempa
  11677.   \fi
  11678.   \if\noexpand#1\noexpand\@let@token
  11679.     \blx@usqcheck@i{\blx@usqcheck@iii\blx@tempa}%
  11680.   \fi
  11681.   \blx@usqcheck@ii
  11682. }
  11683.  
  11684. \long\def\blx@usqcheck@iii#1#2{#2#1}
  11685.  
  11686. \long\def\blx@usqcheck@iv#1&#2{%
  11687.   \begingroup
  11688.     \escapechar=-1 %
  11689.     \edef\blx@tempa{\expandafter\@gobble\string#2}%
  11690.     \expandafter\endgroup
  11691.     \ifx\blx@tempa\@empty
  11692.     \else
  11693.       \blx@usqcheck@i\blx@tempb
  11694.     \fi
  11695.     #1&#2%
  11696. }
  11697.  
  11698. \newrobustcmd*{\mkbibemph}{\emph}
  11699. \protected\long\def\blx@imc@mkbibemph#1{%
  11700.   \emph{#1}\blx@imc@setpunctfont\emph}
  11701.  
  11702. \newrobustcmd*{\mkbibbold}{\textbf}
  11703. \protected\long\def\blx@imc@mkbibbold#1{%
  11704.   \textbf{#1}\blx@imc@setpunctfont\textbf}
  11705.  
  11706. \newrobustcmd*{\mkbibitalic}{\textit}
  11707. \protected\long\def\blx@imc@mkbibitalic#1{%
  11708.   \textit{#1}\blx@imc@setpunctfont\textit}
  11709.  
  11710. \blx@regimcs{\mkbibquote \mkbibemph \mkbibbold \mkbibitalic}
  11711.  
  11712. \newcommand*{\bibleftparen}{\blx@postpunct(}
  11713. \newcommand*{\bibrightparen}{\blx@postpunct)\midsentence}
  11714. \newcommand*{\bibleftbracket}{\blx@postpunct[}
  11715. \newcommand*{\bibrightbracket}{\blx@postpunct]\midsentence}
  11716.  
  11717. \def\blx@parenlevel{%
  11718.   \iftoggle{blx@footnote}
  11719.    {\blx@parenlevel@foot}
  11720.    {\blx@parenlevel@text}}
  11721.  
  11722. \newrobustcmd*{\blx@bibopenparen}{%
  11723.   \blx@opencheck\bibopenparen
  11724.   \blx@postpunct
  11725.   \ifnum\blx@parenlevel=\z@
  11726.     \global\blx@parenlevel\@ne
  11727.     \global\c@parenlevel\@ne
  11728.     \expandafter\bibleftparen
  11729.   \else
  11730.     \expandafter\blx@openparen
  11731.   \fi}
  11732.  
  11733. \newrobustcmd*{\blx@bibopenbracket}{%
  11734.   \blx@opencheck\bibopenbracket
  11735.   \blx@postpunct
  11736.   \ifnum\blx@parenlevel=\z@
  11737.     \global\blx@parenlevel1002
  11738.     \global\c@parenlevel\@ne
  11739.     \expandafter\bibleftbracket
  11740.   \else
  11741.     \expandafter\blx@openparen
  11742.   \fi}
  11743.  
  11744. \newrobustcmd*{\blx@bibcloseparen}{%
  11745.   \blx@closecheck\bibcloseparen
  11746.   \blx@postpunct\blx@closeparen}
  11747.  
  11748. \newrobustcmd*{\blx@bibclosebracket}{%
  11749.   \blx@closecheck\bibclosebracket
  11750.   \blx@postpunct\blx@closeparen}
  11751.  
  11752. \def\blx@openparen{%
  11753.   \ifodd\blx@parenlevel
  11754.     \global\advance\blx@parenlevel\@ne
  11755.     \global\advance\c@parenlevel\@ne
  11756.     \expandafter\bibleftbracket
  11757.   \else
  11758.     \global\advance\blx@parenlevel\@ne
  11759.     \global\advance\c@parenlevel\@ne
  11760.     \expandafter\bibleftparen
  11761.   \fi}
  11762.  
  11763. \def\blx@closeparen{%
  11764.   \ifodd\blx@parenlevel
  11765.     \blx@closeparen@i
  11766.     \expandafter\bibrightparen
  11767.   \else
  11768.     \blx@closeparen@i
  11769.     \expandafter\bibrightbracket
  11770.   \fi}
  11771.  
  11772. \def\blx@closeparen@i{%
  11773.   \ifnum\blx@parenlevel=1002
  11774.     \global\blx@parenlevel\z@
  11775.     \global\c@parenlevel\z@
  11776.   \else
  11777.     \global\advance\blx@parenlevel\m@ne
  11778.     \global\advance\c@parenlevel\m@ne
  11779.   \fi}
  11780.  
  11781. \def\blx@opencheck#1{%
  11782.   \ifnum\numexpr\blx@parenlevel+\@ne
  11783.     \ifnum\blx@parenlevel>\@m -1001\fi
  11784.   >\c@maxparens
  11785.     \blx@err@nestparen{\string#1}%
  11786.     \blx@errormark
  11787.   \fi}
  11788.  
  11789. \def\blx@closecheck#1{%
  11790.   \ifnum\numexpr\blx@parenlevel
  11791.     \ifnum\blx@parenlevel>\@m -1001\fi
  11792.   >\c@maxparens
  11793.     \blx@err@nestparen{\string#1}%
  11794.     \blx@errormark
  11795.   \fi
  11796.   \ifnum\blx@parenlevel<\@ne
  11797.     \blx@err@matchparen{Unmatched \string#1}%
  11798.     \blx@errormark
  11799.   \fi}
  11800.  
  11801. \protected\def\blx@errormark{%
  11802.   \rule[0.25ex]{1.25ex}{1.25ex}}
  11803.  
  11804. \AtEndDocument{%
  11805.   \unless\ifnum\blx@parenlevel@text=\z@
  11806.     \blx@err@matchparen{%
  11807.       Unbalanced parentheses or brackets in the document body}%
  11808.   \fi
  11809.   \unless\ifnum\blx@parenlevel@foot=\z@
  11810.     \blx@err@matchparen{%
  11811.       Unbalanced parentheses or brackets in a foot or endnote}%
  11812.   \fi}
  11813.  
  11814. \newrobustcmd{\mkbibparens}[1]{%
  11815.   \begingroup
  11816.   \blx@blxinit
  11817.   \blx@setsfcodes
  11818.   \bibopenparen#1\bibcloseparen
  11819.   \endgroup}
  11820.  
  11821. \newrobustcmd{\mkbibbrackets}[1]{%
  11822.   \begingroup
  11823.   \blx@blxinit
  11824.   \blx@setsfcodes
  11825.   \bibopenbracket#1\bibclosebracket
  11826.   \endgroup}
  11827.  
  11828. \newrobustcmd*{\parentext}{\mkbibparens}
  11829. \newrobustcmd*{\brackettext}{\mkbibbrackets}
  11830.  
  11831. \newrobustcmd{\mkbibsuperscript}[1]{%
  11832.   \unspace\allowhyphens\textsuperscript{%
  11833.     \begingroup
  11834.     \protected\long\def\mkbibsuperscript##1{%
  11835.       \blx@warning{Nested superscript}%
  11836.       \mkbibbrackets{##1}}%
  11837.     #1\endgroup}}
  11838.  
  11839. \newrobustcmd{\mkbibfootnote}{\blx@mkbibfootnote{}}
  11840. \newrobustcmd{\mkbibfootnotetext}{\blx@mkbibfootnote{text}}
  11841. \newrobustcmd{\blx@mkbibfootnote}[2]{%
  11842.   \iftoggle{blx@footnote}
  11843.    {\blx@warning{Nested notes}%
  11844.      \addspace\mkbibparens{#2}}
  11845.    {\unspace
  11846.     \ifnum\blx@notetype=\tw@
  11847.       \expandafter\@firstoftwo
  11848.     \else
  11849.       \expandafter\@secondoftwo
  11850.     \fi
  11851.       {\csuse{blx@theendnote#1}{\protecting{\blxmkbibnote{end}{#2}}}}
  11852.       {\csuse{footnote#1}{\protecting{\blxmkbibnote{foot}{#2}}}}}}
  11853.  
  11854. \newrobustcmd{\mkbibendnote}{\blx@mkbibendnote{}}
  11855. \newrobustcmd{\mkbibendnotetext}{\blx@mkbibendnote{text}}
  11856. \newrobustcmd{\blx@mkbibendnote}[2]{%
  11857.   \iftoggle{blx@footnote}
  11858.    {\blx@warning{Nested notes}%
  11859.      \addspace\mkbibparens{#2}}
  11860.    {\unspace
  11861.     \ifnum\blx@notetype=\@ne
  11862.       \expandafter\@firstoftwo
  11863.     \else
  11864.       \expandafter\@secondoftwo
  11865.     \fi
  11866.       {\csuse{footnote#1}{\protecting{\blxmkbibnote{foot}{#2}}}}
  11867.       {\csuse{blx@theendnote#1}{\protecting{\blxmkbibnote{end}{#2}}}}}}
  11868.  
  11869. \newrobustcmd{\blxmkbibnote}[2]{%
  11870.   \begingroup
  11871.   \blx@blxinit
  11872.   \blx@setsfcodes
  11873.   \blx@postpunct@agroup
  11874.   \toggletrue{blx@footnote}%
  11875.   \csuse{bib#1notewrapper}{#2}%
  11876.   \endgroup}
  11877.  
  11878. \newcommand{\bibfootnotewrapper}[1]{%
  11879.   \bibsentence#1\addperiod}
  11880.  
  11881. \newcommand{\bibendnotewrapper}[1]{%
  11882.   \bibsentence#1\addperiod}
  11883.  
  11884. \AtEndPreamble{%
  11885.   \def\blx@theendnote{\blx@err@endnote\footnote}%
  11886.   \def\blx@theendnotetext{\blx@err@endnote\footnotetext}%
  11887.   \ifdef\endnote
  11888.     {\def\blx@theendnote{\endnote}%
  11889.      \ifdef\endnotetext
  11890.        {\def\blx@theendnotetext{\endnotetext}}
  11891.       {}}
  11892.    {\ifdef\pagenote
  11893.       {\def\blx@theendnote{\pagenote}%
  11894.         \ifdef\pagenotetext
  11895.           {\def\blx@theendnotetext{\pagenotetext}}
  11896.          {}}
  11897.       {}}}
  11898.  
  11899. \newrobustcmd*{\mknumalph}[1]{%
  11900.   \begingroup
  11901.   \blx@tempcnta=#1\relax
  11902.   \ifnum\blx@tempcnta>702 %
  11903.   \else
  11904.     \ifnum\blx@tempcnta>26 %
  11905.       \advance\blx@tempcnta\m@ne
  11906.       \divide\blx@tempcnta26\relax
  11907.       \blx@numalph\blx@tempcnta
  11908.       \multiply\blx@tempcnta26\relax
  11909.       \blx@tempcnta=\numexpr#1-\blx@tempcnta\relax
  11910.     \fi
  11911.   \fi
  11912.   \blx@numalph\blx@tempcnta
  11913.   \endgroup}
  11914. \def\blx@numalph#1{%
  11915.   \ifcase#1\relax\blx@warning@entry{Value out of range}\number#1\or
  11916.  a\or b\or c\or d\or e\or f\or g\or h\or i\or j\or k\or l\or m\or
  11917.  n\or o\or p\or q\or r\or s\or t\or u\or v\or w\or x\or y\or z\else
  11918.  \blx@warning@entry{Value out of range}\number#1\fi}
  11919.  
  11920. % {<macro>}[<pre>]{<vol>}[<post>] => <macro>{<pre>}{{<vol>}{<post>}}
  11921.  
  11922. \newrobustcmd*{\volcitecmd}{%
  11923.   \AtNextCite{\DeclareFieldAlias{postnote}{volcitenote}}%
  11924.   \begingroup\let\blx@citeargs\blx@volciteargs}
  11925.  
  11926. \protected\def\blx@volciteargs#1{%
  11927.   \endgroup
  11928.   \@ifnextchar[%]
  11929.     {\blx@volciteargs@i{#1}}
  11930.    {\blx@volciteargs@i{#1}[]}}
  11931.  
  11932. \long\def\blx@volciteargs@i#1[#2]#3{%
  11933.   \@ifnextchar[%]
  11934.     {\blx@volciteargs@ii{#1}{#2}{#3}}
  11935.    {\blx@citeargs@iii{#1{#2}{{#3}{}}}}}
  11936.  
  11937. \long\def\blx@volciteargs@ii#1#2#3[#4]{%
  11938.   \blx@citeargs@iii{#1{#2}{{#3}{#4}}}}
  11939.  
  11940. \newrobustcmd*{\multivolcitecmd}{%
  11941.   \AtNextCite{\DeclareFieldAlias{postnote}{volcitenote}}%
  11942.   \def\blx@hook@mcite@before{%
  11943.     \global\undef\blx@hook@mcite@before
  11944.     \let\blx@citeargs\blx@volmciteargs}}
  11945.  
  11946. \protected\def\blx@volmciteargs#1{%
  11947.   \@ifnextchar[%]
  11948.     {\blx@volciteargs@i{#1}}
  11949.    {\blx@volciteargs@i{#1}[]}}
  11950.  
  11951. %% Control file
  11952.  
  11953. \begingroup
  11954. \let~\space
  11955. \@makeother\<
  11956. \@makeother\>
  11957. \@makeother\.
  11958. \@makeother\:
  11959. \@makeother\?
  11960. \@makeother\"
  11961. \@makeother\-
  11962. \@makeother\=
  11963. \@makeother\/
  11964. \xdef\blx@xml@file{%
  11965.   \blx@sig@bcf\blx@nl
  11966.   \blx@ver@bcf\blx@nl}
  11967. \xdef\blx@xml@endfile{%
  11968.   </bcf:controlfile>}
  11969. \xdef\blx@xml@comment#1{%
  11970.   ~~<!-- #1 -->\blx@nl}
  11971. \xdef\blx@xml@options#1#2#3{%
  11972.   ~~<bcf:options%
  11973.     \noexpand\ifblank{#1}{}{ component="#1"}%
  11974.     \noexpand\ifblank{#2}{}{ type="#2"}%
  11975.   >\blx@nl
  11976.   #3%
  11977.   ~~</bcf:options>\blx@nl}
  11978. \xdef\blx@xml@option#1#2{%
  11979.   ~~~~<bcf:option type="#1">\blx@nl
  11980.   #2%
  11981.   ~~~~</bcf:option>\blx@nl}
  11982. \xdef\blx@xml@ordered#1#2#3{%
  11983.   ~~~~~~<bcf:value order="#1"#2%
  11984.   >#3</bcf:value>\blx@nl}
  11985.  
  11986. \xdef\blx@xml@datafieldset#1#2{%
  11987.   ~~<bcf:datafieldset name="#1">\blx@nl
  11988.   #2%
  11989.   ~~</bcf:datafieldset>\blx@nl}
  11990.  
  11991. \xdef\blx@xml@datafieldsets@member#1{%
  11992.   ~~~~<bcf:member#1/>\blx@nl}
  11993.  
  11994. \xdef\blx@xml@transliteration#1#2{%
  11995.   ~~<bcf:transliteration entrytype="#1">\blx@nl
  11996.   #2%
  11997.   ~~</bcf:transliteration>\blx@nl}
  11998. \xdef\blx@xml@translit#1#2#3#4{%
  11999.   ~~~~<bcf:translit #1target="#2" from="#3" to="#4"/>\blx@nl}
  12000.  
  12001. \xdef\blx@xml@sourcemap#1{%
  12002.   ~~<bcf:sourcemap>\blx@nl
  12003.   #1%
  12004.   ~~</bcf:sourcemap>\blx@nl}
  12005. \xdef\blx@xml@sourcemap@maps#1#2{%
  12006.   ~~~~<bcf:maps#1>\blx@nl
  12007.   #2%
  12008.   ~~~~</bcf:maps>\blx@nl}
  12009. \xdef\blx@xml@sourcemap@map#1#2{%
  12010.   ~~~~~~<bcf:map#1>\blx@nl
  12011.   #2%
  12012.   ~~~~~~</bcf:map>\blx@nl}
  12013. \xdef\blx@xml@sourcemap@perdatasource#1{%
  12014.   ~~~~~~~~<bcf:per\string_datasource>#1</bcf:per\string_datasource>\blx@nl}
  12015. \xdef\blx@xml@sourcemap@pertype#1{%
  12016.   ~~~~~~~~<bcf:per\string_type>#1</bcf:per\string_type>\blx@nl}
  12017. \xdef\blx@xml@sourcemap@pernottype#1{%
  12018.   ~~~~~~~~<bcf:per\string_nottype>#1</bcf:per\string_nottype>\blx@nl}
  12019. \xdef\blx@xml@sourcemap@step#1{%
  12020.   ~~~~~~~~<bcf:map\string_step#1/>\blx@nl}
  12021.  
  12022. \xdef\blx@xml@labelalphanametemplate#1#2{%
  12023.   ~~<bcf:labelalphanametemplate name="#1">\blx@nl
  12024.   #2%
  12025.   ~~</bcf:labelalphanametemplate>\blx@nl}
  12026. \xdef\blx@xml@labelalphanametemplatenamepart#1#2#3{%
  12027.   ~~~~<bcf:namepart #1#2>#3</bcf:namepart>\blx@nl}
  12028.  
  12029. \xdef\blx@xml@labelalphatemplate#1#2{%
  12030.   ~~<bcf:labelalphatemplate type="#1">\blx@nl
  12031.   #2%
  12032.   ~~</bcf:labelalphatemplate>\blx@nl}
  12033. \xdef\blx@xml@labelalpha@element#1#2{%
  12034.   ~~~~<bcf:labelelement order="#1">\blx@nl
  12035.   #2%
  12036.   ~~~~</bcf:labelelement>\blx@nl}
  12037. \xdef\blx@xml@labelalpha@part#1#2{%
  12038.   ~~~~~~<bcf:labelpart#1>#2</bcf:labelpart>\blx@nl}
  12039.  
  12040. \xdef\blx@xml@extradate#1{%
  12041.   ~~<bcf:extradatespec>\blx@nl
  12042.   #1%
  12043.   ~~</bcf:extradatespec>\blx@nl}
  12044. \xdef\blx@xml@extradatescope#1{%
  12045.   ~~~~<bcf:scope>\blx@nl
  12046.   #1%
  12047.   ~~~~</bcf:scope>\blx@nl}
  12048. \xdef\blx@xml@edordered#1#2{%
  12049.   ~~~~~~<bcf:field order="#1">#2</bcf:field>\blx@nl}
  12050.  
  12051. \xdef\blx@xml@inheritance#1{%
  12052.   ~~<bcf:inheritance>\blx@nl
  12053.   #1%
  12054.   ~~</bcf:inheritance>\blx@nl}
  12055. \xdef\blx@xml@inherit@defaults#1#2{%
  12056.   ~~~~<bcf:defaults#1>\blx@nl
  12057.   #2%
  12058.   ~~~~</bcf:defaults>\blx@nl}
  12059. \xdef\blx@xml@inherit@data#1#2{%
  12060.   ~~~~<bcf:inherit#1>\blx@nl
  12061.   #2%
  12062.   ~~~~</bcf:inherit>\blx@nl}
  12063. \xdef\blx@xml@inherit@type#1#2#3{%
  12064.   ~~~~~~<bcf:type\string_pair source="#1" target="#2"#3/>\blx@nl}
  12065. \xdef\blx@xml@inherit@field#1#2#3{%
  12066.   ~~~~~~<bcf:field source="#1" target="#2"#3/>\blx@nl}
  12067. \xdef\blx@xml@inherit@block#1{%
  12068.   ~~~~~~<bcf:field source="#1" skip="true"/>\blx@nl}
  12069.  
  12070. \xdef\blx@xml@nosorts#1{%
  12071.   ~~<bcf:nosorts>\blx@nl
  12072.   #1%
  12073.   ~~</bcf:nosorts>\blx@nl}
  12074. \xdef\blx@xml@nosort#1#2{%
  12075.   ~~~~<bcf:nosort field="#1" value="#2"/>\blx@nl}
  12076.  
  12077. \xdef\blx@xml@noinits#1{%
  12078.   ~~<bcf:noinits>\blx@nl
  12079.   #1%
  12080.   ~~</bcf:noinits>\blx@nl}
  12081. \xdef\blx@xml@noinit#1{%
  12082.   ~~~~<bcf:noinit value="#1"/>\blx@nl}
  12083.  
  12084. \xdef\blx@xml@nolabels#1{%
  12085.   ~~<bcf:nolabels>\blx@nl
  12086.   #1%
  12087.   ~~</bcf:nolabels>\blx@nl}
  12088. \xdef\blx@xml@nolabel#1{%
  12089.   ~~~~<bcf:nolabel value="#1"/>\blx@nl}
  12090.  
  12091. \xdef\blx@xml@nolabelwidthcounts#1{%
  12092.   ~~<bcf:nolabelwidthcounts>\blx@nl
  12093.   #1%
  12094.   ~~</bcf:nolabelwidthcounts>\blx@nl}
  12095. \xdef\blx@xml@nolabelwidthcount#1{%
  12096.   ~~~~<bcf:nolabelwidthcount value="#1"/>\blx@nl}
  12097.  
  12098. \xdef\blx@xml@uniquenametemplate#1#2{%
  12099.   ~~<bcf:uniquenametemplate name="#1">\blx@nl%
  12100.   #2%
  12101.   ~~</bcf:uniquenametemplate>\blx@nl}
  12102.  
  12103. \xdef\blx@xml@uniquenametemplatenamepart#1#2#3{%
  12104.   ~~~~<bcf:namepart #1#2>#3</bcf:namepart>\blx@nl}
  12105.  
  12106. \xdef\blx@xml@sortingnamekeytemplate#1#2{%
  12107.   ~~<bcf:sortingnamekeytemplate name="#1">\blx@nl%
  12108.   #2%
  12109.   ~~</bcf:sortingnamekeytemplate>\blx@nl}
  12110.  
  12111. \xdef\blx@xml@sortingnamekeykeypart#1#2{%
  12112.   ~~~~<bcf:keypart#1>\blx@nl
  12113.   #2%
  12114.   ~~~~</bcf:keypart>\blx@nl}
  12115.  
  12116. \xdef\blx@xml@sortingnamekeynamepart#1#2#3{%
  12117.   ~~~~~~<bcf:part type="namepart"#1#2>#3</bcf:part>\blx@nl}
  12118.  
  12119. \xdef\blx@xml@sortingnamekeyliteral#1#2{%
  12120.   ~~~~~~<bcf:part type="literal"#1>#2</bcf:part>\blx@nl}
  12121.  
  12122. \xdef\blx@xml@sortingtemplate#1#2#3{%
  12123.   ~~<bcf:sortingtemplate name="#1"#2>\blx@nl%
  12124.   #3%
  12125.   ~~</bcf:sortingtemplate>\blx@nl}
  12126. \xdef\blx@xml@presort#1#2{%
  12127.   ~~<bcf:presort\noexpand\ifblank{#1}{}{ type="#1"}>%
  12128.   #2</bcf:presort>\blx@nl}
  12129.  
  12130. \xdef\blx@xml@sortexclude#1#2{%
  12131.   ~~<bcf:sortexclusion\noexpand\ifblank{#1}{}{ type="#1"}>\blx@nl
  12132.   #2%
  12133.   ~~</bcf:sortexclusion>\blx@nl}
  12134. \xdef\blx@xml@exclude#1{%
  12135.   ~~~~<bcf:exclusion>#1</bcf:exclusion>\blx@nl}
  12136. \xdef\blx@xml@sortinclude#1#2{%
  12137.   ~~<bcf:sortinclusion\noexpand\ifblank{#1}{}{ type="#1"}>\blx@nl
  12138.   #2%
  12139.   ~~</bcf:sortinclusion>\blx@nl}
  12140. \xdef\blx@xml@include#1{%
  12141.   ~~~~<bcf:inclusion>#1</bcf:inclusion>\blx@nl}
  12142. \xdef\blx@xml@sort#1#2{%
  12143.   ~~~~<bcf:sort #1>\blx@nl
  12144.   #2%
  12145.   ~~~~</bcf:sort>\blx@nl}
  12146. \xdef\blx@xml@sortitem#1#2{%
  12147.   ~~~~~~<bcf:sortitem #1>#2</bcf:sortitem>\blx@nl}
  12148. \xdef\blx@xml@section#1{%
  12149.   ~~<bcf:section number="#1">}
  12150. \xdef\blx@xml@endsection{%
  12151.   ~~</bcf:section>}
  12152.  
  12153. \xdef\blx@xml@dlist@refcontext#1#2#3#4#5{%
  12154.   ~~~~~~~~~~~~~~~~sortingtemplatename="#1"\blx@nl
  12155.   ~~~~~~~~~~~~~~~~sortingnamekeytemplatename="#2"\blx@nl
  12156.   ~~~~~~~~~~~~~~~~labelprefix="#3"\blx@nl
  12157.   ~~~~~~~~~~~~~~~~uniquenametemplatename="#4"\blx@nl
  12158.   ~~~~~~~~~~~~~~~~labelalphanametemplatename="#5"}
  12159. \xdef\blx@xml@dlist#1#2#3#4#5{%
  12160.   ~~<bcf:datalist section="#3"\blx@nl
  12161.   ~~~~~~~~~~~~~~~~name="#1"\blx@nl
  12162.   ~~~~~~~~~~~~~~~~type="#2"\blx@nl
  12163.   #4>\blx@nl
  12164.   #5%
  12165.   ~~</bcf:datalist>\blx@nl}
  12166. \xdef\blx@xml@dlistfilterorbegin{%
  12167.   ~~~~<bcf:filteror>\blx@nl}
  12168. \xdef\blx@xml@dlistfilterorend{%
  12169.   ~~~~</bcf:filteror>\blx@nl}
  12170. \xdef\blx@xml@dlistfilter#1#2{%
  12171.   ~~~~<bcf:filter type="#1">#2</bcf:filter>\blx@nl}
  12172.  
  12173. \xdef\blx@xml@bibdata#1#2{%
  12174.   ~~<bcf:bibdata section="#1">\blx@nl
  12175.   #2%
  12176.   ~~</bcf:bibdata>\blx@nl}
  12177. \xdef\blx@xml@datasource#1#2#3#4{%
  12178.   ~~~~<bcf:datasource type="#1" datatype="#2"#3>#4</bcf:datasource>\blx@nl}
  12179. \xdef\blx@xml@citekey#1#2#3{%
  12180.   ~~~~<bcf:citekey order="#3"#2>#1</bcf:citekey>}
  12181. \xdef\blx@xml@citeset#1#2{%
  12182.   ~~~~<bcf:citekey type="set" members="#2">#1</bcf:citekey>}
  12183. \xdef\blx@xml@svalue#1#2{%
  12184.   \blx@xml@option{singlevalued}{%
  12185.   ~~~~~~<bcf:key>#1</bcf:key>\blx@nl
  12186.   ~~~~~~<bcf:value>#2</bcf:value>\blx@nl}}
  12187. \xdef\blx@xml@mvalue#1#2{%
  12188.   \blx@xml@option{multivalued}{%
  12189.   ~~~~~~<bcf:key>#1</bcf:key>\blx@nl
  12190.   #2}}
  12191. \xdef\blx@xml@toggle#1{%
  12192.   \blx@xml@svalue{#1}{\noexpand\iftoggle{blx@#1}{1}{0}}}
  12193. \xdef\blx@xml@options@scope#1#2{%
  12194.   ~~<bcf:optionscope type="#1">\blx@nl
  12195.   #2%
  12196.   ~~</bcf:optionscope>\blx@nl}
  12197. \xdef\blx@xml@option@scope#1#2{%
  12198.   ~~~~<bcf:option datatype="#1">#2</bcf:option>\blx@nl}
  12199. \endgroup
  12200.  
  12201. \def\blx@bcf@options@global{%
  12202.   \blx@xml@comment{GLOBAL}%
  12203.   \blx@xml@options{biblatex}{global}{%
  12204.     \blx@xml@svalue{alphaothers}{\labelalphaothers}%
  12205.     \blx@xml@toggle{labelalpha}%
  12206.     \blx@xml@mvalue{labelnamespec}{\blx@bcf@labelnamespec}%
  12207.     \blx@xml@toggle{labeltitle}%
  12208.     \blx@xml@mvalue{labeltitlespec}{\blx@bcf@labeltitlespec}%
  12209.     \blx@xml@toggle{labeltitleyear}%
  12210.     \blx@xml@toggle{labeldateparts}%
  12211.     \blx@xml@mvalue{labeldatespec}{\blx@bcf@labeldatespec}%
  12212.     \blx@xml@toggle{julian}%
  12213.     \blx@xml@svalue{gregorianstart}{\blx@gregorianstart}%
  12214.     \blx@xml@svalue{maxalphanames}{\blx@maxalphanames}%
  12215.     \blx@xml@svalue{maxbibnames}{\blx@maxbibnames}%
  12216.     \blx@xml@svalue{maxcitenames}{\blx@maxcitenames}%
  12217.     \blx@xml@svalue{maxsortnames}{\blx@maxsortnames}%
  12218.     \blx@xml@svalue{maxitems}{\blx@maxitems}%
  12219.     \blx@xml@svalue{minalphanames}{\blx@minalphanames}%
  12220.     \blx@xml@svalue{minbibnames}{\blx@minbibnames}%
  12221.     \blx@xml@svalue{mincitenames}{\blx@mincitenames}%
  12222.     \blx@xml@svalue{minsortnames}{\blx@minsortnames}%
  12223.     \blx@xml@svalue{minitems}{\blx@minitems}%
  12224.     \blx@xml@toggle{singletitle}%
  12225.     \blx@xml@svalue{sortalphaothers}{\sortalphaothers}%
  12226.     \blx@xml@svalue{sortlocale}{\blx@sortlocale}%
  12227.     \blx@xml@svalue{sortingtemplatename}{\blx@sorting}%
  12228.     \blx@xml@toggle{sortsets}%
  12229.     \blx@xml@svalue{uniquelist}{\blx@uniquelist}%
  12230.     \blx@xml@svalue{uniquename}{\blx@uniquename}%
  12231.     \blx@xml@toggle{uniqueprimaryauthor}%
  12232.     \blx@xml@toggle{uniquetitle}%
  12233.     \blx@xml@toggle{uniquebaretitle}%
  12234.     \blx@xml@toggle{uniquework}%
  12235.     \blx@xml@toggle{useprefix}%
  12236.     \blx@xml@nametoggles
  12237.   }%
  12238. }
  12239.  
  12240. \def\blx@bcf@options@type#1{%
  12241.   \blx@xml@comment{#1}%
  12242.   \blx@xml@options{biblatex}{#1}{%
  12243.     \blx@xml@toggle{labelalpha}%
  12244.     \blx@xml@mvalue{labelnamespec}{%
  12245.       \ifcsdef{blx@bcf@labelnamespec@#1}
  12246.        {\csuse{blx@bcf@labelnamespec@#1}}
  12247.        {\blx@bcf@labelnamespec}}%
  12248.     \blx@xml@toggle{labeltitle}%
  12249.     \blx@xml@mvalue{labeltitlespec}{%
  12250.       \ifcsdef{blx@bcf@labeltitlespec@#1}
  12251.        {\csuse{blx@bcf@labeltitlespec@#1}}
  12252.        {\blx@bcf@labeltitlespec}}%
  12253.     \blx@xml@toggle{labeltitleyear}%
  12254.     \blx@xml@toggle{labeldateparts}%
  12255.     \blx@xml@mvalue{labeldatespec}{%
  12256.       \ifcsdef{blx@bcf@labeldatespec@#1}
  12257.        {\csuse{blx@bcf@labeldatespec@#1}}
  12258.        {\blx@bcf@labeldatespec}}%
  12259.     \blx@xml@svalue{maxalphanames}{\blx@maxalphanames}%
  12260.     \blx@xml@svalue{maxbibnames}{\blx@maxbibnames@type}%
  12261.     \blx@xml@svalue{maxcitenames}{\blx@maxcitenames@type}%
  12262.     \blx@xml@svalue{maxsortnames}{\blx@maxsortnames@type}%
  12263.     \blx@xml@svalue{maxitems}{\blx@maxitems@type}%
  12264.     \blx@xml@svalue{minalphanames}{\blx@minalphanames}%
  12265.     \blx@xml@svalue{minbibnames}{\blx@minbibnames@type}%
  12266.     \blx@xml@svalue{mincitenames}{\blx@mincitenames@type}%
  12267.     \blx@xml@svalue{minsortnames}{\blx@minsortnames@type}%
  12268.     \blx@xml@svalue{minitems}{\blx@minitems@type}%
  12269.     \blx@xml@toggle{singletitle}%
  12270.     \blx@xml@toggle{skipbib}%
  12271.     \blx@xml@toggle{skiplab}%
  12272.     \blx@xml@toggle{skipbiblist}%
  12273.     \blx@xml@svalue{uniquelist}{\blx@uniquelist}%
  12274.     \blx@xml@svalue{uniquename}{\blx@uniquename}%
  12275.     \blx@xml@toggle{uniqueprimaryauthor}%
  12276.     \blx@xml@toggle{uniquetitle}%
  12277.     \blx@xml@toggle{uniquebaretitle}%
  12278.     \blx@xml@toggle{uniquework}%
  12279.     \blx@xml@toggle{useprefix}%
  12280.     \blx@xml@nametoggles
  12281.   }%
  12282. }
  12283.  
  12284. \def\blx@ctrlwrite{%
  12285.   \begingroup
  12286.   \blx@safe@actives
  12287.   \let\protect\string
  12288.   % options
  12289.   \edef\labelalphaothers{\labelalphaothers}%
  12290.   \edef\sortalphaothers{\sortalphaothers}%
  12291.   \blx@xmlsanitizeafter{\def\labelalphaothers}{\labelalphaothers}%
  12292.   \blx@xmlsanitizeafter{\def\sortalphaothers}{\sortalphaothers}%
  12293.   % Expand the global use* name toggles
  12294.   \let\blx@xml@nametoggles\@empty
  12295.   \def\do##1{\eappto\blx@xml@nametoggles{\blx@xml@toggle{use##1}}}%
  12296.   \abx@donames
  12297.   \edef\blx@tempa{%
  12298.     \blx@xml@file
  12299.     \blx@xml@comment{BIBER OPTIONS}%
  12300.     \blx@xml@options{biber}{global}{%
  12301.       \blx@xml@svalue{output_encoding}{\blx@texencoding}%
  12302.       \blx@xml@svalue{input_encoding}{\blx@bibencoding}%
  12303.       \blx@xml@toggle{debug}%
  12304.       \blx@xml@svalue{mincrossrefs}{\blx@mincrossrefs}%
  12305.       \blx@xml@svalue{minxrefs}{\blx@minxrefs}%
  12306.       \blx@xml@toggle{sortcase}%
  12307.       \blx@xml@toggle{sortupper}%
  12308.     }%
  12309.     \blx@xml@comment{BIBLATEX OPTIONS}%
  12310.     \blx@bcf@options@global
  12311.   }%
  12312.   \ifdef\blx@opts@type
  12313.     {\def\do##1{%
  12314.        \begingroup
  12315.        \let\protect\relax
  12316.        \blx@setoptions@type{##1}%
  12317.        % Expand the type use* name toggles
  12318.        \let\blx@xml@nametoggles\@empty
  12319.        \def\do####1{\eappto\blx@xml@nametoggles{\blx@xml@toggle{use####1}}}%
  12320.        \abx@donames
  12321.        \blx@checkoptions@type
  12322.        \xappto\blx@tempa{\blx@bcf@options@type{##1}}%
  12323.        \endgroup}%
  12324.      \dolistloop\blx@opts@type}
  12325.     {}%
  12326.   % options scope
  12327.   % GLOBAL
  12328.   \def\do##1{%
  12329.     \begingroup
  12330.     \def\do####1{\xappto\blx@bcf@options@scope@global{\blx@xml@option@scope{##1}{####1}}}%
  12331.     \dolistcsloop{blx@globalopts@##1}%
  12332.     \endgroup}%
  12333.   \dolistloop\blx@globalopts@datatypes
  12334.   % ENTRYTYPE
  12335.   \def\do##1{%
  12336.     \begingroup
  12337.     \def\do####1{\xappto\blx@bcf@options@scope@type{\blx@xml@option@scope{##1}{####1}}}%
  12338.     \dolistcsloop{blx@typeopts@##1}%
  12339.     \endgroup}%
  12340.   \dolistloop\blx@typeopts@datatypes
  12341.   % ENTRY
  12342.   \def\do##1{%
  12343.     \begingroup
  12344.     \def\do####1{\xappto\blx@bcf@options@scope@entry{\blx@xml@option@scope{##1}{####1}}}%
  12345.     \dolistcsloop{blx@entryopts@##1}%
  12346.     \endgroup}%
  12347.   \dolistloop\blx@entryopts@datatypes
  12348.   % NAMELIST
  12349.   \def\do##1{%
  12350.     \begingroup
  12351.     \def\do####1{\xappto\blx@bcf@options@scope@namelist{\blx@xml@option@scope{##1}{####1}}}%
  12352.     \dolistcsloop{blx@namelistopts@##1}%
  12353.     \endgroup}%
  12354.   \dolistloop\blx@entryopts@datatypes
  12355.   % NAME
  12356.   \def\do##1{%
  12357.     \begingroup
  12358.     \def\do####1{\xappto\blx@bcf@options@scope@name{\blx@xml@option@scope{##1}{####1}}}%
  12359.     \dolistcsloop{blx@nameopts@##1}%
  12360.     \endgroup}%
  12361.   \dolistloop\blx@entryopts@datatypes
  12362.  
  12363.   \eappto\blx@tempa{%
  12364.     \blx@xml@comment{BIBLATEX OPTION SCOPE}%
  12365.     \blx@xml@options@scope{GLOBAL}{\blx@bcf@options@scope@global}%
  12366.     \blx@xml@options@scope{ENTRYTYPE}{\blx@bcf@options@scope@type}%
  12367.     \blx@xml@options@scope{ENTRY}{\blx@bcf@options@scope@entry}%
  12368.     \blx@xml@options@scope{NAMELIST}{\blx@bcf@options@scope@namelist}%
  12369.     \blx@xml@options@scope{NAME}{\blx@bcf@options@scope@name}}
  12370.   % datafieldsets
  12371.   \def\do##1{%
  12372.     \xappto\blx@bcf@datafieldsets{\blx@xml@datafieldset{##1}{\csuse{blx@datafieldsetmembers@##1}}}}
  12373.   \dolistloop\blx@datafieldsets
  12374.  
  12375.   \eappto\blx@tempa{%
  12376.     \blx@xml@comment{DATAFIELDSETS}%
  12377.     \blx@bcf@datafieldsets}%
  12378.   % sourcemap
  12379.   \ifbool{sourcemap}
  12380.   {\eappto\blx@tempa{%
  12381.      \blx@xml@comment{SOURCEMAP}%
  12382.      \blx@xml@sourcemap{%
  12383.        \ifdef\blx@sourcemap@user
  12384.          {\blx@sourcemap@user}
  12385.         {}%
  12386.        \ifdef\blx@sourcemap@style
  12387.          {\blx@sourcemap@style}
  12388.         {}%
  12389.        \ifdef\blx@sourcemap@defaults@bibtex
  12390.          {\blx@sourcemap@defaults@bibtex}
  12391.         {}%
  12392.        \ifdef\blx@sourcemap@defaults@biblatexml
  12393.          {\blx@sourcemap@defaults@biblatexml}
  12394.         {}}}}
  12395.  {}%
  12396.   % labelalpha name template
  12397.   \eappto\blx@tempa{\blx@xml@comment{LABELALPHA NAME TEMPLATE}}%
  12398.   \def\do##1{%
  12399.     \eappto\blx@tempa{%
  12400.       \blx@xml@labelalphanametemplate{##1}{\csuse{blx@labelalphanametemplate@##1}}}}%
  12401.   \dolistloop\blx@lantemplatespecs
  12402.   % labelalpha template
  12403.   \eappto\blx@tempa{%
  12404.     \blx@xml@comment{LABELALPHA TEMPLATE}}%
  12405.   \def\do##1{%
  12406.     \eappto\blx@tempa{%
  12407.       \blx@xml@labelalphatemplate{##1}{%
  12408.       \csuse{blx@labelalphatemplate@##1}}}}%
  12409.   \dolistloop\blx@latem@type
  12410.   % extradate specification
  12411.   \eappto\blx@tempa{%
  12412.     \blx@xml@comment{EXTRADATE}%
  12413.     \blx@xml@extradate{\csuse{blx@bcf@extradatespec}}}%
  12414.   % data inheritance
  12415.   \eappto\blx@tempa{%
  12416.     \blx@xml@comment{INHERITANCE}%
  12417.     \blx@xml@inheritance{%
  12418.       \csuse{blx@inherit@default}%
  12419.       \csuse{blx@inherit@data}}}%
  12420.   % noinit
  12421.   \ifcsdef{blx@noinit}
  12422.     {\eappto\blx@tempa{%
  12423.       \blx@xml@comment{NOINIT}%
  12424.       \blx@xml@noinits{%
  12425.         \csuse{blx@noinit}}}}%
  12426.     {}%
  12427.   % nolabel
  12428.   \ifcsdef{blx@nolabel}
  12429.     {\eappto\blx@tempa{%
  12430.       \blx@xml@comment{NOLABEL}%
  12431.       \blx@xml@nolabels{%
  12432.         \csuse{blx@nolabel}}}}%
  12433.     {}%
  12434.   % nolabel
  12435.   \ifcsdef{blx@nolabelwidthcount}
  12436.     {\eappto\blx@tempa{%
  12437.       \blx@xml@comment{NOLABELWIDTHCOUNT}%
  12438.       \blx@xml@nolabelwidthcounts{%
  12439.         \csuse{blx@nolabelwidthcount}}}}%
  12440.     {}%
  12441.   % nosort
  12442.   \ifcsdef{blx@nosort}
  12443.     {\eappto\blx@tempa{%
  12444.       \blx@xml@comment{NOSORT}%
  12445.       \blx@xml@nosorts{%
  12446.         \csuse{blx@nosort}}}}%
  12447.     {}%
  12448.   % transliteration
  12449.   \ifdefempty\blx@translits
  12450.     {}
  12451.    {\eappto\blx@tempa{\blx@xml@comment{TRANSLITERATION}}%
  12452.      \def\do##1{%
  12453.        \eappto\blx@tempa{\blx@xml@transliteration{##1}{\csuse{blx@translit@##1}}}}%
  12454.      \dolistloop\blx@translits}%
  12455.   % uniquenametemplate
  12456.   \eappto\blx@tempa{\blx@xml@comment{UNIQUENAME TEMPLATES}}%
  12457.   \def\do##1{%
  12458.     \eappto\blx@tempa{%
  12459.       \blx@xml@uniquenametemplate{##1}{\csuse{blx@uniquenametemplate@##1}}}}%
  12460.   \dolistloop\blx@untemplatespecs
  12461.   % sortingnamekeytemplate
  12462.   \eappto\blx@tempa{\blx@xml@comment{SORTING NAME KEY TEMPLATES}}%
  12463.   \def\do##1{%
  12464.     \eappto\blx@tempa{%
  12465.       \blx@xml@sortingnamekeytemplate{##1}{\csuse{blx@sortingnamekeytemplate@##1}}}}%
  12466.   \dolistloop\blx@sortingnamekeytemplates
  12467.   % presort/sorting excludes/sorting includes
  12468.   \def\do##1{%
  12469.     \eappto\blx@bcf@presort{\csuse{blx@bcf@presort@##1}}%
  12470.     \eappto\blx@bcf@exclude{\csuse{blx@bcf@exclude@##1}}%
  12471.     \eappto\blx@bcf@include{\csuse{blx@bcf@include@##1}}}%
  12472.   \abx@doentrytypes
  12473.   \do{*}% entrytype wildcard
  12474.   \eappto\blx@tempa{%
  12475.     \blx@bcf@presort
  12476.     \blx@bcf@exclude
  12477.     \blx@bcf@include}%
  12478.   % datamodel
  12479.   \eappto\blx@tempa{%
  12480.     \blx@xml@comment{DATA MODEL}%
  12481.     \blx@xml@datamodel{%
  12482.       \blx@xml@datamodel@constants{%
  12483.         \blx@bcf@datamodel@constants
  12484.       }%
  12485.       \blx@xml@datamodel@entrytypes{%
  12486.         \blx@bcf@datamodel@entrytypes
  12487.       }%
  12488.       \blx@xml@datamodel@fields{%
  12489.         \blx@bcf@datamodel@fields
  12490.       }%
  12491.       \blx@bcf@datamodel@entryfields
  12492.       \blx@bcf@datamodel@constraints
  12493.     }%
  12494.   }%
  12495.   % files
  12496.   \let\blx@tempb\@empty
  12497.   \blx@bibdata\blx@tempb\blx@bibfiles
  12498.   \eappto\blx@tempa{%
  12499.     \blx@xml@comment{CITATION DATA}%
  12500.     \blx@xml@comment{SECTION 0}%
  12501.     \blx@xml@bibdata{0}{\blx@tempb}%
  12502.     \blx@xml@section{0}%
  12503.   }%
  12504.   \immediate\openout\blx@bcfout\jobname.bcf\relax
  12505.   \blx@auxwrite\blx@bcfout{}{\blx@tempa}%
  12506.   \global\undef\blx@tempa
  12507.   \endgroup
  12508.   \AfterEndDocument{%
  12509.     \def\do##1{%
  12510.       \csxappto{blx@sortingtemplates}{%
  12511.         \blx@xml@sortingtemplate{##1}
  12512.                        {\ifcsdef{blx@sortdef@locale@##1}{ locale="\csuse{blx@sortdef@locale@##1}"}{}}
  12513.                        {\csuse{blx@sortingtemplate@##1}}}}%
  12514.       \dolistloop\blx@sortingtemplatenames
  12515.     \blx@auxwrite\blx@bcfout{}{%
  12516.       \blx@xml@endsection\blx@nl
  12517.       \blx@xml@comment{SORTING TEMPLATES}%
  12518.       \csuse{blx@sortingtemplates}%
  12519.       \blx@xml@comment{DATALISTS}%
  12520.       \csuse{blx@dlists}%
  12521.       \blx@xml@endfile}%
  12522.     \immediate\closeout\blx@bcfout}}
  12523.  
  12524. %% Customisation
  12525.  
  12526. % nolabel
  12527. \newrobustcmd*{\DeclareNolabel}[1]{%
  12528.   \begingroup
  12529.   \let\nolabel\blx@nolabel@setup
  12530.   \let\blx@tempa\@empty
  12531.   #1%
  12532.   \global\let\blx@nolabel\blx@tempa
  12533.   \endgroup}
  12534. \@onlypreamble\DeclareNolabel
  12535.  
  12536. \newcommand*{\blx@nolabel@setup}[1]{%
  12537.   \eappto\blx@tempa{%
  12538.     \blx@xml@nolabel{#1}}}
  12539.  
  12540. % nolabelwidthcount
  12541. \newrobustcmd*{\DeclareNolabelwidthcount}[1]{%
  12542.   \begingroup
  12543.   \let\nolabel\blx@nolabelwidthcount@setup
  12544.   \let\blx@tempa\@empty
  12545.   #1%
  12546.   \global\let\blx@nolabelwidthcount\blx@tempa
  12547.   \endgroup}
  12548. \@onlypreamble\DeclareNolabelwidthcount
  12549.  
  12550. \newcommand*{\blx@nolabelwidthcount@setup}[1]{%
  12551.   \eappto\blx@tempa{%
  12552.     \blx@xml@nolabelwidthcount{#1}}}
  12553.  
  12554. % nosort
  12555. \newrobustcmd*{\DeclareNosort}[1]{%
  12556.   \begingroup
  12557.   \let\nosort\blx@nosort@setup
  12558.   \let\blx@tempa\@empty
  12559.   #1%
  12560.   \global\let\blx@nosort\blx@tempa
  12561.   \endgroup}
  12562. \@onlypreamble\DeclareNosort
  12563.  
  12564. \newcommand*{\blx@nosort@setup}[2]{%
  12565.   \eappto\blx@tempa{%
  12566.     \blx@xml@nosort{#1}{#2}}}
  12567.  
  12568. % noinit
  12569. \newrobustcmd*{\DeclareNoinit}[1]{%
  12570.   \begingroup
  12571.   \let\noinit\blx@noinit@setup
  12572.   \let\blx@tempa\@empty
  12573.   #1%
  12574.   \global\let\blx@noinit\blx@tempa
  12575.   \endgroup}
  12576. \@onlypreamble\DeclareNoinit
  12577.  
  12578. \newcommand*{\blx@noinit@setup}[1]{%
  12579.   \eappto\blx@tempa{%
  12580.     \blx@xml@noinit{#1}}}
  12581.  
  12582. % datafieldsets
  12583. \newrobustcmd*{\DeclareDatafieldSet}[2]{%
  12584.   \begingroup
  12585.   \let\member\blx@datafieldset@member
  12586.   \let\blx@tempa\@empty
  12587.   \def\blx@setname{#1}
  12588.  \cslet{blx@datafieldset@#1}\@empty
  12589.   #2%
  12590.   \csxdef{blx@datafieldsetmembers@#1}{\blx@tempa}%
  12591.   \listgadd\blx@datafieldsets{#1}%
  12592.   \global\csletcs{datafieldset#1}{blx@datafieldset@#1}% expose user-facing macro
  12593.   \endgroup}
  12594. \@onlypreamble\DeclareDatafieldSet
  12595.  
  12596. \newcommand*{\blx@datafieldset@member}[1][2]{%
  12597.   \let\blx@dm@fieldtype\@empty
  12598.   \let\blx@dm@datatype\@empty
  12599.   \let\blx@member@field\@empty
  12600.   \let\blx@tempb\@empty
  12601.   \setkeys{blx@datafieldsets@member}{#1}%
  12602.   \eappto\blx@tempa{%
  12603.     \blx@xml@datafieldsets@member{\blx@tempb}}%
  12604.   \ifdefempty\blx@member@field
  12605.     {}
  12606.    {\listcsxadd{blx@datafieldset@\blx@setname}{\blx@member@field}}%
  12607.   % Set some internal macros in case biblatex needs to use the set
  12608.   \ifboolexpr{%
  12609.     not test {\ifdefempty{\blx@dm@fieldtype}}
  12610.    and
  12611.    not test {\ifdefempty{\blx@dm@datatype}}}
  12612.       {\def\do##1{%
  12613.          \listcsxadd{blx@datafieldset@\blx@setname}{##1}}
  12614.       \dolistcsloop{blx@datamodelfields@types@\blx@dm@fieldtype @\blx@dm@datatype}}
  12615.      {\ifdefempty{\blx@dm@fieldtype}
  12616.         {}
  12617.          {\def\do##1{%
  12618.            \listcsxadd{blx@datafieldset@\blx@setname}{##1}}
  12619.          \dolistcsloop{blx@datamodelfields@fieldtypes@\blx@dm@fieldtype}}%
  12620.        \ifdefempty{\blx@dm@datatype}
  12621.         {}
  12622.          {\def\do##1{%
  12623.            \listcsxadd{blx@datafieldset@\blx@setname}{##1}}
  12624.          \dolistcsloop{blx@datamodelfields@datatypes@\blx@dm@datatype}}}}
  12625.  
  12626. \define@key{blx@datafieldsets@member}{datatype}{% characters
  12627.   \appto\blx@tempb{ datatype="#1"}%
  12628.   \def\blx@dm@datatype{#1}}
  12629. \define@key{blx@datafieldsets@member}{fieldtype}{% characters
  12630.   \appto\blx@tempb{ fieldtype="#1"}%
  12631.   \def\blx@dm@fieldtype{#1}}
  12632. \define@key{blx@datafieldsets@member}{field}{% characters
  12633.   \appto\blx@tempb{ field="#1"}%
  12634.   \def\blx@member@field{#1}}
  12635.  
  12636. % sourcemap
  12637. \newrobustcmd*{\DeclareSourcemap}[1]{%
  12638.   \booltrue{sourcemap}%
  12639.   \begingroup
  12640.   \let\maps\blx@usersourcemap@maps
  12641.   \let\blx@tempa\@empty
  12642.   #1%
  12643.   \xappto\blx@sourcemap@user\blx@tempa%
  12644.   \endgroup}
  12645. \@onlypreamble\DeclareSourcemap
  12646.  
  12647. \newrobustcmd*{\DeclareStyleSourcemap}[1]{%
  12648.   \booltrue{sourcemap}%
  12649.   \begingroup
  12650.   \let\maps\blx@stylesourcemap@maps
  12651.   \let\blx@tempa\@empty
  12652.   #1%
  12653.   \xappto\blx@sourcemap@style\blx@tempa%
  12654.   \endgroup}
  12655.  
  12656. \@onlypreamble\DeclareStyleSourcemap
  12657.  
  12658. \newrobustcmd*{\DeclareDriverSourcemap}[2][]{%
  12659.   \booltrue{sourcemap}%
  12660.   \begingroup
  12661.   \let\blx@tempa\@empty
  12662.   \let\blx@tempb\@empty
  12663.   \let\blx@tempc\@empty
  12664.   \let\blx@tempd\@empty
  12665.   \let\map\blx@sourcemap@map
  12666.   #2%
  12667.   \ifblank{#1}
  12668.    {\setkeys{blx@sourcemap@maps}{datatype=bibtex, level=driver}}
  12669.    {\setkeys{blx@sourcemap@maps}{#1, level=driver}}%
  12670.   \eappto\blx@tempa{%
  12671.     \blx@xml@sourcemap@maps{\blx@tempb}{\blx@tempc}}%
  12672.   \csxdef{blx@sourcemap@defaults@\blx@tempd}{\blx@tempa}%
  12673.   \endgroup}
  12674. \@onlypreamble\DeclareDriverSourcemap
  12675.  
  12676. \newcommand*{\blx@usersourcemap@maps}[2][]{%
  12677.   \let\blx@tempb\@empty
  12678.   \let\blx@tempc\@empty
  12679.   \let\map\blx@sourcemap@map
  12680.   \ifblank{#1}
  12681.    {\setkeys{blx@sourcemap@maps}{datatype=bibtex, level=user}}
  12682.    {\setkeys{blx@sourcemap@maps}{#1, level=user}}%
  12683.   #2%
  12684.   \eappto\blx@tempa{%
  12685.     \blx@xml@sourcemap@maps{\blx@tempb}{\blx@tempc}}}
  12686.  
  12687. \newcommand*{\blx@stylesourcemap@maps}[2][]{%
  12688.   \let\blx@tempb\@empty
  12689.   \let\blx@tempc\@empty
  12690.   \let\map\blx@sourcemap@map
  12691.   \ifblank{#1}
  12692.    {\setkeys{blx@sourcemap@maps}{datatype=bibtex, level=style}}
  12693.    {\setkeys{blx@sourcemap@maps}{#1, level=style}}%
  12694.   #2%
  12695.   \eappto\blx@tempa{%
  12696.     \blx@xml@sourcemap@maps{\blx@tempb}{\blx@tempc}}}
  12697.  
  12698. \define@key{blx@sourcemap@maps}{datatype}{% characters
  12699.   \eappto\blx@tempb{ datatype="#1"}%
  12700.   \eappto\blx@tempd{#1}}
  12701. \define@key{blx@sourcemap@maps}{overwrite}[true]{% true|false
  12702.   \ifstrequal{#1}{true}
  12703.    {\appto\blx@tempb{ map\string_overwrite="1"}}
  12704.    {}}
  12705. \define@key{blx@sourcemap@maps}{level}{% user|style|driver
  12706.     \appto\blx@tempb{ level="#1"}}
  12707.  
  12708. \newcommand*{\blx@sourcemap@map}[2][]{%
  12709.   \let\blx@tempm\@empty
  12710.   \let\blx@tempe\@empty
  12711.   \let\perdatasource\blx@sourcemap@perdatasource
  12712.   \let\pertype\blx@sourcemap@pertype
  12713.   \let\pernottype\blx@sourcemap@pernottype
  12714.   \let\step\blx@sourcemap@step
  12715.   \ifblank{#1}
  12716.    {}
  12717.    {\setkeys{blx@sourcemap@map}{#1}}%
  12718.   #2%
  12719.   \eappto\blx@tempc{%
  12720.     \blx@xml@sourcemap@map{\blx@tempm}{\blx@tempe}}}
  12721.  
  12722. \define@key{blx@sourcemap@map}{overwrite}[true]{% true|false
  12723.   \ifstrequal{#1}{true}
  12724.    {\appto\blx@tempm{ map\string_overwrite="1"}}
  12725.    {}}
  12726. \define@key{blx@sourcemap@map}{foreach}{% characters
  12727.   \eappto\blx@tempm{ map\string_foreach="#1"}}
  12728. \define@key{blx@sourcemap@map}{refsection}{% integer
  12729.   \eappto\blx@tempm{ refsection="#1"}}
  12730.  
  12731. \newcommand*{\blx@sourcemap@perdatasource}[1]{%
  12732.   \eappto\blx@tempe{%
  12733.     \blx@xml@sourcemap@perdatasource{#1}}}
  12734.  
  12735. \newcommand*{\blx@sourcemap@pertype}[1]{%
  12736.   \eappto\blx@tempe{%
  12737.     \blx@xml@sourcemap@pertype{#1}}}
  12738.  
  12739. \newcommand*{\blx@sourcemap@pernottype}[1]{%
  12740.   \eappto\blx@tempe{%
  12741.     \blx@xml@sourcemap@pernottype{#1}}}
  12742.  
  12743. \newcommand*{\blx@sourcemap@step}[1][2]{%
  12744.   \let\blx@tempf\@empty
  12745.   \setkeys{blx@sourcemap@step}{#1}%
  12746.   \eappto\blx@tempe{%
  12747.     \blx@xml@sourcemap@step{\blx@tempf}}}
  12748.  
  12749. \define@key{blx@sourcemap@step}{typesource}{% characters
  12750.   \eappto\blx@tempf{ map\string_type\string_source="#1"}}
  12751. \define@key{blx@sourcemap@step}{typetarget}{% characters
  12752.   \eappto\blx@tempf{ map\string_type\string_target="#1"}}
  12753. \define@key{blx@sourcemap@step}{final}[true]{% true|false
  12754.   \ifstrequal{#1}{true}
  12755.    {\appto\blx@tempf{ map\string_final="1"}}
  12756.    {}}
  12757. \define@key{blx@sourcemap@step}{fieldsource}{% characters
  12758.   \eappto\blx@tempf{ map\string_field\string_source="#1"}}
  12759. \define@key{blx@sourcemap@step}{notfield}{% characters
  12760.   \eappto\blx@tempf{ map\string_notfield="#1"}}
  12761. \define@key{blx@sourcemap@step}{fieldtarget}{% characters
  12762.   \eappto\blx@tempf{ map\string_field\string_target="#1"}}
  12763. \define@key{blx@sourcemap@step}{fieldset}{% characters
  12764.   \eappto\blx@tempf{ map\string_field\string_set="#1"}}
  12765. % We are sanitising the XML here as it's the value of an attribute which
  12766. % might contain quotes or ampersands (URLs, for example)
  12767. \define@key{blx@sourcemap@step}{fieldvalue}{% characters
  12768.   \blx@xmlsanitizeafter{\def\blx@temps}{#1}%
  12769.   \eappto\blx@tempf{ map\string_field\string_value="\blx@temps"}}
  12770. \define@key{blx@sourcemap@step}{append}[true]{% true|false
  12771.   \ifstrequal{#1}{true}
  12772.    {\appto\blx@tempf{ map\string_append="1"}}
  12773.    {}}
  12774. \define@key{blx@sourcemap@step}{null}[true]{% true|false
  12775.   \ifstrequal{#1}{true}
  12776.    {\appto\blx@tempf{ map\string_null="1"}}
  12777.    {}}
  12778. \define@key{blx@sourcemap@step}{entrynull}[true]{% true|false
  12779.   \ifstrequal{#1}{true}
  12780.    {\appto\blx@tempf{ map\string_entry\string_null="1"}}
  12781.    {}}
  12782. \define@key{blx@sourcemap@step}{entrynocite}[true]{% true|false
  12783.   \ifstrequal{#1}{true}
  12784.    {\appto\blx@tempf{ map\string_entry\string_nocite="1"}}
  12785.    {}}
  12786. \define@key{blx@sourcemap@step}{entrynew}{% characters
  12787.   \appto\blx@tempf{ map\string_entry\string_new="#1"}}
  12788. \define@key{blx@sourcemap@step}{entrynewtype}{% characters
  12789.   \appto\blx@tempf{ map\string_entry\string_newtype="#1"}}
  12790. \define@key{blx@sourcemap@step}{entrytarget}{% characters
  12791.   \appto\blx@tempf{ map\string_entrytarget="#1"}}
  12792. \define@key{blx@sourcemap@step}{entryclone}{% characters
  12793.   \appto\blx@tempf{ map\string_entry\string_clone="#1"}}
  12794. \define@key{blx@sourcemap@step}{origfield}[true]{% true|false
  12795.   \ifstrequal{#1}{true}
  12796.    {\appto\blx@tempf{ map\string_origfield="1"}}
  12797.    {}}
  12798. \define@key{blx@sourcemap@step}{origfieldval}[true]{% true|false
  12799.   \ifstrequal{#1}{true}
  12800.    {\appto\blx@tempf{ map\string_origfieldval="1"}}
  12801.    {}}
  12802. \define@key{blx@sourcemap@step}{origentrytype}[true]{% true|false
  12803.   \ifstrequal{#1}{true}
  12804.    {\appto\blx@tempf{ map\string_origentrytype="1"}}
  12805.    {}}
  12806. \define@key{blx@sourcemap@step}{match}{% characters
  12807.   \appto\blx@tempf{ map\string_match="#1"}}
  12808. \define@key{blx@sourcemap@step}{matchi}{% characters
  12809.   \appto\blx@tempf{ map\string_matchi="#1"}}
  12810. \define@key{blx@sourcemap@step}{notmatch}{% characters
  12811.   \appto\blx@tempf{ map\string_notmatch="#1"}}
  12812. \define@key{blx@sourcemap@step}{notmatchi}{% characters
  12813.   \appto\blx@tempf{ map\string_notmatchi="#1"}}
  12814. \define@key{blx@sourcemap@step}{replace}{% characters
  12815.   \eappto\blx@tempf{ map\string_replace="#1"}}
  12816.  
  12817. % [<specname>]{<spec>}
  12818. \newrobustcmd*{\DeclareLabelalphaNameTemplate}[2][]{%
  12819.   \begingroup
  12820.   \ifblank{#1}
  12821.    {\def\blx@lantname{global}}% default
  12822.     {\def\blx@lantname{#1}}%
  12823.   \let\namepart\blx@lantem@namepart
  12824.   \let\blx@tempa\@empty
  12825.   \blx@tempcnta\z@
  12826.   #2%
  12827.   \global\cslet{blx@labelalphanametemplate@\blx@lantname}\blx@tempa
  12828.  \xifinlist\blx@lantname\blx@lantemplatespecs
  12829.    {}
  12830.    {\listxadd\blx@lantemplatespecs\blx@lantname}%
  12831.   \endgroup}
  12832. \@onlypreamble\DeclareLabelalphaNameTemplate
  12833. \blx@collectopts{xml}{blx@globalopts}{labelalphanametemplate}% for passing to the .bcf
  12834. \DeclareEntryOption[string]{labelalphanametemplatename}{%
  12835.   \def\blx@refcontext@labelalphanametemplatename{#1}}
  12836.  
  12837. \newcommand*{\blx@lantem@namepart}[2][]{%
  12838.   \advance\blx@tempcntb\@ne
  12839.   \edef\blx@tempe{order="\the\blx@tempcntb"}%
  12840.   \let\blx@tempc\@empty
  12841.   \ifblank{#1}
  12842.    {}
  12843.    {\setkeys{blx@lantem@namepart}{#1}}%
  12844.   \eappto\blx@tempa{%
  12845.     \blx@xml@labelalphanametemplatenamepart{\blx@tempe}{\blx@tempc}{#2}}}
  12846.  
  12847. \define@key{blx@lantem@namepart}{use}[true]{% use* option for namepart true|false
  12848.   \ifstrequal{#1}{true}
  12849.    {\appto\blx@tempc{ use="1"}}
  12850.    {}}
  12851.  
  12852. \define@key{blx@lantem@namepart}{pre}[true]{% pre option for namepart true|false
  12853.   \ifstrequal{#1}{true}
  12854.    {\appto\blx@tempc{ pre="1"}}
  12855.    {}}
  12856.  
  12857. \define@key{blx@lantem@namepart}{compound}[true]{% base option for namepart true|false
  12858.   \ifstrequal{#1}{true}
  12859.    {\appto\blx@tempc{ substring\string_compound="1"}}
  12860.    {}}
  12861.  
  12862. \define@key{blx@lantem@namepart}{strwidth}{% integer
  12863.   \eappto\blx@tempc{ substring\string_width="#1"}}
  12864.  
  12865. \define@key{blx@lantem@field}{strside}{% left|right
  12866.   \ifstrequal{#1}{right}
  12867.    {\eappto\blx@tempc{ substring\string_side="right"}}
  12868.    {\eappto\blx@tempc{ substring\string_side="left"}}}
  12869.  
  12870. % [<entrytype>]{<spec>}
  12871. \newrobustcmd*{\DeclareLabelalphaTemplate}[2][]{%
  12872.    \ifblank{#1}
  12873.     {\blx@latem{#2}{global}}
  12874.     {\forcsvlist{\blx@latem{#2}}{#1}}}
  12875. \@onlypreamble\DeclareLabelalphaTemplate
  12876. \blx@collectopts{xml}{blx@globalopts}{labelalphatemplate}% for passing to the .bcf
  12877. \blx@collectopts{xml}{blx@typeopts}{labelalphatemplate}% for passing to the .bcf
  12878.  
  12879. \def\blx@latem#1#2{%
  12880.   \begingroup
  12881.   \let\labelelement\blx@latem@element
  12882.   \let\field\blx@latem@field
  12883.   \let\literal\blx@latem@literal
  12884.   \blx@tempcnta\z@
  12885.   \let\blx@tempa\@empty
  12886.   #1%
  12887.   \ifdef\blx@latem@type
  12888.     {\ifinlist{#2}\blx@latem@type
  12889.      {\global\cslet{blx@labelalphatemplate@#2}\blx@tempa}
  12890.      {\listgadd\blx@latem@type{#2}%
  12891.        \global\cslet{blx@labelalphatemplate@#2}\blx@tempa}}
  12892.    {\listgadd\blx@latem@type{#2}%
  12893.      \global\cslet{blx@labelalphatemplate@#2}\blx@tempa}%
  12894.   \endgroup}
  12895.  
  12896. \newcommand*{\blx@latem@element}[1]{%
  12897.   \advance\blx@tempcnta\@ne
  12898.   \let\blx@tempb\@empty
  12899.   #1%
  12900.   \eappto\blx@tempa{%
  12901.     \blx@xml@labelalpha@element{\the\blx@tempcnta}{\blx@tempb}}}
  12902.  
  12903. \newcommand*{\blx@latem@literal}[1]{%
  12904.   \blx@xmlsanitizeafter{\def\blx@temps}{#1}%
  12905.   \eappto\blx@tempb{%
  12906.     \blx@xml@labelalpha@part{}{\expandafter\regexp\expandafter{\blx@temps}}}}
  12907.  
  12908. \newcommand*{\blx@latem@field}[2][]{%
  12909.   \let\blx@tempc\@empty
  12910.   \ifblank{#1}
  12911.    {}
  12912.    {\setkeys{blx@latem@field}{#1}}%
  12913.   \eappto\blx@tempb{%
  12914.     \blx@xml@labelalpha@part{\blx@tempc}{#2}}}
  12915.  
  12916. \define@key{blx@latem@field}{uppercase}[true]{% true|false
  12917.   \ifstrequal{#1}{true}
  12918.    {\appto\blx@tempc{ uppercase="1"}}
  12919.    {}}
  12920. \define@key{blx@latem@field}{lowercase}[true]{% true|false
  12921.   \ifstrequal{#1}{true}
  12922.    {\appto\blx@tempc{ lowercase="1"}}
  12923.    {}}
  12924. \define@key{blx@latem@field}{final}[true]{% true|false
  12925.   \ifstrequal{#1}{true}
  12926.    {\appto\blx@tempc{ final="1"}}
  12927.    {}}
  12928. \define@key{blx@latem@field}{strwidth}{% integer
  12929.     \eappto\blx@tempc{ substring\string_width="#1"}}
  12930. \define@key{blx@latem@field}{varwidth}[true]{% "v"
  12931.   \ifstrequal{#1}{true}
  12932.    {\appto\blx@tempc{ substring\string_width="v"}}
  12933.    {}}
  12934. \define@key{blx@latem@field}{varwidthnorm}[true]{% "vf"
  12935.   \ifstrequal{#1}{true}
  12936.    {\appto\blx@tempc{ substring\string_width="vf"}}
  12937.    {}}
  12938. \define@key{blx@latem@field}{varwidthlist}[true]{% "l"
  12939.   \ifstrequal{#1}{true}
  12940.    {\appto\blx@tempc{ substring\string_width="l"}}
  12941.    {}}
  12942. \define@key{blx@latem@field}{strfixedcount}{%
  12943.     \eappto\blx@tempc{ substring\string_fixed\string_threshold="#1"}}
  12944. \define@key{blx@latem@field}{strwidthmax}{%
  12945.     \eappto\blx@tempc{ substring\string_width\string_max="#1"}}
  12946. \define@key{blx@latem@field}{strside}{% left|right
  12947.   \ifstrequal{#1}{right}
  12948.    {\eappto\blx@tempc{ substring\string_side="right"}}
  12949.    {\eappto\blx@tempc{ substring\string_side="left"}}}
  12950. \define@key{blx@latem@field}{namessep}{%
  12951.     \eappto\blx@tempc{ namessep="#1"}}
  12952. \define@key{blx@latem@field}{ifnames}{%
  12953.     \eappto\blx@tempc{ ifnames="#1"}}
  12954. \define@key{blx@latem@field}{names}{%
  12955.     \eappto\blx@tempc{ names="#1"}}
  12956. \define@key{blx@latem@field}{noalphaothers}[true]{%
  12957.     \eappto\blx@tempc{ noalphaothers="1"}}
  12958. \define@key{blx@latem@field}{padchar}{%
  12959.   \blx@xmlsanitizeafter{\def\blx@temps}{#1}%
  12960.   \eappto\blx@tempc{ pad\string_char="\expandafter\regexp\expandafter{\blx@temps}"}}
  12961. \define@key{blx@latem@field}{padside}{% left|right
  12962.   \ifstrequal{#1}{left}
  12963.    {\eappto\blx@tempc{ pad\string_side="left"}}
  12964.    {\eappto\blx@tempc{ pad\string_side="right"}}}
  12965.  
  12966. % [<exceptions>]{<options>}
  12967. \newrobustcmd*{\DefaultInheritance}[2][]{%
  12968.   \begingroup
  12969.   \let\blx@tempf\@empty
  12970.   \ifblank{#2}
  12971.    {}
  12972.    {\setkeys{blx@inherit@default}{#2}}%
  12973.   \edef\blx@tempa{\space
  12974.    inherit\string_all="\iftoggle{blx@inherit@all}{true}{false}"\space
  12975.    override\string_target="\iftoggle{blx@inherit@override}{true}{false}"%
  12976.     \blx@tempf}%
  12977.   \let\blx@tempb\@empty
  12978.   \let\except\blx@inherit@except
  12979.   #1%
  12980.   \xdef\blx@inherit@default{%
  12981.     \blx@xml@inherit@defaults{\blx@tempa}{\blx@tempb}}%
  12982.   \endgroup}
  12983. \@onlypreamble\DefaultInheritance
  12984.  
  12985. \newtoggle{blx@inherit@all}
  12986. \newtoggle{blx@inherit@override}
  12987.  
  12988. \define@key{blx@inherit@default}{all}[true]{% true|false
  12989.   \settoggle{blx@inherit@all}{#1}}
  12990. \define@key{blx@inherit@default}{override}[true]{% true|false
  12991.   \settoggle{blx@inherit@override}{#1}}
  12992. \define@key{blx@inherit@default}{ignore}{% csv list
  12993.   \edef\blx@tempf{ ignore="#1"}}
  12994.  
  12995. % {<source>}{<target>}{<options>}
  12996. \newcommand*{\blx@inherit@except}[3]{%
  12997.   \let\blx@tempc\@empty
  12998.   \ifblank{#3}
  12999.    {}
  13000.    {\setkeys{blx@inherit@except}{#3}}%
  13001.   \eappto\blx@tempb{%
  13002.     \blx@xml@inherit@type{#1}{#2}{\blx@tempc}}}
  13003.  
  13004. \define@key{blx@inherit@except}{all}[true]{% true|false
  13005.   \eappto\blx@tempc{ inherit\string_all="#1"}}
  13006. \define@key{blx@inherit@except}{override}[true]{% true|false
  13007.   \eappto\blx@tempc{ override\string_target="#1"}}
  13008. \define@key{blx@inherit@except}{ignore}{% csv list
  13009.   \eappto\blx@tempc{ ignore="#1"}}
  13010.  
  13011. % {<type,type,...>}{<type,type,...>}{<spec>}
  13012. \newrobustcmd*{\DeclareDataInheritance}[4][]{%
  13013.   \begingroup
  13014.   \let\blx@tempa\@empty
  13015.   \let\blx@tempf\@empty
  13016.   \ifblank{#1}
  13017.    {}
  13018.    {\setkeys{blx@inherit}{#1}}%
  13019.   \forcsvlist{\blx@inherit@i{#3}}{#2}%
  13020.   \let\blx@tempb\@empty
  13021.   \let\inherit\blx@inherit@field
  13022.   \let\noinherit\blx@inherit@block
  13023.   #4%
  13024.   \xappto\blx@inherit@data{%
  13025.     \blx@xml@inherit@data{\blx@tempf}{%
  13026.       \blx@tempa
  13027.       \blx@tempb}}%
  13028.   \endgroup}
  13029. \@onlypreamble\DeclareDataInheritance
  13030.  
  13031. \def\blx@inherit@i#1#2{%
  13032.   \forcsvlist{\blx@inherit@ii{#2}}{#1}}
  13033.  
  13034. \def\blx@inherit@ii#1#2{%
  13035.   \eappto\blx@tempa{\blx@xml@inherit@type{#1}{#2}{}}}
  13036.  
  13037. \blx@collectopts{xml}{blx@globalopts}{inheritance}% for passing to the .bcf
  13038.  
  13039. % [<options>]{<source>}{<target>}
  13040. \newcommand*{\blx@inherit@field}[3][]{%
  13041.   \let\blx@tempc\@empty
  13042.   \ifblank{#1}
  13043.    {}
  13044.    {\setkeys{blx@inherit@field}{#1}}%
  13045.   \eappto\blx@tempb{%
  13046.     \blx@xml@inherit@field{#2}{#3}{\blx@tempc}}}
  13047.  
  13048. \newcommand*{\blx@inherit@block}[1]{%
  13049.   \eappto\blx@tempb{\blx@xml@inherit@block{#1}}}
  13050.  
  13051. \define@key{blx@inherit}{ignore}{% csv list
  13052.   \edef\blx@tempf{ ignore="#1"}}
  13053.  
  13054. \define@key{blx@inherit@field}{override}[true]{% true|false
  13055.   \ifstrequal{#1}{true}
  13056.    {\edef\blx@tempc{ override\string_target="true"}}
  13057.    {\edef\blx@tempc{ override\string_target="false"}}}
  13058.  
  13059. \newrobustcmd*{\ResetDataInheritance}{%
  13060.   \global\csundef{blx@inherit@data}}
  13061. \@onlypreamble\ResetDataInheritance
  13062.  
  13063. % {<name>}{<spec>}
  13064. \newrobustcmd*{\DeclareBiblistFilter}[2]{%
  13065.   \begingroup
  13066.   \let\filteror\blx@biblistfilteror
  13067.   \let\filter\blx@biblistfilter
  13068.   \let\blx@tempa\@empty
  13069.   #2%
  13070.   \global\cslet{blx@biblistfilters@#1}\blx@tempa
  13071.  \endgroup}
  13072. \@onlypreamble\DeclareBiblistFilter
  13073.  
  13074. \newcommand*{\blx@biblistfilteror}[1]{%
  13075.   \eappto\blx@tempa{\blx@xml@dlistfilterorbegin}%
  13076.   #1%
  13077.   \eappto\blx@tempa{\blx@xml@dlistfilterorend}}
  13078.  
  13079. \newcommand*{\blx@biblistfilter}[1][2]{%
  13080.   \let\blx@tempc\@empty
  13081.   \let\blx@tempd\@empty
  13082.   \setkeys{blx@biblistfilter@filter}{#1}%
  13083.   \eappto\blx@tempa{%
  13084.     \blx@xml@dlistfilter{\blx@tempc}{\blx@tempd}}}
  13085.  
  13086. \define@key{blx@biblistfilter@filter}{type}{%
  13087.   \def\blx@tempc{#1}}
  13088. \define@key{blx@biblistfilter@filter}{filter}{%
  13089.   \def\blx@tempd{#1}}
  13090.  
  13091. % Predefine filters for label fields
  13092. \def\do#1{\DeclareBiblistFilter{#1}{\filter[type=field,filter=#1]}}
  13093. \abx@dolabelfields
  13094.  
  13095. \define@key{blx@biblist2}{biblistfilter}{\blx@key@biblistfilter{#1}}
  13096. \define@key{blx@biblist1}{biblistfilter}{}
  13097.  
  13098. \def\blx@key@biblistfilter#1{%
  13099.   \ifcsundef{blx@biblistfilters@#1}
  13100.    {\blx@error
  13101.        {BiblistFilter '#1' not found}
  13102.        {The BiblistFilter '#1' could not be found.\MessageBreak
  13103.         Use '\string\DeclareBiblistFilter' to define it}}
  13104.    {\def\blx@thebiblistfilter{#1}}}
  13105.  
  13106. % [<langids>][<entrytype>]{translitsource}{translittarget}
  13107. \newrobustcmd*{\DeclareSortTranslit}[2][]{%
  13108.   \begingroup
  13109.   \ifblank{#1}
  13110.    {\def\blx@tempa{*}}
  13111.    {\def\blx@tempa{#1}}%
  13112.   \let\translit\blx@translit@setup
  13113.   \let\blx@tempb\@empty
  13114.   #2%
  13115.   \global\cslet{blx@translit@\blx@tempa}\blx@tempb
  13116.  \xifinlist\blx@tempa\blx@translits
  13117.    {}
  13118.    {\listxadd\blx@translits\blx@tempa}%
  13119.   \endgroup}
  13120. \@onlypreamble\DeclareSortTranslit
  13121. \blx@collectopts{xml}{blx@globalopts}{translit}% for passing to the .bcf
  13122. \blx@collectopts{xml}{blx@typeopts}{translit}% for passing to the .bcf
  13123.  
  13124. \newcommand*{\blx@translit@setup}[4][]{%
  13125.   \eappto\blx@tempb{%
  13126.     \ifblank{#1}
  13127.     {\blx@xml@translit{}{#2}{#3}{#4}}
  13128.     {\blx@xml@translit{langids="#1" }{#2}{#3}{#4}}}}
  13129.  
  13130. % [<specname>]{<spec>}
  13131. \newrobustcmd*{\DeclareUniquenameTemplate}[2][]{%
  13132.   \begingroup
  13133.   \ifblank{#1}
  13134.    {\def\blx@untname{global}}% default
  13135.     {\def\blx@untname{#1}}%
  13136.   \let\namepart\blx@untemp@namepart
  13137.   \let\blx@tempa\@empty
  13138.   \blx@tempcnta\z@
  13139.   #2%
  13140.   \global\cslet{blx@uniquenametemplate@\blx@untname}\blx@tempa
  13141.  \xifinlist\blx@untname\blx@untemplatespecs
  13142.    {}
  13143.    {\listxadd\blx@untemplatespecs\blx@untname}%
  13144.   \endgroup}
  13145. \@onlypreamble\DeclareUniquenameTemplate
  13146. \blx@collectopts{xml}{blx@globalopts}{uniquenametemplate}% for passing to the .bcf
  13147. \DeclareEntryOption[string]{uniquenametemplatename}{%
  13148.   \def\blx@refcontext@uniquenametemplatename{#1}}
  13149.  
  13150. \newcommand*{\blx@untemp@namepart}[2][]{%
  13151.   \advance\blx@tempcntb\@ne
  13152.   \edef\blx@tempe{order="\the\blx@tempcntb"}%
  13153.   \let\blx@tempc\@empty
  13154.   \ifblank{#1}
  13155.    {}
  13156.    {\setkeys{blx@untemp@namepart}{#1}}%
  13157.   \eappto\blx@tempa{%
  13158.     \blx@xml@uniquenametemplatenamepart{\blx@tempe}{\blx@tempc}{#2}}}
  13159.  
  13160. \define@key{blx@untemp@namepart}{use}[true]{% use* option for namepart true|false
  13161.   \ifstrequal{#1}{true}
  13162.    {\appto\blx@tempc{ use="1"}}
  13163.    {}}
  13164.  
  13165. \define@key{blx@untemp@namepart}{base}[true]{% base option for namepart true|false
  13166.   \ifstrequal{#1}{true}
  13167.    {\appto\blx@tempc{ base="1"}}
  13168.    {}}
  13169.  
  13170. \define@key{blx@untemp@namepart}{disambiguation}{% disambiguation option for namepart none|inits|full|fullonly
  13171.   \appto\blx@tempc{ disambiguation="#1"}}
  13172.  
  13173. % [<templatename>]{<template>}
  13174. \newrobustcmd*{\DeclareSortingNamekeyTemplate}[2][]{%
  13175.   \begingroup
  13176.   \ifblank{#1}
  13177.    {\def\blx@snkname{global}}% default
  13178.     {\def\blx@snkname{#1}}%
  13179.   \let\namepart\blx@sortnk@namepart
  13180.   \let\keypart\blx@sortnk@keypart
  13181.   \let\literal\blx@sortnk@literal
  13182.   \let\blx@tempa\@empty
  13183.   \blx@tempcnta\z@
  13184.   #2%
  13185.   \global\cslet{blx@sortingnamekeytemplate@\blx@snkname}\blx@tempa
  13186.  \xifinlist\blx@snkname\blx@sortingnamekeytemplates
  13187.    {}
  13188.    {\listxadd\blx@sortingnamekeytemplates\blx@snkname}%
  13189.   \endgroup}
  13190. \@onlypreamble\DeclareSortingNamekeyTemplate
  13191. \blx@collectopts{xml}{blx@globalopts}{sortingnamekeytemplate}% for passing to the .bcf
  13192. \DeclareEntryOption[string]{sortingnamekeytemplatename}{%
  13193.   \def\blx@refcontext@sortingnamekeytemplatename{#1}}
  13194.  
  13195. % User-mode macro for checking sorting name template options
  13196. \def\ifuniquenametemplatename#1{%
  13197.   \expandafter\ifstrequal\expandafter{\blx@refcontext@uniquenametemplatename}{#1}}
  13198. \def\iflabelalphanametemplatename#1{%
  13199.   \expandafter\ifstrequal\expandafter{\blx@refcontext@labelalphanametemplatename}{#1}}
  13200. \def\ifsortingnamekeytemplatename#1{%
  13201.   \expandafter\ifstrequal\expandafter{\blx@refcontext@sortingnamekeytemplatename}{#1}}
  13202.  
  13203. \newcommand*{\blx@sortnk@keypart}[1]{%
  13204.   \advance\blx@tempcnta\@ne
  13205.   \blx@tempcntb\z@
  13206.   \edef\blx@tempd{ order="\the\blx@tempcnta"}%
  13207.   \let\blx@tempb\@empty
  13208.   #1%
  13209.   \eappto\blx@tempa{%
  13210.     \blx@xml@sortingnamekeykeypart{\blx@tempd}{\blx@tempb}}}
  13211.  
  13212. \newcommand*{\blx@sortnk@literal}[1]{%
  13213.   \advance\blx@tempcntb\@ne
  13214.   \edef\blx@tempe{ order="\the\blx@tempcntb"}%
  13215.   \let\blx@tempc\@empty
  13216.   \eappto\blx@tempb{%
  13217.     \blx@xml@sortingnamekeyliteral{\blx@tempe}{#1}}}
  13218.  
  13219. \newcommand*{\blx@sortnk@namepart}[2][]{%
  13220.   \advance\blx@tempcntb\@ne
  13221.   \edef\blx@tempe{ order="\the\blx@tempcntb"}%
  13222.   \let\blx@tempc\@empty
  13223.   \ifblank{#1}
  13224.    {}
  13225.    {\setkeys{blx@sortnk@namepart}{#1}}%
  13226.   \eappto\blx@tempb{%
  13227.     \blx@xml@sortingnamekeynamepart{\blx@tempe}{\blx@tempc}{#2}}}
  13228.  
  13229. \define@key{blx@sortnk@namepart}{use}[true]{% use* option for namepart true|false
  13230.   \ifstrequal{#1}{true}
  13231.    {\appto\blx@tempc{ use="1"}}
  13232.    {\appto\blx@tempc{ use="0"}}}
  13233.  
  13234. \define@key{blx@sortnk@namepart}{inits}[true]{% initials only option for namepart true|false
  13235.   \ifstrequal{#1}{true}
  13236.    {\appto\blx@tempc{ inits="1"}}
  13237.    {\appto\blx@tempc{ inits="0"}}}
  13238.  
  13239. % [options]{<templatename>}{<template>}
  13240. \newrobustcmd*{\DeclareSortingTemplate}[3][]{%
  13241.   \ifblank{#1}
  13242.    {}
  13243.    {\setkeys{blx@sortdef@sorting}{#1}%
  13244.      \csxdef{blx@sortdef@locale@#2}{\blx@templ}}%
  13245.   \begingroup
  13246.   \def\name{%LEGACY(<2.0)
  13247.     \blx@warning@noline{%
  13248.       '\string\name' is deprecated in sorting specifications, please use '\string\field'}%
  13249.     \blx@sortdef@field}%
  13250.   \def\list{%LEGACY(<2.0)
  13251.     \blx@warning@noline{%
  13252.       '\string\list' is deprecated in sorting specifications, please use '\string\field'}%
  13253.     \blx@sortdef@field}%
  13254.   \let\sort\blx@sortdef@sort
  13255.   \let\field\blx@sortdef@field
  13256.   \let\literal\blx@sortdef@literal
  13257.   \def\citeorder{\blx@sortdef@field{citeorder}}%
  13258.   \blx@tempcnta\z@
  13259.   \let\blx@tempa\@empty
  13260.   #3%
  13261.   \global\cslet{blx@sortingtemplate@#2}\blx@tempa
  13262.  \endgroup}
  13263. \@onlypreamble\DeclareSortingTemplate
  13264. \blx@collectopts{xml}{blx@globalopts}{sortingtemplate}% for passing to the .bcf
  13265.  
  13266. \define@key{blx@sortdef@sorting}{locale}{% locale name
  13267.   \def\blx@templ{#1}}
  13268.  
  13269. \newcommand*{\blx@sortdef@sort}[2][]{%
  13270.   \advance\blx@tempcnta\@ne
  13271.   \blx@tempcntb\z@
  13272.   \let\blx@tempb\@empty
  13273.   \edef\blx@tempc{order="\the\blx@tempcnta"}%
  13274.   \ifblank{#1}
  13275.    {}
  13276.    {\setkeys{blx@sortdef@sort}{#1}}%
  13277.   \let\do\@firstofone
  13278.   #2%
  13279.   \eappto\blx@tempa{%
  13280.     \blx@xml@sort{\blx@tempc}{\blx@tempb}}}
  13281.  
  13282. \define@key{blx@sortdef@sort}{locale}{% locale name
  13283.   \eappto\blx@tempc{ locale="#1"}}
  13284. \define@key{blx@sortdef@sort}{direction}{% ascending|descending
  13285.   \ifstrequal{#1}{ascending}
  13286.    {\eappto\blx@tempc{ sort\string_direction="ascending"}}
  13287.    {\eappto\blx@tempc{ sort\string_direction="descending"}}}
  13288. \define@key{blx@sortdef@sort}{final}[true]{% true|false
  13289.   \ifstrequal{#1}{true}
  13290.    {\appto\blx@tempc{ final="1"}}
  13291.    {}}
  13292. \define@key{blx@sortdef@sort}{sortcase}[true]{% true|false
  13293.   \ifstrequal{#1}{true}
  13294.    {\appto\blx@tempc{ sortcase="1"}}
  13295.    {\appto\blx@tempc{ sortcase="0"}}}
  13296. \define@key{blx@sortdef@sort}{sortupper}[true]{% true|false
  13297.   \ifstrequal{#1}{true}
  13298.    {\appto\blx@tempc{ sortupper="1"}}
  13299.    {\appto\blx@tempc{ sortupper="0"}}}
  13300.  
  13301. \newcommand*{\blx@sortdef@field}[2][]{%
  13302.   \advance\blx@tempcntb\@ne
  13303.   \edef\blx@tempd{order="\the\blx@tempcntb"}%
  13304.   \ifblank{#1}
  13305.    {}
  13306.    {\setkeys{blx@sortdef@field}{#1}}%
  13307.   \eappto\blx@tempb{%
  13308.     \blx@xml@sortitem{\blx@tempd}{#2}}}
  13309.  
  13310. \define@key{blx@sortdef@field}{padside}{% left|right
  13311.   \ifstrequal{#1}{right}
  13312.    {\eappto\blx@tempd{ pad\string_side="right"}}
  13313.    {\eappto\blx@tempd{ pad\string_side="left"}}}
  13314. \define@key{blx@sortdef@field}{padwidth}{% integer
  13315.   \eappto\blx@tempd{ pad\string_width="#1"}}
  13316. \define@key{blx@sortdef@field}{padchar}{% character
  13317.   \blx@xmlsanitizeafter{\def\blx@tempe}{#1}%
  13318.   \eappto\blx@tempd{ pad\string_char="\blx@tempe"}}
  13319. \define@key{blx@sortdef@field}{strside}{% left|right
  13320.   \ifstrequal{#1}{right}
  13321.    {\eappto\blx@tempd{ substring\string_side="right"}}
  13322.    {\eappto\blx@tempd{ substring\string_side="left"}}}
  13323. \define@key{blx@sortdef@field}{strwidth}{% integer
  13324.   \eappto\blx@tempd{ substring\string_width="#1"}}
  13325.  
  13326. \def\blx@sortdef@literal#1{%
  13327.   \advance\blx@tempcntb\@ne
  13328.   \blx@xmlsanitizeafter{\def\blx@tempe}{#1}%
  13329.   \eappto\blx@tempb{%
  13330.     \blx@xml@sortitem{order="\the\blx@tempcntb"}{\blx@tempe}}}
  13331.  
  13332. % [<type,type,...>]{<string>}
  13333. \newrobustcmd*{\DeclarePresort}[2][]{%
  13334.   \begingroup
  13335.   \blx@xmlsanitizeafter{\def\blx@tempa}{#2}%
  13336.   \ifblank{#1}
  13337.    {\xdef\blx@bcf@presort{\blx@xml@presort{}{\blx@tempa}}}
  13338.    {\notblank{#2}
  13339.       {\forcsvlist{\blx@defpresort\blx@tempa}{#1}}
  13340.       {\forcsvlist\blx@undefpresort{#1}}}%
  13341.   \endgroup}
  13342. \@onlypreamble\DeclarePresort
  13343. \blx@collectopts{string}{blx@globalopts}{presort}% for passing to the .bcf
  13344. \blx@collectopts{string}{blx@typeopts}{presort}% for passing to the .bcf
  13345. \blx@collectopts{string}{blx@entryopts}{presort}% for passing to the .bcf
  13346.  
  13347. \def\blx@defpresort#1#2{%
  13348.   \csxdef{blx@bcf@presort@#2}{\blx@xml@presort{#2}{#1}}}
  13349. \def\blx@undefpresort#1{%
  13350.   \global\csundef{blx@bcf@presort@#1}}
  13351.  
  13352. % {<entrytype,...>}{<field,...>}
  13353. \newrobustcmd*{\DeclareSortExclusion}[2]{%
  13354.   \forcsvlist{\blx@sortexclude{#2}}{#1}}
  13355. \blx@collectopts{xml}{blx@typeopts}{sortexclusion}% for passing to the .bcf
  13356.  
  13357. % {<field>}{<entrytype>}
  13358. \def\blx@sortexclude#1#2{%
  13359.   \begingroup
  13360.   \ifblank{#1}
  13361.    {\global\csundef{blx@bcf@exclude@#2}}
  13362.    {\let\blx@tempa\@empty
  13363.     \forcsvlist\blx@sortexclude@i{#1}%
  13364.      \csxdef{blx@bcf@exclude@#2}{%
  13365.        \blx@xml@sortexclude{#2}{\blx@tempa}}}
  13366.  \endgroup}
  13367.  
  13368. \def\blx@sortexclude@i#1{%
  13369.   \appto\blx@tempa{\blx@xml@exclude{#1}}}
  13370.  
  13371. % {<entrytype,...>}{<field,...>}
  13372. \newrobustcmd*{\DeclareSortInclusion}[2]{%
  13373.   \forcsvlist{\blx@sortinclude{#2}}{#1}}
  13374. \blx@collectopts{xml}{blx@typeopts}{sortinclusion}% for passing to the .bcf
  13375.  
  13376. % {<field>}{<entrytype>}
  13377. \def\blx@sortinclude#1#2{%
  13378.   \begingroup
  13379.   \ifblank{#1}
  13380.    {\global\csundef{blx@bcf@include@#2}}
  13381.    {\let\blx@tempa\@empty
  13382.     \forcsvlist\blx@sortinclude@i{#1}%
  13383.      \csxdef{blx@bcf@include@#2}{%
  13384.        \blx@xml@sortinclude{#2}{\blx@tempa}}}
  13385.  \endgroup}
  13386.  
  13387. \def\blx@sortinclude@i#1{%
  13388.   \appto\blx@tempa{\blx@xml@include{#1}}}
  13389.  
  13390. % {<field,field,...>}
  13391. \newrobustcmd*{\DeclareExtradate}[1]{%
  13392.   \begingroup
  13393.   \let\blx@tempa\@empty
  13394.   \let\scope\blx@extradate@scope
  13395.   #1%
  13396.   \global\let\blx@bcf@extradatespec\blx@tempa
  13397.   \endgroup}
  13398. \@onlypreamble\DeclareExtradate
  13399. \blx@collectopts{xml}{blx@globalopts}{extradatespec}% for passing to the .bcf
  13400.  
  13401. \newrobustcmd*{\blx@extradate@scope}[1]{%
  13402.   \let\blx@tempb\@empty
  13403.   \let\field\blx@ordereded@field
  13404.   #1%
  13405.   \csxappto{blx@tempa}{%
  13406.     \noexpand\blx@xml@extradatescope{\blx@tempb}}}
  13407.  
  13408. \newcommand*{\blx@ordereded@field}[1]{%
  13409.   \advance\blx@tempcnta\@ne
  13410.     \csxappto{blx@tempb}{%
  13411.       \noexpand\blx@xml@edordered{\the\blx@tempcnta}{#1}}}
  13412.  
  13413. % [<type,type,...>]{<field,field,...>}
  13414. \newrobustcmd*{\DeclareLabelname}[2][]{%
  13415.   \begingroup
  13416.   \let\blx@tempa\@empty
  13417.   \def\blx@tempb{labelnamespec}%
  13418.   \let\field\blx@ordered@field
  13419.   \ifblank{#1}
  13420.    {\global\cslet{blx@bcf@labelnamespec}\@empty}
  13421.    {\def\blx@tempa{#1}%
  13422.      \def\do##1{\global\cslet{blx@bcf@labelnamespec@##1}\@empty}%
  13423.      \expandafter\docsvlist\expandafter{#1}}%
  13424.   #2%
  13425.   \endgroup}
  13426. \@onlypreamble\DeclareLabelname
  13427. \blx@collectopts{xml}{blx@globalopts}{labelnamespec}% for passing to the .bcf
  13428. \blx@collectopts{xml}{blx@typeopts}{labelnamespec}% for passing to the .bcf
  13429.  
  13430. \newrobustcmd*{\DeclareLabeltitle}[2][]{%
  13431.   \begingroup
  13432.   \let\blx@tempa\@empty
  13433.   \def\blx@tempb{labeltitlespec}%
  13434.   \let\field\blx@ordered@field
  13435.   \ifblank{#1}
  13436.    {\global\cslet{blx@bcf@labeltitlespec}\@empty}
  13437.    {\def\blx@tempa{#1}%
  13438.      \def\do##1{\global\cslet{blx@bcf@labeltitlespec@##1}\@empty}%
  13439.      \expandafter\docsvlist\expandafter{#1}}%
  13440.   #2%
  13441.   \endgroup}
  13442. \@onlypreamble\DeclareLabeltitle
  13443. \blx@collectopts{xml}{blx@globalopts}{labeltitlespec}% for passing to the .bcf
  13444. \blx@collectopts{xml}{blx@typeopts}{labeltitlespec}% for passing to the .bcf
  13445.  
  13446. \newrobustcmd*{\DeclareLabeldate}[2][]{%
  13447.   \begingroup
  13448.   \let\blx@tempa\@empty
  13449.   \def\blx@tempb{labeldatespec}%
  13450.   \let\field\blx@orderedld@field
  13451.   \let\literal\blx@orderedld@literal
  13452.   \ifblank{#1}
  13453.    {\global\cslet{blx@bcf@labeldatespec}\@empty}
  13454.    {\def\blx@tempa{#1}%
  13455.      \def\do##1{\global\cslet{blx@bcf@labeldatespec@##1}\@empty}%
  13456.      \expandafter\docsvlist\expandafter{#1}}%
  13457.   #2%
  13458.   \endgroup}
  13459. \@onlypreamble\DeclareLabeldate
  13460. \blx@collectopts{xml}{blx@globalopts}{labeldatespec}% for passing to the .bcf
  13461. \blx@collectopts{xml}{blx@typeopts}{labeldatespec}% for passing to the .bcf
  13462.  
  13463. \newcommand*{\blx@ordered@field}[2][]{%
  13464.   \let\blx@tempc\@empty
  13465.   \ifblank{#1}
  13466.    {}
  13467.    {\setkeys{blx@ordered@field}{#1}}%
  13468.   \advance\blx@tempcnta\@ne
  13469.   \ifdefempty{\blx@tempa}
  13470.    {\csxappto{blx@bcf@\blx@tempb}{%
  13471.        \noexpand\blx@xml@ordered{\the\blx@tempcnta}{\blx@tempc}{#2}}}
  13472.     {\def\do##1{%
  13473.        \blx@addtypeopt{##1}%
  13474.        \csxappto{blx@bcf@\blx@tempb @##1}{%
  13475.          \noexpand\blx@xml@ordered{\the\blx@tempcnta}{\blx@tempc}{#2}}}%
  13476.      \expandafter\docsvlist\expandafter{\blx@tempa}}}
  13477.  
  13478. \newcommand*{\blx@orderedld@field}[2][]{%
  13479.   \let\blx@tempc\@empty
  13480.   \ifblank{#1}
  13481.    {}
  13482.    {\setkeys{blx@ordered@field}{#1}}%
  13483.   \advance\blx@tempcnta\@ne
  13484.   \ifdefempty{\blx@tempa}
  13485.    {\csxappto{blx@bcf@\blx@tempb}{%
  13486.        \noexpand\blx@xml@ordered{\the\blx@tempcnta}{ type="field"\blx@tempc}{#2}}}
  13487.     {\def\do##1{%
  13488.        \blx@addtypeopt{##1}%
  13489.        \csxappto{blx@bcf@\blx@tempb @##1}{%
  13490.          \noexpand\blx@xml@ordered{\the\blx@tempcnta}{ type="field"\blx@tempc}{#2}}}%
  13491.      \expandafter\docsvlist\expandafter{\blx@tempa}}}
  13492.  
  13493. \newcommand*{\blx@orderedld@literal}[1]{%
  13494.   \advance\blx@tempcnta\@ne
  13495.   \ifdefempty{\blx@tempa}
  13496.    {\csxappto{blx@bcf@\blx@tempb}{%
  13497.        \noexpand\blx@xml@ordered{\the\blx@tempcnta}{ type="string"}{#1}}}
  13498.     {\def\do##1{%
  13499.        \blx@addtypeopt{##1}%
  13500.        \csxappto{blx@bcf@\blx@tempb @##1}{%
  13501.          \noexpand\blx@xml@ordered{\the\blx@tempcnta}{ type="string"}{#1}}}%
  13502.      \expandafter\docsvlist\expandafter{\blx@tempa}}}
  13503.  
  13504. %% Package options
  13505.  
  13506. % [<entrytype,entrytype,...>]{<options>}
  13507.  
  13508. \newrobustcmd*{\ExecuteBibliographyOptions}[2][]{%
  13509.   \ifblank{#1}
  13510.    {\setkeys{blx@opt@pre}{#2}}
  13511.    {\forcsvlist{\blx@typeoptions{#2}}{#1}}}
  13512. \@onlypreamble\ExecuteBibliographyOptions
  13513.  
  13514. \def\blx@typeoptions#1#2{%
  13515.   \blx@addtypeopt{#2}%
  13516.   \csappto{blx@opts@type@#2}{#1,}}
  13517.  
  13518. \def\blx@addtypeopt#1{%
  13519.   \notblank{#1}
  13520.    {\ifdef\blx@opts@type
  13521.       {\ifinlist{#1}\blx@opts@type
  13522.          {}
  13523.          {\listgadd\blx@opts@type{#1}}}
  13524.       {\listgadd\blx@opts@type{#1}}}
  13525.    {}}
  13526.  
  13527. % load-time only
  13528.  
  13529. % Have to have a dummy for this as it's set much earlier but is passed
  13530. % through to here where we just ignore it
  13531. \define@key{blx@opt@ldt}{datamodel}{}
  13532.  
  13533. \define@key{blx@opt@ldt}{backend}{%
  13534.   \ifstrequal{#1}{biber}
  13535.    {}
  13536.    {\ifboolexpr{
  13537.       test {\ifstrequal{#1}{bibtex}}
  13538.       or
  13539.       test {\ifstrequal{#1}{bibtex8}}}
  13540.       {\settoggle{blx@bibtex}{true}%
  13541.         \newtoggle{blx@bibtex8}%
  13542.         \ifstrequal{#1}{bibtex8}
  13543.          {\settoggle{blx@bibtex8}{true}}
  13544.          {}}%
  13545.        {\blx@err@invopt{backend=#1}{}}}}
  13546.  
  13547. \define@key{blx@opt@ldt}{style}{%
  13548.   \def\blx@cbxfile{#1}%
  13549.   \def\blx@bbxfile{#1}}
  13550.  
  13551. \define@key{blx@opt@ldt}{bibstyle}{%
  13552.   \def\blx@bbxfile{#1}}
  13553.  
  13554. \define@key{blx@opt@ldt}{citestyle}{%
  13555.   \def\blx@cbxfile{#1}}
  13556.  
  13557. \define@key{blx@opt@ldt}{natbib}[true]{%
  13558.   \settoggle{blx@natbib}{#1}}
  13559.  
  13560. \define@key{blx@opt@ldt}{mcite}[true]{%
  13561.   \settoggle{blx@mcite}{#1}}
  13562.  
  13563. \define@key{blx@opt@ldt}{noerroretextools}[true]{%
  13564.   \blx@warning@noline{%
  13565.     The option 'noerroretextools' is deprecated.\MessageBreak
  13566.     Define the control sequence '\string\blx@noerroretextools'\MessageBreak
  13567.     before loading biblatex instead}%
  13568.   \ifstrequal{#1}{true}
  13569.    {\global\cslet{blx@noerroretextools}\@empty}
  13570.    {\csgundef{blx@noerroretextools}}}
  13571.  
  13572. % load-time and preamble
  13573.  
  13574. \DeclareBibliographyOption[boolean]{debug}[true]{%
  13575.   \settoggle{blx@debug}{#1}}
  13576.  
  13577. \DeclareBibliographyOption[boolean]{loadfiles}[true]{%
  13578.   \settoggle{blx@loadfiles}{#1}}
  13579.  
  13580. \DeclareBibliographyOption[integer]{mincrossrefs}{%
  13581.   \ifnum#1<\z@
  13582.     \def\blx@mincrossrefs{1}%
  13583.   \else
  13584.     \def\blx@mincrossrefs{#1}%
  13585.   \fi}
  13586.  
  13587. \DeclareBibliographyOption[integer]{minxrefs}{%
  13588.   \ifnum#1<\z@
  13589.     \def\blx@minxrefs{1}%
  13590.   \else
  13591.     \def\blx@minxrefs{#1}%
  13592.   \fi}
  13593. \def\blx@minxrefs{2}
  13594.  
  13595. \DeclareBibliographyOption[string]{texencoding}{%
  13596.   \ifstrequal{#1}{auto}
  13597.    {\undef\blx@texencoding}
  13598.    {\def\blx@texencoding{#1}}}
  13599.  
  13600. \DeclareBibliographyOption[string]{bibencoding}{%
  13601.   \ifcsdef{blx@bibenc@#1}
  13602.    {\letcs\blx@bibencoding{blx@bibenc@#1}}
  13603.    {\def\blx@bibencoding{#1}}}
  13604.  
  13605. \def\abx@mapbibenc#1#2{\csdef{blx@bibenc@#1}{#2}}
  13606. \abx@mapbibenc{inputenc}{auto}
  13607. \abx@mapbibenc{x-ascii}{ascii}
  13608.  
  13609. \def\abx@mapinpenc#1#2{\csdef{blx@inpenc@#1}{#2}}
  13610. \abx@mapinpenc{utf8x}{utf8}
  13611. \abx@mapinpenc{lutf8}{utf8}
  13612. \abx@mapinpenc{x-ascii}{ascii}
  13613.  
  13614. \DeclareBibliographyOption[boolean]{safeinputenc}[true]{%
  13615.   \settoggle{blx@safeinputenc}{#1}}
  13616. \newtoggle{blx@safeinputenc}
  13617.  
  13618. % global "sorting" option becomes "sortingtemplatename" in the .bcf and so
  13619. % don't use \DeclareBibliographyOption. This is a legacy naming issue
  13620. % unlikely to be corrected as "sorting" is an obvious name for biblatex users
  13621. % "sorting" is used in the .bcf for the actual sorting template definitions and is
  13622. % an XML format option
  13623. \define@key{blx@opt@pre}{sorting}{%
  13624.   \def\blx@sorting{#1}%
  13625.   \def\blx@refcontext@sortingtemplatename{#1}}
  13626. \blx@collectopts{string}{blx@globalopts}{sortingtemplatename}% for passing to the .bcf
  13627.  
  13628. \AtEndPreamble{%
  13629.   \ifcsdef{blx@sortingtemplate@\blx@sorting}
  13630.    {}
  13631.    {\blx@err@invopt{sorting=\blx@sorting}{}%
  13632.      \def\blx@sorting{nty}%
  13633.      \def\blx@refcontext@sortingtemplatename{nty}}%
  13634.   \listxadd\blx@sortingtemplatenames\blx@sorting
  13635.   \def\blx@refcontext@sortingnamekeytemplatename{global}%
  13636.   \let\blx@refcontext@labelprefix\@empty
  13637.   \let\blx@refcontext@labelprefix@real\@empty
  13638.   \def\blx@refcontext@uniquenametemplatename{global}%
  13639.   \def\blx@refcontext@labelalphanametemplatename{global}%
  13640.   \blx@xdef@refcontext{\blx@refcontext@sortingtemplatename/\blx@refcontext@sortingnamekeytemplatename/\blx@refcontext@labelprefix/\blx@refcontext@uniquenametemplatename/\blx@refcontext@labelalphanametemplatename}%
  13641.   \listxadd\blx@refcontexts\blx@refcontext@context}
  13642.  
  13643. \DeclareBibliographyOption[boolean]{sortcase}[true]{%
  13644.   \settoggle{blx@sortcase}{#1}}
  13645.  
  13646. \DeclareBibliographyOption[boolean]{sortupper}[true]{%
  13647.   \settoggle{blx@sortupper}{#1}}
  13648.  
  13649. \DeclareBibliographyOption[integer]{maxnames}{%
  13650.   \numdef\blx@maxcitenames{#1}%
  13651.   \numdef\blx@maxbibnames{#1}%
  13652.   \numdef\blx@maxsortnames{#1}}
  13653. \DeclareBibliographyOption[integer]{minnames}{%
  13654.   \numdef\blx@mincitenames{#1}%
  13655.   \numdef\blx@minbibnames{#1}%
  13656.   \numdef\blx@minsortnames{#1}}
  13657. \DeclareTypeOption[integer]{maxnames}{%
  13658.   \numdef\blx@maxcitenames@type{#1}%
  13659.   \numdef\blx@maxbibnames@type{#1}%
  13660.   \numdef\blx@maxsortnames@type{#1}%
  13661.   \c@maxnames#1\relax}
  13662. \DeclareTypeOption[integer]{minnames}{%
  13663.   \numdef\blx@mincitenames@type{#1}%
  13664.   \numdef\blx@minbibnames@type{#1}%
  13665.   \numdef\blx@minsortnames@type{#1}%
  13666.   \c@minnames#1\relax}
  13667. \DeclareEntryOption[integer]{maxnames}{%
  13668.   \c@maxnames#1\relax}
  13669. \DeclareEntryOption[integer]{minnames}{%
  13670.   \c@minnames#1\relax}
  13671.  
  13672. \DeclareBibliographyOption[integer]{maxbibnames}{%
  13673.   \numdef\blx@maxbibnames{#1}%
  13674.   \numdef\blx@maxsortnames{#1}}
  13675. \DeclareBibliographyOption[integer]{minbibnames}{%
  13676.   \numdef\blx@minbibnames{#1}%
  13677.   \numdef\blx@minsortnames{#1}}
  13678. \DeclareTypeOption[integer]{maxbibnames}{%
  13679.   \numdef\blx@maxbibnames@type{#1}%
  13680.   \numdef\blx@maxsortnames@type{#1}%
  13681.   \iftoggle{blx@bibliography}
  13682.    {\c@maxnames#1\relax}
  13683.    {}}
  13684. \DeclareTypeOption[integer]{minbibnames}{%
  13685.   \numdef\blx@minbibnames@type{#1}%
  13686.   \numdef\blx@minsortnames@type{#1}%
  13687.   \iftoggle{blx@bibliography}
  13688.    {\c@minnames#1\relax}
  13689.    {}}
  13690. \DeclareEntryOption[integer]{maxbibnames}{%
  13691.   \iftoggle{blx@bibliography}
  13692.    {\c@maxnames#1\relax}
  13693.    {}}
  13694. \DeclareEntryOption[integer]{minbibnames}{%
  13695.   \iftoggle{blx@bibliography}
  13696.    {\c@minnames#1\relax}
  13697.    {}}
  13698.  
  13699. \DeclareBibliographyOption[integer]{maxcitenames}{%
  13700.   \numdef\blx@maxcitenames{#1}}
  13701. \DeclareBibliographyOption[integer]{mincitenames}{%
  13702.   \numdef\blx@mincitenames{#1}}
  13703. \DeclareTypeOption[integer]{maxcitenames}{%
  13704.   \numdef\blx@maxcitenames@type{#1}%
  13705.   \iftoggle{blx@bibliography}
  13706.    {}
  13707.    {\c@maxnames#1\relax}}
  13708. \DeclareTypeOption[integer]{mincitenames}{%
  13709.   \numdef\blx@mincitenames@type{#1}%
  13710.   \iftoggle{blx@bibliography}
  13711.    {}
  13712.    {\c@minnames#1\relax}}
  13713. \DeclareEntryOption[integer]{maxcitenames}{%
  13714.   \iftoggle{blx@bibliography}
  13715.    {}
  13716.    {\c@maxnames#1\relax}}
  13717. \DeclareEntryOption[integer]{mincitenames}{%
  13718.   \iftoggle{blx@bibliography}
  13719.    {}
  13720.    {\c@minnames#1\relax}}
  13721.  
  13722. \DeclareBibliographyOption[integer]{maxsortnames}{%
  13723.   \numdef\blx@maxsortnames{#1}}
  13724. \DeclareBibliographyOption[integer]{minsortnames}{%
  13725.   \numdef\blx@minsortnames{#1}}
  13726. \DeclareTypeOption[integer]{maxsortnames}{%
  13727.   \numdef\blx@maxsortnames@type{#1}}
  13728. \DeclareTypeOption[integer]{minsortnames}{%
  13729.   \numdef\blx@minsortnames@type{#1}}
  13730. \DeclareEntryOption[integer]{maxsortnames}{}
  13731. \DeclareEntryOption[integer]{minsortnames}{}
  13732.  
  13733. \appto\blx@checkoptions@global{%
  13734.   \blx@maxmin@num{maxbibnames}{minbibnames}\blx@maxbibnames\blx@minbibnames
  13735.  \blx@maxmin@num{maxcitenames}{mincitenames}\blx@maxcitenames\blx@mincitenames
  13736.  \blx@maxmin@num{maxsortnames}{minsortnames}\blx@maxsortnames\blx@minsortnames}
  13737. \appto\blx@checkoptions@type{%
  13738.   \blx@maxmin@num{maxbibnames}{minbibnames}\blx@maxbibnames@type\blx@minbibnames@type
  13739.  \blx@maxmin@num{maxcitenames}{mincitenames}\blx@maxcitenames@type\blx@mincitenames@type
  13740.  \blx@maxmin@num{maxsortnames}{minsortnames}\blx@maxsortnames@type\blx@minsortnames@type}
  13741. \appto\blx@checkoptions@entry{%
  13742.   \blx@maxmin@cnt{maxnames}{minnames}\c@maxnames\c@minnames}
  13743.  
  13744. \DeclareBibliographyOption[integer]{maxitems}{%
  13745.   \numdef\blx@maxitems{#1}}
  13746. \DeclareBibliographyOption[integer]{minitems}{%
  13747.   \numdef\blx@minitems{#1}}
  13748. \DeclareTypeOption[integer]{maxitems}{%
  13749.   \numdef\blx@maxitems@type{#1}%
  13750.   \c@maxitems#1\relax}
  13751. \DeclareTypeOption[integer]{minitems}{%
  13752.   \numdef\blx@minitems@type{#1}%
  13753.   \c@minitems#1\relax}
  13754. \DeclareEntryOption[integer]{maxitems}{%
  13755.   \c@maxitems#1\relax}
  13756. \DeclareEntryOption[integer]{minitems}{%
  13757.   \c@minitems#1\relax}
  13758.  
  13759. \appto\blx@checkoptions@global{%
  13760.   \blx@maxmin@num{maxitems}{minitems}\blx@maxitems\blx@minitems}
  13761. \appto\blx@checkoptions@type{%
  13762.   \blx@maxmin@num{maxitems}{minitems}\blx@maxitems@type\blx@minitems@type}
  13763. \appto\blx@checkoptions@entry{%
  13764.   \blx@maxmin@cnt{maxitems}{minitems}\c@maxitems\blx@minitems}
  13765.  
  13766. \DeclareBibliographyOption[integer]{maxalphanames}{%
  13767.   \numdef\blx@maxalphanames{#1}}
  13768. \DeclareBibliographyOption[integer]{minalphanames}{%
  13769.   \numdef\blx@minalphanames{#1}}
  13770. \DeclareTypeOption[integer]{maxalphanames}{%
  13771.   \numdef\blx@maxalphanames{#1}}
  13772. \DeclareTypeOption[integer]{minalphanames}{%
  13773.   \numdef\blx@minalphanames{#1}}
  13774. \DeclareEntryOption[integer]{maxalphanames}{%
  13775.   \numdef\blx@maxalphanames{#1}}
  13776. \DeclareEntryOption[integer]{minalphanames}{%
  13777.   \numdef\blx@minalphanames{#1}}
  13778.  
  13779. \appto\blx@checkoptions@global{%
  13780.   \blx@maxmin@num{maxalphanames}{minalphanames}\blx@maxalphanames\blx@minalphanames}
  13781. \appto\blx@checkoptions@type{%
  13782.   \blx@maxmin@num{maxalphanames}{minalphanames}\blx@maxalphanames\blx@minalphanames}
  13783.  
  13784. \def\blx@maxmin@num#1#2#3#4{%
  13785.   \ifnumless#3\@ne
  13786.     {\blx@err@invopt{#1=#3}{'#1' must be greater than zero}%
  13787.      \let#3\@ne}
  13788.     {}%
  13789.   \ifnumless#4\@ne
  13790.     {\blx@err@invopt{#2=#4}{'#2' must be greater than zero}%
  13791.      \let#4\@ne}
  13792.     {}%
  13793.   \ifnumless#3#4
  13794.     {\blx@err@confopt{#1/#2}{'#1' must be greater than or equal to '#2'}%
  13795.      \let#3#4}
  13796.     {}}
  13797.  
  13798. \def\blx@maxmin@cnt#1#2#3#4{%
  13799.   \ifnumless#3\@ne
  13800.     {\blx@err@invopt{#1=\number#3}{'#1' must be greater than zero}%
  13801.      #3\@ne}
  13802.     {}%
  13803.   \ifnumless#4\@ne
  13804.     {\blx@err@invopt{#2=\number#4}{'#2' must be greater than zero}%
  13805.      #4\@ne}
  13806.     {}%
  13807.   \ifnumless#3#4
  13808.     {\blx@err@confopt{#1/#2}{'#1' must be greater than or equal to '#2'}%
  13809.      #3=#4}
  13810.     {}}
  13811.  
  13812. \DeclareBibliographyOption[boolean]{terseinits}[true]{%
  13813.   \ifstrequal{#1}{true}
  13814.    {\toggletrue{blx@terseinits}
  13815.     \renewrobustcmd*{\bibinitperiod}{}
  13816.     \renewrobustcmd*{\bibinitdelim}{}
  13817.     \renewrobustcmd*{\bibinithyphendelim}{}}
  13818.    {\togglefalse{blx@terseinits}
  13819.     \renewrobustcmd*{\bibinitperiod}{\adddot}
  13820.     \renewrobustcmd*{\bibinitdelim}{\addnbspace}
  13821.     \renewrobustcmd*{\bibinithyphendelim}{\adddot\mbox{-}}}}
  13822.  
  13823. \DeclareBibliographyOption[boolean]{abbreviate}[true]{%
  13824.   \ifstrequal{#1}{true}
  13825.    {\def\abx@str{abx@sstr}}
  13826.    {\def\abx@str{abx@lstr}}}
  13827.  
  13828. \DeclareBibliographyOption[boolean]{dateabbrev}[true]{%
  13829.   \ifstrequal{#1}{true}
  13830.    {\let\abx@bibmonth\blx@imc@bibsstring
  13831.     \let\abx@bibseason\blx@imc@bibsstring}
  13832.    {\let\abx@bibmonth\blx@imc@biblstring
  13833.     \let\abx@bibseason\blx@imc@biblstring}}
  13834.  
  13835. \DeclareBibliographyOption[string]{sortlocale}{%
  13836.   \edef\blx@sortlocale{\detokenize{#1}}}
  13837.  
  13838. \DeclareBibliographyOption[string]{language}{%
  13839.   \togglefalse{blx@autolangbib}%
  13840.   \togglefalse{blx@autolangcite}%
  13841.   \ifboolexpr{
  13842.    test {\ifstrequal{#1}{auto}}
  13843.    or
  13844.    test {\ifstrequal{#1}{autobib}}
  13845.    or
  13846.    test {\ifstrequal{#1}{autocite}}
  13847.  }
  13848.  {\def\blx@languagename{english}%
  13849.    \ifstrequal{#1}{auto}
  13850.    {\toggletrue{blx@autolangbib}%
  13851.      \toggletrue{blx@autolangcite}}
  13852.    {}%
  13853.    \ifstrequal{#1}{autobib}
  13854.    {\toggletrue{blx@autolangbib}}
  13855.    {}%
  13856.    \ifstrequal{#1}{autocite}
  13857.    {\toggletrue{blx@autolangcite}}
  13858.    {}}
  13859.   % If language is explicit, we do want to auto-switch but only to the
  13860.   % selected language
  13861.   {\IfFileExists{#1.lbx}
  13862.    {\toggletrue{blx@autolangbib}%
  13863.      \toggletrue{blx@autolangcite}%
  13864.      \edef\blx@languagename{#1}%
  13865.      \edef\blx@forcelanguagename{#1}}
  13866.    {\blx@error
  13867.      {Language '#1' not supported}
  13868.      {Failed to find a matching '#1.lbx' file}}}}
  13869.  
  13870. \DeclareBibliographyOption[boolean]{clearlang}[true]{%
  13871.   \settoggle{blx@clearlang}{#1}}
  13872.  
  13873. \DeclareBibliographyOption[string]{autolang}{%
  13874.   \blx@autolang@i{#1}}
  13875.  
  13876. \def\blx@autolang@i#1{%
  13877.   \ifcsdef{blx@opt@autolang@#1}
  13878.    {\csuse{blx@opt@autolang@#1}}
  13879.    {\blx@err@invopt{autolang=#1}{}}}
  13880.  
  13881. \def\blx@opt@autolang@none{%
  13882.   \undef\blx@thelangenv
  13883.   \let\blx@hook@initlang\@empty
  13884.   \let\blx@hook@endlang\@empty}
  13885. \def\blx@opt@autolang@hyphen{%
  13886.   \def\blx@thelangenv{hyphenrules}%
  13887.   \let\blx@hook@initlang\@empty
  13888.   \let\blx@hook@endlang\@empty}
  13889. \csdef{blx@opt@autolang@other*}{%
  13890.   \def\blx@thelangenv{otherlanguage*}%
  13891.   \def\blx@hook@initlang{\@quotereset\@ne}%
  13892.   \def\blx@hook@endlang{\blx@postpunct}}
  13893. \def\blx@opt@autolang@other{%
  13894.   \def\blx@thelangenv{otherlanguage}%
  13895.   \def\blx@hook@initlang{\@quotereset\@ne}%
  13896.   \def\blx@hook@endlang{\blx@postpunct}}
  13897. \def\blx@opt@autolang@langname{%
  13898.   \@ifpackageloaded{polyglossia}
  13899.    {\def\blx@thelangenv{langname}}
  13900.    {\def\blx@thelangenv{otherlanguage}}%
  13901.   \def\blx@hook@initlang{\@quotereset\@ne}%
  13902.   \def\blx@hook@endlang{\blx@postpunct}}
  13903.  
  13904. \DeclareBibliographyOption[boolean]{indexing}[true]{%
  13905.   \blx@opt@index{#1}}
  13906. \DeclareTypeOption[boolean]{indexing}[true]{%
  13907.   \blx@opt@index{#1}}
  13908. \DeclareEntryOption[boolean]{indexing}[true]{%
  13909.   \blx@opt@index{#1}}
  13910. \def\blx@opt@index#1{%
  13911.   \ifcsdef{blx@opt@index@#1}
  13912.    {\csuse{blx@opt@index@#1}}
  13913.    {\blx@err@invopt{indexing=#1}{}}}
  13914. \def\blx@opt@index@true{%
  13915.   \toggletrue{blx@citeindex}%
  13916.   \toggletrue{blx@bibindex}}
  13917. \def\blx@opt@index@false{%
  13918.   \togglefalse{blx@citeindex}%
  13919.   \togglefalse{blx@bibindex}}
  13920. \def\blx@opt@index@cite{%
  13921.   \toggletrue{blx@citeindex}%
  13922.   \togglefalse{blx@bibindex}}
  13923. \def\blx@opt@index@bib{%
  13924.   \togglefalse{blx@citeindex}%
  13925.   \toggletrue{blx@bibindex}}
  13926.  
  13927. \DeclareBibliographyOption[boolean]{sortcites}[true]{%
  13928.   \ifstrequal{#1}{true}
  13929.    {\let\blx@thecitesort\blx@citesort
  13930.     \let\blx@thenotecheck\blx@notecheck
  13931.     \booltrue{sortcites}}
  13932.    {\let\blx@thecitesort\blx@citenosort
  13933.     \let\blx@thenotecheck\relax}}
  13934.  
  13935. \DeclareBibliographyOption[boolean]{sortsets}[true]{%
  13936.   \settoggle{blx@sortsets}{#1}}
  13937.  
  13938. \DeclareBibliographyOption[boolean]{hyperref}[true]{%
  13939.   \ifcsdef{blx@opt@hyperref@#1}
  13940.    {\letcs\blx@hyperref{blx@opt@hyperref@#1}}
  13941.    {\blx@err@invopt{hyperref=#1}{}}}
  13942. \def\blx@opt@hyperref@false{0}
  13943. \def\blx@opt@hyperref@true{1}
  13944. \def\blx@opt@hyperref@auto{2}
  13945. \def\blx@opt@hyperref@manual{3}
  13946.  
  13947. \def\blx@warn@usedmanualhyperrefs#1{%
  13948.   \blx@warning@noline{The command '\string#1' can\MessageBreak
  13949.    only be used with 'hyperref=manual'}}
  13950. \def\blx@warn@multiplemanualhyperrefs{%
  13951.   \blx@warning@noline{You must call either '\string\BiblatexManualHyperrefOn'\MessageBreak
  13952.    or '\string\BiblatexManualHyperrefOff' exactly once.\MessageBreak
  13953.    Subsequent calls to either command will be ignored}}
  13954. \def\BiblatexManualHyperrefOn{%
  13955.   \ifnum\blx@hyperref=\thr@@
  13956.     \blx@mkhyperref
  13957.     \global\undef\blx@mkhyperref
  13958.     \global\undef\blx@mknohyperref
  13959.     \global\let\BiblatexManualHyperrefOn\blx@warn@multiplemanualhyperrefs
  13960.     \global\let\BiblatexManualHyperrefOff\blx@warn@multiplemanualhyperrefs
  13961.   \else
  13962.     \blx@warn@usedmanualhyperrefs{\BiblatexManualHyperrefOn}%
  13963.   \fi}
  13964. \def\BiblatexManualHyperrefOff{%
  13965.   \ifnum\blx@hyperref=\thr@@
  13966.     \blx@mknohyperref
  13967.     \global\undef\blx@mkhyperref
  13968.     \global\undef\blx@mknohyperref
  13969.     \global\let\BiblatexManualHyperrefOn\blx@warn@multiplemanualhyperrefs
  13970.     \global\let\BiblatexManualHyperrefOff\blx@warn@multiplemanualhyperrefs
  13971.   \else
  13972.     \blx@warn@usedmanualhyperrefs{\BiblatexManualHyperrefOff}%
  13973.   \fi}
  13974.  
  13975. \DeclareBibliographyOption[boolean]{backref}[true]{%
  13976.   \ifstrequal{#1}{true}
  13977.    {\let\blx@backref\blx@addbackref
  13978.     \let\abx@aux@backref\blx@aux@backref
  13979.     \booltrue{backtracker}}
  13980.    {\let\blx@backref\@gobble
  13981.     \let\abx@aux@backref\@gobblefive
  13982.     \boolfalse{backtracker}}}
  13983.  
  13984. \DeclareBibliographyOption[string]{backrefsetstyle}{%
  13985.   \ifcsdef{blx@opt@backrefsetstyle@#1}
  13986.    {\letcs\blx@backrefsetstyle{blx@opt@backrefsetstyle@#1}}
  13987.    {\blx@err@invopt{backrefsetstyle=#1}{}}}
  13988. \def\blx@opt@backrefsetstyle@setonly{0}
  13989. \def\blx@opt@backrefsetstyle@memonly{1}
  13990. \def\blx@opt@backrefsetstyle@setormem{2}
  13991. \def\blx@opt@backrefsetstyle@setandmem{3}
  13992. \def\blx@opt@backrefsetstyle@memandset{4}
  13993. \def\blx@opt@backrefsetstyle@setplusmem{5}
  13994.  
  13995. \appto\blx@mkhyperref{%
  13996.   \ifHy@plainpages
  13997.     \blx@warning@noline{%
  13998.       hyperref package option 'plainpages' enabled.\MessageBreak
  13999.       This may cause problems with hyperlinked back\MessageBreak
  14000.       references. 'plainpages=false' is recommended}%
  14001.   \fi
  14002.   \ifHy@pageanchor\else
  14003.     \blx@warning@noline{%
  14004.       hyperref package option 'pageanchor' disabled.\MessageBreak
  14005.       This will cause problems with hyperlinked back\MessageBreak
  14006.       references. 'pageanchor=true' is required}%
  14007.   \fi}
  14008.  
  14009. \DeclareBibliographyOption[string]{block}{%
  14010.   \ifcsdef{blx@opt@block@#1}
  14011.    {\csuse{blx@opt@block@#1}}
  14012.    {\blx@err@invopt{block=#1}{}}}
  14013. \def\blx@opt@block@none{%
  14014.   \let\blx@bibsetup\@empty
  14015.   \let\newblockpunct\@empty}
  14016. \def\blx@opt@block@par{%
  14017.   \let\blx@bibsetup\@empty
  14018.   \def\newblockpunct{\par}}
  14019. \def\blx@opt@block@nbpar{%
  14020.   \def\blx@bibsetup{\interlinepenalty\@M}%
  14021.   \def\newblockpunct{\par\nobreak}}
  14022. \def\blx@opt@block@space{%
  14023.   \let\blx@bibsetup\@empty
  14024.   \def\newblockpunct{%
  14025.     \unspace\space
  14026.     \hskip  0.11em
  14027.     \@plus  0.33em
  14028.     \@minus 0.07em}}
  14029. \def\blx@opt@block@ragged{%
  14030.   \let\blx@bibsetup\raggedright
  14031.   \def\newblockpunct{%
  14032.     \unspace\penalty-9\relax\space}}
  14033.  
  14034. \DeclareBibliographyOption[boolean]{pagetracker}[true]{%
  14035.   \ifcsdef{blx@opt@pagetracker@#1}
  14036.    {\csuse{blx@opt@pagetracker@#1}}
  14037.    {\blx@err@invopt{pagetracker=#1}{}}}
  14038. \def\blx@opt@pagetracker@true{%
  14039.   \if@twoside
  14040.     \blx@opt@pagetracker@spread
  14041.   \else
  14042.     \blx@opt@pagetracker@page
  14043.   \fi}
  14044. \def\blx@opt@pagetracker@false{%
  14045.   \let\blx@pagetracker\relax
  14046.   \let\abx@aux@page\@gobbletwo
  14047.   \let\abx@aux@fnpage\@gobbletwo
  14048.   \boolfalse{pagetracker}}
  14049. \def\blx@opt@pagetracker@page{%
  14050.   \let\blx@pagetracker\blx@pagetracker@context
  14051.   \let\abx@aux@page\blx@aux@page
  14052.   \let\abx@aux@fnpage\blx@aux@fnpage
  14053.   \booltrue{pagetracker}}
  14054. \def\blx@opt@pagetracker@spread{%
  14055.   \if@twoside
  14056.     \let\blx@pagetracker\blx@pagetracker@context
  14057.     \let\abx@aux@page\blx@aux@spread
  14058.     \let\abx@aux@fnpage\blx@aux@fnspread
  14059.     \booltrue{pagetracker}%
  14060.   \else
  14061.     \blx@warning@noline{%
  14062.       LaTeX not in twoside mode\MessageBreak
  14063.       Falling back to 'pagetracker=page'}%
  14064.     \blx@opt@pagetracker@page
  14065.   \fi}
  14066.  
  14067. \DeclareBibliographyOption[boolean]{citecounter}[true]{%
  14068.   \ifcsdef{blx@opt@citecounter@#1}
  14069.    {\csuse{blx@opt@citecounter@#1}}
  14070.    {\blx@err@invopt{citecounter=#1}{}}}
  14071. \def\blx@opt@citecounter@true{%
  14072.   \let\blx@setcitecounter\blx@setcitecounter@global
  14073.   \let\blx@citecounter\blx@citecounter@global
  14074.   \let\abx@aux@count\blx@aux@count
  14075.   \let\abx@aux@fncount\blx@aux@fncount
  14076.   \booltrue{citetracker}}
  14077. \def\blx@opt@citecounter@context{%
  14078.   \let\blx@setcitecounter\blx@setcitecounter@context
  14079.   \let\blx@citecounter\blx@citecounter@context
  14080.   \let\abx@aux@count\blx@aux@count
  14081.   \let\abx@aux@fncount\blx@aux@fncount
  14082.   \booltrue{citetracker}}
  14083. \def\blx@opt@citecounter@false{%
  14084.   \let\blx@setcitecounter\relax
  14085.   \let\blx@citecounter\relax
  14086.   \let\abx@aux@count\@gobbletwo
  14087.   \let\abx@aux@fncount\@gobbletwo}
  14088.  
  14089. \DeclareBibliographyOption[boolean]{citetracker}[true]{%
  14090.   \ifcsdef{blx@opt@citetracker@#1}
  14091.    {\csuse{blx@opt@citetracker@#1}}
  14092.    {\blx@err@invopt{citetracker=#1}{}}}
  14093. \def\blx@opt@citetracker@true{%
  14094.   \let\blx@imc@ifciteseen\blx@ifciteseen@global
  14095.   \let\blx@imc@ifentryseen\blx@ifentryseen@global
  14096.   \let\blx@citetracker\blx@citetracker@global
  14097.   \booltrue{citetracker}}
  14098. \def\blx@opt@citetracker@false{%
  14099.   \let\blx@imc@ifciteseen\@secondoftwo
  14100.   \protected\long\def\blx@imc@ifentryseen##1##2##3{##3}%
  14101.   \let\blx@citetracker\relax}
  14102. \def\blx@opt@citetracker@context{%
  14103.   \let\blx@imc@ifciteseen\blx@ifciteseen@context
  14104.   \let\blx@imc@ifentryseen\blx@ifentryseen@context
  14105.   \let\blx@citetracker\blx@citetracker@context
  14106.   \booltrue{citetracker}}
  14107. \def\blx@opt@citetracker@strict{%
  14108.   \let\blx@imc@ifciteseen\blx@ifciteseen@global
  14109.   \let\blx@imc@ifentryseen\blx@ifentryseen@global
  14110.   \def\blx@citetracker{%
  14111.     \blx@ifcitesingle{\blx@citetracker@global}{}}%
  14112.   \booltrue{citetracker}}
  14113. \def\blx@opt@citetracker@constrict{%
  14114.   \let\blx@imc@ifciteseen\blx@ifciteseen@context
  14115.   \let\blx@imc@ifentryseen\blx@ifentryseen@context
  14116.   \def\blx@citetracker{%
  14117.     \blx@ifcitesingle{\blx@citetracker@context}{}}%
  14118.   \booltrue{citetracker}}
  14119.  
  14120. \DeclareBibliographyOption[boolean]{ibidtracker}[true]{%
  14121.   \ifcsdef{blx@opt@ibidtracker@#1}
  14122.    {\csuse{blx@opt@ibidtracker@#1}}
  14123.    {\blx@err@invopt{ibidtracker=#1}{}}}
  14124. \def\blx@opt@ibidtracker@true{%
  14125.   \let\blx@imc@ifciteibid\blx@ifciteibid@global
  14126.   \let\blx@ibidtracker\blx@ibidtracker@global
  14127.   \let\blx@ibidreset\blx@ibidreset@global
  14128.   \booltrue{citetracker}}
  14129. \def\blx@opt@ibidtracker@false{%
  14130.   \let\blx@imc@ifciteibid\@secondoftwo
  14131.   \let\blx@ibidtracker\relax
  14132.   \let\blx@ibidreset\relax}
  14133. \def\blx@opt@ibidtracker@context{%
  14134.   \let\blx@imc@ifciteibid\blx@ifciteibid@context
  14135.   \let\blx@ibidtracker\blx@ibidtracker@context
  14136.   \let\blx@ibidreset\blx@ibidreset@context
  14137.   \booltrue{citetracker}}
  14138. \def\blx@opt@ibidtracker@strict{%
  14139.   \let\blx@imc@ifciteibid\blx@ifciteibid@strict
  14140.   \let\blx@ibidtracker\blx@ibidtracker@strict
  14141.   \let\blx@ibidreset\blx@ibidreset@global
  14142.   \booltrue{citetracker}}
  14143. \def\blx@opt@ibidtracker@constrict{%
  14144.   \let\blx@imc@ifciteibid\blx@ifciteibid@constrict
  14145.   \let\blx@ibidtracker\blx@ibidtracker@constrict
  14146.   \let\blx@ibidreset\blx@ibidreset@context
  14147.   \booltrue{citetracker}}
  14148.  
  14149. \DeclareBibliographyOption[boolean]{idemtracker}[true]{%
  14150.   \ifcsdef{blx@opt@idemtracker@#1}
  14151.    {\csuse{blx@opt@idemtracker@#1}}
  14152.    {\blx@err@invopt{idemtracker=#1}{}}}
  14153. \def\blx@opt@idemtracker@true{%
  14154.   \let\blx@imc@ifciteidem\blx@ifciteidem@global
  14155.   \let\blx@idemtracker\blx@idemtracker@global
  14156.   \let\blx@idemreset\blx@idemreset@global
  14157.   \booltrue{citetracker}}
  14158. \def\blx@opt@idemtracker@false{%
  14159.   \let\blx@imc@ifciteidem\@secondoftwo
  14160.   \let\blx@idemtracker\relax
  14161.   \let\blx@idemreset\relax}
  14162. \def\blx@opt@idemtracker@context{%
  14163.   \let\blx@imc@ifciteidem\blx@ifciteidem@context
  14164.   \let\blx@idemtracker\blx@idemtracker@context
  14165.   \let\blx@idemreset\blx@idemreset@context
  14166.   \booltrue{citetracker}}
  14167. \def\blx@opt@idemtracker@strict{%
  14168.   \let\blx@imc@ifciteidem\blx@ifciteidem@strict
  14169.   \let\blx@idemtracker\blx@idemtracker@strict
  14170.   \let\blx@idemreset\blx@idemreset@global
  14171.   \booltrue{citetracker}}
  14172. \def\blx@opt@idemtracker@constrict{%
  14173.   \let\blx@imc@ifciteidem\blx@ifciteidem@constrict
  14174.   \let\blx@idemtracker\blx@idemtracker@constrict
  14175.   \let\blx@idemreset\blx@idemreset@context
  14176.   \booltrue{citetracker}}
  14177.  
  14178. \DeclareBibliographyOption[boolean]{opcittracker}[true]{%
  14179.   \ifcsdef{blx@opt@opcittracker@#1}
  14180.    {\csuse{blx@opt@opcittracker@#1}}
  14181.    {\blx@err@invopt{opcittracker=#1}{}}}
  14182. \def\blx@opt@opcittracker@true{%
  14183.   \let\blx@imc@ifopcit\blx@ifopcit@global
  14184.   \let\blx@opcittracker\blx@opcittracker@global
  14185.   \let\blx@opcitreset\blx@opcitreset@global
  14186.   \booltrue{citetracker}}
  14187. \def\blx@opt@opcittracker@false{%
  14188.   \let\blx@imc@ifopcit\@secondoftwo
  14189.   \let\blx@opcittracker\relax
  14190.   \let\blx@opcitreset\relax}
  14191. \def\blx@opt@opcittracker@context{%
  14192.   \let\blx@imc@ifopcit\blx@ifopcit@context
  14193.   \let\blx@opcittracker\blx@opcittracker@context
  14194.   \let\blx@opcitreset\blx@opcitreset@context
  14195.   \booltrue{citetracker}}
  14196. \def\blx@opt@opcittracker@strict{%
  14197.   \let\blx@imc@ifopcit\blx@ifopcit@strict
  14198.   \let\blx@opcittracker\blx@opcittracker@strict
  14199.   \let\blx@opcitreset\blx@opcitreset@global
  14200.   \booltrue{citetracker}}
  14201. \def\blx@opt@opcittracker@constrict{%
  14202.   \let\blx@imc@ifopcit\blx@ifopcit@constrict
  14203.   \let\blx@opcittracker\blx@opcittracker@constrict
  14204.   \let\blx@opcitreset\blx@opcitreset@context
  14205.   \booltrue{citetracker}}
  14206.  
  14207. \DeclareBibliographyOption[boolean]{loccittracker}[true]{%
  14208.   \ifcsdef{blx@opt@loccittracker@#1}
  14209.    {\csuse{blx@opt@loccittracker@#1}}
  14210.    {\blx@err@invopt{loccittracker=#1}{}}}
  14211. \def\blx@opt@loccittracker@true{%
  14212.   \let\blx@imc@ifloccit\blx@ifloccit@global
  14213.   \let\blx@loccittracker\blx@loccittracker@global
  14214.   \let\blx@loccitreset\blx@loccitreset@global
  14215.   \booltrue{citetracker}}
  14216. \def\blx@opt@loccittracker@false{%
  14217.   \let\blx@imc@ifloccit\@secondoftwo
  14218.   \let\blx@loccittracker\relax
  14219.   \let\blx@loccitreset\relax}
  14220. \def\blx@opt@loccittracker@context{%
  14221.   \let\blx@imc@ifloccit\blx@ifloccit@context
  14222.   \let\blx@loccittracker\blx@loccittracker@context
  14223.   \let\blx@loccitreset\blx@loccitreset@context
  14224.   \booltrue{citetracker}}
  14225. \def\blx@opt@loccittracker@strict{%
  14226.   \let\blx@imc@ifloccit\blx@ifloccit@strict
  14227.   \let\blx@loccittracker\blx@loccittracker@strict
  14228.   \let\blx@loccitreset\blx@loccitreset@global
  14229.   \booltrue{citetracker}}
  14230. \def\blx@opt@loccittracker@constrict{%
  14231.   \let\blx@imc@ifloccit\blx@ifloccit@constrict
  14232.   \let\blx@loccittracker\blx@loccittracker@constrict
  14233.   \let\blx@loccitreset\blx@loccitreset@context
  14234.   \booltrue{citetracker}}
  14235.  
  14236. \DeclareBibliographyOption[boolean]{parentracker}[true]{%
  14237.   \ifstrequal{#1}{true}
  14238.    {\let\bibopenparen\blx@bibopenparen
  14239.     \let\bibcloseparen\blx@bibcloseparen
  14240.     \let\bibopenbracket\blx@bibopenbracket
  14241.     \let\bibclosebracket\blx@bibclosebracket}
  14242.    {\protected\def\bibopenparen{\bibleftparen}%
  14243.      \protected\def\bibcloseparen{\bibrightparen}%
  14244.      \protected\def\bibopenbracket{\bibleftbracket}%
  14245.      \protected\def\bibclosebracket{\bibrightbracket}}}
  14246.  
  14247. \DeclareBibliographyOption[integer]{maxparens}{%
  14248.   \ifnumless{#1}{1}
  14249.    {\blx@err@invopt{maxparens=#1}{}}
  14250.    {\setcounter{maxparens}{#1}}}
  14251.  
  14252. \newtoggle{blx@labeldateusetime}
  14253. \DeclareBibliographyOption[boolean]{labeldateusetime}[true]{%
  14254.   \ifstrequal{#1}{true}
  14255.    {\toggletrue{blx@labeldateusetime}}
  14256.    {\togglefalse{blx@labeldateusetime}}}
  14257.  
  14258. \DeclareBibliographyOption[string]{labeldate}{%
  14259.    % 'true' or 'false' means that the user thinks that this is the old 'labeldate'
  14260.    % option which is now 'labeldateparts' (which is a boolean).
  14261.    \ifboolexpr{%
  14262.      test {\ifstrequal{#1}{true}}
  14263.     or
  14264.     test {\ifstrequal{#1}{false}}}
  14265.      {\blx@warning@noline{%
  14266.        'labeldate' option used to determine whether to provide label date fields and\MessageBreak
  14267.        extradate field is renamed to 'labeldateparts', setting this instead. This option is
  14268.        now used to set the format of the labeldate}%
  14269.       \settoggle{blx@labeldateparts}{#1}}
  14270.     {\ifstrequal{#1}{iso8601}
  14271.        {\blx@warning@noline{%
  14272.           'iso8601' date format specifier is deprecated.\MessageBreak
  14273.           Use 'iso' instead}%
  14274.         \def\blx@dateformat@labeldate{iso}%
  14275.         \renewrobustcmd*{\bibdateeraendprefix}{\bibdateeraprefix}}
  14276.       {\ifstrequal{#1}{edtf}
  14277.           {\blx@warning@noline{%
  14278.              'edtf' date format specifier is deprecated.\MessageBreak
  14279.              Use 'iso' instead}%
  14280.            \def\blx@dateformat@labeldate{iso}%
  14281.            \renewrobustcmd*{\bibdateeraendprefix}{\bibdateeraprefix}}
  14282.          {\def\blx@dateformat@labeldate{#1}}}%
  14283.       \ifstrequal{#1}{ymd}
  14284.         {\renewrobustcmd*{\bibdaterangesep}{\slash}%
  14285.           \renewrobustcmd*{\bibtimerangesep}{\slash}%
  14286.           \renewrobustcmd*{\bibdateeraendprefix}{\bibdateeraprefix}}
  14287.         {}%
  14288.       \ifstrequal{#1}{iso}% bibdaterangesep hard-coded to slash, no extra space before prefices
  14289.         {\renewrobustcmd*{\bibdateeraendprefix}{\bibdateeraprefix}}
  14290.        {}%
  14291.       \ifcsdef{mkdaterange#1}
  14292.       {\protected\def\blx@imc@printlabeldate{\csuse{mkdaterange#1}{label}}
  14293.        \protected\def\blx@imc@printlabeldateextra{\csuse{mkdaterange#1extra}{label}}}
  14294.       {\ifcsdef{mkbibrange#1}%LEGACY(<3.5)
  14295.          {\protected\def\blx@imc@printlabeldate{\csuse{mkbibrange#1}{label}}
  14296.          \protected\def\blx@imc@printlabeldateextra{\csuse{mkbibrange#1extra}{label}}}
  14297.         {\blx@err@invopt{labeldate=#1}{}}}}}
  14298.  
  14299. \DeclareBibliographyOption[string]{labeltime}{%
  14300.   \ifcsdef{mktimerange#1}
  14301.    {\def\blx@timeformat@labeltime{#1}%
  14302.      \protected\def\blx@imc@printlabeltime{\csuse{mktimerange#1}{label}}}
  14303.    {\blx@err@invopt{labeltime=#1}{}}}
  14304.  
  14305. % Date meta-information
  14306. \DeclareBibliographyOption[string]{dateera}{%
  14307.   \ifboolexpr{%
  14308.               test {\ifstrequal{#1}{astronomical}}
  14309.              or
  14310.              test {\ifstrequal{#1}{secular}}
  14311.              or
  14312.              test {\ifstrequal{#1}{christian}}}
  14313.  {\def\blx@dateera{#1}%
  14314.    \ifstrequal{#1}{secular}
  14315.     {\def\blx@dateera@bce{beforecommonera}%
  14316.       \def\blx@dateera@ce{commonera}}
  14317.     {}%
  14318.    \ifstrequal{#1}{christian}
  14319.     {\def\blx@dateera@bce{beforechrist}%
  14320.       \def\blx@dateera@ce{annodomini}}
  14321.     {}}
  14322.  {\blx@err@invopt{dateera=#1}{}}}
  14323.  
  14324. % Effectively turns off dateeraauto since it's only used on ce dates which
  14325. % are never less than zero (as that would be a bce date)
  14326. \numdef\blx@dateeraauto{0}
  14327. \DeclareBibliographyOption[integer]{dateeraauto}{%
  14328.   \numdef\blx@dateeraauto{#1}}
  14329.  
  14330. \newtoggle{blx@datecirca}
  14331. \DeclareBibliographyOption[boolean]{datecirca}[true]{%
  14332.   \ifstrequal{#1}{true}
  14333.    {\toggletrue{blx@datecirca}%
  14334.      \protected\def\datecircaprint{%
  14335.        \ifdatecirca{\bibstring{circa}\printdelim{datecircadelim}}{}}%
  14336.      \protected\def\enddatecircaprint{%
  14337.        \ifenddatecirca{\bibstring{circa}\printdelim{datecircadelim}}{}}%
  14338.      \protected\def\datecircaprintedtf{%LEGACY(<3.9)
  14339.        \blx@warning@noline{%
  14340.          '\string\datecircaprintedtf' is deprecated.
  14341.          Please use '\string\datecircaprintiso'}%
  14342.        \datecircaprintiso}%
  14343.      \protected\def\enddatecircaprintedtf{%LEGACY(<3.9)
  14344.        \blx@warning@noline{%
  14345.          '\string\enddatecircaprintedtf' is deprecated.
  14346.          Please use '\string\enddatecircaprintiso'}%
  14347.        \enddatecircaprintiso}%
  14348.      \protected\def\datecircaprintiso{%
  14349.        \ifdatecirca{\textasciitilde}{}}%
  14350.      \protected\def\enddatecircaprintiso{%
  14351.        \ifenddatecirca{\textasciitilde}{}}}
  14352.    {\togglefalse{blx@datecirca}}}
  14353.  
  14354. \newtoggle{blx@dateuncertain}
  14355. \DeclareBibliographyOption[boolean]{dateuncertain}[true]{%
  14356.   \ifstrequal{#1}{true}
  14357.    {\toggletrue{blx@dateuncertain}%
  14358.      \protected\def\dateuncertainprint{%
  14359.        \ifdateuncertain{\bibdateuncertain}{}}%
  14360.      \protected\def\enddateuncertainprint{%
  14361.        \ifenddateuncertain{\bibdateuncertain}{}}}
  14362.    {\togglefalse{blx@dateuncertain}}}
  14363.  
  14364. % *time format options - auto-created for all datamodel date fields
  14365. % *date format options - auto-created for all datamodel date fields
  14366. % *dateusetime options - auto-created for all datamodel date fields
  14367. % Date metadata toggles are defined in one of the \abx@dobooleans calls
  14368. \def\do#1{%
  14369.   \DeclareBibliographyOption[string]{#1date}{%
  14370.     \ifstrequal{##1}{iso8601}
  14371.      {\blx@warning@noline{'iso8601' date format specifier is deprecated.\MessageBreak
  14372.         Use 'iso' instead}%
  14373.        \csdef{blx@dateformat@#1date}{iso}}
  14374.      {\ifstrequal{##1}{edtf}
  14375.         {\blx@warning@noline{'edtf' date format specifier is deprecated.\MessageBreak
  14376.            Use 'iso' instead}%
  14377.           \csdef{blx@dateformat@#1date}{iso}}
  14378.         {\csdef{blx@dateformat@#1date}{##1}}}%
  14379.     \ifstrequal{##1}{ymd}
  14380.      {\renewrobustcmd*{\bibdaterangesep}{\slash}%
  14381.        \renewrobustcmd*{\bibtimerangesep}{\slash}%
  14382.        \renewrobustcmd*{\bibdateeraendprefix}{\bibdateeraprefix}}
  14383.      {}%
  14384.     \ifcsdef{mkdaterange##1}
  14385.      {\protected\csedef{blx@imc@print#1date}{\noexpand\csuse{mkdaterange##1}{#1}}%
  14386.        \protected\csedef{blx@imc@print#1dateextra}{\noexpand\csuse{mkdaterange##1extra}{#1}}}
  14387.      {\ifcsdef{mkbibrange##1}%LEGACY(<3.5)
  14388.         {\blx@warning@noline{%
  14389.            '\string\mkbibrange##1(extra)' date range macro in style is deprecated,\MessageBreak
  14390.            please define '\string\mkdaterange##1(extra)' instead}%
  14391.          \protected\csedef{blx@imc@print#1date}{\noexpand\csuse{mkbibrange##1}{#1}}%
  14392.          \protected\csedef{blx@imc@print#1dateextra}{\noexpand\csuse{mkbibrange##1extra}{#1}}}
  14393.        {\blx@err@invopt{#1date=##1}{}}}}%
  14394.     % Default for new date fields is "comp" but this is overridden below by
  14395.     % biblatex defaults
  14396.     \setkeys{blx@opt@pre}{#1date=comp}%
  14397.     % Time format options
  14398.     \DeclareBibliographyOption[string]{#1time}{%
  14399.       \csdef{blx@timeformat@#1time}{##1}%
  14400.       \ifcsdef{mktimerange##1}
  14401.        {\protected\csedef{blx@imc@print#1time}{\csuse{mktimerange##1}{#1}}}
  14402.        {\blx@err@invopt{#1time=##1}{}}}%
  14403.     % Default for new time fields is "24h"
  14404.     \setkeys{blx@opt@pre}{#1time=24h}%
  14405.     % Boolean to determine if times are printed with dates
  14406.     \newtoggle{blx@#1dateusetime}%
  14407.     \DeclareBibliographyOption[boolean]{#1dateusetime}{%
  14408.       \ifstrequal{##1}{true}
  14409.        {\toggletrue{blx@#1dateusetime}}
  14410.        {\togglefalse{blx@#1dateusetime}}}}
  14411. \abx@dodatetypes
  14412.  
  14413. \DeclareBibliographyOption[string]{alldatesusetime}{%
  14414.   \def\do##1{\ExecuteBibliographyOptions{##1usetime=#1}}%
  14415.   \abx@dodates
  14416.   \do{labeldate}}
  14417.  
  14418. \DeclareBibliographyOption[string]{alldates}{%
  14419.   \def\do##1{\ExecuteBibliographyOptions{##1=#1}}%
  14420.   \abx@dodates
  14421.   \do{labeldate}}
  14422.  
  14423. \DeclareBibliographyOption[string]{alltimes}{%
  14424.   \def\do##1{%
  14425.     \ExecuteBibliographyOptions{##1time=#1}}%
  14426.   \abx@dodatetypes
  14427.   \do{label}}
  14428.  
  14429. \newtoggle{blx@julian}
  14430. \def\blx@gregorianstart{1582-10-15}
  14431. \DeclareBibliographyOption[boolean]{julian}[true]{%
  14432.   \ifstrequal{#1}{true}
  14433.    {\toggletrue{blx@julian}}
  14434.    {\togglefalse{blx@julian}}}
  14435.  
  14436. \DeclareBibliographyOption[string]{gregorianstart}{%
  14437.   \def\blx@gregorianstart{#1}}
  14438.  
  14439. \newtoggle{blx@datezeros}\toggletrue{blx@datezeros}
  14440. \DeclareBibliographyOption[boolean]{datezeros}[true]{%
  14441.   \ifstrequal{#1}{true}
  14442.    {\toggletrue{blx@datezeros}%
  14443.      \let\blx@imc@mkyearzeros\blx@imc@forcezerosy
  14444.      \let\blx@imc@mkmonthzeros\blx@imc@forcezerosmdt
  14445.      \let\blx@imc@mkdayzeros\blx@imc@forcezerosmdt}
  14446.     {\togglefalse{blx@datezeros}%
  14447.      \let\blx@imc@mkyearzeros\blx@imc@stripzeros
  14448.      \let\blx@imc@mkmonthzeros\blx@imc@stripzeros
  14449.      \let\blx@imc@mkdayzeros\blx@imc@stripzeros}}
  14450.  
  14451. \newtoggle{blx@timezeros}\toggletrue{blx@timezeros}
  14452. \DeclareBibliographyOption[boolean]{timezeros}[true]{%
  14453.   \ifstrequal{#1}{true}
  14454.    {\toggletrue{blx@timezeros}%
  14455.      \let\blx@imc@mktimezeros\blx@imc@forcezerosmdt}
  14456.     {\togglefalse{blx@timezeros}%
  14457.      \let\blx@imc@mktimezeros\blx@imc@stripzeros}}
  14458.  
  14459. \newtoggle{blx@timezones}
  14460. \DeclareBibliographyOption[boolean]{timezones}[true]{%
  14461.   \ifstrequal{#1}{true}
  14462.    {\toggletrue{blx@timezones}}
  14463.    {\togglefalse{blx@timezones}}}
  14464.  
  14465. \newtoggle{blx@seconds}
  14466. \DeclareBibliographyOption[boolean]{seconds}[true]{%
  14467.   \ifstrequal{#1}{true}
  14468.    {\toggletrue{blx@seconds}}
  14469.    {\togglefalse{blx@seconds}}}
  14470.  
  14471. \DeclareBibliographyOption[string]{autocite}{%
  14472.   \ifcsundef{blx@acite@#1}
  14473.    {\blx@error
  14474.       {Autocite command '#1' undefined}
  14475.       {The autocite command '#1' has not been defined by
  14476.        the\MessageBreak selected citation style}}
  14477.    {\letcs\autocite{blx@acite@#1}%
  14478.      \letcs\autocites{blx@macite@#1}}}
  14479.  
  14480. \DeclareBibliographyOption[string]{notetype}{%
  14481.   \ifcsdef{blx@opt@notetype@#1}
  14482.    {\blx@notetype\csuse{blx@opt@notetype@#1}}
  14483.    {\blx@err@invopt{notetype=#1}{}}}
  14484. \cslet{blx@opt@notetype@foot+end}\z@
  14485. \let\blx@opt@notetype@footonly\@ne
  14486. \let\blx@opt@notetype@endonly\tw@
  14487.  
  14488. \DeclareBibliographyOption[boolean]{autopunct}[true]{%
  14489.   \ifstrequal{#1}{true}
  14490.    {\DeclareAutoPunctuation{.,;:!?}}
  14491.    {\DeclareAutoPunctuation{}}}
  14492.  
  14493. \DeclareBibliographyOption[boolean]{punctfont}[true]{%
  14494.   \ifstrequal{#1}{true}
  14495.    {\let\blx@ifpuncthook\@firstoftwo}
  14496.    {\let\blx@ifpuncthook\@secondoftwo}}
  14497.  
  14498. \DeclareBibliographyOption[boolean]{labelnumber}[true]{%
  14499.   \settoggle{blx@labelnumber}{#1}%
  14500.   \iftoggle{blx@labelnumber}
  14501.    {}
  14502.    {\setkeys{blx@opt@pre}{defernumbers=false}}}
  14503. \DeclareTypeOption[boolean]{labelnumber}[true]{%
  14504.   \settoggle{blx@labelnumber}{#1}}
  14505.  
  14506. \DeclareBibliographyOption[boolean]{labelalpha}[true]{%
  14507.   \settoggle{blx@labelalpha}{#1}}
  14508. \DeclareTypeOption[boolean]{labelalpha}[true]{%
  14509.   \settoggle{blx@labelalpha}{#1}}
  14510.  
  14511. \DeclareBibliographyOption[boolean]{labeltitle}[true]{%
  14512.   \settoggle{blx@labeltitle}{#1}}
  14513. \DeclareTypeOption[boolean]{labeltitle}[true]{%
  14514.   \settoggle{blx@labeltitle}{#1}}
  14515.  
  14516. \DeclareBibliographyOption[boolean]{labeltitleyear}[true]{%
  14517.   \settoggle{blx@labeltitleyear}{#1}}
  14518. \DeclareTypeOption[boolean]{labeltitleyear}[true]{%
  14519.   \settoggle{blx@labeltitleyear}{#1}}
  14520.  
  14521. \DeclareBibliographyOption[boolean]{labeldateparts}[true]{%
  14522.   \settoggle{blx@labeldateparts}{#1}}
  14523. \DeclareTypeOption[boolean]{labeldateparts}[true]{%
  14524.   \settoggle{blx@labeldateparts}{#1}}
  14525.  
  14526. \DeclareBibliographyOption[boolean]{uniquelist}[true]{%
  14527.   \ifcsdef{blx@opt@uniquelist@#1}
  14528.    {\letcs\blx@uniquelist{blx@opt@uniquelist@#1}}
  14529.    {\blx@err@invopt{uniquelist=#1}{}}}
  14530. \DeclareTypeOption[boolean]{uniquelist}[true]{%
  14531.   \ifcsdef{blx@opt@uniquelist@#1}
  14532.    {\letcs\blx@uniquelist{blx@opt@uniquelist@#1}}
  14533.    {\blx@err@invopt{uniquelist=#1}{}}}
  14534. \DeclareEntryOption[boolean]{uniquelist}[true]{%
  14535.   \ifcsdef{blx@opt@uniquelist@#1}
  14536.    {\letcs\blx@uniquelist{blx@opt@uniquelist@#1}}
  14537.    {\blx@err@invopt{uniquelist=#1}{}}}
  14538. \def\blx@opt@uniquelist@false{0}
  14539. \def\blx@opt@uniquelist@true{1}
  14540. \def\blx@opt@uniquelist@minyear{2}
  14541.  
  14542. \DeclareBibliographyOption[boolean]{uniquename}[true]{%
  14543.   \ifcsdef{blx@opt@uniquename@#1}
  14544.    {\letcs\blx@uniquename{blx@opt@uniquename@#1}}
  14545.    {\blx@err@invopt{uniquename=#1}{}}}
  14546. \DeclareTypeOption[boolean]{uniquename}[true]{%
  14547.   \ifcsdef{blx@opt@uniquename@#1}
  14548.    {\letcs\blx@uniquename{blx@opt@uniquename@#1}}
  14549.    {\blx@err@invopt{uniquename=#1}{}}}
  14550. \DeclareEntryOption[boolean]{uniquename}[true]{%
  14551.   \ifcsdef{blx@opt@uniquename@#1}
  14552.    {\letcs\blx@uniquename{blx@opt@uniquename@#1}}
  14553.    {\blx@err@invopt{uniquename=#1}{}}}
  14554. \def\blx@opt@uniquename@false{0}
  14555. \def\blx@opt@uniquename@init{1}
  14556. \def\blx@opt@uniquename@true{2}
  14557. \def\blx@opt@uniquename@full{2}
  14558. \def\blx@opt@uniquename@allinit{3}
  14559. \def\blx@opt@uniquename@allfull{4}
  14560. \def\blx@opt@uniquename@mininit{5}
  14561. \def\blx@opt@uniquename@minfull{6}
  14562.  
  14563. \DeclareBibliographyOption[boolean]{noroman}[true]{%
  14564.   \settoggle{blx@noroman}{#1}}
  14565. \DeclareTypeOption[boolean]{noroman}[true]{%
  14566.   \settoggle{blx@noroman}{#1}}
  14567. \DeclareEntryOption[boolean]{noroman}[true]{%
  14568.   \settoggle{blx@noroman}{#1}}
  14569.  
  14570. \DeclareBibliographyOption[boolean]{singletitle}[true]{%
  14571.   \settoggle{blx@singletitle}{#1}}
  14572. \DeclareTypeOption[boolean]{singletitle}[true]{%
  14573.   \settoggle{blx@singletitle}{#1}}
  14574.  
  14575. \DeclareBibliographyOption[boolean]{uniquetitle}[true]{%
  14576.   \settoggle{blx@uniquetitle}{#1}}
  14577. \DeclareTypeOption[boolean]{uniquetitle}[true]{%
  14578.   \settoggle{blx@uniquetitle}{#1}}
  14579.  
  14580. \DeclareBibliographyOption[boolean]{uniquebaretitle}[true]{%
  14581.   \settoggle{blx@uniquebaretitle}{#1}}
  14582. \DeclareTypeOption[boolean]{uniquebaretitle}[true]{%
  14583.   \settoggle{blx@uniquebaretitle}{#1}}
  14584.  
  14585. \DeclareBibliographyOption[boolean]{uniquework}[true]{%
  14586.   \settoggle{blx@uniquework}{#1}}
  14587. \DeclareTypeOption[boolean]{uniquework}[true]{%
  14588.   \settoggle{blx@uniquework}{#1}}
  14589.  
  14590. \DeclareBibliographyOption[boolean]{uniqueprimaryauthor}[true]{%
  14591.   \settoggle{blx@uniqueprimaryauthor}{#1}}
  14592.  
  14593. \DeclareBibliographyOption[boolean]{defernumbers}[true]{%
  14594.   \settoggle{blx@defernumbers}{#1}%
  14595.   \iftoggle{blx@defernumbers}
  14596.    {\setkeys{blx@opt@pre}{labelnumber}%
  14597.      \let\blx@thelabelnumber\blx@addlabelnumber
  14598.      \let\abx@aux@number\blx@aux@number}
  14599.     {\let\blx@thelabelnumber\relax
  14600.     \let\abx@aux@number\@gobblefive}}
  14601.  
  14602. \DeclareBibliographyOption[boolean]{locallabelwidth}[true]{%
  14603.   \blx@key@locallabelwidth{#1}}
  14604.  
  14605. %{<switch>}{<patch>}{<pre>}{<post>}
  14606. \def\blx@patchsection@switch#1#2#3#4{%
  14607.   \AtEndPreamble{%
  14608.     #3%
  14609.     \ifcase#1
  14610.     \or % 1: part
  14611.       \blx@refpatch@part{#2}%
  14612.     \or % 2: chapter
  14613.       \blx@refpatch@chapter{#2}%
  14614.     \or % 3: section
  14615.       \blx@refpatch@sect{section}{#2}{1}%
  14616.     \or % 4: subsection
  14617.       \blx@refpatch@sect{subsection}{#2}{2}%
  14618.     \or % 5: chapter+ = part, chapter
  14619.       \blx@refpatch@part{#2}%
  14620.       \blx@refpatch@chapter{#2}%
  14621.     \or % 6: section+ = part, chapter, section
  14622.       \blx@refpatch@part{#2}%
  14623.       \ifundef\chapter
  14624.         {}
  14625.        {\blx@refpatch@chapter{#2}}%
  14626.       \blx@refpatch@sect{section}{#2}{1}%
  14627.     \or % 7: subsection+ = part, chapter, section, subsection
  14628.       \blx@refpatch@part{#2}%
  14629.       \ifundef\chapter
  14630.         {}
  14631.        {\blx@refpatch@chapter{#2}}%
  14632.       \blx@refpatch@sect{section}{#2}{1}%
  14633.       \blx@refpatch@sect{subsection}{#2}{2}%
  14634.     \fi
  14635.     #4%
  14636.   }%
  14637. }
  14638.  
  14639. \DeclareBibliographyOption[string]{refsection}{%
  14640.   \ifcsdef{blx@opt@refsection@#1}
  14641.    {\letcs\blx@refsecreset@level{blx@opt@refsection@#1}}
  14642.    {\blx@err@invopt{refsection=#1}{}}}
  14643. \csdef{blx@opt@refsection@none}{0}
  14644. \csdef{blx@opt@refsection@part}{1}
  14645. \csdef{blx@opt@refsection@chapter}{2}
  14646. \csdef{blx@opt@refsection@section}{3}
  14647. \csdef{blx@opt@refsection@subsection}{4}
  14648. \csdef{blx@opt@refsection@chapter+}{5}
  14649. \csdef{blx@opt@refsection@section+}{6}
  14650. \csdef{blx@opt@refsection@subsection+}{7}
  14651.  
  14652. \blx@patchsection@switch{\blx@refsecreset@level}{\newrefsection}{}{}
  14653.  
  14654. \DeclareBibliographyOption[string]{refsegment}{%
  14655.   \ifcsdef{blx@opt@refsegment@#1}
  14656.    {\letcs\blx@refsegreset@level{blx@opt@refsegment@#1}}
  14657.    {\blx@err@invopt{refsegment=#1}{}}}
  14658. \csdef{blx@opt@refsegment@none}{0}
  14659. \csdef{blx@opt@refsegment@part}{1}
  14660. \csdef{blx@opt@refsegment@chapter}{2}
  14661. \csdef{blx@opt@refsegment@section}{3}
  14662. \csdef{blx@opt@refsegment@subsection}{4}
  14663. \csdef{blx@opt@refsegment@chapter+}{5}
  14664. \csdef{blx@opt@refsegment@section+}{6}
  14665. \csdef{blx@opt@refsegment@subsection+}{7}
  14666.  
  14667. \blx@patchsection@switch{\blx@refsegreset@level}
  14668.  {\newrefsegment}
  14669.  {\ifnumgreater\blx@refsegreset@level\z@
  14670.     {\ifnumgreater\blx@refsegreset@level\blx@refsecreset@level
  14671.        {}
  14672.        {\blx@err@confopt
  14673.           {refsegment/refsection}
  14674.           {The 'refsegment' option must point to a
  14675.            lower-level\MessageBreak document division
  14676.            than 'refsection'}%
  14677.          \def\blx@refsegreset@level{0}}}
  14678.     {}}
  14679.  {}
  14680.  
  14681. \DeclareBibliographyOption[string]{citereset}{%
  14682.   \ifcsdef{blx@opt@citereset@#1}
  14683.    {\letcs\blx@citereset@level{blx@opt@citereset@#1}}
  14684.    {\blx@err@invopt{citereset=#1}{}}}
  14685. \csdef{blx@opt@citereset@none}{0}
  14686. \csdef{blx@opt@citereset@part}{1}
  14687. \csdef{blx@opt@citereset@chapter}{2}
  14688. \csdef{blx@opt@citereset@section}{3}
  14689. \csdef{blx@opt@citereset@subsection}{4}
  14690. \csdef{blx@opt@citereset@chapter+}{5}
  14691. \csdef{blx@opt@citereset@section+}{6}
  14692. \csdef{blx@opt@citereset@subsection+}{7}
  14693.  
  14694. \blx@patchsection@switch{\blx@citereset@level}{\citereset\blx@inf@creset}{}{}
  14695.  
  14696. \DeclareBibliographyOption[boolean]{bibwarn}[true]{%
  14697.   \ifstrequal{#1}{true}
  14698.    {\def\blx@bbl@thewarn{\blx@bbl@warn}}
  14699.    {\let\blx@bbl@thewarn\@gobble}}
  14700.  
  14701. % Name field options
  14702. \def\do#1{%
  14703.   \DeclareBibliographyOption[boolean]{use#1}[true]{%
  14704.     \settoggle{blx@use#1}{##1}}
  14705.  \DeclareTypeOption[boolean]{use#1}[true]{%
  14706.     \settoggle{blx@use#1}{##1}}
  14707.  \DeclareEntryOption[boolean]{use#1}[true]{%
  14708.     \settoggle{blx@use#1}{##1}}}
  14709. \abx@donames
  14710.  
  14711. % Entry options
  14712. \DeclareBibliographyOption[boolean]{useprefix}[true]{%
  14713.   \settoggle{blx@useprefix}{#1}}
  14714. \DeclareTypeOption[boolean]{useprefix}[true]{%
  14715.   \settoggle{blx@useprefix}{#1}}
  14716. \DeclareEntryOption[boolean]{useprefix}[true]{%
  14717.   \settoggle{blx@useprefix}{#1}}
  14718.  
  14719. \DeclareTypeOption[boolean]{skipbib}[true]{%
  14720.   \settoggle{blx@skipbib}{#1}}
  14721. \DeclareEntryOption[boolean]{skipbib}[true]{%
  14722.   \settoggle{blx@skipbib}{#1}}
  14723.  
  14724. \DeclareTypeOption[boolean]{skipbiblist}[true]{%
  14725.   \settoggle{blx@skipbiblist}{#1}}
  14726. \DeclareEntryOption[boolean]{skipbiblist}[true]{%
  14727.   \settoggle{blx@skipbiblist}{#1}}
  14728.  
  14729. \DeclareTypeOption[boolean]{skiplab}[true]{%
  14730.   \settoggle{blx@skiplab}{#1}}
  14731. \DeclareEntryOption[boolean]{skiplab}[true]{%
  14732.   \settoggle{blx@skiplab}{#1}}
  14733.  
  14734. \DeclareTypeOption[boolean]{dataonly}[true]{%
  14735.   \settoggle{blx@skipbib}{#1}%
  14736.   \settoggle{blx@skipbiblist}{#1}%
  14737.   \settoggle{blx@skiplab}{#1}}
  14738. \DeclareEntryOption[boolean]{dataonly}[true]{%
  14739.   \settoggle{blx@skipbib}{#1}%
  14740.   \settoggle{blx@skipbiblist}{#1}%
  14741.   \settoggle{blx@skiplab}{#1}}
  14742.  
  14743. % Option processor/scheduler
  14744. \DeclareOption*{%
  14745.   \begingroup
  14746.   \def\blx@tempa#1=#2&{#1}%
  14747.   \edef\blx@tempa{%
  14748.     \expandafter\blx@tempa\CurrentOption=&}%
  14749.   \ifcsundef{KV@blx@opt@ldt@\blx@tempa}
  14750.    {\endgroup
  14751.     \eappto\blx@theoptions{\CurrentOption,}}
  14752.    {\edef\blx@tempa{\endgroup
  14753.       \noexpand\setkeys{blx@opt@ldt}{\CurrentOption}}%
  14754.      \blx@tempa}}
  14755.  
  14756. \def\blx@processoptions{%
  14757.   \ifundef\blx@theoptions
  14758.     {}
  14759.    {\begingroup
  14760.     \edef\blx@tempa{\endgroup
  14761.       \noexpand\setkeys{blx@opt@pre}{\blx@theoptions}}%
  14762.      \blx@tempa}}
  14763.  
  14764. %% Initial setup
  14765.  
  14766. % Set defaults
  14767. \setkeys{blx@opt@ldt}{style=numeric}
  14768. \setkeys{blx@opt@pre}{%
  14769.   sorting=nty,sortlocale=auto,sortcase,sortupper,sortcites=false,
  14770.   maxnames=3,minnames=1,maxalphanames=3,minalphanames=1,
  14771.   maxitems=3,minitems=1,mincrossrefs=2,minxrefs=2,useauthor=true,useeditor=true,
  14772.   usetranslator=false,indexing=false,abbreviate=true,dateabbrev=true,dateera=astronomical,
  14773.   backref=false,backrefsetstyle=setonly,pagetracker=false,ibidtracker=false,
  14774.   idemtracker=false,opcittracker=false,loccittracker=false,citetracker=false,
  14775.   citecounter=false,block=none,language=autobib,clearlang=true,autolang=none,
  14776.   date=comp,labeldate=year,origdate=comp,eventdate=comp,urldate=short,
  14777.   autopunct=true,punctfont=false,defernumbers=false,timezeros=true,
  14778.   refsection=none,refsegment=none,citereset=none,hyperref=auto,
  14779.   parentracker,maxparens=3,bibencoding=auto,bibwarn,timezones=false,
  14780.   seconds=false,julian=false,labeltime=24h,locallabelwidth=false}
  14781.  
  14782. % Load Unicode enhancements (only for LuaTeX and XeTeX)
  14783. \ifboolexpr{
  14784.    not test {\ifundef\XeTeXrevision}
  14785.    or
  14786.    not test {\ifundef\luatexversion}}
  14787.  {\blx@inputonce{blx-unicode.def}{enhanced support for Unicode engines}{}{}{}{}}
  14788.  {}
  14789.  
  14790. % Load compatibility code
  14791. \blx@inputonce{blx-compat.def}{compatibility code}{}{}{}{}
  14792.  
  14793. % Restore catcodes
  14794. \blx@catcodes
  14795. \undef\blx@catcodes
  14796.  
  14797. % Process load-time options
  14798. \ProcessOptions*
  14799.  
  14800. % Switch to BibTeX support if requested
  14801. \iftoggle{blx@bibtex}
  14802.  {\blx@inputonce{blx-bibtex.def}{BibTeX backend compatibility}{}{}{}{}}
  14803.  {}
  14804.  
  14805. % Load citation and bibliography styles, configuration file
  14806. \blx@inputonce{biblatex.def}{generic definitions}{}{}{}{}
  14807. \iftoggle{blx@natbib}
  14808.  {\blx@inputonce{blx-natbib.def}{natbib compatibility}{}{}{}{}}
  14809.  {}
  14810. \iftoggle{blx@mcite}
  14811.  {\blx@inputonce{blx-mcite.def}{mcite-like commands}{}{}{}{}}
  14812.  {}
  14813. \RequireBibliographyStyle{\blx@bbxfile}
  14814. \RequireCitationStyle{\blx@cbxfile}
  14815. \blx@secinit
  14816. \citereset
  14817. \blx@inputonce{biblatex.cfg}{configuration file}{}{}{}{}
  14818.  
  14819. % Process preamble options
  14820. \blx@processoptions
  14821.  
  14822. % Deferred setup at end of preamble
  14823. \AtEndPreamble{%
  14824.   \blx@checkoptions@global
  14825.   \c@maxnames\blx@maxcitenames\relax
  14826.   \c@minnames\blx@mincitenames\relax
  14827.   \c@maxitems\blx@maxitems\relax
  14828.   \c@minitems\blx@minitems\relax
  14829.   \togglefalse{abx@bool@xinits}
  14830.  \def\do#1{\iftoggle{abx@bool@#1inits}{\toggletrue{abx@bool@xinits}}{}}
  14831.  \abx@donameparts
  14832.  \iftoggle{abx@bool@xinits}
  14833.     {\ifnumequal\blx@uniquename\blx@opt@uniquename@full
  14834.        {\blx@warn@conflopt{%
  14835.           '<namepart>inits' conflicts with 'uniquename=full'.\MessageBreak
  14836.           Setting 'uniquename=init'}%
  14837.         \setkeys{blx@opt@pre}{uniquename=init}}
  14838.       {}%
  14839.      \ifnumequal\blx@uniquename\blx@opt@uniquename@allfull
  14840.        {\blx@warn@conflopt{%
  14841.           '<namepart>inits' conflicts with 'uniquename=allfull'.\MessageBreak
  14842.           Setting 'uniquename=allinit}%
  14843.         \setkeys{blx@opt@pre}{uniquename=allinit}}
  14844.       {}%
  14845.      \ifnumequal\blx@uniquename\blx@opt@uniquename@minfull
  14846.        {\blx@warn@conflopt{%
  14847.           '<namepart>inits' conflicts with 'uniquename=minfull'.\MessageBreak
  14848.           Setting 'uniquename=mininit}%
  14849.         \setkeys{blx@opt@pre}{uniquename=mininit}}
  14850.       {}}
  14851.    {}%
  14852.   \nottoggle{blx@labeldateparts}
  14853.     {\ifnumequal\blx@uniquelist\blx@opt@uniquelist@minyear
  14854.        {\blx@warn@conflopt{%
  14855.           'uniquelist=minyear' requires 'labeldateparts'.\MessageBreak
  14856.           Setting 'uniquelist=true'}%
  14857.         \setkeys{blx@opt@pre}{uniquelist}}
  14858.       {}}
  14859.    {}%
  14860.     \def\do#1{%
  14861.       \ifcsstring{blx@dateformat@#1}{iso}
  14862.        {\blx@stripfromendinto{#1}{date}\blx@datetype
  14863.         \ifdefstring\blx@dateera{astronomical}{}
  14864.            {\blx@warn@conflopt{%
  14865.               '#1=iso' requires 'dateera=astronomical'.\MessageBreak
  14866.               Setting 'dateera=astrononmical'}%
  14867.             \setkeys{blx@opt@pre}{dateera=astronomical}}%
  14868.           \ifcsstring{blx@timeformat@\blx@datetype time}{24h}%
  14869.            {}
  14870.            {\blx@warn@conflopt{%
  14871.               '#1=iso' requires '\blx@datetype time=24h'.\MessageBreak
  14872.               Setting '\blx@datetype time=24h'}%
  14873.             \setkeys{blx@opt@pre}{\blx@datetype time=24h}}%
  14874.          \iftoggle{blx@julian}
  14875.            {\blx@warn@conflopt{%
  14876.               '#1=iso' requires 'julian=false'.\MessageBreak
  14877.               Setting 'julian=false'}%
  14878.             \setkeys{blx@opt@pre}{julian=false}}
  14879.           {}%
  14880.          \nottoggle{blx@datezeros}
  14881.            {\blx@warn@conflopt{%
  14882.               '#1=iso' requires 'datezeros=true'.\MessageBreak
  14883.               Setting 'datezeros=true'}%
  14884.             \setkeys{blx@opt@pre}{datezeros=true}}
  14885.           {}%
  14886.          \nottoggle{blx@timezeros}
  14887.            {\blx@warn@conflopt{%
  14888.               '#1=iso' requires 'timezeros=true'.\MessageBreak
  14889.               Setting 'timezeros=true'}%
  14890.             \setkeys{blx@opt@pre}{timezeros=true}}
  14891.           {}%
  14892.          \nottoggle{blx@seconds}
  14893.            {\blx@warn@conflopt{%
  14894.               '#1=iso' requires 'seconds=true'.\MessageBreak
  14895.               Setting 'seconds=true'}%
  14896.             \setkeys{blx@opt@pre}{seconds=true}}
  14897.           {}}
  14898.        {}}%
  14899.     \abx@dodates
  14900.     \do{labeldate}}
  14901.  
  14902. \def\blx@checkencoding{%
  14903.   \ifdef\blx@texencoding
  14904.     {\blx@info@noline{%
  14905.        Input encoding '\blx@texencoding' specified}}
  14906.     {\ifundef\inputencodingname
  14907.       {\ifundef\XeTeXrevision
  14908.          {\ifundef\luatexversion
  14909.             {\def\blx@texencoding{ascii}%
  14910.               \blx@info@noline{%
  14911.                 No input encoding detected.\MessageBreak
  14912.                 Assuming '\blx@texencoding'}}
  14913.              {\def\blx@texencoding{utf8}%
  14914.               \blx@info@noline{%
  14915.                 LuaTeX detected.\MessageBreak
  14916.                 Assuming input encoding '\blx@texencoding'}}}
  14917.           {\def\blx@texencoding{utf8}%
  14918.            \blx@info@noline{%
  14919.              XeTeX detected.\MessageBreak
  14920.              Assuming input encoding '\blx@texencoding'}}}
  14921.        {\ifcsdef{blx@inpenc@\inputencodingname}
  14922.          {\letcs\blx@texencoding{blx@inpenc@\inputencodingname}}
  14923.          {\let\blx@texencoding\inputencodingname}%
  14924.         \blx@info@noline{%
  14925.           Input encoding '\blx@texencoding' detected}}}%
  14926.   \ifdef\blx@bibencoding
  14927.     {\ifdefstring\blx@bibencoding{ascii}
  14928.        {\blx@info@noline{%
  14929.           Data encoding '\blx@bibencoding' specified.\MessageBreak
  14930.           No need to reencode data}}
  14931.        {\ifdefstring\blx@bibencoding{auto}
  14932.           {\let\blx@bibencoding\blx@texencoding
  14933.            \blx@info@noline{%
  14934.              Automatic encoding selection.\MessageBreak
  14935.              Assuming data encoding '\blx@bibencoding'}}
  14936.           {\ifdefstrequal\blx@bibencoding\blx@texencoding
  14937.              {\blx@info@noline{%
  14938.                 Data encoding '\blx@bibencoding' specified.\MessageBreak
  14939.                 No need to reencode data}}
  14940.              {\blx@info@noline{%
  14941.                    Data encoding '\blx@bibencoding' specified.\MessageBreak
  14942.                    Backend will reencode on the fly}}}}}
  14943.     {\def\blx@bibencoding{ascii}%
  14944.      \blx@info@noline{%
  14945.         Data encoding not specified.\MessageBreak
  14946.         Assuming '\blx@bibencoding'}}%
  14947.   \ifboolexpr{%
  14948.     togl {blx@safeinputenc}
  14949.    and ( test {\@ifpackageloaded{inputenc}}
  14950.          or
  14951.          test {\@ifpackageloaded{inputenx}} )
  14952.  }
  14953.    {\def\blx@texencoding{ascii}%
  14954.      \blx@info@noline{%
  14955.         Input encoding '\blx@texencoding' forced by\MessageBreak
  14956.         'safeinputenc' option}}
  14957.     {}%
  14958. }
  14959.  
  14960. % Deferred last minute setup
  14961. \AtBeginDocument{%
  14962.   \blx@auxwrite\@mainaux{}{\string\abx@aux@refcontext{\blx@refcontext@context}}
  14963.  \blx@checkencoding
  14964.  \if@filesw
  14965.    \blx@ctrlwrite
  14966.  \fi
  14967.  \blx@bblinput
  14968.  \blx@maxsection\z@
  14969.  \csuse{abx@preamble}%
  14970.   \blx@inf@refsec
  14971.   \blx@inf@refseg}
  14972.  
  14973. \AtEndOfPackage{%
  14974.   % Data model macros are forbidden after package load is finished
  14975.   \def\blx@warn@dm#1{\blx@warning@noline{Data model macro '#1' cannot be used in preamble}}
  14976.  \def\ResetDatamodelEntrytypes{\blx@warn@dm{ResetDatamodelEntrytypes}}
  14977.  \def\ResetDatamodelFields{\blx@warn@dm{ResetDatamodelFields}}
  14978.  \def\ResetDatamodelEntryfields{\blx@warn@dm{ResetDatamodelEntryfields}}
  14979.  \def\ResetDatamodelConstraints{\blx@warn@dm{ResetDatamodelConstraints}}
  14980.  \renewcommand*{\DeclareDatamodelEntrytypes}[2][]{\blx@warn@dm{DeclareDatamodelEntrytypes}}
  14981.  \renewcommand*{\DeclareDatamodelFields}[2][]{\blx@warn@dm{DeclareDatamodelFields}}
  14982.  \renewcommand*{\DeclareDatamodelEntryfields}[2][]{\blx@warn@dm{DeclareDatamodelEntryfields}}
  14983.  \renewcommand*{\DeclareDatamodelConstraints}[2][]{\blx@warn@dm{DeclareDatamodelConstraints}}
  14984.  \renewcommand*{\DeclareDatamodelConstant}[3][]{\blx@warn@dm{DeclareDatamodelConstant}}
  14985.   \AtBeginDocument{%
  14986.     \let\do\undef
  14987.     \blx@dopreamblecmds
  14988.     \let\do\noexpand}}
  14989.  
  14990. \def\BiblatexHungarianWarningOff{\global\let\lbx@hu@loadinfo\@empty}
  14991.  
  14992. \endinput
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement