% $Id: biblatex.def,v 0.9a 2010/03/19 19:52:15 lehman beta $

\ProvidesFile{biblatex.def}
[\abx@rcsid $Id: biblatex.def,v 0.9a 2010/03/19 19:52:15 lehman beta $
 biblatex generic definitions]

% ------------------------------------------------------------------
% FORMATTING COMMANDS
% ------------------------------------------------------------------

% Generic formatting commands and hooks
% ------------------------------------------------------------------

% Used in citations, bibliography, list of shorthands

\newcommand*{\mkbibnamefirst}[1]{#1}
\newcommand*{\mkbibnamelast}[1]{#1}
\newcommand*{\mkbibnameprefix}[1]{#1}
\newcommand*{\mkbibnameaffix}[1]{#1}
\newcommand*{\bibellipsis}{[\textellipsis\unkern]\midsentence}

% Delimiters used in citations, bibliography, list of shorthands

\newcommand*{\multinamedelim}{\addcomma\space}
\newcommand*{\finalnamedelim}{%
  \ifnumgreater{\value{liststop}}{2}{\finalandcomma}{}%
  \addspace\bibstring{and}\space}
\newcommand*{\revsdnamedelim}{}
\newcommand*{\andothersdelim}{\addspace}

\newcommand*{\multilistdelim}{\addcomma\space}
\newcommand*{\finallistdelim}{%
  \ifnumgreater{\value{liststop}}{2}{\finalandcomma}{}%
  \addspace\bibstring{and}\space}
\newcommand*{\andmoredelim}{\addspace}

% Used in citations

\newcommand*{\multicitedelim}{\addsemicolon\space}
\newcommand*{\compcitedelim}{\addcomma\space}
\newcommand*{\supercitedelim}{\addcomma}
\newcommand*{\prenotedelim}{\addspace}
\newcommand*{\postnotedelim}{\addcomma\space}
\newcommand*{\nameyeardelim}{\addspace}

% Used in the bibliography and the list of shorthands

\newcommand*{\newunitpunct}{\addperiod\space}
\newcommand*{\entrysetpunct}{\addsemicolon\space}
\newcommand*{\finentrypunct}{\addperiod}
\newcommand*{\labelnamepunct}{\newunitpunct}
\newcommand*{\subtitlepunct}{\newunitpunct}
\newcommand*{\intitlepunct}{\addcolon\space}
\newcommand*{\bibpagespunct}{\addcomma\space}
\newcommand*{\bibnamedash}{%
  \ifdimless{\leftmargin}{0.75em}
    {\mbox{\textemdash\space}}
    {\makebox[\leftmargin][l]{%
       \ifdimless{\leftmargin}{1.25em}
         {\textendash}
	 {\textemdash}}}}

% \bibsetup is a generic hook controlling the (low-level) layout of
% the bibliography and the list of shorthands. The default
% definition should work fine in most cases.

\newcommand*{\bibsetup}{%
  \interlinepenalty=5000\relax
  \widowpenalty=10000\relax
  \clubpenalty=10000\relax
  \biburlsetup
  \raggedbottom
  \frenchspacing
  \sloppy}

% The penalties above are not specific to biblatex. These are
% low-level TeX features. \interlinepenalty is the penalty assigned
% to page breaks within a paragraph (i.e., in this case, a
% bibliography entry); \clubpenalty is an additional penalty
% assigned to page breaks after the first line of a paragraph;
% \widowpenalty is an additional penalty assigned to page breaks
% before the last line of a paragraph. Note that the value 10000
% means 'infinite' as far as TeX is concerned. Setting a penalty to
% 10000 will unconditionally suppress the respective breakpoint.
%
% The net effect of the above settings is as follows. Breaking a
% bibliography entry across pages is discouraged, but not suppressed
% altogether. If a bibliography entry spans less than four lines,
% TeX will always keep it on one page. If it spans four or more
% lines, it may be broken across pages, provided that there are at
% least two lines on the page before and after the break.
%
% These penalties should normally be used in conjunction with
% \raggedbottom. If you don't like that and remove \raggedbottom
% from the definition of \bibsetup, make sure to provide some
% stretchability between bibliography entries by setting \bibitemsep
% to a suitable value, e.g.:
%
% \setlength{\bibitemsep}{0.5\baselineskip plus 0.5\baselineskip}
%
% Using \frenchspacing in the bibliography is recommended. If you
% want more visual separation, try the package option 'block=space'.
% This will yield better results than \nonfrenchspacing.

% \citesetup is a generic hook for citations.

\newcommand*{\citesetup}{%
  \biburlsetup
  \frenchspacing}

% Local setup for \url; see comments in url.sty for details.

\newcommand*{\biburlsetup}{%
  \Urlmuskip=0mu plus 2mu\relax
  \mathchardef\UrlBreakPenalty=200\relax
  \mathchardef\UrlBigBreakPenalty=100\relax
  \mathchardef\UrlEmergencyPenalty=9000\relax
  \appto\UrlSpecials{%
    \do\0{\mathchar`\0\penalty\UrlEmergencyPenalty}%
    \do\1{\mathchar`\1\penalty\UrlEmergencyPenalty}%
    \do\2{\mathchar`\2\penalty\UrlEmergencyPenalty}%
    \do\3{\mathchar`\3\penalty\UrlEmergencyPenalty}%
    \do\4{\mathchar`\4\penalty\UrlEmergencyPenalty}%
    \do\5{\mathchar`\5\penalty\UrlEmergencyPenalty}%
    \do\6{\mathchar`\6\penalty\UrlEmergencyPenalty}%
    \do\7{\mathchar`\7\penalty\UrlEmergencyPenalty}%
    \do\8{\mathchar`\8\penalty\UrlEmergencyPenalty}%
    \do\9{\mathchar`\9\penalty\UrlEmergencyPenalty}}%
  \def\UrlBreaks{%
    \do\.\do\@\do\/\do\\\do\!\do\_\do\|\do\;\do\>\do\]\do\)\do\}%
    \do\,\do\?\do\'\do\+\do\=\do\#\do\$\do\&\do\*\do\^\do\"}%
  \def\UrlBigBreaks{\do\:\do\-}}

% The above code allows linebreaks after numbers as a last resort.
% This is often the only way to break DOIs. It also allows breaks
% after hyphens and adjusts \Urlmuskip to add some stretchability
% to URLs.

% The default font of the bibliography and the list of shorthands.
% We simply reset the current font to the global defaults.

\newcommand*{\bibfont}{\normalfont\normalsize}

% Some length registers which may be used to fine-tune the
% (high-level) layout of the bibliography.

\setlength{\bibhang}{\parindent}
\setlength{\biblabelsep}{2\labelsep}
\setlength{\bibitemsep}{\itemsep}
\setlength{\bibnamesep}{0pt}
\setlength{\bibinitsep}{0pt}
\setlength{\bibparsep}{0pt}

% Miscellaneous facilities
% ------------------------------------------------------------------

% The counter 'abbrvpenalty' holds the penalty used in short or
% abbreviated bibliography strings. For example, a linebreak in
% expressions such as "et al." or "ed. by" is unfortunate, but should
% still be possible to prevent overfull boxes. We use TeX's
% \hyphenpenalty (normally 50) as the default value. The idea is
% making TeX treat the whole expression as if it were a single,
% hyphenatable word as far as line-breaking is concerned. If you
% dislike such linebreaks, use a higher value. If you do not mind
% them at all, set this counter to zero. If you want to suppress them
% unconditionally, set it to 10000.
\setcounter{abbrvpenalty}{\hyphenpenalty}

% The counter 'highnamepenalty' also holds a penalty affecting the
% line-breaking of names. This penalty is inserted between smaller
% chunks of a name, for example between the first and the middle
% name. The default value is \hyphenpenalty. If you dislike such
% linebreaks, use a higher value. If you do not mind them at all,
% set this counter to zero. If you prefer the traditional BibTeX
% behavior, set it to 10000.
\setcounter{highnamepenalty}{\hyphenpenalty}

% The counter 'lownamepenalty' holds a penalty which affects the
% line-breaking of names. This penalty is inserted between larger
% chunks of a name, for example between the chunk consisting of all
% first names and the last name. The default value is half the
% \hyphenpenalty. If you dislike such linebreaks, use a higher
% value. If you do not mind them at all, set this counter to zero.
\setcounter{lownamepenalty}{\numexpr\hyphenpenalty/2\relax}

% Note that default values assigned to the above counters are
% deliberately very low to prevent overfull boxes. This implies that
% you will hardly notice any effect on line-breaking if the text is
% set justified. If you set these counters to 10000 to suppress the
% respective breakpoints, you will notice their effect but you may
% also be confronted with overfull boxes. Keep in mind that
% line-breaking in the bibliography is often more difficult than in
% the body text and that you can not resort to rephrasing a
% sentence. In some cases it may be preferable to set the entire
% bibliography \raggedright (by modifying \bibsetup) to prevent
% suboptimal linebreaks. In this case, even the very low default
% penalties will make a visible difference.

% File name prefixes for external abstracts and annotations
\newcommand*{\bibabstractprefix}{bibabstract-}
\newcommand*{\bibannotationprefix}{bibannotation-}

% Print acronyms in small caps if possible
\newcommand*{\mkbibacro}[1]{%
  \ifcsundef{\f@encoding/\f@family/\f@series/sc}
    {#1}
    {\textsc{\MakeLowercase{#1}}}}

% ------------------------------------------------------------------
% ADDITIONAL PACKAGE OPTIONS
% ------------------------------------------------------------------

% Style of compressed page ranges in back references

\DeclareBibliographyOption{backrefstyle}{%
  \ifcsdef{abx@opt@pagerefstyle@#1}
    {\letcs\abx@pagerefstyle{abx@opt@pagerefstyle@#1}}
    {\PackageError{biblatex}
       {Option 'backrefstyle=#1' invalid}
       {The option you have supplied is invalid.\MessageBreak
        See the biblatex manual for valid option keys
	and possible values}}}
\newcommand*{\abx@pagerefstyle}{1}
\csdef{abx@opt@pagerefstyle@none}{-1}
\csdef{abx@opt@pagerefstyle@two}{0}
\csdef{abx@opt@pagerefstyle@three}{1}
\csdef{abx@opt@pagerefstyle@two+}{2}
\csdef{abx@opt@pagerefstyle@three+}{3}
\csdef{abx@opt@pagerefstyle@all+}{4}

% arXiv path/format selector
%
% abs    = abstract page
% ps     = PostScript version
% pdf    = PDF version
% format = format selector

\DeclareBibliographyOption{arxiv}{\def\abx@arxivpath{#1}}
\newcommand*{\abx@arxivpath}{abs}

% ------------------------------------------------------------------
% FIELD FORMATS (#1 is the value of the field)
% ------------------------------------------------------------------

% The fallback used by \printfield

\DeclareFieldFormat{default}{#1}

% The default used by \citefield

\DeclareFieldFormat{citefield}{#1}

% Used in citations

\DeclareFieldFormat{citetitle}{\mkbibemph{#1}}
\DeclareFieldFormat[article]{citetitle}{\mkbibquote{#1\isdot}}
\DeclareFieldFormat[inbook]{citetitle}{\mkbibquote{#1\isdot}}
\DeclareFieldFormat[incollection]{citetitle}{\mkbibquote{#1\isdot}}
\DeclareFieldFormat[inproceedings]{citetitle}{\mkbibquote{#1\isdot}}
\DeclareFieldFormat[patent]{citetitle}{\mkbibquote{#1\isdot}}
\DeclareFieldFormat[thesis]{citetitle}{\mkbibquote{#1\isdot}}
\DeclareFieldFormat[unpublished]{citetitle}{\mkbibquote{#1\isdot}}
\DeclareFieldFormat[suppbook]{citetitle}{#1}
\DeclareFieldFormat[suppcollection]{citetitle}{#1}
\DeclareFieldFormat[suppperiodical]{citetitle}{#1}
\DeclareFieldFormat{labelyear}{#1}% = the '1995' part in 'Jones 1995a'
\DeclareFieldFormat{extrayear}{\mknumalph{#1}}% = the 'a' in 'Jones 1995a'
\DeclareFieldFormat{labelalpha}{#1}% = the 'Jon95' part of 'Jon95a'
\DeclareFieldFormat{extraalpha}{\mknumalph{#1}}% = the 'a' in 'Jon95a'
\DeclareFieldFormat{shorthand}{#1\isdot}
\DeclareFieldFormat{shorthandintro}{%
  \ifcapital{\MakeCapital{#1}}{#1}\isdot}
% citation commands
\DeclareFieldFormat{prenote}{#1\isdot}
\DeclareFieldFormat{postnote}{\mkpageprefix[pagination]{#1}}
% multicite commands
\DeclareFieldFormat{multiprenote}{#1\isdot}
\DeclareFieldFormat{multipostnote}{\mkpageprefix[pagination]{#1}}

% Used by \citeurl

\DeclareFieldFormat{citeurl}{\url{#1}}

% Used in the bibliography and the list of shorthands

\DeclareFieldFormat{booktitle}{\mkbibemph{#1}}
\DeclareFieldFormat{chapter}{\bibstring{chapter}~#1}
\DeclareFieldFormat{doi}{%
  \mkbibacro{DOI}\addcolon\space
  \ifhyperref
    {\href{http://dx.doi.org/#1}{\nolinkurl{#1}}}
    {\nolinkurl{#1}}}
\DeclareFieldFormat{edition}{%
  \ifinteger{#1}
    {\mkbibordedition{#1}~\bibstring{edition}}
    {#1\isdot}}
\DeclareFieldFormat{eprint}{%
  \iffieldundef{eprinttype}
    {eprint}
    {\thefield{eprinttype}}%
  \addcolon\space
  \ifhyperref
    {\url{#1}}
    {\nolinkurl{#1}}}
\DeclareFieldFormat{eprint:arxiv}{%
  arXiv\addcolon\space
  \ifhyperref
    {\href{http://arxiv.org/\abx@arxivpath/#1}{\nolinkurl{#1}}}
    {\nolinkurl{#1}}}
\DeclareFieldFormat{eprint:jstor}{%
  JSTOR\addcolon\space
  \ifhyperref
    {\href{http://www.jstor.org/stable/#1}{\nolinkurl{#1}}}
    {\nolinkurl{#1}}}
\DeclareFieldFormat{eprint:pubmed}{%
  PMID\addcolon\space
  \ifhyperref
    {\href{http://www.ncbi.nlm.nih.gov/pubmed/#1}{\nolinkurl{#1}}}
    {\nolinkurl{#1}}}
\DeclareFieldFormat{eprint:googlebooks}{%
  Google Books\addcolon\space
  \ifhyperref
    {\href{http://books.google.com/books?id=#1}{\nolinkurl{#1}}}
    {\nolinkurl{#1}}}
\DeclareFieldFormat{file}{\url{#1}}
\DeclareFieldFormat{isbn}{\mkbibacro{ISBN}\addcolon\space #1}
\DeclareFieldFormat{isrn}{\mkbibacro{ISRN}\addcolon\space #1}
\DeclareFieldFormat{issn}{\mkbibacro{ISSN}\addcolon\space #1}
\DeclareFieldFormat{journaltitle}{\mkbibemph{#1}}
\DeclareFieldFormat{issuetitle}{\mkbibemph{#1}}
\DeclareFieldFormat{maintitle}{\mkbibemph{#1}}
\DeclareFieldFormat{month}{\mkbibmonth{#1}}
\DeclareFieldFormat{note}{#1\isdot}
\DeclareFieldFormat{number}{#1}% number in a series
\DeclareFieldFormat[article]{number}{#1}% number of a journal
\DeclareFieldFormat{pages}{\mkpageprefix[bookpagination]{#1}}
\DeclareFieldFormat{pagetotal}{\mkpagetotal[bookpagination]{#1}}
\DeclareFieldFormat{part}{.#1}% physical part of a logical volume
\DeclareFieldFormat{series}{#1}% publication series
\DeclareFieldFormat[article]{series}{% series of a journal
  \ifinteger{#1}
    {\mkbibordseries{#1}~\bibstring{jourser}}
    {\ifbibstring{#1}{\bibstring{#1}}{#1}}}
\DeclareFieldFormat{pubstate}{\ifbibstring{#1}{\bibstring{#1}}{#1}}
\DeclareFieldFormat{title}{\mkbibemph{#1}}
\DeclareFieldFormat[article]{title}{\mkbibquote{#1\isdot}}
\DeclareFieldFormat[inbook]{title}{\mkbibquote{#1\isdot}}
\DeclareFieldFormat[incollection]{title}{\mkbibquote{#1\isdot}}
\DeclareFieldFormat[inproceedings]{title}{\mkbibquote{#1\isdot}}
\DeclareFieldFormat[patent]{title}{\mkbibquote{#1\isdot}}
\DeclareFieldFormat[thesis]{title}{\mkbibquote{#1\isdot}}
\DeclareFieldFormat[unpublished]{title}{\mkbibquote{#1\isdot}}
\DeclareFieldFormat[suppbook]{title}{#1}
\DeclareFieldFormat[suppcollection]{title}{#1}
\DeclareFieldFormat[suppperiodical]{title}{#1}
\DeclareFieldFormat{type}{\ifbibstring{#1}{\bibstring{#1}}{#1}}
\DeclareFieldFormat{url}{\mkbibacro{URL}\addcolon\space\url{#1}}
\DeclareFieldFormat{urldate}{\mkbibparens{\bibstring{urlseen}\space#1}}
\DeclareFieldFormat{version}{\bibstring{version}~#1}
\DeclareFieldFormat{volume}{\bibstring{volume}~#1}% volume of a book
\DeclareFieldFormat[article]{volume}{#1}% volume of a journal
\DeclareFieldFormat{volumes}{#1~\bibstring{volumes}}

\DeclareFieldAlias[periodical]{number}[article]{number}
\DeclareFieldAlias[periodical]{series}[article]{series}
\DeclareFieldAlias[periodical]{volume}[article]{volume}

% Generic formats for \printtext

\DeclareFieldFormat{emph}{\mkbibemph{#1}}
\DeclareFieldFormat{bold}{\textbf{#1}}
\DeclareFieldFormat{smallcaps}{\textsc{#1}}
\DeclareFieldFormat{parens}{\mkbibparens{#1}}
\DeclareFieldFormat{brackets}{\mkbibbrackets{#1}}
\DeclareFieldFormat{bibhyperref}{\bibhyperref{#1}}
\DeclareFieldFormat{bibhyperlink}{\bibhyperlink{\thefield{entrykey}}{#1}}
\DeclareFieldFormat{bibhypertarget}{\bibhypertarget{\thefield{entrykey}}{#1}}
\DeclareFieldFormat{titlecase}{#1}
\DeclareFieldFormat{noformat}{#1}

% ------------------------------------------------------------------
% LITERAL LIST FORMATS (#1 is the current item)
% ------------------------------------------------------------------

% Formatting directives for literal lists
% ------------------------------------------------------------------

% The fallback used by \printlist

\DeclareListFormat{default}{%
  \usebibmacro{list:delim}{#1}%
  #1\isdot
  \usebibmacro{list:andothers}}

% The default used by \citelist

\DeclareListAlias{citelist}{default}

% Used in the bibliography

\DeclareListFormat{publisher}{%
  \usebibmacro{list:delim}{#1}%
  #1\isdot
  \usebibmacro{list:andothers}}

\DeclareListFormat{language}{%
  \usebibmacro{list:delim}{%
    \ifbibstring{#1}
      {\bibxstring{#1}}
      {\ifbibstring{lang#1}
         {\bibxstring{lang#1}}
         {#1}}}%
  \ifbibstring{#1}
    {\bibstring{#1}}
    {\ifbibstring{lang#1}
       {\bibstring{lang#1}}
       {#1}}%
  \usebibmacro{list:andothers}}

\DeclareListFormat{location}{%
  \usebibmacro{list:delim}{#1}%
  #1\isdot
  \usebibmacro{list:andothers}}

\DeclareListFormat[patent]{location}{%
  \usebibmacro{list:plain}%
  \ifbibstring{#1}{\bibstring{#1}}{#1\isdot}%
  \usebibmacro{list:andothers}}

\DeclareListFormat{pageref}{%
  \ifnumless{\abx@pagerefstyle}{0}
    {\usebibmacro{list:plain}#1}
    {\ifnumequal{\value{listcount}}{1}
       {\usebibmacro{pageref:init}}
       {}%
     \usebibmacro{pageref:comp}{#1}%
     \ifnumequal{\value{listcount}}{\value{liststop}}
       {\usebibmacro{pageref:dump}}
       {}}}

\DeclareListAlias{origlocation}{location}
\DeclareListAlias{origpublisher}{publisher}
\DeclareListAlias{institution}{default}
\DeclareListAlias{organization}{default}

% Auxiliary macros for list formatting directives
% ------------------------------------------------------------------

\newbibmacro*{list:delim}[1]{%
  \ifthenelse{\value{listcount}>\value{liststart}}
    {\ifthenelse{\value{listcount}<\value{liststop}\OR
                 \ifmoreitems}
       {\multilistdelim}
       {\lbx@finallistdelim{#1}}}
    {}}

\newbibmacro*{list:plain}{%
  \ifthenelse{\value{listcount}>\value{liststart}}
    {\multilistdelim}
    {}}

\newbibmacro*{list:andothers}{%
  \ifthenelse{\value{listcount}=\value{liststop}\AND
              \ifmoreitems}
    {\ifnumgreater{\value{liststop}}{1}{\finalandcomma}{}%
     \andmoredelim\bibstring{andmore}}
    {}}

\newbibmacro*{pageref:init}{%
  \let\abx@range@hold=\empty
  \def\abx@range@diff{0}%
  \def\abx@range@prev{-1}%
  \def\abx@range@this{0}%
  \def\abx@range@last{-1}}

\newbibmacro*{pageref:comp}[1]{%
  \numdef\abx@range@prev{\abx@range@prev+1}%
  \ifinteger{#1}
    {\def\abx@range@num{#1}%
     \def\abx@range@this{1}%
     \ifnumequal{\abx@range@this}{\abx@range@last}
       {}
       {\def\abx@range@prev{-1}}}
    {\ifrmnum{#1}
       {\numdef\abx@range@num{\rmntonum{#1}}%
        \def\abx@range@this{2}%
	\ifnumequal{\abx@range@this}{\abx@range@last}
	  {}
	  {\def\abx@range@prev{-1}}}
       {\undef\abx@range@num
        \def\abx@range@this{0}%
	\def\abx@range@prev{-1}}}%
  \ifdef\abx@range@num
    {\ifnumequal{\abx@range@num}{\abx@range@prev}
       {\def\abx@range@hold{#1}%
        \numdef\abx@range@diff{\abx@range@diff+1}}
       {\usebibmacro{pageref:dump}%
	\ifnumgreater{\abx@range@last}{-1}
	  {\multilistdelim}
	  {}%
	\ifhyperref
	  {\hyperlink{page.#1}{#1}}
	  {#1}}%
     \edef\abx@range@prev{\abx@range@num}}
    {\usebibmacro{pageref:dump}%
     \ifnumgreater{\abx@range@last}{-1}
       {\multilistdelim}
       {}%
     \ifhyperref
       {\hyperlink{page.#1}{#1}}
       {#1}%
     \def\abx@range@prev{-1}}%
  \edef\abx@range@last{\abx@range@this}}

\newbibmacro*{pageref:dump}{%
  \ifnumgreater{\abx@range@diff}{0}
    {\ifcase\abx@pagerefstyle\relax % two
       \bibrangedash
       \ifhyperref
	 {\hyperlink{page.\abx@range@hold}{\abx@range@hold}}
	 {\abx@range@hold}%
     \or % three
       \ifnumless{\abx@range@diff}{2}
	 {\multilistdelim}
	 {\bibrangedash}%
       \ifhyperref
	 {\hyperlink{page.\abx@range@hold}{\abx@range@hold}}
	 {\abx@range@hold}%
     \or % two+
       \ifnumless{\abx@range@diff}{2}
	 {\sqspace
	  \ifhyperref
	    {\hyperlink{page.\abx@range@hold}{\bibstring{sequens}}}
	    {\bibstring{sequens}}}
	 {\bibrangedash
	  \ifhyperref
	    {\hyperlink{page.\abx@range@hold}{\abx@range@hold}}
	    {\abx@range@hold}}%
     \or % three+
       \ifnumless{\abx@range@diff}{2}
	 {\sqspace
	  \ifhyperref
	    {\hyperlink{page.\abx@range@hold}{\bibstring{sequens}}}
	    {\bibstring{sequens}}}
	 {\ifnumless{\abx@range@diff}{3}
	    {\sqspace
	     \ifhyperref
	       {\hyperlink{page.\abx@range@hold}{\bibstring{sequentes}}}
	       {\bibstring{sequentes}}}
	    {\bibrangedash
	     \ifhyperref
	       {\hyperlink{page.\abx@range@hold}{\abx@range@hold}}
	       {\abx@range@hold}}}%
     \else % all+
       \ifnumless{\abx@range@diff}{2}
	 {\sqspace
	  \ifhyperref
	    {\hyperlink{page.\abx@range@hold}{\bibstring{sequens}}}
	    {\bibstring{sequens}}}
	 {\sqspace
	  \ifhyperref
	    {\hyperlink{page.\abx@range@hold}{\bibstring{sequentes}}}
	    {\bibstring{sequentes}}}%
     \fi
     \def\abx@range@diff{0}}
    {}}

% ------------------------------------------------------------------
% NAME LIST FORMATS
% ------------------------------------------------------------------

% Argments passed to formatting directives for name lists:
%
% #1 = last name
% #2 = last name (initials)
% #3 = first name
% #4 = first name (initials)
% #5 = name prefix, a.k.a. 'von part'
% #6 = name prefix (initials)
% #7 = name affix, a.k.a. 'junior part'
% #8 = name affix (initials)

% Formatting directives for name lists
% ------------------------------------------------------------------

% The fallback used by \printnames
\DeclareNameFormat{default}{%
  \iffirstinits
    {\usebibmacro{name:first-last}{#1}{#4}{#5}{#7}}
    {\usebibmacro{name:first-last}{#1}{#3}{#5}{#7}}%
  \usebibmacro{name:andothers}}

% The default used by \citename
\DeclareNameAlias{citename}{default}

% Used in all citations

\DeclareNameFormat{labelname}{%
  \ifcase\value{uniquename}%
    \usebibmacro{name:last}{#1}{#3}{#5}{#7}%
  \or
    \ifuseprefix
      {\usebibmacro{name:first-last}{#1}{#4}{#5}{#8}}
      {\usebibmacro{name:first-last}{#1}{#4}{#6}{#8}}%
  \or
    \usebibmacro{name:first-last}{#1}{#3}{#5}{#7}%
  \fi
  \usebibmacro{name:andothers}}

% Used in the bibliography

\DeclareNameFormat{sortname}{%
  \ifnumequal{\value{listcount}}{1}
    {\iffirstinits
       {\usebibmacro{name:last-first}{#1}{#4}{#5}{#7}}
       {\usebibmacro{name:last-first}{#1}{#3}{#5}{#7}}%
     \ifblank{#3#5}
       {}
       {\usebibmacro{name:revsdelim}}}
    {\iffirstinits
       {\usebibmacro{name:first-last}{#1}{#4}{#5}{#7}}
       {\usebibmacro{name:first-last}{#1}{#3}{#5}{#7}}}%
  \usebibmacro{name:andothers}}

% Not used by default

\DeclareNameFormat{initsonly}{%
  \usebibmacro{name:first-last}{#2}{#4}{#6}{#8}%
  \usebibmacro{name:andothers}}

\DeclareNameAlias{author}{default}
\DeclareNameAlias{bookauthor}{author}
\DeclareNameAlias{editor}{default}
\DeclareNameAlias{editora}{editor}
\DeclareNameAlias{editorb}{editor}
\DeclareNameAlias{editorc}{editor}
\DeclareNameAlias{translator}{default}

\DeclareNameAlias{byauthor}{default}
\DeclareNameAlias{bybookauthor}{byauthor}
\DeclareNameAlias{byeditor}{default}
\DeclareNameAlias{byeditora}{byeditor}
\DeclareNameAlias{byeditorb}{byeditor}
\DeclareNameAlias{byeditorc}{byeditor}
\DeclareNameAlias{bytranslator}{default}

\DeclareNameAlias{withcommentator}{default}
\DeclareNameAlias{withannotator}{default}
\DeclareNameAlias{withintroduction}{default}
\DeclareNameAlias{withforeword}{default}
\DeclareNameAlias{withafterword}{default}

% Auxiliary macros for name formatting directives
% ------------------------------------------------------------------

\newbibmacro*{name:last}[4]{%
  \ifuseprefix
    {\usebibmacro{name:delim}{#3#1}%
     \usebibmacro{name:hook}{#3#1}%
     \ifblank{#3}
       {}
       {\ifcapital
          {\mkbibnameprefix{\MakeCapital{#3}}\isdot}
          {\mkbibnameprefix{#3}\isdot}%
        \ifpunctmark{'}{}{\addhighpenspace}}}
    {\usebibmacro{name:delim}{#1}%
     \usebibmacro{name:hook}{#1}}%
  \mkbibnamelast{#1}}%

\newbibmacro*{name:first-last}[4]{%
  \usebibmacro{name:delim}{#2#3#1}%
  \usebibmacro{name:hook}{#2#3#1}%
  \ifblank{#2}{}{\mkbibnamefirst{#2}\isdot\addlowpenspace}%
  \ifblank{#3}{}{%
    \mkbibnameprefix{#3}\isdot
    \ifpunctmark{'}
      {}
      {\ifuseprefix{\addhighpenspace}{\addlowpenspace}}}%
  \mkbibnamelast{#1}\isdot
  \ifblank{#4}{}{\addlowpenspace\mkbibnameaffix{#4}\isdot}}

\newbibmacro*{name:last-first}[4]{%
  \ifuseprefix
    {\usebibmacro{name:delim}{#3#1}%
     \usebibmacro{name:hook}{#3#1}%
     \ifblank{#3}{}{%
       \ifcapital
         {\mkbibnameprefix{\MakeCapital{#3}}\isdot}
	 {\mkbibnameprefix{#3}\isdot}%
       \ifpunctmark{'}{}{\addhighpenspace}}%
     \mkbibnamelast{#1}\isdot
     \ifblank{#4}{}{\addlowpenspace\mkbibnameaffix{#4}\isdot}%
     \ifblank{#2}{}{\addcomma\addlowpenspace\mkbibnamefirst{#2}\isdot}}
    {\usebibmacro{name:delim}{#1}%
     \usebibmacro{name:hook}{#1}%
     \mkbibnamelast{#1}\isdot
     \ifblank{#4}{}{\addlowpenspace\mkbibnameaffix{#4}\isdot}%
     \ifblank{#2#3}{}{\addcomma}%
     \ifblank{#2}{}{\addlowpenspace\mkbibnamefirst{#2}\isdot}%
     \ifblank{#3}{}{\addlowpenspace\mkbibnameprefix{#3}\isdot}}}

\newbibmacro*{name:hook}[1]{%
  \ifnumequal{\value{listcount}}{1}
    {\lbx@initnamehook{#1}}
    {}}

\newbibmacro*{name:delim}[1]{%
  \ifthenelse{\value{listcount}>\value{liststart}}
    {\ifthenelse{\value{listcount}<\value{liststop}\OR
                 \ifmorenames}
       {\multinamedelim}
       {\lbx@finalnamedelim{#1}}}
    {}}

\newbibmacro*{name:revsdelim}{%
  \ifthenelse{\(\value{liststop}=1\AND\ifmorenames\)\OR
                \value{liststop}=2}
    {\revsdnamedelim}
    {}}

\newbibmacro*{name:andothers}{%
  \ifthenelse{\value{listcount}=\value{liststop}\AND
              \ifmorenames}
    {\ifnumgreater{\value{liststop}}{1}{\finalandcomma}{}%
     \andothersdelim\bibstring{andothers}}
    {}}

% ------------------------------------------------------------------
% INDEX FORMATS FOR FIELDS (#1 is the value of the field)
% ------------------------------------------------------------------

% There is no need to test if a field to be indexed is empty because
% \indexfield performs this test implicitly.

% The fallback used by \indexfield

\DeclareIndexFieldFormat{default}{\index{#1}}

% Used in the bibliography and in citations

\DeclareIndexFieldFormat{indextitle}{%
  \usebibmacro{index:title}{\index}{#1}}

\newbibmacro*{index:title}[2]{%
  \usebibmacro{index:field}{#1}{\thefield{indexsorttitle}}{\emph{#2}}}

\newbibmacro*{index:field}[3]{%
  \begingroup
  \protected@edef\theindexentry{%
    \unexpanded{#1}{#2\actualoperator\unexpanded{#3}}}%
  \theindexentry
  \endgroup}

% ------------------------------------------------------------------
% INDEX FORMATS FOR LITERAL LISTS (#1 is the current item)
% ------------------------------------------------------------------

% The fallback used by \indexlist

\DeclareIndexListFormat{default}{\index{#1}}

% ------------------------------------------------------------------
% INDEX FORMATS FOR NAME LISTS
% ------------------------------------------------------------------

% Argments passed to indexing directives for name lists:
%
% #1 = last name
% #2 = last name (initials)
% #3 = first name
% #4 = first name (initials)
% #5 = name prefix, a.k.a 'von part'
% #6 = name prefix (initials)
% #7 = name affix, a.k.a 'junior part'
% #8 = name affix (initials)

% Indexing directives for name lists
% ------------------------------------------------------------------

% The fallback used by \indexnames

\DeclareIndexNameFormat{default}{%
  \usebibmacro{index:name}{\index}{#1}{#3}{#5}{#7}}

% Used in citations

\DeclareIndexNameAlias{labelname}{default}

% Used in the bibliography

\DeclareIndexNameAlias{author}{default}
\DeclareIndexNameAlias{editor}{default}
\DeclareIndexNameAlias{bookauthor}{default}

% Auxiliary macros for name indexing directives
% ------------------------------------------------------------------

% When generating an index entry, we need to test which parts of a
% name are actually available to prevent spurious punctuation and
% spaces. Since those parts which are not available yield an empty
% argument, we can use the \ifblank test from etoolbox.sty to analyze
% the name.
%
% Note that the standard LaTeX \index command simply writes its
% argument to the .idx file without preventing expansion. This means
% that all \ifblank tests are expanded on the way and will not end
% up in the index. The index package, however, prevents expansion.
% This would lead to \ifblank ending up in the .idx file. To avoid
% that, we preprocess the index entry inside an \edef. We use
% \unexpanded to protect the \index command and the actual data from
% expansion. This definition will work with both index.sty and the
% standard indexing facilities.
%
% We also use \ifuseprefix to ensure that the name prefix is handled
% properly. \actualoperator is the so-called actual operator, as
% defined by the 'actual' specifier in the .ist file. The makeindex
% programm will use the part preceeding the \actualoperator
% delimiter for sorting. The part after the delimiter is used as the
% index is printed. Note that this is not specific to biblatex, see
% the makeindex documentation for details.

\newcommand*{\actualoperator}{@}

\newbibmacro*{index:name}[5]{%
  \begingroup
  \ifuseprefix
    {\edef\theindexentry{%
       \unexpanded{#1}{%
         \ifblank{#4}{}{\unexpanded{#4} }%
         \expandonce{\@firstofone #2}% remove spurious braces
         \ifblank{#5}{}{ \unexpanded{#5}}%
         \ifblank{#3}{}{, \unexpanded{#3}}%
         \actualoperator
         \ifblank{#4}{}{\unexpanded{\MakeCapital{#4}} }%
         \unexpanded{#2}%
         \ifblank{#5}{}{ \unexpanded{#5}}%
         \ifblank{#3}{}{, \unexpanded{#3}}}}}
    {\edef\theindexentry{%
       \unexpanded{#1}{%
         \expandonce{\@firstofone #2}% remove spurious braces
         \ifblank{#5}{}{ \unexpanded{#5}}%
         \ifblank{#3#4}{}{,}%
         \ifblank{#3}{}{ \unexpanded{#3}}%
         \ifblank{#4}{}{ \unexpanded{#4}}}}}%
  \theindexentry
  \endgroup}

% ------------------------------------------------------------------
% MACROS FOR LBX FILES
% ------------------------------------------------------------------

\newcommand*{\lbx@initnamehook}[1]{}
\newcommand*{\lbx@finalnamedelim}[1]{\finalnamedelim}
\newcommand*{\lbx@finallistdelim}[1]{\finallistdelim}

\newcommand*{\lbx@fromlang}{%
  \iffieldundef{origlanguage}
    {\unspace}
    {\bibstring{from\thefield{origlanguage}}}}

% ------------------------------------------------------------------
% MISCELLANEOUS
% ------------------------------------------------------------------

% ordinals

\newcommand*{\mkbibordedition}{\mkbibordinal}
\newcommand*{\mkbibordseries}{\mkbibordinal}

% american

\newrobustcmd*{\uspunctuation}{%
  \DeclareQuotePunctuation{.,}%
  \DeclarePunctuationPairs{comma}{*}}
\newrobustcmd*{\stdpunctuation}{%
  \DeclareQuotePunctuation{}%
  \DeclarePunctuationPairs{comma}{*!?}}

% french

\newtoggle{smartof}
\newrobustcmd*{\smartof}{\global\toggletrue{smartof}}
\newrobustcmd*{\forceD}[1]{#1}
\newrobustcmd*{\forceDE}[1]{#1}

\AtBeginDocument{%
  \@ifpackageloaded{babel}
    {\ifdef\AutoSpaceBeforeFDP
       {\newrobustcmd*{\EnsureAutoSpaceBeforeFDP}{%
	  \iflanguage{french}
	    {\AutoSpaceBeforeFDP}
	    {}}%
	\appto\bibsetup{\EnsureAutoSpaceBeforeFDP}%
	\appto\citesetup{\EnsureAutoSpaceBeforeFDP}}
       {}}
    {}}

% spanish

\newcounter{smartand}
\setcounter{smartand}{1}
\newrobustcmd*{\forceY}[1]{#1}
\newrobustcmd*{\forceE}[1]{#1}

% ------------------------------------------------------------------
% PREDEFINED HEADINGS
% ------------------------------------------------------------------

\newcommand*{\abx@classtype}{0}
\@ifclassloaded{article}
 {}
 {\@ifclassloaded{book}
   {\def\abx@classtype{1}}
   {\@ifclassloaded{report}
     {\def\abx@classtype{1}}
     {\@ifclassloaded{scrartcl}
        {\def\abx@classtype{2}}
        {\@ifclassloaded{scrbook}
           {\def\abx@classtype{3}}
           {\@ifclassloaded{scrreprt}
              {\def\abx@classtype{3}}
              {\@ifclassloaded{memoir}
                {\ifartopt
                   \def\abx@classtype{4}%
                 \else
                   \def\abx@classtype{5}%
                 \fi}
                {\ifundef\chapter
                   {}
                   {\def\abx@classtype{1}}}}}}}}}

\ifcase\abx@classtype\relax % article
  \defbibheading{bibliography}[\refname]{%
    \section*{#1}%
    \markboth{\MakeUppercase{#1}}{\MakeUppercase{#1}}}
  \defbibheading{shorthands}[\losname]{%
    \section*{#1}%
    \markboth{\MakeUppercase{#1}}{\MakeUppercase{#1}}}
  \defbibheading{bibintoc}[\refname]{%
    \section*{#1}%
    \addcontentsline{toc}{section}{#1}%
    \markboth{\MakeUppercase{#1}}{\MakeUppercase{#1}}}
  \defbibheading{losintoc}[\losname]{%
    \section*{#1}%
    \addcontentsline{toc}{section}{#1}%
    \markboth{\MakeUppercase{#1}}{\MakeUppercase{#1}}}
  \defbibheading{bibnumbered}[\refname]{%
    \section{#1}%
    \if@twoside\markright{\MakeUppercase{#1}}\fi}
  \defbibheading{losnumbered}[\losname]{%
    \section{#1}%
    \if@twoside\markright{\MakeUppercase{#1}}\fi}
  \defbibheading{subbibliography}[\refname]{%
    \subsection*{#1}}
  \defbibheading{subbibintoc}[\refname]{%
    \subsection*{#1}%
    \addcontentsline{toc}{subsection}{#1}}
  \defbibheading{subbibnumbered}[\refname]{%
    \subsection{#1}}

\or % book/report
  \defbibheading{bibliography}[\bibname]{%
    \chapter*{#1}%
    \markboth{\MakeUppercase{#1}}{\MakeUppercase{#1}}}
  \defbibheading{shorthands}[\losname]{%
    \chapter*{#1}%
    \markboth{\MakeUppercase{#1}}{\MakeUppercase{#1}}}
  \defbibheading{bibintoc}[\bibname]{%
    \chapter*{#1}%
    \addcontentsline{toc}{chapter}{#1}%
    \markboth{\MakeUppercase{#1}}{\MakeUppercase{#1}}}
  \defbibheading{losintoc}[\losname]{%
    \chapter*{#1}%
    \addcontentsline{toc}{chapter}{#1}%
    \markboth{\MakeUppercase{#1}}{\MakeUppercase{#1}}}
  \defbibheading{bibnumbered}[\bibname]{%
    \chapter{#1}%
    \if@twoside\markright{\MakeUppercase{#1}}\fi}
  \defbibheading{losnumbered}[\losname]{%
    \chapter{#1}%
    \if@twoside\markright{\MakeUppercase{#1}}\fi}
  \defbibheading{subbibliography}[\refname]{%
    \section*{#1}%
    \if@twoside\markright{\MakeUppercase{#1}}\fi}
  \defbibheading{subbibintoc}[\refname]{%
    \section*{#1}%
    \addcontentsline{toc}{section}{#1}%
    \if@twoside\markright{\MakeUppercase{#1}}\fi}
  \defbibheading{subbibnumbered}[\refname]{%
    \section{#1}}

\or % scrartcl
  \defbibheading{bibliography}[\refname]{%
    \ifkomabibtotocnumbered
      {\section{#1}}
      {\ifkomabibtotoc
         {\addsec{#1}}
         {\section*{#1}}%
       \markboth{#1}{#1}}}
  \defbibheading{shorthands}[\losname]{%
    \ifkomabibtotocnumbered
      {\section{#1}}
      {\ifkomabibtotoc
         {\addsec{#1}}
         {\section*{#1}}%
       \markboth{#1}{#1}}}
  \defbibheading{bibintoc}[\refname]{%
    \addsec{#1}%
    \markboth{#1}{#1}}
  \defbibheading{losintoc}[\losname]{%
    \addsec{#1}%
    \markboth{#1}{#1}}
  \defbibheading{bibnumbered}[\refname]{%
    \section{#1}%
    \markboth{\sectionmarkformat#1}{\sectionmarkformat#1}}
  \defbibheading{losnumbered}[\losname]{%
    \section{#1}%
    \markboth{\sectionmarkformat#1}{\sectionmarkformat#1}}
  \defbibheading{subbibliography}[\refname]{%
    \subsection*{#1}}
  \defbibheading{subbibintoc}[\refname]{%
    \subsection*{#1}%
    \addcontentsline{toc}{subsection}{#1}}
  \defbibheading{subbibnumbered}[\refname]{%
    \subsection{#1}}

\or % scrbook/scrreprt
  \defbibheading{bibliography}[\bibname]{%
    \ifkomabibtotocnumbered
      {\chapter{#1}}
      {\ifkomabibtotoc
         {\addchap{#1}}
         {\chapter*{#1}}%
       \markboth{#1}{#1}}}
  \defbibheading{shorthands}[\losname]{%
    \ifkomabibtotocnumbered
      {\chapter{#1}}
      {\ifkomabibtotoc
         {\addchap{#1}}
         {\chapter*{#1}}%
       \markboth{#1}{#1}}}
  \defbibheading{bibintoc}[\bibname]{%
    \addchap{#1}%
    \markboth{#1}{#1}}
  \defbibheading{losintoc}[\losname]{%
    \addchap{#1}%
    \markboth{#1}{#1}}
  \defbibheading{bibnumbered}[\bibname]{%
    \chapter{#1}%
    \markboth{\chaptermarkformat#1}{\chaptermarkformat#1}}
  \defbibheading{losnumbered}[\losname]{%
    \chapter{#1}%
    \markboth{\chaptermarkformat#1}{\chaptermarkformat#1}}
  \defbibheading{subbibliography}[\refname]{%
    \section*{#1}%
    \if@twoside\markright{\sectionmarkformat#1}\fi}
  \defbibheading{subbibintoc}[\refname]{%
    \addsec{#1}%
    \markboth{#1}{#1}}
  \defbibheading{subbibnumbered}[\refname]{%
    \section{#1}}

\or % memoir (article)
  \defbibheading{bibliography}[\refname]{%
    \section*{#1}%
    \ifmemoirbibintoc
      {\phantomsection
       \addcontentsline{toc}{section}{#1}}
      {}%
    \markboth{\MakeUppercase{#1}}{\MakeUppercase{#1}}}
  \defbibheading{shorthands}[\losname]{%
    \section*{#1}%
    \ifmemoirbibintoc
      {\phantomsection
       \addcontentsline{toc}{section}{#1}}
      {}%
    \markboth{\MakeUppercase{#1}}{\MakeUppercase{#1}}}
  \defbibheading{bibintoc}[\refname]{%
    \section*{#1}%
    \phantomsection
    \addcontentsline{toc}{section}{#1}%
    \markboth{\MakeUppercase{#1}}{\MakeUppercase{#1}}}
  \defbibheading{losintoc}[\losname]{%
    \section*{#1}%
    \phantomsection
    \addcontentsline{toc}{section}{#1}%
    \markboth{\MakeUppercase{#1}}{\MakeUppercase{#1}}}
  \defbibheading{bibnumbered}[\refname]{%
    \section{#1}}
  \defbibheading{losnumbered}[\losname]{%
    \section{#1}}
  \defbibheading{subbibliography}[\refname]{%
    \subsection*{#1}%
    \ifmemoirbibintoc
      {\phantomsection
       \addcontentsline{toc}{subsection}{#1}}
      {}%
    \if@twoside\markright{\MakeUppercase{#1}}\fi}
  \defbibheading{subbibintoc}[\refname]{%
    \subsection*{#1}%
    \phantomsection
    \addcontentsline{toc}{subsection}{#1}%
    \if@twoside\markright{\MakeUppercase{#1}}\fi}
  \defbibheading{subbibnumbered}[\refname]{%
    \subsection{#1}}

\or % memoir (book)
  \defbibheading{bibliography}[\bibname]{%
    \chapter*{#1}%
    \ifmemoirbibintoc
      {\phantomsection
       \addcontentsline{toc}{chapter}{#1}}
      {}%
    \markboth{\MakeUppercase{#1}}{\MakeUppercase{#1}}}
  \defbibheading{shorthands}[\losname]{%
    \chapter*{#1}%
    \ifmemoirbibintoc
      {\phantomsection
       \addcontentsline{toc}{chapter}{#1}}
      {}%
    \markboth{\MakeUppercase{#1}}{\MakeUppercase{#1}}}
  \defbibheading{bibintoc}[\bibname]{%
    \chapter*{#1}%
    \phantomsection
    \addcontentsline{toc}{chapter}{#1}%
    \markboth{\MakeUppercase{#1}}{\MakeUppercase{#1}}}
  \defbibheading{losintoc}[\losname]{%
    \chapter*{#1}%
    \phantomsection
    \addcontentsline{toc}{chapter}{#1}%
    \markboth{\MakeUppercase{#1}}{\MakeUppercase{#1}}}
  \defbibheading{bibnumbered}[\bibname]{%
    \chapter{#1}%
    \if@twoside\markright{\MakeUppercase{#1}}\fi}
  \defbibheading{losnumbered}[\losname]{%
    \chapter{#1}%
    \if@twoside\markright{\MakeUppercase{#1}}\fi}
  \defbibheading{subbibliography}[\refname]{%
    \section*{#1}%
    \ifmemoirbibintoc
      {\phantomsection
       \addcontentsline{toc}{section}{#1}}
      {}%
    \if@twoside\markright{\MakeUppercase{#1}}\fi}
  \defbibheading{subbibintoc}[\refname]{%
    \section*{#1}%
    \phantomsection
    \addcontentsline{toc}{section}{#1}%
    \if@twoside\markright{\MakeUppercase{#1}}\fi}
  \defbibheading{subbibnumbered}[\refname]{%
    \section{#1}}

\fi

% ------------------------------------------------------------------
% GENERIC CITATION COMMANDS
% ------------------------------------------------------------------

\DeclareCiteCommand{\fullcite}
  {\usebibmacro{prenote}}
  {\usedriver
     {\DeclareNameAlias{sortname}{default}}
     {\thefield{entrytype}}}
  {\multicitedelim}
  {\usebibmacro{postnote}}

\DeclareCiteCommand{\footfullcite}[\mkbibfootnote]
  {\usebibmacro{prenote}}
  {\usedriver
     {\DeclareNameAlias{sortname}{default}}
     {\thefield{entrytype}}}
  {\multicitedelim}
  {\usebibmacro{postnote}}

\DeclareCiteCommand{\citeauthor}
  {\boolfalse{citetracker}%
   \boolfalse{pagetracker}%
   \usebibmacro{prenote}}
  {\ifciteindex
     {\indexnames{labelname}}
     {}%
   \printnames{labelname}}
  {\multicitedelim}
  {\usebibmacro{postnote}}

\DeclareCiteCommand{\citetitle}
  {\boolfalse{citetracker}%
   \boolfalse{pagetracker}%
   \usebibmacro{prenote}}
  {\ifciteindex
     {\indexfield{indextitle}}
     {}%
   \printfield[citetitle]{labeltitle}}
  {\multicitedelim}
  {\usebibmacro{postnote}}

\DeclareCiteCommand*{\citetitle}
  {\boolfalse{citetracker}%
   \boolfalse{pagetracker}%
   \usebibmacro{prenote}}
  {\ifciteindex
     {\indexfield{indextitle}}
     {}%
   \printfield[citetitle]{title}}
  {\multicitedelim}
  {\usebibmacro{postnote}}

\DeclareCiteCommand{\citeyear}
  {\boolfalse{citetracker}%
   \boolfalse{pagetracker}%
   \usebibmacro{prenote}}
  {\printfield{year}}
  {\multicitedelim}
  {\usebibmacro{postnote}}

\DeclareCiteCommand{\citeurl}
  {\boolfalse{citetracker}%
   \boolfalse{pagetracker}%
   \usebibmacro{prenote}}
  {\printfield[citeurl]{url}}
  {\multicitedelim}
  {\usebibmacro{postnote}}

\DeclareCiteCommand{\notecite}
  {\printfield{prenote}%
   \setunit*{\prenotedelim}}
  {\nocite{\thefield{entrykey}}}
  {}
  {\printfield{postnote}}

\DeclareCiteCommand{\pnotecite}[\mkbibparens]
  {\printfield{prenote}%
   \setunit*{\prenotedelim}}
  {\nocite{\thefield{entrykey}}}
  {}
  {\printfield{postnote}}

\DeclareCiteCommand{\fnotecite}[\mkbibfootnote]
  {\printfield{prenote}%
   \setunit*{\prenotedelim}}
  {\nocite{\thefield{entrykey}}}
  {}
  {\printfield{postnote}}

\newrobustcmd*{\volcite}{\volcitecmd\cite}
\newrobustcmd*{\pvolcite}{\volcitecmd\parencite}
\newrobustcmd*{\fvolcite}{\volcitecmd\footcite}
\newrobustcmd*{\ftvolcite}{\volcitecmd\footcitetext}
\newrobustcmd*{\tvolcite}{\volcitecmd\textcite}
\newrobustcmd*{\avolcite}{\volcitecmd\autocite}

\newrobustcmd*{\Cite}{\bibsentence\cite}
\newrobustcmd*{\Parencite}{\bibsentence\parencite}
\newrobustcmd*{\Footcite}{\footcite}
\newrobustcmd*{\Footcitetext}{\footcitetext}
\newrobustcmd*{\Textcite}{\bibsentence\textcite}
\newrobustcmd*{\Citeauthor}{\bibsentence\citeauthor}
\newrobustcmd*{\Citetitle}{\bibsentence\citetitle}

\newrobustcmd*{\Volcite}{\volcitecmd\Cite}
\newrobustcmd*{\Pvolcite}{\volcitecmd\Parencite}
\newrobustcmd*{\Fvolcite}{\volcitecmd\Footcite}
\newrobustcmd*{\Ftvolcite}{\volcitecmd\Footcitetext}
\newrobustcmd*{\Tvolcite}{\volcitecmd\Textcite}
\newrobustcmd*{\Avolcite}{\volcitecmd\Autocite}

\newrobustcmd*{\Notecite}{\bibsentence\notecite}
\newrobustcmd*{\Pnotecite}{\bibsentence\pnotecite}
\newrobustcmd*{\Fnotecite}{\fnotecite}

\DeclareMultiCiteCommand{\cites}{\cite}{\multicitedelim}
\DeclareMultiCiteCommand{\parencites}[\mkbibparens]{\parencite}{\multicitedelim}
\DeclareMultiCiteCommand{\footcites}[\mkbibfootnote]{\footcite}{\multicitedelim}
\DeclareMultiCiteCommand{\footcitetexts}[\mkbibfootnotetext]{\footcitetext}{\multicitedelim}
\DeclareMultiCiteCommand{\supercites}[\mkbibsuperscript]{\supercite}{\supercitedelim}
\DeclareMultiCiteCommand{\textcites}{\textcite}{\multicitedelim}

\newrobustcmd*{\Cites}{\bibsentence\cites}
\newrobustcmd*{\Parencites}{\bibsentence\parencites}
\newrobustcmd*{\Footcites}{\footcites}
\newrobustcmd*{\Footcitetexts}{\footcitetexts}
\newrobustcmd*{\Textcites}{\bibsentence\textcites}

\DeclareAutoCiteCommand{plain}{\cite}{\cites}
\DeclareAutoCiteCommand{inline}{\parencite}{\parencites}
\DeclareAutoCiteCommand{footnote}[l]{\footcite}{\footcites}
\DeclareAutoCiteCommand{superscript}[l]{\supercite}{\supercites}

\newrobustcmd*{\Autocite}{\bibsentence\autocite}
\newrobustcmd*{\Autocites}{\bibsentence\autocites}

% ------------------------------------------------------------------
% GENERIC CITATION MACROS
% ------------------------------------------------------------------

\newbibmacro*{citeindex}{%
  \ifciteindex
    {\indexnames{labelname}%
     \indexfield{indextitle}}
    {}}

\newbibmacro*{shorthandintro}{%
  \iffieldundef{shorthandintro}
    {\iffieldundef{shorthand}
       {}
       {\setunit{\addspace}%
        \printtext[parens]{%
          \bibstring{citedas}\space
          \printfield{shorthand}}}}
    {\setunit{\addspace}%
     \printtext[parens]{\printfield{shorthandintro}}}}

% citation commands

\newbibmacro*{prenote}{%
  \iffieldundef{prenote}
    {}
    {\printfield{prenote}%
     \setunit{\prenotedelim}}}

\newbibmacro*{postnote}{%
  \iffieldundef{postnote}
    {}
    {\setunit{\postnotedelim}%
     \printfield{postnote}}}

% multicite commands

\newbibmacro*{multiprenote}{%
  \iffieldundef{multiprenote}
    {}
    {\printfield{multiprenote}%
     \prenotedelim}}

\newbibmacro*{multipostnote}{%
  \iffieldundef{multipostnote}
    {}
    {\postnotedelim
     \printfield{multipostnote}}}

% ------------------------------------------------------------------
% GENERIC BIBLIOGRAPHY MACROS
% ------------------------------------------------------------------

\newbibmacro*{bibindex}{%
  \ifbibindex
    {\indexnames{labelname}%
     \indexfield{indextitle}}
    {}}

\newbibmacro*{author/editor}{%
  \ifthenelse{\ifuseauthor\AND\NOT\ifnameundef{author}}
    {\usebibmacro{author}}
    {\usebibmacro{editor}}}

\newbibmacro*{author/editor+others}{%
  \ifthenelse{\ifuseauthor\AND\NOT\ifnameundef{author}}
    {\usebibmacro{author}}
    {\usebibmacro{editor+others}}}

\newbibmacro*{author/translator}{%
  \ifthenelse{\ifuseauthor\AND\NOT\ifnameundef{author}}
    {\usebibmacro{author}}
    {\usebibmacro{translator}}}

\newbibmacro*{author/translator+others}{%
  \ifthenelse{\ifuseauthor\AND\NOT\ifnameundef{author}}
    {\usebibmacro{author}}
    {\usebibmacro{translator+others}}}

\newbibmacro*{author/editor/translator}{%
  \ifthenelse{\ifuseauthor\AND\NOT\ifnameundef{author}}
    {\usebibmacro{author}}
    {\ifthenelse{\ifuseeditor\AND\NOT\ifnameundef{editor}}
       {\usebibmacro{editor}}
       {\usebibmacro{translator}}}}

\newbibmacro*{author/editor+others/translator+others}{%
  \ifthenelse{\ifuseauthor\AND\NOT\ifnameundef{author}}
    {\usebibmacro{author}}
    {\ifthenelse{\ifuseeditor\AND\NOT\ifnameundef{editor}}
       {\usebibmacro{editor+others}}
       {\usebibmacro{translator+others}}}}

\newbibmacro*{author}{%
  \ifthenelse{\ifuseauthor\AND\NOT\ifnameundef{author}}
    {\printnames{author}%
     \iffieldundef{authortype}
       {}
       {\setunit{\addcomma\space}%
	\usebibmacro{authorstrg}}}
    {}}

\newbibmacro*{editor}{%
  \ifthenelse{\ifuseeditor\AND\NOT\ifnameundef{editor}}
    {\printnames{editor}%
     \setunit{\addcomma\space}%
     \usebibmacro{editorstrg}%
     \clearname{editor}}
    {}}

\newbibmacro*{editor+others}{%
  \ifthenelse{\ifuseeditor\AND\NOT\ifnameundef{editor}}
    {\printnames{editor}%
     \setunit{\addcomma\space}%
     \usebibmacro{editor+othersstrg}%
     \clearname{editor}}
    {}}

\newbibmacro*{translator}{%
  \ifthenelse{\ifusetranslator\AND\NOT\ifnameundef{translator}}
    {\printnames{translator}%
     \setunit{\addcomma\space}%
     \usebibmacro{translatorstrg}%
     \clearname{translator}}
    {}}

\newbibmacro*{translator+others}{%
  \ifthenelse{\ifusetranslator\AND\NOT\ifnameundef{translator}}
    {\printnames{translator}%
     \setunit{\addcomma\space}%
     \usebibmacro{translator+othersstrg}%
     \clearname{translator}}
    {}}

\newbibmacro*{authorstrg}{%
  \iffieldundef{authortype}
    {}
    {\ifthenelse{\value{author}>1\OR\ifandothers{author}}
       {\bibstring{\thefield{authortype}s}}
       {\bibstring{\thefield{authortype}}}}}

\newbibmacro*{editorstrg}{%
  \iffieldundef{editortype}
    {\ifthenelse{\value{editor}>1\OR\ifandothers{editor}}
       {\bibstring{editors}}
       {\bibstring{editor}}}
    {\ifthenelse{\value{editor}>1\OR\ifandothers{editor}}
       {\bibstring{\thefield{editortype}s}}
       {\bibstring{\thefield{editortype}}}}}

\newbibmacro*{editor+othersstrg}{%
  \iffieldundef{editortype}
    {\ifthenelse{\value{editor}>1\OR\ifandothers{editor}}
       {\def\abx@tempa{editors}}
       {\def\abx@tempa{editor}}}
    {\ifthenelse{\value{editor}>1\OR\ifandothers{editor}}
       {\edef\abx@tempa{\thefield{editortype}s}}
       {\edef\abx@tempa{\thefield{editortype}}}}%
  \let\abx@tempb=\empty
  \ifnamesequal{editor}{translator}
    {\appto\abx@tempa{tr}%
     \appto\abx@tempb{\clearname{translator}}}
    {}%
  \ifnamesequal{editor}{commentator}
    {\appto\abx@tempa{co}%
     \appto\abx@tempb{\clearname{commentator}}}
    {\ifnamesequal{editor}{annotator}
       {\appto\abx@tempa{an}%
	\appto\abx@tempb{\clearname{annotator}}}
       {}}%
  \ifnamesequal{editor}{introduction}
    {\appto\abx@tempa{in}%
     \appto\abx@tempb{\clearname{introduction}}}
    {\ifnamesequal{editor}{foreword}
       {\appto\abx@tempa{fo}%
	\appto\abx@tempb{\clearname{foreword}}}
       {\ifnamesequal{editor}{afterword}
          {\appto\abx@tempa{af}%
           \appto\abx@tempb{\clearname{afterword}}}
          {}}}%
  \ifbibxstring{\abx@tempa}
    {\bibstring{\abx@tempa}%
     \abx@tempb}
    {\usebibmacro{editorstrg}}}

\newbibmacro*{translatorstrg}{%
  \ifthenelse{\value{translator}>1\OR\ifandothers{translator}}
    {\bibstring{translators}}
    {\bibstring{translator}}}

\newbibmacro*{translator+othersstrg}{%
  \ifthenelse{\value{translator}>1\OR\ifandothers{translator}}
    {\def\abx@tempa{translators}}
    {\def\abx@tempa{translator}}%
  \ifnamesequal{translator}{commentator}
    {\appto\abx@tempa{co}%
     \clearname{commentator}}
    {\ifnamesequal{translator}{annotator}
       {\appto\abx@tempa{an}%
	\clearname{annotator}}
       {}}%
  \ifnamesequal{translator}{introduction}
    {\appto\abx@tempa{in}%
     \clearname{introduction}}
    {\ifnamesequal{translator}{foreword}
       {\appto\abx@tempa{fo}%
	\clearname{foreword}}
       {\ifnamesequal{translator}{afterword}
          {\appto\abx@tempa{af}%
           \clearname{afterword}}
          {}}}%
  \bibstring{\abx@tempa}}

\newbibmacro*{byauthor}{%
  \ifthenelse{\ifuseauthor\OR\ifnameundef{author}}
    {}
    {\usebibmacro{bytypestrg}{author}{author}%
     \setunit{\addspace}%
     \printnames[byauthor]{author}}}

\newbibmacro*{bybookauthor}{%
  \ifnamesequal{author}{bookauthor}
    {}
    {\printnames{bookauthor}}}

\newbibmacro*{byeditor}{%
  \ifnameundef{editor}
    {}
    {\usebibmacro{bytypestrg}{editor}{editor}%
     \setunit{\addspace}%
     \printnames[byeditor]{editor}%
     \newunit}%
  \usebibmacro{byeditorx}}

\newbibmacro*{byeditorx}{%
  \ifnameundef{editora}
    {}
    {\usebibmacro{bytypestrg}{editora}{editor}%
     \setunit{\addspace}%
     \printnames[byeditora]{editora}%
     \newunit}%
  \ifnameundef{editorb}
    {}
    {\usebibmacro{bytypestrg}{editorb}{editor}%
     \setunit{\addspace}%
     \printnames[byeditorb]{editorb}%
     \newunit}%
  \ifnameundef{editorc}
    {}
    {\usebibmacro{bytypestrg}{editorc}{editor}%
     \setunit{\addspace}%
     \printnames[byeditorc]{editorc}%
     \newunit}}

\newbibmacro*{bytranslator}{%
  \ifnameundef{translator}
    {}
    {\bibstring{bytranslator}%
     \setunit{\addspace}%
     \printnames[bytranslator]{translator}}}

\newbibmacro*{byholder}{%
  \printnames{holder}}

\newbibmacro*{byeditor+others}{%
  \ifnameundef{editor}
    {}
    {\usebibmacro{byeditor+othersstrg}%
     \setunit{\addspace}%
     \printnames[byeditor]{editor}%
     \clearname{editor}%
     \newunit}%
  \usebibmacro{byeditorx}%
  \usebibmacro{bytranslator+others}}

\newbibmacro*{bytranslator+others}{%
  \ifnameundef{translator}
    {}
    {\usebibmacro{bytranslator+othersstrg}%
     \setunit{\addspace}%
     \printnames[bytranslator]{translator}%
     \clearname{translator}%
     \newunit}%
  \usebibmacro{withothers}}

\newbibmacro*{bytypestrg}[2]{%
  \iffieldundef{#1type}
    {\bibstring{by#2}}
    {\bibstring{by\thefield{#1type}}}}

\newbibmacro*{byeditor+othersstrg}{%
  \iffieldundef{editortype}
    {\def\abx@tempa{byeditor}}
    {\edef\abx@tempa{by\thefield{editortype}}}%
  \let\abx@tempb=\empty
  \ifnamesequal{editor}{translator}
    {\appto\abx@tempa{tr}%
     \appto\abx@tempb{\clearname{translator}}}
    {}%
  \ifnamesequal{editor}{commentator}
    {\appto\abx@tempa{co}%
     \appto\abx@tempb{\clearname{commentator}}}
    {\ifnamesequal{editor}{annotator}
       {\appto\abx@tempa{an}%
        \appto\abx@tempb{\clearname{annotator}}}
       {}}%
  \ifnamesequal{editor}{introduction}
    {\appto\abx@tempa{in}%
     \appto\abx@tempb{\clearname{introduction}}}
    {\ifnamesequal{editor}{foreword}
       {\appto\abx@tempa{fo}%
        \appto\abx@tempb{\clearname{foreword}}}
       {\ifnamesequal{editor}{afterword}
          {\appto\abx@tempa{af}%
           \appto\abx@tempb{\clearname{afterword}}}
          {}}}%
  \ifbibxstring{\abx@tempa}
    {\bibstring{\abx@tempa}%
     \abx@tempb}
    {\usebibmacro{bytypestrg}{editor}{editor}}}

\newbibmacro*{bytranslator+othersstrg}{%
  \def\abx@tempa{bytranslator}%
  \ifnamesequal{translator}{commentator}
    {\appto\abx@tempa{co}%
     \clearname{commentator}}
    {\ifnamesequal{translator}{annotator}
       {\appto\abx@tempa{an}%
	\clearname{annotator}}
       {}}%
  \ifnamesequal{translator}{introduction}
    {\appto\abx@tempa{in}%
     \clearname{introduction}}
    {\ifnamesequal{translator}{foreword}
       {\appto\abx@tempa{fo}%
	\clearname{foreword}}
       {\ifnamesequal{translator}{afterword}
          {\appto\abx@tempa{af}%
           \clearname{afterword}}
          {}}}%
  \bibstring{\abx@tempa}}

\newbibmacro*{withcommentator}{%
  \ifnameundef{commentator}
    {}
    {\bibstring{withcommentator}%
     \setunit{\addspace}%
     \printnames[withcommentator]{commentator}}}

\newbibmacro*{withannotator}{%
  \ifnameundef{annotator}
    {}
    {\bibstring{withannotator}%
     \setunit{\addspace}%
     \printnames[withannotator]{annotator}}}

\newbibmacro*{withintroduction}{%
  \ifnameundef{introduction}
    {}
    {\bibstring{withintroduction}%
     \setunit{\addspace}%
     \printnames[withintroduction]{introduction}}}

\newbibmacro*{withforeword}{%
  \ifnameundef{foreword}
    {}
    {\bibstring{withforeword}%
     \setunit{\addspace}%
     \printnames[withforeword]{foreword}}}

\newbibmacro*{withafterword}{%
  \ifnameundef{afterword}
    {}
    {\bibstring{withafterword}%
     \setunit{\addspace}%
     \printnames[withafterword]{afterword}}}

\newbibmacro*{withothers}{%
  \usebibmacro{withcommentator}%
  \clearname{commentator}%
  \newunit
  \usebibmacro{withannotator}%
  \clearname{annotator}%
  \newunit
  \usebibmacro{withintroduction}%
  \clearname{introduction}%
  \newunit
  \usebibmacro{withforeword}%
  \clearname{foreword}%
  \newunit
  \usebibmacro{withafterword}
  \clearname{afterword}}

\newbibmacro*{title}{%
  \ifthenelse{\iffieldundef{title}\AND\iffieldundef{subtitle}}
    {}
    {\printtext[title]{%
       \printfield[titlecase]{title}%
       \setunit{\subtitlepunct}%
       \printfield[titlecase]{subtitle}}%
     \newunit}%
  \printfield{titleaddon}}

\newbibmacro*{booktitle}{%
  \ifthenelse{\iffieldundef{booktitle}\AND\iffieldundef{booksubtitle}}
    {}
    {\printtext[booktitle]{%
       \printfield[titlecase]{booktitle}%
       \setunit{\subtitlepunct}%
       \printfield[titlecase]{booksubtitle}}%
     \newunit}%
  \printfield{booktitleaddon}}

\newbibmacro*{maintitle}{%
  \ifthenelse{\iffieldundef{maintitle}\AND\iffieldundef{mainsubtitle}}
    {}
    {\printtext[maintitle]{%
       \printfield[titlecase]{maintitle}%
       \setunit{\subtitlepunct}%
       \printfield[titlecase]{mainsubtitle}}%
     \newunit}%
  \printfield{maintitleaddon}}

\newbibmacro*{journal}{%
  \iffieldundef{journaltitle}
    {}
    {\printtext[journaltitle]{%
       \printfield[titlecase]{journaltitle}%
       \setunit{\subtitlepunct}%
       \printfield[titlecase]{journalsubtitle}}}}

\newbibmacro*{periodical}{%
  \iffieldundef{title}
    {}
    {\printtext[title]{%
       \printfield[titlecase]{title}%
       \setunit{\subtitlepunct}%
       \printfield[titlecase]{subtitle}}}}

\newbibmacro*{issue}{%
  \iffieldundef{issuetitle}
    {}
    {\printtext[issuetitle]{%
       \printfield[titlecase]{issuetitle}%
       \setunit{\subtitlepunct}%
       \printfield[titlecase]{issuesubtitle}}}}

\newbibmacro*{in:}{%
  \printtext{%
    \bibstring{in}\intitlepunct}}

\newbibmacro*{date}{\printdate}

\newbibmacro*{url+urldate}{%
  \printfield{url}%
  \iffieldundef{urlyear}
    {}
    {\setunit*{\addspace}%
     \printtext[urldate]{\printurldate}}}

\newbibmacro*{pageref}{%
  \iflistundef{pageref}
    {}
    {\printtext[parens]{%
       \ifnumgreater{\value{pageref}}{1}
         {\bibstring{backrefpages}\ppspace}
	 {\bibstring{backrefpage}\ppspace}%
       \printlist[pageref][-\value{listtotal}]{pageref}}}}

\newbibmacro*{eprint}{%
  \iffieldundef{eprinttype}
    {\printfield{eprint}}
    {\printfield[eprint:\strfield{eprinttype}]{eprint}}}

\newbibmacro*{annotation}{%
  \iffieldundef{annotation}
    {\printfile[annotation]{\bibannotationprefix\thefield{entrykey}.tex}}
    {\printfield{annotation}}}

\newbibmacro*{abstract}{%
  \iffieldundef{abstract}
    {\printfile[abstract]{\bibabstractprefix\thefield{entrykey}.tex}}
    {\printfield{abstract}}}

\endinput
