% This is a biblatex citation style file, adapted from Lehman's
% authortitle-cverb.cbx.  It is heavily modified, with the intention
% of providing footnote citations and a bibliography formatted
% according to the specifications of the Chicago Manual of Style.

\ProvidesFile{chicago-notes16.cbx}[2022/11/16 v 3.18b biblatex citation style]

%%%% Biblatex initialization + Chicago options + Toggles %%%%

\newbool{cms:bracket}% Date-handling booleans
\newbool{cms:extraparens}
\newbool{cms:comma}
\newbool{cms:nd}

\ifdef{\ExplSyntaxOff}{}{\RequirePackage{xparse}\RequirePackage{expl3}}%

\ExplSyntaxOn%

\cs_if_exist:NTF \__text_change_case_switch_titleonly:nnNnnnn
{}
{\cs_new:Npn \__text_change_case_switch_titleonly:nnNnnnn #1#2#3#4#5#6#7
  {
    \__text_change_case_store:n {#7}
    \__text_change_case_break:w
  }
}

\ExplSyntaxOff

\providecommand*{\mkibid}[1]{#1}

\providetoggle{cms@oneyear}% Needed for author-date
\providetoggle{cms@reprint}% ditto
\providetoggle{cms@switchdates}% ditto

\providetoggle{cms@jrcomma}% For comma before Jr./Sr.

\providetoggle{cms@url}% These are for the field-exclusion options
\providetoggle{cms@urltime}% 17th ed.
\providetoggle{cms@doi}
\providetoggle{cms@doionly}
\providetoggle{cms@eprint}
\providetoggle{cms@isbn}
\providetoggle{cms@numbermonth}
\providetoggle{cms@bookpages}
\providetoggle{cms@hidevolumes}% Modify volume fix
\providetoggle{cms@bookseries}
\providetoggle{cms@notefield}
\providetoggle{cms@addendum}
\providetoggle{cms@comprange}
\providetoggle{cms@compyears}
\providetoggle{cms@modpostnote}
\providetoggle{cms@url@innotes}
\providetoggle{cms@ukord}

\providetoggle{cms@bc}% Attempt to provide correct dateera handling
\providetoggle{cms@alwaysrange}% Turns off decade and century handling
\providetoggle{cms@decaderange}% Only turns off decade handling
\providetoggle{cms@centuryrange}% Only turns off century handling
\providetoggle{cms@nodatebrackets}% For brackets in uncertain & circa
\providetoggle{cms@noyearbrackets}%
\providetoggle{cms@nodates}%

\providetoggle{cms@strict}
\providetoggle{cms@headlessnote}
\providetoggle{cms@origcite}
\providetoggle{cms@fullnote}
\providetoggle{cms@shortnote}
\providetoggle{cms@allshort}
\providetoggle{cms@noibid}
\providetoggle{cms@noidem}
\providetoggle{cms@namedash}
\providetoggle{cms@usecompiler}
\providetoggle{cms@shorthandibid}
\providetoggle{cms@printshhand}
\providetoggle{cms@fullshhand}
\providetoggle{cms@inheritshhand}
\providetoggle{cms@firstshort}
\providetoggle{cms@origpublished}
\providetoggle{cms@loccit}
\providetoggle{cms@annotation}
\providetoggle{cms@postposit}
\providetoggle{cms@legalnotes}% For legal types
\providetoggle{cms@supranotes}% Ditto
\providetoggle{cms@noneshort}% Ditto
\providetoggle{cms@vol}
\providetoggle{cms@postvol}
\providetoggle{cms@usedvol}
\providetoggle{cms@citecrossref}
\providetoggle{cms@bibcrossref}
\providetoggle{cms@bookcitexref}
\providetoggle{cms@bookbibxref}
\providetoggle{cms@xrefvol}
\providetoggle{cms@xrefpart}
\providetoggle{cms@omitxrefdate}
\providetoggle{cms@xrefurl}
\providetoggle{cms@related}
\providetoggle{cms@citerel}
\providetoggle{cms@gencite}
\providetoggle{cms@genallnames}

\AtEveryCitekey{%
  \iffieldundef{userc}%
  {}%
  {\nocite{\thefield{userc}}}%
  \global\togglefalse{cms@loccit}%
  \global\csundef{@cmsst}%
  \iffieldequalstr{pubstate}{reprint}%
  {\toggletrue{cms@reprint}}%
  {\togglefalse{cms@reprint}}%
  \ifboolexpr{%
    test {\iffieldundef{origyear}}%
    or
    test {\iffieldundef{year}}%
    or
    not test {\iffieldint{year}}%
    or
    not test {\iffieldint{origyear}}%
    or
    togl {cms@switchdates}%
  }%
  {}%
  {\ifboolexpr{% Needed for open-ended ranges
      test {\iffieldundef{endyear}}%
      or
      not test {\iffieldnum{endyear}}%
    }%
    {\ifthenelse{\thefield{origyear}>\thefield{year}}%
      {\toggletrue{cms@switchdates}}%
      {}}%
    {\ifthenelse{\thefield{origyear}>\thefield{endyear}}%
      {\toggletrue{cms@switchdates}}%
      {}}}}%

\protected\def\cms@warning@noline#1{%
  \begingroup
  \blx@safe@actives
  \PackageWarningNoLine{biblatex-chicago}{#1}%
  \endgroup}

%% These are options for extended date attributes

\DeclareBiblatexOption{global,entry}[boolean]{alwaysrange}[true]{%
  \settoggle{cms@alwaysrange}{#1}}%

\DeclareBiblatexOption{global,entry}[boolean]{decaderange}[true]{%
  \settoggle{cms@decaderange}{#1}}%

\DeclareBiblatexOption{global,entry}[boolean]{centuryrange}[true]{%
  \settoggle{cms@centuryrange}{#1}}%

\DeclareBiblatexOption{global,type,entry}[boolean]{nodatebrackets}[true]{%
  \settoggle{cms@nodatebrackets}{#1}}%

\DeclareBiblatexOption{global,type,entry}[boolean]{noyearbrackets}[true]{%
  \settoggle{cms@noyearbrackets}{#1}}%

\DeclareBiblatexOption{global,type,entry}[boolean]{nodates}[true]{%
  \settoggle{cms@nodates}{#1}}%

\DeclareBiblatexOption{global,entry}[boolean]{genallnames}[true]{%
  \settoggle{cms@genallnames}{#1}}

\DeclareBibliographyOption{annotation}[true]{%
  \global\toggletrue{cms@annotation}}

\DeclareBibliographyOption[boolean]{noibid}[true]{%
  \global\toggletrue{cms@noibid}}

\DeclareBibliographyOption[boolean]{dashed}[true]{%
  \settoggle{cms@namedash}{#1}}

\DeclareBibliographyOption[boolean]{short}[true]{%
  \global\settoggle{cms@allshort}{#1}}

\DeclareBibliographyOption[boolean]{legalnotes}[true]{%
  \global\settoggle{cms@legalnotes}{#1}}

\DeclareBiblatexOption{global,entry}[boolean]{supranotes}[true]{%
  \settoggle{cms@supranotes}{#1}}

\DeclareBiblatexOption{global,type,entry}[boolean]{noneshort}[true]{%
  \settoggle{cms@noneshort}{#1}}

\DeclareBibliographyOption[boolean]{shorthandibid}[true]{%
  \global\toggletrue{cms@shorthandibid}}

\DeclareBibliographyOption[boolean]{shorthandfull}[true]{%
  \settoggle{cms@fullshhand}{#1}}

\DeclareBibliographyOption[boolean]{inheritshorthand}[true]{%
  \settoggle{cms@inheritshhand}{#1}%
  \iftoggle{cms@inheritshhand}%
  {\DeclareDataInheritance{*}{*}{%
  \inherit{shorthand}{shorthand}
  \inherit{shorthandintro}{shorthandintro}
  }}%
  {}}%

\DeclareBiblatexOption{global,entry}[boolean]{shorthandfirst}[true]{%
  \settoggle{cms@firstshort}{#1}}

\DeclareBibliographyOption[boolean]{compresspages}[true]{%
  \global\settoggle{cms@comprange}{#1}}%

\DeclareBibliographyOption[boolean]{compressyears}[true]{%
  \global\settoggle{cms@compyears}{#1}}%

\DeclareBibliographyOption[string]{postnotepunct}[true]{%
  \ifcsdef{cms@opt@ppunct@#1}%
  {\csuse{cms@opt@ppunct@#1}}%
  {\blx@err@invopt{postnotepunct=#1}{}}}%
\def\cms@opt@ppunct@true{%
  \global\toggletrue{cms@modpostnote}}%
\def\cms@opt@ppunct@false{}%

\DeclareBiblatexOption{global,entry}[boolean]{usecompiler}[true]{%
  \settoggle{blx@usenamec}{#1}}

\DeclareBiblatexOption{global,entry}[boolean]{juniorcomma}[true]{%
  \settoggle{cms@jrcomma}{#1}}

\DeclareBiblatexOption{global,entry}[boolean]{delayvolume}[true]{%
  \settoggle{cms@postvol}{#1}}

\DeclareBiblatexOption{global,entry}[string]{longcrossref}[false]{%
  \ifcsdef{cms@opt@lxref@#1}%
  {\csuse{cms@opt@lxref@#1}}%
  {\blx@err@invopt{longcrossref=#1}{}}}%
\def\cms@opt@lxref@none{%
  \togglefalse{cms@citecrossref}%
  \togglefalse{cms@bibcrossref}%
  \togglefalse{cms@bookcitexref}%
  \togglefalse{cms@bookbibxref}}%
\def\cms@opt@lxref@true{%
  \toggletrue{cms@citecrossref}%
  \toggletrue{cms@bibcrossref}}%
\def\cms@opt@lxref@false{%
  \togglefalse{cms@citecrossref}%
  \togglefalse{cms@bibcrossref}}%
\def\cms@opt@lxref@notes{%
  \toggletrue{cms@citecrossref}%
  \togglefalse{cms@bibcrossref}}%
\def\cms@opt@lxref@bib{%
  \togglefalse{cms@citecrossref}%
  \toggletrue{cms@bibcrossref}}%

\DeclareBiblatexOption{global,entry}[string]{booklongxref}[true]{%
  \ifcsdef{cms@opt@bklxref@#1}%
  {\csuse{cms@opt@bklxref@#1}}%
  {\blx@err@invopt{booklongxref=#1}{}}}%
\def\cms@opt@bklxref@true{%
  \toggletrue{cms@bookcitexref}%
  \toggletrue{cms@bookbibxref}}%
\def\cms@opt@bklxref@false{%
  \togglefalse{cms@bookcitexref}%
  \togglefalse{cms@bookbibxref}}%
\def\cms@opt@bklxref@notes{%
  \toggletrue{cms@bookcitexref}%
  \togglefalse{cms@bookbibxref}}%
\def\cms@opt@bklxref@bib{%
  \togglefalse{cms@bookcitexref}%
  \toggletrue{cms@bookbibxref}}%

\DeclareBiblatexOption{global,entry}[boolean]{omitxrefdate}[true]{%
  \settoggle{cms@omitxrefdate}{#1}}%

\DeclareBiblatexOption{global,entry}[boolean]{xrefurl}[true]{%
  \settoggle{cms@xrefurl}{#1}}%

\DeclareBiblatexOption{global,entry}[string]{journalabbrev}[false]{%
  \ifcsdef{cms@opt@jtabb@#1}%
  {\csuse{cms@opt@jtabb@#1}}%
  {\csuse{cms@opt@jtabb@false}\cms@warning@noline%
    {'journalabbrev=#1' isn't a valid option.\MessageBreak
      The default - 'false' - has been set.\MessageBreak
      Please see biblatex-chicago.pdf for valid\MessageBreak
      option keys}}}%
\def\cms@opt@jtabb@true{%
  \toggletrue{cms@citejtabb}%
  \toggletrue{cms@bibjtabb}}%
\def\cms@opt@jtabb@false{%
  \togglefalse{cms@citejtabb}%
  \togglefalse{cms@bibjtabb}}%
\def\cms@opt@jtabb@notes{%
  \toggletrue{cms@citejtabb}%
  \togglefalse{cms@bibjtabb}}%
\def\cms@opt@jtabb@bib{%
  \togglefalse{cms@citejtabb}%
  \toggletrue{cms@bibjtabb}}%

\DeclareBibliographyOption[boolean]{ordinalgb}[true]{%
  \settoggle{cms@ukord}{#1}}%

% The field-exclusion options %

\DeclareBiblatexOption{global,type,entry}[boolean]{urlnotes}[true]{%
  \settoggle{cms@url@innotes}{#1}}%

\DeclareBiblatexOption{global,type,entry}[boolean]{urlstamp}[true]{%
  \settoggle{cms@urltime}{#1}}%

\DeclareBiblatexOption{global,type,entry}[boolean]{isbn}[true]{%
  \settoggle{cms@isbn}{#1}}%
\DeclareBiblatexOption{global,type,entry}[boolean]{url}[true]{%
  \settoggle{cms@url}{#1}}%
\DeclareBiblatexOption{global,type,entry}[string]{doi}[true]{%
  \ifcsdef{cms@opt@doi@#1}%
  {\csuse{cms@opt@doi@#1}}%
  {\blx@err@invopt{doi=#1}{}}}%
\def\cms@opt@doi@true{%
  \toggletrue{cms@doi}}%
\def\cms@opt@doi@false{%
  \togglefalse{cms@doi}}%
\def\cms@opt@doi@only{%
  \toggletrue{cms@doionly}}%
\DeclareBiblatexOption{global,type,entry}[boolean]{eprint}[true]{%
  \settoggle{cms@eprint}{#1}}%
\DeclareBiblatexOption{global,type,entry}[boolean]{numbermonth}[true]{%
  \settoggle{cms@numbermonth}{#1}}%
\DeclareBiblatexOption{global,type,entry}[boolean]{bookpages}[true]{%
  \settoggle{cms@bookpages}{#1}}%
\DeclareBiblatexOption{global,type,entry}[boolean]{includeall}[true]{%
  \settoggle{cms@isbn}{#1}%
  \settoggle{cms@url}{#1}%
  \settoggle{cms@urltime}{#1}% 17th ed.
  \settoggle{cms@doi}{#1}%
  \settoggle{cms@eprint}{#1}%
  \settoggle{cms@numbermonth}{#1}%
  \settoggle{cms@bookpages}{#1}}%
\DeclareBiblatexOption{global,type,entry}[boolean]{hidevolumes}[true]{%
  \settoggle{cms@hidevolumes}{#1}}%

\DeclareBiblatexOption{global,type,entry}[boolean]{addendum}[true]{%
  \settoggle{cms@addendum}{#1}}%
\DeclareBiblatexOption{global,type,entry}[boolean]{bookseries}[true]{%
  \settoggle{cms@bookseries}{#1}}%
\DeclareBiblatexOption{global,type,entry}[boolean]{notefield}[true]{%
  \settoggle{cms@notefield}{#1}}%
\DeclareBibliographyOption{completenotes}[true]{%
  \settoggle{cms@addendum}{#1}%
  \settoggle{cms@bookseries}{#1}%
  \settoggle{cms@notefield}{#1}}%

\DeclareBiblatexOption{global,type,entry}[string]{related}[bib]{%
  \ifcsdef{cms@opt@rel@#1}%
  {\csuse{cms@opt@rel@#1}}%
  {\csuse{cms@opt@rel@bib}\cms@warning@noline%
    {'related=#1' is not a valid option.\MessageBreak
      The default - 'bib' - has been set.\MessageBreak
      Please see biblatex-chicago.pdf for valid\MessageBreak
      option keys}}}%
\def\cms@opt@rel@true{%
  \settoggle{cms@citerel}{true}%
  \settoggle{cms@related}{true}}%
\def\cms@opt@rel@false{%
  \settoggle{cms@citerel}{false}%
  \settoggle{cms@related}{false}}%
\def\cms@opt@rel@bib{%
  \settoggle{cms@citerel}{false}%
  \settoggle{cms@related}{true}}%
\def\cms@opt@rel@notes{%
  \settoggle{cms@citerel}{true}%
  \settoggle{cms@related}{false}}%

% Adding a disambiguating field to short notes otherwise identical %

\DeclareBiblatexOption{global,type,entry}[string]{shortextrafield}{%
  \def\cms@xfield{#1}}%

\DeclareBiblatexOption{global,type,entry}[string]{shortextraformat}{%
  \def\cms@xformat{#1}}%

\DeclareBiblatexOption{global,type,entry}[string]{shortextrapunct}[comma]{%
  \ifcsdef{cms@opt@shxp@#1}%
    {\csuse{cms@opt@shxp@#1}}%
    {\csuse{cms@opt@shxp@comma}\cms@warning@noline%
      {'shortextrapunct=#1' is not a valid option.\MessageBreak
        The default - 'comma' - has been set.\MessageBreak
        Please see biblatex-chicago.pdf for valid\MessageBreak
        option keys}}}%
\def\cms@opt@shxp@none{%
  \let\shortextrapunct\@empty}%
\def\cms@opt@shxp@comma{%
  \def\shortextrapunct{\addcomma\addspace}}%
\def\cms@opt@shxp@colon{%
  \def\shortextrapunct{\addcolon\addspace}}%
\def\cms@opt@shxp@space{%
  \def\shortextrapunct{\addspace}}%
\def\cms@opt@shxp@semicolon{%
  \def\shortextrapunct{\addsemicolon\addspace}}%
\def\cms@opt@shxp@period{%
  \def\shortextrapunct{\addperiod\addspace}}%

% Controlling punctuation before titleaddon fields %

\DeclareBiblatexOption{global,type,entry}[string]{ptitleaddon}[period]{%
  \ifcsdef{cms@opt@ptao@#1}%
    {\csuse{cms@opt@ptao@#1}}%
    {\csuse{cms@opt@ptao@period}\cms@warning@noline%
      {'ptitleaddon=#1' is not a valid option.\MessageBreak
        The default - 'period' - has been set.\MessageBreak
        Please see biblatex-chicago.pdf for valid\MessageBreak
        option keys}}}%
\def\cms@opt@ptao@none{%
  \let\ptitleaddonpunct\@empty}%
\def\cms@opt@ptao@comma{%
  \def\ptitleaddonpunct{\addcomma\addspace}}%
\def\cms@opt@ptao@colon{%
  \def\ptitleaddonpunct{\addcolon\addspace}}%
\def\cms@opt@ptao@space{%
  \def\ptitleaddonpunct{\addspace}}%
\def\cms@opt@ptao@semicolon{%
  \def\ptitleaddonpunct{\addsemicolon\addspace}}%
\def\cms@opt@ptao@period{%
  \def\ptitleaddonpunct{\addperiod\addspace}}%

\DeclareBiblatexOption{global,type,entry}[string]{ctitleaddon}[comma]{%
  \ifcsdef{cms@opt@ctao@#1}%
    {\csuse{cms@opt@ctao@#1}}%
    {\csuse{cms@opt@ctao@comma}\cms@warning@noline%
      {'ctitleaddon=#1' is not a valid option.\MessageBreak
        The default - 'comma' - has been set.\MessageBreak
        Please see biblatex-chicago.pdf for valid\MessageBreak
        option keys}}}%
\def\cms@opt@ctao@none{%
  \let\ctitleaddonpunct\@empty}%
\def\cms@opt@ctao@comma{%
  \def\ctitleaddonpunct{\addcomma\addspace}}%
\def\cms@opt@ctao@colon{%
  \def\ctitleaddonpunct{\addcolon\addspace}}%
\def\cms@opt@ctao@space{%
  \def\ctitleaddonpunct{\addspace}}%
\def\cms@opt@ctao@semicolon{%
  \def\ctitleaddonpunct{\addsemicolon\addspace}}%
\def\cms@opt@ctao@period{%
  \def\ctitleaddonpunct{\addperiod\addspace}}%

% Controlling punctuation before shorthand in notes %

\DeclareBiblatexOption{global,type,entry}[string]{shorthandpunct}[space]{%
  \ifcsdef{cms@opt@shp@#1}%
    {\csuse{cms@opt@shp@#1}}%
    {\csuse{cms@opt@shp@space}\cms@warning@noline%
      {'shorthandpunct=#1' isn't a valid option.\MessageBreak
        The default - 'space' - has been set.\MessageBreak
        Please see biblatex-chicago.pdf for valid\MessageBreak
        option keys}}}%
\def\cms@opt@shp@none{%
  \let\shorthandpunct\@empty}%
\def\cms@opt@shp@comma{%
  \def\shorthandpunct{\addcomma\addspace}}%
\def\cms@opt@shp@colon{%
  \def\shorthandpunct{\addcolon\addspace}}%
\def\cms@opt@shp@space{%
  \def\shorthandpunct{\addspace}}%
\def\cms@opt@shp@semicolon{%
  \def\shorthandpunct{\addsemicolon\addspace}}%
\def\cms@opt@shp@period{%
  \def\shorthandpunct{\addperiod\addspace}}%
\def\cms@opt@shp@emdash{%
  \def\shorthandpunct{\addthinspace\textemdash\addthinspace}}%
\def\cms@opt@shp@endash{%
  \def\shorthandpunct{\addspace\textendash\addspace}}%

\ExecuteBibliographyOptions{includeall,completenotes,hidevolumes,%
  related,booklongxref,ptitleaddon,ctitleaddon,shorthandpunct,urlnotes,%
  legalnotes,supranotes,shortextrapunct,dashed}

\iftoggle{cms@legalnotes}%
{\ExecuteBibliographyOptions[jurisdiction,legal,legislation]{skipbib}}%
{}%

% For author-date compatibility %

\DeclareEntryOption[boolean]{switchdates}[true]{%
  \settoggle{cms@switchdates}{#1}}%

\DeclareEntryOption{cmsdate}{}%

\DeclareBibliographyOption{cmsdate}{}%

\DeclareBibliographyOption[boolean]{strict}[true]{%
  \settoggle{cms@strict}{#1}%
  \iftoggle{cms@strict}%
  {\let\splitfootnoterule\footnoterule
    \renewcommand\footnoterule{}%
    \advance\skip\footins 4\p@\@plus2\p@\relax
    \gdef\split@prev{0}
    \let\pagefootnoterule\footnoterule
    % \def\splitfootnoterule{\kern-3\p@ \hrule \kern2.6\p@}
    \def\footnoterule{\relax
      \ifnum\split@prev=\z@
      \pagefootnoterule
      \else
      \splitfootnoterule
      \fi
      \xdef\split@prev{\the\insertpenalties}%
    }}%
  {}}


\protected\def\blx@newcunit{%
  \iftoggle{blx@keepunit}%
  {}%
  {\global\let\blx@unitpunct\newcunitpunct
    \global\toggletrue{blx@unit}}}%

\appto\blx@blxinit{%
  \let\newcunit\blx@newcunit}

\newcommand*{\newcunitpunct}{\addcomma\addspace}

\def\mkbibcurdinal#1{%
  \@tempcnta0#1 \the\@tempcnta}%

\@ifpackagelater{biblatex}{2010/08/28}
{}%
{\PackageError{biblatex}
  {Outdated 'biblatex' package}
  {The Chicago style requires biblatex v0.9 or later.\MessageBreak
    You are using: '\csuse{ver@biblatex.sty}'.\MessageBreak
    This is a fatal error. I'm aborting now.}%
  \endinput}

% American-specific punctuation change for 16th edition %

\DefineBibliographyExtras{american}{%
  \DeclarePunctuationPairs{comma}{*!?}}

%%%% Initialize and define bibstrings %%%%

\DefineBibliographyStrings{english}{%
  citedas = {hereafter cited as},}

%%%% This one needed for 16th edition. Others in cms-*.lbx %%%%

%%%% Cite macros for use by the citation commands %%%%

\newbibmacro*{cite:init}{%
  \global\let\cbx@lastkey\undefined}

\newbibmacro*{cite:save}{%
  \savefield{entrykey}{\cbx@lastkey}%
  \ifthenelse{\ifentrytype{inreference}\OR\ifentrytype{reference}\OR%
    \ifentrytype{mvreference}}%
  {\global\toggletrue{cms@noidem}}%
  {\global\togglefalse{cms@noidem}}}%

\newbibmacro*{cite}{%
  \ifboolexpr{%
    test {\ifciteseen}%
    and
    (
    not togl {cms@noneshort}% Intended for Bluebook citations
    or
    (
    test {\ifciteibid}%
    and
    not test {\iffirstonpage}%
    and
    not togl {cms@noibid}%
    )
    )
  }%
    {\ifboolexpr{%
        test {\iffieldundef{shorthand}}%
        or
        (
        togl {blx@skipbiblist}%
        and
        togl {cms@inheritshhand}%
        and
        not test {\iffieldundef{crossref}}%
        )
      }%
       {\ifthenelse{\ifciteibid\AND\NOT\iffirstonpage}%
         {\usebibmacro{cite:ibid}%
           \usebibmacro{cite:save}}%
          {\global\toggletrue{cms@shortnote}%
            \global\togglefalse{cms@fullnote}%
            \usebibmacro{cite:short}%
           \usebibmacro{cite:save}}}%
       {\iftoggle{cms@shorthandibid}%
         {\ifthenelse{\ifciteibid\AND\NOT\iffirstonpage}%
           {\usebibmacro{cite:ibid}%
             \usebibmacro{cite:save}}%
           {\usebibmacro{cite:shorthand}%
             \usebibmacro{cite:save}%
             \global\toggletrue{cms@noidem}}}%
         {\usebibmacro{cite:shorthand}%
           \usebibmacro{cite:save}%
           \global\toggletrue{cms@noidem}}}}%
     {\ifboolexpr{%
         togl{cms@firstshort}%
         and
         not test {\iffieldundef{shorthand}}%
       }%
       {\usebibmacro{cite:shorthand}%
         \usebibmacro{cite:save}%
         \global\toggletrue{cms@noidem}}%
       {\iftoggle{cms@allshort}%
         {\global\toggletrue{cms@shortnote}%
           \global\togglefalse{cms@fullnote}%
           \global\toggletrue{cms@printshhand}%
           \usebibmacro{cite:short}%
           \usebibmacro{cite:save}}%
         {\global\toggletrue{cms@fullnote}%
           \global\togglefalse{cms@shortnote}%
           \usebibmacro{footcite:save}% FIXME!!
           \usebibmacro{cite:full}%
           \usebibmacro{cite:save}}}}}%

\newbibmacro*{cite:full}{%
  \printtext[bibhypertarget]{%
    \usedriver
      {\DeclareNameAlias{sortname}{default}\frenchspacing}%
      {cite:\thefield{entrytype}}}}%

\newbibmacro*{cite:short}{%
  \ifentrytype{jurisdiction}%
  {\usebibmacro{cite:short:jurisdiction}}%
  {\ifentrytype{legal}%
    {\usebibmacro{cite:short:legal}}%
    {\ifentrytype{legislation}%
      {\usebibmacro{cite:short:legislation}}%
      {\usebibmacro{cite:short:cms}}}}}%

\newbibmacro*{cite:short:cms}{% was cite:short
  \usebibmacro{allshort+firstcite+xref}%
  \ifthenelse{\ifnameundef{labelname}\OR%
    \ifentrytype{inreference}\OR%
    \ifentrytype{reference}\OR%
    \ifentrytype{mvreference}}%
  {\ifthenelse{\iffieldequalstr{entrysubtype}{magazine}\AND\NOT%
      \ifentrytype{periodical}}% Simplify .bib creation
    {\ifuseauthor%
      {\ifboolexpr{%
          not test {\iffieldundef{shortjournal}}%
          and
          ((
          test {\ifcitation}%
          and
          togl {cms@citejtabb}%
          )
          or
          (
          test {\ifbibliography}%
          and
          togl {cms@bibjtabb}%
          ))
        }%
        {\printfield[shortjournal]{shortjournal}\newcunit}%
        {\printfield[journaltitle]{journaltitle}\newcunit}}%
      {}}%
    {\ifentrytype{manual}%
      {\printlist{organization}\isdot\newcunit}%
      {}}}%
  {\ifboolexpr{%
      test {\ifciteidem}%
      and
      not test {\ifbibliography}%
      and
      not test {\iffirstonpage}%
      and
      not togl {cms@noidem}%
      and
      not togl {cms@headlessnote}%
    }%
    {\bibstring[\mkibid]{idem\thefield{gender}}%
      \classicpunct}%
    {\iffieldequalstr{authortype}{anon}%
      {\bibleftbracket\printnames{labelname}%
        \bibrightbracket\classicpunct}%
      {\iffieldequalstr{authortype}{anon?}%
        {\bibleftbracket\printnames{labelname}?%
          \bibrightbracket\classicpunct}%
        {\printnames{labelname}%\usebibmacro{choose+labelname}%
          \isdot\classicpunct}}}}%
  \ifboolexpr{%
    (
    test {\ifentrytype{review}}%
    or
    test {\ifentrytype{suppperiodical}}%
    )
    and
    test {\iffieldequalstr{relatedtype}{reviewof}}%
    and
    togl {cms@citerel}%
  }%
  {\usebibmacro{related:init}%
    \usebibmacro{related}}%
  {\ifboolexpr{%
      togl {cms@allshort}%
      or
      test {\ifbibliography}%
    }%
    {\printtext[bibhyperref]{%
        \printfield[citetitle]{labeltitle}}}%
    {\printtext[cmshyperlink]{%
        \printfield[citetitle]{labeltitle}}}%
    \ifboolexpr{%
      test {\iffieldundef{extratitle}}%
      or
      test {\ifcsundef{cms@xfield}}%
    }%
    {}%
    {\setunit{\shortextrapunct}%
      \usebibmacro{shortnote+extrafield}}}}%:\thefield{entrytype}?

\newbibmacro*{shortnote+extrafield}{% Disambiguate otherwise identical
  \iffieldundef{\csuse{cms@xfield}}% short notes
  {\iflistundef{\csuse{cms@xfield}}%
    {\ifnameundef{\csuse{cms@xfield}}%
      {\cms@xtime}% See below; stops spurious parentheses appearing
      {\printtext[\csuse{cms@xformat}]{%
          \printnames[default]{\csuse{cms@xfield}}}}}%
    {\printtext[\csuse{cms@xformat}]{%
        \printlist{\csuse{cms@xfield}}}}}%
  {\ifboolexpr{%
      test {\ifcsstring{cms@xfield}{month}}%
      or
      test {\ifcsstring{cms@xfield}{origmonth}}%
      or
      test {\ifcsstring{cms@xfield}{eventmonth}}%
      or
      test {\ifcsstring{cms@xfield}{urlmonth}}%
    }%
    {\printtext[\csuse{cms@xformat}]{%
        \mkbibmonth{\thefield{\csuse{cms@xfield}}}}}%
    {\ifboolexpr{%
        test {\ifcsstring{cms@xfield}{day}}%
        or
        test {\ifcsstring{cms@xfield}{origday}}%
        or
        test {\ifcsstring{cms@xfield}{eventday}}%
        or
        test {\ifcsstring{cms@xfield}{urlday}}%
      }%
      {\printtext[\csuse{cms@xformat}]{%
          \printfield[letterday]{\csuse{cms@xfield}}}}%
      {\ifboolexpr{%
          test {\ifcsstring{cms@xfield}{yeardivision}}%
          or
          test {\ifcsstring{cms@xfield}{origyeardivision}}%
          or
          test {\ifcsstring{cms@xfield}{eventyeardivision}}%
          or
          test {\ifcsstring{cms@xfield}{urlyeardivision}}%
        }%
        {\printtext[\csuse{cms@xformat}]{%
            \mkbibyeardivision{\thefield{\csuse{cms@xfield}}}}}%
        {\IfSubStr{\cms@xfield}{year}%
          {\StrCut{\cms@xfield}{year}\cms@yeartype\cms@tempnull%
            \iffieldundef{\csuse{cms@yeartype}year}%
            {}%
            {\printtext[\csuse{cms@xformat}]{%
                \csuse{print\cms@yeartype dateextra}}}}%
          {\printtext[\csuse{cms@xformat}]{%
              \printfield{\csuse{cms@xfield}}}}}}}}}%

\newrobustcmd*{\cms@xtime}{% Tests for presence of field before printing
  \IfSubStr{\cms@xfield}{time}%
  {\StrCut{\cms@xfield}{time}\cms@timetype\cms@tempnull%
    \iffieldundef{\csuse{cms@timetype}hour}%
    {}%
    {\printtext[\csuse{cms@xformat}]{%
        \csuse{print\cms@timetype date}%
        \newcunit\csuse{print\cms@timetype time}}}}%
  {\IfSubStr{\cms@xfield}{date}%
    {\StrCut{\cms@xfield}{date}\cms@datetype\cms@tempnull%
      \ifthenelse{\iffieldundef{\csuse{cms@datetype}year}\AND%
        \iffieldundef{\csuse{cms@datetype}month}\AND%
        \iffieldundef{\csuse{cms@datetype}yeardivision}}%
      {}%
      {\printtext[\csuse{cms@xformat}]{%
          \csuse{print\cms@datetype date}}}}%
    {}}}

\newbibmacro*{footcite:save}{%
  \ifboolexpr{%
    test {\iffootnote}%
    and
    (
    test {\ifentrytype{legal}}%
    or
    (
    test {\ifentrytype{legislation}}%
    and
    (
    test {\iffieldequalstr{entrysubtype}{un}}%
    or
    test {\iffieldequalstr{entrysubtype}{hearing}}%
    )))
  }%
  {\csxdef{cbx@f@\thefield{entrykey}}{\the\value{instcount}}%
    \label{cbx@\the\value{instcount}}}%
  {}}%

\newbibmacro*{cite:short:jurisdiction}{%
  \iffieldundef{labeltitle}%
  {}%
  {\ifboolexpr{%
    togl {cms@allshort}%
    or
    test {\ifbibliography}%
  }%
  {\printtext[bibhyperref]{%
      \printfield[citetitle]{labeltitle}}}%
  {\printtext[cmshyperlink]{%
      \printfield[citetitle]{labeltitle}}}}%
  \newcunit% Fixme: giving us a duplicate comma
  \printfield[jourvol]{volume}%
  \setunit*{\addnbspace}%
  \iffieldundef{shortjournal}% Test eliminates spurious comma
  {}%
  {\printtext[shortjournal]{%
      \printfield[jtsnoformat]{shortjournal}}}%
  \iffieldundef{issue}%
  {\printfield[jurisdictionser]{series}}%
  {\setunit{\addspace}%
    \printfield{issue}}% Better ideas?
  % \newcunit%
  \usebibmacro{juridpostnote}}%

\newbibmacro*{cite:short:legal}{%
  \iffieldundef{labeltitle}%
  {}%
  {\ifboolexpr{%
    togl {cms@allshort}%
    or
    test {\ifbibliography}%
  }%
  {\printtext[bibhyperref]{%
      \printfield[citetitle]{labeltitle}}}%
  {\printtext[cmshyperlink]{%
      \printfield[citetitle]{labeltitle}}}}%
  \newcunit% Fixme: giving us a duplicate comma
  \printfield[jourvol]{volume}%
  \setunit*{\addnbspace}%
  \iffieldundef{shortjournal}% Test eliminates spurious comma
  {}%
  {\printtext[shortjournal]{%
      \printfield[jtsnoformat]{shortjournal}}}%
  \printfield[legalser]{series}%
  \setunit{\addspace}%
  \printfield{issue}%
  % \newcunit%
  \ifboolexpr{%
    togl {cms@supranotes}%
    and
    test {\iffootnote}%
  }%
  {\newcunit%
    \printtext{\bibstring{supranote}\addnbspace%
      \ref{cbx@\csuse{cbx@f@\thefield{entrykey}}}}}% ??
  {}%
  \usebibmacro{juridpostnote}}%

\newbibmacro*{cite:short:legislation}{%
  \iffieldequalstr{entrysubtype}{constitution}%
  {\usebibmacro{clegis+news+title}%
    \setunit{\addspace}%
    \printfield[juridnum]{number}%
    \newcunit%
    \printfield{part}%
    \newcunit%
    \printfield{chapter}}%
  {\iffieldequalstr{labeltitlesource}{shorttitle}%
    {\ifboolexpr{%
        togl {cms@allshort}%
        or
        test {\ifbibliography}%
      }%
      {\printtext[bibhyperref]{%
          \printfield[citetitle]{labeltitle}}}%
      {\printtext[cmshyperlink]{%
          \printfield[citetitle]{labeltitle}}}}%
    {\ifboolexpr{%
        test {\iffieldundef{shortjournal}}%
        or
        (
        not test {\iffieldundef{volume}}%
        and
        not test {\iffieldint{volume}}%
        )
      }%
      {\ifboolexpr{%
          test {\iffieldundef{entrysubtype}}%
          and
          not test {\iflistundef{location}}
        }%
        {\printlist{location}%
          \setunit{\addspace}}%
        {}%
        \ifboolexpr{%
          togl {cms@allshort}%
          or
          test {\ifbibliography}%
        }%
        {\printtext[bibhyperref]{%
            \printfield[citetitle]{labeltitle}}}%
        {\printtext[cmshyperlink]{%
            \printfield[citetitle]{labeltitle}}}%
        \setunit{\addspace}%
        \printfield[juridnum]{number}%
        \newcunit%
        \printfield{part}%
        \newcunit%
        \printfield{chapter}}%
      {\printfield{note}%
        \newcunit%
        \printfield[jourvol]{volume}%
        \setunit*{\addnbspace}%
        \iffieldundef{shortjournal}% Test eliminates spurious comma
        {}%
        {\printtext[shortjournal]{%
            \printfield[jtsnoformat]{shortjournal}}}%
        \printfield[legislationser]{series}%
        \setunit{\addspace}%
        \printfield{issue}%
        \newcunit%
        \printfield{part}%
        \newcunit%
        \printfield{chapter}%
      }}}%
  \newcunit%
  \ifboolexpr{%
    togl {cms@supranotes}%
    and
    test {\iffootnote}%
    and
    (
    test {\iffieldequalstr{entrysubtype}{un}}%
    or
    test {\iffieldequalstr{entrysubtype}{hearing}}%
    )
  }%
  {\newcunit%
    \printtext{\bibstring{supranote}\addnbspace%
      \ref{cbx@\csuse{cbx@f@\thefield{entrykey}}}}}% ??
  {}%
  \usebibmacro{juridpostnote}}%

\newbibmacro*{cite:shorthand}{%
  \ifthenelse{\ifentrytype{jurisdiction}\OR\ifentrytype{legal}\OR%
    \ifentrytype{legislation}}%
  {\usebibmacro{cite:shorthand:legal}}%
  {\usebibmacro{cite:shorthand:cms}}}

\newbibmacro*{cite:shorthand:cms}{%
  \usebibmacro{allshort+firstcite+xref}%
  \iftoggle{cms@allshort}%
  {\printtext[bibhyperref]{%
      \printfield{shorthand}}}%
  {\printtext[cmshyperlink]{%
      \printfield{shorthand}}}}

\newbibmacro*{cite:shorthand:legal}{%
  \usebibmacro{allshort+firstcite+xref}%
  \iftoggle{cms@allshort}%
  {\printtext[bibhyperref]{%
      \printfield{shorthand}}}%
  {\printtext[cmshyperlink]{%
      \printfield{shorthand}}}%
  \ifboolexpr{%
    test {\iffootnote}%
    and
    (
    test {\ifentrytype{legal}}%
    or
    (
    test {\ifentrytype{legislation}}%
    and
    (
    test {\iffieldequalstr{entrysubtype}{un}}%
    or
    test {\iffieldequalstr{entrysubtype}{hearing}}%
    )))
  }%
  {\newcunit%
    \printtext{\bibstring{supranote}\addnbspace%
      \ref{cbx@\csuse{cbx@f@\thefield{entrykey}}}%
      \newcunit}}% ??
  {}}%

\newbibmacro*{cms:shorthandintro}{% For changing the citedas phrase
  \iffieldundef{shorthand}%
  {}%
  {\iffieldundef{shorthandintro}%
    {\ifthenelse{\ifentrytype{jurisdiction}\OR\ifentrytype{legal}\OR%
        \ifentrytype{legislation}}%
      {\printtext[brackets]{%
        \bibstring{hereinafter}\addspace%
        \printfield{shorthand}}}%
      {\printtext[parens]{%
        \bibstring{citedas}\addspace%
        \printfield{shorthand}}}}%
    {%\addspace%\setunit{\addspace}% Ditto
      \printfield{shorthandintro}}}}

\newbibmacro*{choose:ibidstring}{%
  \ifthenelse{\ifentrytype{jurisdiction}\OR\ifentrytype{legal}\OR%
    \ifentrytype{legislation}}%
  {\bibsstring[\mkbibemph]{ibidem}}%
  {\bibstring[\mkibid]{ibidem}}}

\newbibmacro*{cite:ibid}{%
  \ifboolexpr{%
    togl {cms@noibid}%
    or
    test {\ifbibliography}% Needed for inheritshorthand option
  }%
  {\global\toggletrue{cms@shortnote}%
    \global\togglefalse{cms@fullnote}%
    \usebibmacro{cite:short}%
    \usebibmacro{cite:save}}%
  {\iftoggle{cms@allshort}%
    {\printtext[bibhyperref]{%
        \usebibmacro{choose:ibidstring}}}%\bibstring[\mkibid]{ibidem}
    {\printtext[cmshyperlink]{%
        \usebibmacro{choose:ibidstring}}}%\bibstring[\mkibid]{ibidem}
    \ifboolexpr{%
      test {\ifloccit}%
      or
      (
      test {\ifciteibid}%
      and
      test {\iffieldequalcs{postnote}{cms@pnsaved}}%
      and
      not test {\ifdefvoid{\blx@loccittracker}}% Package option=false
      )
    }%
    {\global\toggletrue{cms@loccit}}%
    {}}}%

\newbibmacro*{cite:journal}{%
  \ifthenelse{\ifciteibid\AND\NOT\iffirstonpage}%
  {\iffieldundef{prenote}%
    {\bibsentence\usebibmacro{cite:ibid}}%
    {\usebibmacro{cite:ibid}}%
    \usebibmacro{cite:save}}%
  {\iffieldundef{journaltitle}%
    {\usebibmacro{cite:short}%
      \usebibmacro{cite:save}}%
    {\ifboolexpr{%
      test {\ifciteidem}%
      and
      not test {\ifbibliography}%
      and
      not test {\iffirstonpage}%
      and
      not togl {cms@noidem}%
    }%
    {\iffieldundef{prenote}%
      {\bibsentence\bibstring[\mkibid]{idem\thefield{gender}}%
        \newcunit}%
      {\bibstring[\mkibid]{idem\thefield{gender}}%
        \newcunit}}%
    {\iffieldequalstr{authortype}{anon}%
      {\bibleftbracket\printnames{labelname}%
        \bibrightbracket\newcunit}%
      {\iffieldequalstr{authortype}{anon?}%
        {\bibleftbracket\printnames{labelname}?%
          \bibrightbracket\newcunit}%
        {\printnames{labelname}%
          \isdot\newcunit}}}%
    \iftoggle{cms@allshort}%
    {\ifboolexpr{%
        not test {\iffieldundef{shortjournal}}%
        and
        ((
        test {\ifcitation}%
        and
        togl {cms@citejtabb}%
        )
        or
        (
        test {\ifbibliography}%
        and
        togl {cms@bibjtabb}%
        ))
      }%
      {\printtext[bibhyperref]{%
          \printfield[shortjournal]{shortjournal}}}%
      {\printtext[bibhyperref]{%
          \printfield[journaltitle]{journaltitle}}}}%
    {\ifboolexpr{%
        not test {\iffieldundef{shortjournal}}%
        and
        ((
        test {\ifcitation}%
        and
        togl {cms@citejtabb}%
        )
        or
        (
        test {\ifbibliography}%
        and
        togl {cms@bibjtabb}%
        ))
      }%
      {\printtext[bibhyperlink]{%
          \printfield[shortjournal]{shortjournal}}}%
      {\printtext[bibhyperlink]{%
          \printfield[journaltitle]{journaltitle}}}}%
    \iffieldundef{volume}%
    {\iffieldundef{number}%
      {\iffieldundef{issue}%
        {\newcunit%
          \usebibmacro{number+or+month}}%
        {\newcunit%
          \printfield{issue}%
          \setunit{\addspace}%
          \usebibmacro{cmsyear}}}%
      {\newcunit%
        \printfield[journum]{number}}}%
    {\toggletrue{cms@fullnote}%
      \togglefalse{cms@shortnote}%
      \setunit{\addspace}%
      \printfield[jourvol]{volume}%
      \ifthenelse{\iffieldundef{pagination}\AND%
        \iffieldundef{bookpagination}}%
      {\setunit{\postvolpunct}}%
      {\setunit{\addcolon\addspace}}}}}}%

%% Macros from verbose.cbx %%

\newbibmacro*{textcite}{%
  \ifnameundef{labelname}%
  {\printfield[citetitle]{labeltitle}}%
  {\printnames{labelname}}%
  \ifboolexpr{%
    togl {cms@gencite}%
    and
    (
    test {\iflastcitekey}%
    or
    togl {cms@genallnames}%
    )
  }%
  {\thegen}%
  {}}%

\newbibmacro*{textcite:init}{%
  \citetrackerfalse%
  \pagetrackerfalse%
  \iffirstcitekey
    {\global\undef\cbx@lasthash}%
    {}}%

\newbibmacro*{textcite:count}{%
  \stepcounter{textcitetotal}%
  \ifnumgreater{\value{uniquelist}}{\value{maxnames}}%
    {\ifnumgreater{\value{uniquelist}}{\value{textcitemaxnames}}%
       {\setcounter{textcitemaxnames}{\value{uniquelist}}}%
       {}}%
    {\ifnumless{\value{labelname}}{\value{maxnames}}%
       {\ifnumgreater{\value{labelname}}{\value{textcitemaxnames}}%
          {\setcounter{textcitemaxnames}{\value{labelname}}}%
          {}}%
       {\ifnumgreater{\value{maxnames}}{\value{textcitemaxnames}}%
          {\setcounter{textcitemaxnames}{\value{maxnames}}}%
          {}}}}%

%%%% Citation Commands, internal and external %%%%

\DeclareCiteCommand{\cite}
  {\usebibmacro{prenote}}
  {\usebibmacro{citeindex}%
   \usebibmacro{cite}}
  {\multicitedelim}
  {\usebibmacro{cite:postnote}}

\DeclareCiteCommand{\cmsnoopcite}%
{}{}{}{}%

\DeclareCiteCommand{\bibxrefcite}
  {\usebibmacro{backref+check}}% So cites in biblio don't turn up
  {\usebibmacro{cms-in:}%        in backref list
    \ifthenelse{\iffieldequals{fullhash}{\bbx@lasthash}\AND\NOT%
      \(\ifentrytype{collection}\OR\ifentrytype{proceedings}\OR%
      \ifentrytype{mvcollection}\OR\ifentrytype{mvproceedings}\)}%
    {\clearname{author}%
      \clearname{shortauthor}%
      \clearname{labelname}}%
    {}%
    \toggletrue{cms@shortnote}%
    \togglefalse{cms@fullnote}%
    \ifboolexpr{%
      togl {cms@inheritshhand}%
      and
      not test {\iffieldundef{shorthand}}%
    }%
    {\usebibmacro{cite}}%
    {\usebibmacro{cite:short}}}% Would {cite} be better?
  {}%
  {\usebibmacro{crossref:volume+postnote}}% Volume fix

\DeclareCiteCommand{\bookbibxrefcite}
  {\usebibmacro{backref+check}}% So cites in biblio don't turn up
  {\iffieldequals{fullhash}{\bbx@lasthash}% in backref list
    {\ifthenelse{\ifentrytype{collection}\OR%
        \ifentrytype{proceedings}\OR\ifentrytype{mvcollection}\OR%
        \ifentrytype{mvproceedings}}%
      {\clearname{editor}%
        \clearname{shorteditor}%
        \clearname{labelname}}%
      {\clearname{author}%
        \clearname{shortauthor}%
        \clearname{labelname}}}%
    {}%
    \toggletrue{cms@shortnote}%
    \togglefalse{cms@fullnote}%
    \usebibmacro{bibxref-in:}%
    \ifboolexpr{%
      togl {cms@inheritshhand}%
      and
      not test {\iffieldundef{shorthand}}%
    }%
    {\usebibmacro{cite}}%
    {\usebibmacro{cite:short}}}%
  {}%
  {\usebibmacro{crossref:volume+postnote}}% Volume fix

\DeclareCiteCommand*{\cite}
  {\usebibmacro{cite:init}%
    \usebibmacro{prenote}}
  {\usebibmacro{citeindex}%
    \blx@ibidreset
    \usebibmacro{cite}}
  {\multicitedelim}
  {\usebibmacro{postnote}}

\DeclareCiteCommand{\parencite}[\mkbibparens]
  {\usebibmacro{prenote}}
  {\usebibmacro{citeindex}%
   \usebibmacro{cite}}
  {\multicitedelim}
  {\usebibmacro{cite:postnote}}

\DeclareCiteCommand{\footcite}[\mkbibfootnote]
  {\usebibmacro{prenote}}%\bibsentence
  {\usebibmacro{citeindex}%
   \usebibmacro{cite}}
  {\multicitedelim}
  {\usebibmacro{cite:postnote}}

\DeclareCiteCommand{\smartcite}
  [\iffootnote{}{\mkbibfootnote}]
  {\usebibmacro{prenote}}%\bibsentence
  {\usebibmacro{citeindex}%
   \usebibmacro{cite}}
  {\multicitedelim}
  {\usebibmacro{cite:postnote}}

\DeclareMultiCiteCommand{\smartcites}[\iffootnote{}{\mkbibfootnote}]%
{\smartcite}{\multicitedelim}

\DeclareCiteCommand{\footfullcite}[\mkbibfootnote]
  {\usebibmacro{prenote}}%\bibsentence
  {\usebibmacro{citeindex}%
    \toggletrue{cms@fullnote}%
    \togglefalse{cms@shortnote}%
    \usebibmacro{footcite:save}%
    \usebibmacro{cite:full}%
    \usebibmacro{cite:save}}
  {\multicitedelim}
  {}

\DeclareCiteCommand{\fullcite}
  {\usebibmacro{prenote}}%\bibsentence
  {\usebibmacro{citeindex}%
    \toggletrue{cms@fullnote}%
    \togglefalse{cms@shortnote}%
    \usebibmacro{footcite:save}%
    \usebibmacro{cite:full}%
    \usebibmacro{cite:save}}
  {\multicitedelim}
  {}

\DeclareCiteCommand{\origfullcite}
  {\usebibmacro{backref+check}%
    \ifhyperref%
    {\hypertarget{cite.\the\c@refsection @\abx@field@entrykey}{}}%
    {}%
    \nopunct}%\unspace% Put \nopunct and \unspace here for 0.8e.
  {\usedriver
    {\DeclareNameAlias{sortname}{default}\clearfield{postnote}%
      \usebibmacro{clearorigin}\clearfield{userf}\clearfield{shorthand}%
      \toggletrue{cms@fullnote}\toggletrue{cms@headlessnote}%
      \frenchspacing}%
    {cite:\thefield{entrytype}}%
    \iflistundef{pageref}{}{\newunit\usebibmacro{pageref}}}%
  {\multicitedelim}%
  {\finentry}% Helps with annotated bibliographies (?)

\DeclareCiteCommand{\origpublcite}% Similar to above, w/o title.
  {\usebibmacro{backref+check}%
    \ifhyperref%
    {\hypertarget{cite.\the\c@refsection @\abx@field@entrykey}{}}%
    {}%
    \nopunct}%\unspace Put \nopunct and \unspace here for 0.8e.
  {\usedriver
    {\DeclareNameAlias{sortname}{default}\clearfield{postnote}%
      \usebibmacro{clearpublin}\clearfield{shorthand}%
      \usebibmacro{cms:titlehook}%
      \toggletrue{cms@fullnote}\toggletrue{cms@headlessnote}%
      \toggletrue{cms@origpublished}\frenchspacing}%
    {cite:\thefield{entrytype}}%
    \iflistundef{pageref}{}{\newunit\usebibmacro{pageref}}}%
  {\multicitedelim}%
  {\finentry}

\DeclareCiteCommand{\headlessfullcite}
  {\usebibmacro{prenote}}%
  {\printtext[bibhypertarget]{%
      \usedriver
      {\DeclareNameAlias{sortname}{default}\usebibmacro{cite:save}%
        \toggletrue{cms@fullnote}\toggletrue{cms@headlessnote}%
        \usebibmacro{clear+labelname}\global\toggletrue{cms@noidem}}%
      {cite:\thefield{entrytype}}}}%
  {\multicitedelim}%
  {}%\usebibmacro{finentry}}

\DeclareCiteCommand{\headlesscite}
  {\usebibmacro{prenote}}
  {\usebibmacro{citeindex}%
    \toggletrue{cms@headlessnote}%
    \usebibmacro{clear+labelname}%
    \clearname{labelname}%
    \usebibmacro{cite}%
    \global\toggletrue{cms@noidem}}%
  {\multicitedelim}
  {\usebibmacro{cite:postnote}}

\DeclareCiteCommand{\headlessparencite}[\mkbibparens]
  {\usebibmacro{prenote}}
  {\usebibmacro{citeindex}%
    \toggletrue{cms@headlessnote}%
    \usebibmacro{clear+labelname}%
    \clearname{labelname}%
    \usebibmacro{cite}%
    \global\toggletrue{cms@noidem}}
  {\multicitedelim}
  {\usebibmacro{cite:postnote}}

\DeclareCiteCommand{\headlessparenshortcite}[\mkbibparens]
  {\usebibmacro{prenote}}
  {\usebibmacro{citeindex}%
    \ifboolexpr{%
      togl{cms@firstshort}%
      and
      not test {\iffieldundef{shorthand}}%
    }%
    {\usebibmacro{cite:shorthand}}%
    {\toggletrue{cms@headlessnote}%
      \toggletrue{cms@shortnote}%
      \togglefalse{cms@fullnote}%
      \clearname{labelname}%
      \usebibmacro{cite:short}}%
    \global\toggletrue{cms@noidem}}
  {\multicitedelim}
  {\usebibmacro{cite:postnote}}

\DeclareCiteCommand{\surnamecite}
  {\usebibmacro{prenote}}%\usebibmacro{hlcprenote}}
  {\usebibmacro{citeindex}%
    \ifboolexpr{%
      (
      test {\ifciteseen}%
      or
      togl {cms@allshort}%
      )
      and
      not togl {cms@noneshort}%
    }%
    {\usebibmacro{cite:short}}
    {\renewbibmacro*{author/editor}{\usebibmacro{choose+surname}}%
      \renewbibmacro*{editor}{\usebibmacro{choose+surname}}%
      \renewbibmacro*{author}{\usebibmacro{choose+surname}}%
      \usebibmacro{cite}}}%
  {\multicitedelim}%
  {\usebibmacro{cite:postnote}}

\DeclareMultiCiteCommand{\surnamecites}{surnamecite}{\multicitedelim}

\DeclareCiteCommand{\shortcite}
  {\usebibmacro{prenote}}
  {\toggletrue{cms@shortnote}%
    \togglefalse{cms@fullnote}%
    \usebibmacro{citeindex}%
    \usebibmacro{cite:short}%
    \usebibmacro{cite:save}}
  {\multicitedelim}
  {\usebibmacro{postnote}}

\DeclareCiteCommand{\shorthandcite}
  {\usebibmacro{prenote}}
  {\usebibmacro{citeindex}%
    \iftoggle{cms@shorthandibid}%
    {\ifthenelse{\ifciteibid\AND\NOT\iffirstonpage}%
      {\usebibmacro{cite:ibid}%
        \usebibmacro{cite:save}}%
      {\usebibmacro{cite:shorthand}%
        \usebibmacro{cite:save}%
        \global\toggletrue{cms@noidem}}}%
    {\usebibmacro{cite:shorthand}%
      \usebibmacro{cite:save}%
      \global\toggletrue{cms@noidem}}}
  {\multicitedelim}
  {\usebibmacro{postnote}}

\DeclareCiteCommand{\citejournal}% Name?
  {\usebibmacro{prenote}}
  {\toggletrue{cms@shortnote}%
    \togglefalse{cms@fullnote}%
    \clearfield{pages}%
    \usebibmacro{citeindex}%
    \usebibmacro{cite:journal}%
    \usebibmacro{cite:save}}
  {\multicitedelim}
  {\iftoggle{cms@loccit}%
    {}%
    {\usebibmacro{fullpostnote}}}

\DeclareCiteCommand{\citeauthor}
  {\boolfalse{citetracker}%
   \boolfalse{pagetracker}%
   \usebibmacro{prenote}}
  {\toggletrue{cms@shortnote}%
    \togglefalse{cms@fullnote}%
    \ifciteindex
     {\indexnames{labelname}}
     {}%
   \printnames{labelname}}
  {\multicitedelim}
  {\usebibmacro{postnote}}

\newrobustcmd*{\Headlesscite}{\bibsentence\headlesscite}

\newrobustcmd*{\Headlesscites}{\bibsentence\headlesscites}

\DeclareMultiCiteCommand{\citetitles}{citetitle}{\multicitedelim}

\DeclareMultiCiteCommand{\headlesscites}{headlesscite}{\multicitedelim}

\DeclareMultiCiteCommand{\headlessfullcites}{headlessfullcite}{\multicitedelim}

\DeclareMultiCiteCommand{\headlessparencites}[\mkbibparens]%
{headlessparencite}{\multicitedelim}

\DeclareMultiCiteCommand{\headlessparenshortcites}[\mkbibparens]%
{headlessparenshortcite}{\multicitedelim}

\def\cms@cicpunct{}%

%% Textcite commands adapted from verbose.cbx %%

\DeclareCiteCommand{\cbx@textcite}
  {\usebibmacro{textcite:init}}
  {\iffieldequals{namehash}{\cbx@lasthash}
     {}%
     {\iffirstcitekey
        {}%
        {\textcitedelim}%
      \stepcounter{textcitecount}%
      \usebibmacro{textcite}%
      \savefield{namehash}{\cbx@lasthash}}}
  {}
  {}

\DeclareCiteCommand{\textcite}[\cbx@textcite@init\cbx@textcite\cms@textcite@i]
  {\usebibmacro{textcite:init}%
   \gdef\cbx@savedkeys{}%
   \DeferNextCitekeyHook}
  {\ifthenelse{\iffirstcitekey\AND\value{multicitetotal}>0}%
     {\protected@xappto\cbx@footcite@args{%
        (\thefield{multiprenote})(\thefield{multipostnote})}}%
     {}%
   \xappto\cbx@savedkeys{\thefield{entrykey},}%
   \iffieldequals{namehash}{\cbx@lasthash}%
     {}%
     {\usebibmacro{textcite:count}%
      \savefield{namehash}{\cbx@lasthash}}%
   \ifnumequal{\value{citecount}}{\value{citetotal}}%
     {\protected@xappto\cbx@textcite@args{{\cbx@savedkeys}}%
      \protected@xappto\cbx@footcite@args{%
        [\thefield{prenote}][\thefield{postnote}]{\cbx@savedkeys}}%
      \iflastcitekey
        {\iffootnote
          {\protected@xappto\cbx@textcite@args{\nopunct}%
            \protected@xappto\cbx@footcite@args{\thefield{postpunct}}}%
          {\protected@xappto\cbx@textcite@args{\thefield{postpunct}}% Switch
            \protected@xappto\cbx@footcite@args{\nopunct}}}% these two?
        {}}
     {}}
  {}
  {}

\newrobustcmd{\cbx@textcite@init}[3]{%
  \setcounter{textcitetotal}{0}%
  \setcounter{textcitecount}{0}%
  \setcounter{textcitemaxnames}{0}%
  \def\cbx@textcite@args{#1}\def\cbx@footcite@args{#2}#3%
  \cbx@textcite@args\empty\cbx@footcite@args\empty}

\DeclareMultiCiteCommand{\cbx@textcites}{\cbx@textcite}{}
\DeclareMultiCiteCommand{\textcites}
  [\cbx@textcites@init\cbx@textcites\cms@textcites@i]{\textcite}{}

\let\cbx@textcites@init\cbx@textcite@init
\pretocmd{\cbx@textcites@init}{%
  \UseNextMultiCiteHook%
  \AtNextMultiCite{%
    \renewbibmacro{multiprenote}{}%
    \renewbibmacro{multipostnote}{}}}{}{}

\renewcommand*{\textcitedelim}{%
  \iffinalcitedelim%
  {\ifnumgreater{\value{textcitetotal}}{2}%
    {\addcomma}%
    {}%
    \addspace\bibstring{and}}%
  {\addcomma}%
  \addspace}%

\newrobustcmd{\cms@textcite@i}{%
  \iffootnote{\foottextcite}{\footcite}}

\newrobustcmd{\cms@textcites@i}{%
  \iffootnote{\foottextcites}{\footcites}}

\newcommand{\foottextcite}{\addspace\headlessparenshortcite}

\newcommand{\foottextcites}{\addspace\headlessparenshortcites}

%%% The \gentextcite commands - \textcite in the genitive case %%%

\DeclareCiteCommand{\cms@gentextcite@i}
  {\usebibmacro{textcite:init}%
    \toggletrue{cms@gencite}}%
  {\iffieldequals{namehash}{\cbx@lasthash}%
     {}%
     {\iffirstcitekey
        {}%
        {\textcitedelim}%
      \stepcounter{textcitecount}%
      \usebibmacro{textcite}%
      \savefield{namehash}{\cbx@lasthash}}}
  {}
  {\togglefalse{cms@gencite}}%

\DeclareCiteCommand{\cms@gentextcite}[\cbx@textcite@init\cms@gentextcite@i\cms@textcite@i]
  {\usebibmacro{textcite:init}%
   \gdef\cbx@savedkeys{}%
   \DeferNextCitekeyHook}
  {\ifthenelse{\iffirstcitekey\AND\value{multicitetotal}>0}%
     {\protected@xappto\cbx@footcite@args{%
        (\thefield{multiprenote})(\thefield{multipostnote})}}%
     {}%
   \xappto\cbx@savedkeys{\thefield{entrykey},}%
   \iffieldequals{namehash}{\cbx@lasthash}%
     {}%
     {\usebibmacro{textcite:count}%
      \savefield{namehash}{\cbx@lasthash}}%
   \ifnumequal{\value{citecount}}{\value{citetotal}}%
     {\protected@xappto\cbx@textcite@args{{\cbx@savedkeys}}%
      \protected@xappto\cbx@footcite@args{%
        [\thefield{prenote}][\thefield{postnote}]{\cbx@savedkeys}}%
      \iflastcitekey
        {\iffootnote
          {\protected@xappto\cbx@textcite@args{\nopunct}%
            \protected@xappto\cbx@footcite@args{\thefield{postpunct}}}%
          {\protected@xappto\cbx@textcite@args{\thefield{postpunct}}% Switch
            \protected@xappto\cbx@footcite@args{\nopunct}}}% these two?
        {}}
     {}}
  {}
  {}

\DeclareMultiCiteCommand{\cms@gentextcite@is}{\cms@gentextcite@i}{}
\DeclareMultiCiteCommand{\cms@gentextcites}
  [\cbx@textcites@init\cms@gentextcite@is\cms@textcites@i]{\cms@gentextcite}{}

\newrobustcmd*{\gentextcite}[1][]{%
  \@ifnextchar[%]
  {\gencite@i[#1]}%
  {\gencite@i[][#1]}}%

\def\gencite@i[#1][#2]{%
  \@ifnextchar[%]
  {\gencite@ii[#1][#2]}%
  {\gencite@ii[][#1][#2]}}%

\def\gencite@ii[#1][#2][#3]#4{%
  \ifblank{#1}{\def\thegen{'s}}{\def\thegen{#1}}%
  \gencite@iii[#2][#3]{#4}}%

\def\gencite@iii#1{\cms@gentextcite#1}

\newrobustcmd*{\gentextcites}[1][]{%
  \@ifnextchar(%)
  {\gencites@iv[#1]}%
  {\@ifnextchar[%]
    {\gencites@i[#1]}%
    {\gencites@i[][#1]}}}%

\def\gencites@i[#1][#2]{%
  \@ifnextchar[%]
  {\gencites@ii[#1][#2]}%
  {\gencites@ii[][#1][#2]}}%

\def\gencites@ii[#1][#2][#3]#4{%
  \ifblank{#1}{\def\thegen{'s}}{\def\thegen{#1}}%
  \gencites@iii[#2][#3]{#4}}%

\def\gencites@iii#1{\cms@gentextcites#1}%

\def\gencites@iv[#1]#2{%
  \ifblank{#1}{\def\thegen{'s}}{\def\thegen{#1}}%
  \cms@gentextcites#2}%

\newrobustcmd*{\Gentextcite}{\bibsentence\gentextcite}
\newrobustcmd*{\Gentextcites}{\bibsentence\gentextcites}

%%% End code for \gentextcite %%%

%%%% Drivers for the Long Note Format %%%%

\DeclareBibliographyDriver{cite:article}{%
  \iffieldequalstr{entrysubtype}{magazine}%
  {\usebibmacro{bibindex}%
  \usebibmacro{cmag+news+author}%
  \usebibmacro{hlpunct}%\newcunit\newblock
  \usebibmacro{cmag+news+title}%
  \setunit{\addspace}%
  \usebibmacro{language+transtitle}%
  \setunit{\addcomma\addspace}%\newblock%
  \usebibmacro{cpart+editor+translator}%
  \newcunit%
  \usebibmacro{issuetitle}%
  \setunit{\addcomma\addspace}%
  \usebibmacro{cbyeditor+others}%
  \setunit{\addcomma\addspace}%
  \printfield{note}%
  \setunit{\addcomma\addspace}\newblock
  \usebibmacro{mag+news+date}%
  \usebibmacro{fullpostnote}%
  \newcunit\newblock
  \usebibmacro{caddendum}%
  \newcunit\newblock
  \iftoggle{cms@isbn}%
  {\printfield{issn}}%
  {}%
  \newcunit\newblock
  \usebibmacro{cite+doi+url}%
  \setunit{\shorthandpunct}%
  \usebibmacro{cms:shorthandintro}%
  \newcunit\newblock
  \usebibmacro{pageref}%
  \newcunit\newblock
  \ifboolexpr{%
    togl {cms@citerel}%
    and
    not test {\iffieldequalstr{relatedtype}{reviewof}}%
    and
    not test {\iffieldundef{related}}%
    }%
  {\usebibmacro{related:init}%
    \usebibmacro{related}%
    \newcunit}%
  {}%
  \usebibmacro{finentry}}
  {\usebibmacro{bibindex}%
  \usebibmacro{author/editor}%
  \usebibmacro{hlpunct}%\newcunit\newblock
  \usebibmacro{cmag+news+title}%
  \setunit{\addspace}%
  \usebibmacro{language+transtitle}%
  \setunit{\addcomma\addspace}%
  \usebibmacro{byauthor}%
  \setunit{\addcomma\addspace}%
  \usebibmacro{cpart+editor+translator}%
  \newcunit%
  \usebibmacro{issuetitle}%
  \setunit{\addcomma\addspace}%
  \usebibmacro{cbyeditor+others}%
  \setunit{\addcomma\addspace}%
  \printfield{note}%
  \setunit{\addcomma\addspace}%
  \usebibmacro{cjournal+issue+year+pages}%
  \usebibmacro{fullpostnote}%
  \newcunit\newblock
  \usebibmacro{caddendum}%
  \newcunit\newblock
  \iftoggle{cms@isbn}%
  {\printfield{issn}}%
  {}%
  \newcunit\newblock
  \usebibmacro{cite+doi+url}%
  \setunit{\shorthandpunct}%
  \usebibmacro{cms:shorthandintro}%
  \newcunit\newblock
  \usebibmacro{pageref}%
  \newcunit\newblock
  \ifboolexpr{%
    togl {cms@citerel}%
    and
    not test {\iffieldequalstr{relatedtype}{reviewof}}%
    and
    not test {\iffieldundef{related}}%
    }%
  {\usebibmacro{related:init}%
    \usebibmacro{related}%
    \newcunit}%
  {}%
  \usebibmacro{finentry}}}

\DeclareBibliographyDriver{cite:artwork}{%
  \usebibmacro{bibindex}%
  \usebibmacro{author/editor}%
  \usebibmacro{hlpunct}%\setunit{\addcomma\addspace}\newblock
  \usebibmacro{citaltitle+stitle}%
  \newcunit\newblock
  \usebibmacro{date}%
  \newcunit
  \usebibmacro{byauthor}%
  \newcunit\newblock
  \usebibmacro{cbyeditor+others}%
  \newcunit\newblock
  \printfield{howpublished}%
  \newcunit\newblock
  \printfield{type}%
  \newcunit\newblock
  \printfield{version}%
  \newcunit\newblock
  \usebibmacro{cnotefield}%
  \newcunit\newblock
  \usebibmacro{institution+organization}%
  \newcunit\newblock
  \printlist{location}%
  \usebibmacro{caddendum}%
  \usebibmacro{fullpostnote}%
  \newcunit\newblock
  \usebibmacro{cite+doi+url}%
  \setunit{\shorthandpunct}%
  \usebibmacro{cms:shorthandintro}%
  \newcunit\newblock
  \usebibmacro{pageref}%
  \newcunit\newblock
  \ifboolexpr{%
    togl {cms@citerel}%
    and
    not test {\iffieldundef{related}}%
  }%
  {\usebibmacro{related:init}%
    \usebibmacro{related}%
    \newcunit}%
  {}%
  \usebibmacro{finentry}}

\DeclareBibliographyDriver{cite:audio}{%
  \usebibmacro{bibindex}%
  \usebibmacro{author/editor}%
  \usebibmacro{hlpunct}%\newcunit\newblock
  \usebibmacro{ctitle+stitle}%
  \setunit{\addspace}\newblock%
  \usebibmacro{language+transtitle}%
  \newcunit
  \usebibmacro{byauthor}%
  \newcunit
  \usebibmacro{cpart+editor+translator}%
  \newcunit
  \usebibmacro{chapinscore}%
  \usebibmacro{btitle+bstitle}%
  \newcunit
  \iffieldundef{edition}%
  {}%
  {\usebibmacro{edition}}%
  \newcunit
  \usebibmacro{bybookauthor}%
  \usebibmacro{cbyeditor+others}%
  \iffieldundef{maintitle}%
  {}%
  {\ifthenelse{\iffieldundef{volume}\AND\iffieldundef{part}}%
    {\ifthenelse{\iffieldundef{title}\AND\iffieldundef{booktitle}}%
      {\usebibmacro{cms-in:}}%
      {\bibstring{in}\setunit{\addspace}}%
      \printtext[maintitle]{%
        \printfield[mtnoformat]{maintitle}%
        \setunit{\subtitlepunct}%
        \printfield[smtnoformat]{mainsubtitle}}%
      \setunit{\ctitleaddonpunct}%
      \printfield{maintitleaddon}}
    {\toggletrue{cms@usedvol}%
      \printfield{volume}%
      \printfield{part}%
      \setunit{\addspace}
      \bibstring{ofseries}%
      \setunit{\addspace}
      \printtext[maintitle]{%
        \printfield[mtnoformat]{maintitle}%
        \setunit{\subtitlepunct}%
        \printfield[smtnoformat]{mainsubtitle}}%
      \setunit{\ctitleaddonpunct}
      \printfield{maintitleaddon}}}
  \newcunit
  \usebibmacro{volume+or+volumes}%
  \newcunit\newblock
  \usebibmacro{cser+num}%
  \newcunit\newblock
  \usebibmacro{cnotefield}%
  \newcunit\newblock
  \usebibmacro{cpubl+loc+year}%
  \newcunit
  \printfield{type}%
  \usebibmacro{volfullpostnote}%
  \newcunit\newblock
  \usebibmacro{caddendum}%
  \newcunit\newblock
  \iftoggle{cms@isbn}%
  {\printfield{isan}%
    \newcunit\newblock
    \printfield{ismn}}%
  {}%
  \newcunit\newblock%
  \usebibmacro{cite+doi+url}%
  \setunit{\shorthandpunct}%
  \usebibmacro{cms:shorthandintro}%
  \newcunit\newblock
  \usebibmacro{pageref}%
  \newcunit\newblock
  \ifboolexpr{%
    togl {cms@citerel}%
    and
    not test {\iffieldundef{related}}%
  }%
  {\usebibmacro{related:init}%
    \usebibmacro{related}%
    \newcunit}%
  {}%
  \usebibmacro{finentry}}

\DeclareBibliographyDriver{cite:book}{%
  \usebibmacro{bibindex}%
  \usebibmacro{author/editor}%
  \usebibmacro{hlpunct}%\newcunit\newblock
  \usebibmacro{citaltitle+stitle}%
  \setunit{\addspace}%
  \usebibmacro{cite:xref+date}%
  \newcunit
  \iffieldundef{maintitle}%
  {\iffieldundef{edition}%
    {}%
    {\usebibmacro{edition}}}%
  {}%
  \newcunit
  \usebibmacro{byauthor}%
  \newcunit
  \usebibmacro{cpart+editor+translator}%
  \newcunit
  \ifboolexpr{%
    test {\iffieldundef{crossref}}%
    or
    not test {\ifentryseen{\thefield{crossref}}}%
    or
    togl {cms@bookcitexref}%
  }%
  {\ifboolexpr{%
      test {\iffieldundef{xref}}%
      or
      not test {\ifentryseen{\thefield{xref}}}%
      or
      togl {cms@bookcitexref}%
    }%
  {\usebibmacro{cmtitle+mstitle+vol+part+title+stitle}%
  \newcunit\newblock
  \iffieldundef{edition}%
  {}%
  {\usebibmacro{edition}}%
  \newcunit
  \usebibmacro{cbyeditor+others}%
  \newcunit
  \usebibmacro{volume+or+volumes}%
  \newcunit\newblock
  \usebibmacro{cser+num}%
  \newcunit\newblock
  \usebibmacro{cnotefield}%
  \newcunit\newblock
  \usebibmacro{cpubl+loc+year}%
  \iftoggle{cms@bookpages}%
  {}%
  {\clearfield{pages}}%
  \usebibmacro{caddendum}%
  \usebibmacro{volfullpostnote}%
  \newcunit\newblock
  \printlist[][-\value{listtotal}]{lista}%
  \newcunit\newblock
  \iftoggle{cms@isbn}%
  {\printfield{isbn}}%
  {}%
  \newcunit\newblock
  \usebibmacro{cite+doi+url}%
  \setunit{\shorthandpunct}%
  \usebibmacro{cms:shorthandintro}%
  \newcunit\newblock
  \usebibmacro{pageref}%
  \newcunit\newblock
  \ifboolexpr{%
    togl {cms@citerel}%
    and
    not test {\iffieldundef{related}}%
  }%
  {\usebibmacro{related:init}%
    \usebibmacro{related}%
    \newcunit}%
  {}%
  \usebibmacro{finentry}%
  \usebibmacro{book:xref+finentry}}%
    {\ifpunctmark{.}% This seems to work.
      {\ifbibliography%
        {\setunit{\bibsentence}}{\addspace\bibsentence}}%
      {\ifbibliography{\unspace}{\addcomma\addspace}}% ?!?
      \usebibmacro{xrefprenote}% Volume fix
      \bookbibxrefcite{\thefield{xref}}% Removed \addspace from each.
      \usebibmacro{xrefpostnote}%
      \usebibmacro{finentry}}}%
  {\ifpunctmark{.}% This seems to work.
      {\ifbibliography%
        {\setunit{\bibsentence}}{\addspace\bibsentence}}%
      {\ifbibliography{\unspace}{\addcomma\addspace}}% ?!?
    \usebibmacro{xrefprenote}% Volume fix
    \bookbibxrefcite{\thefield{crossref}}%
    \usebibmacro{xrefpostnote}%
    \usebibmacro{finentry}}}

\DeclareBibliographyDriver{cite:bookinbook}{%
  \usebibmacro{bibindex}%
  \usebibmacro{author/editor}%
  \usebibmacro{hlpunct}%\newcunit\newblock
  \usebibmacro{citaltitle+stitle}%
  \setunit{\addspace}%
  \usebibmacro{cite:xref+date}%
  \newcunit\newblock
  \usebibmacro{byauthor}%
  \newcunit
  \usebibmacro{cpart+editor+translator}%
  \setunit*{\addcomma\addspace}%
  \ifboolexpr{%
    test {\iffieldundef{crossref}}%
    or
    not test {\ifentryseen{\thefield{crossref}}}%
    or
    togl {cms@bookcitexref}%
  }%
  {\ifboolexpr{%
      test {\iffieldundef{xref}}%
      or
      not test {\ifentryseen{\thefield{xref}}}%
      or
      togl {cms@bookcitexref}%
    }%
  {\usebibmacro{cmtitle+mstitle+vol+part+btitle+bstitle}%
  \newcunit
  \iffieldundef{edition}%
  {}%
  {\usebibmacro{edition}}%
  \newcunit
  \usebibmacro{bybookauthor}%
  \usebibmacro{cbyeditor+others}%
  \newcunit
  \usebibmacro{volume+or+volumes}%
  \newcunit\newblock
  \usebibmacro{cser+num}%
  \newcunit\newblock
  \usebibmacro{cnotefield}%
  \newcunit\newblock
  \usebibmacro{cpubl+loc+year}%
  \usebibmacro{caddendum}%
  \usebibmacro{volfullpostnote}%
  \newcunit\newblock
  \iftoggle{cms@isbn}%
  {\printfield{isbn}}%
  {}%
  \newcunit\newblock
  \usebibmacro{cite+doi+url}%
  \setunit{\shorthandpunct}%
  \usebibmacro{cms:shorthandintro}%
  \newcunit\newblock
  \usebibmacro{pageref}%
  \newcunit\newblock
  \ifboolexpr{%
    togl {cms@citerel}%
    and
    not test {\iffieldundef{related}}%
  }%
  {\usebibmacro{related:init}%
    \usebibmacro{related}%
    \newcunit}%
  {}%
  \usebibmacro{finentry}%
  \usebibmacro{book:xref+finentry}}%
    {\ifpunctmark{.}% This seems to work.
      {\ifbibliography%
        {\setunit{\bibsentence}}{\addspace\bibsentence}}%
      {\ifbibliography{\unspace}{\addcomma\addspace}}% ?!?
      \usebibmacro{xrefprenote}% Volume fix
      \bookbibxrefcite{\thefield{xref}}% Removed \addspace from each.
      \usebibmacro{xrefpostnote}%
      \usebibmacro{finentry}}}%
  {\ifpunctmark{.}% This seems to work.
      {\ifbibliography%
        {\setunit{\bibsentence}}{\addspace\bibsentence}}%
      {\ifbibliography{\unspace}{\addcomma\addspace}}% ?!?
    \usebibmacro{xrefprenote}% Volume fix
    \bookbibxrefcite{\thefield{crossref}}%
    \usebibmacro{xrefpostnote}%
    \usebibmacro{finentry}}}

\DeclareBibliographyDriver{cite:booklet}{%
  \usebibmacro{bibindex}%
  \usebibmacro{author/editor}%
  \usebibmacro{hlpunct}%\setunit{\addcomma\addspace}\newblock
  \usebibmacro{citaltitle+stitle}%
  \newcunit\newblock
  \usebibmacro{byauthor}%
  \newcunit
  \usebibmacro{cnotefield}%
  \setunit{\addspace}\newblock%
  \printtext[parens]{%
  \usebibmacro{howpubl+loc+year}}%
  \usebibmacro{caddendum}%
  \usebibmacro{fullpostnote}%
  \newcunit\newblock
  \usebibmacro{cite+doi+url}%
  \setunit{\shorthandpunct}%
  \usebibmacro{cms:shorthandintro}%
  \newcunit\newblock
  \usebibmacro{pageref}%
  \newcunit\newblock
  \ifboolexpr{%
    togl {cms@citerel}%
    and
    not test {\iffieldundef{related}}%
  }%
  {\usebibmacro{related:init}%
    \usebibmacro{related}%
    \newcunit}%
  {}%
  \usebibmacro{finentry}}

\DeclareBibliographyDriver{cite:collection}{%
  \usebibmacro{bibindex}%
  \usebibmacro{editor}%
  \usebibmacro{hlpunct}%\setunit{\addcomma\addspace}\newblock%
  \usebibmacro{citaltitle+stitle}%
  \setunit{\addspace}
  \usebibmacro{cite:xref+date}%
  \newcunit
  \usebibmacro{cpart+editor+translator}%
  \newcunit
  \ifboolexpr{%
    test {\iffieldundef{crossref}}%
    or
    not test {\ifentryseen{\thefield{crossref}}}%
    or
    togl {cms@bookcitexref}%
  }%
  {\ifboolexpr{%
      test {\iffieldundef{xref}}%
      or
      not test {\ifentryseen{\thefield{xref}}}%
      or
      togl {cms@bookcitexref}%
    }%
  {\usebibmacro{cmtitle+mstitle+vol+part+title+stitle}%
  \newcunit\newblock
  \iffieldundef{edition}%
  {}%
  {\usebibmacro{edition}}%
  \newcunit
  \usebibmacro{cbyeditor+others}%
  \newcunit\newblock
  \usebibmacro{volume+or+volumes}%
  \newcunit\newblock
  \usebibmacro{cser+num}%
  \newcunit\newblock
  \usebibmacro{cnotefield}%
  \newcunit\newblock
  \usebibmacro{cpubl+loc+year}%
  \usebibmacro{caddendum}%
  \usebibmacro{volfullpostnote}%
  \newcunit\newblock
  \iftoggle{cms@isbn}%
  {\printfield{isbn}}%
  {}%
  \newcunit\newblock
  \usebibmacro{cite+doi+url}%
  \setunit{\shorthandpunct}%
  \usebibmacro{cms:shorthandintro}%
  \newcunit\newblock
  \usebibmacro{pageref}%
  \newcunit\newblock
  \ifboolexpr{%
    togl {cms@citerel}%
    and
    not test {\iffieldundef{related}}%
  }%
  {\usebibmacro{related:init}%
    \usebibmacro{related}%
    \newcunit}%
  {}%
  \usebibmacro{finentry}%
  \usebibmacro{book:xref+finentry}}%
    {\ifpunctmark{.}% This seems to work.
      {\ifbibliography%
        {\setunit{\bibsentence}}{\addspace\bibsentence}}%
      {\ifbibliography{\unspace}{\addcomma\addspace}}% ?!?
      \usebibmacro{xrefprenote}% Volume fix
      \bookbibxrefcite{\thefield{xref}}% Removed \addspace from each.
      \usebibmacro{xrefpostnote}%
      \usebibmacro{finentry}}}%
  {\ifpunctmark{.}% This seems to work. Only with Vol?
    {\ifbibliography%
      {\setunit{\bibsentence}}{\addspace\bibsentence}}%
    {\ifbibliography{\unspace}{\addcomma\addspace}}% ?!?
    \usebibmacro{xrefprenote}% Volume fix
    \bookbibxrefcite{\thefield{crossref}}%
    \usebibmacro{xrefpostnote}%
    \usebibmacro{finentry}}}

\DeclareBibliographyDriver{cite:customc}{%
  \usebibmacro{bibindex}%
  \usebibmacro{author/editor}%
  \newcunit\newblock
  \printfield{nameaddon}%
  \setunit*{\addspace}%
  \usebibmacro{italtitle+stitle}%
  \usebibmacro{finentry}}

\DeclareBibliographyDriver{cite:image}{%
  \usebibmacro{bibindex}%
  \usebibmacro{author/editor}%
  \usebibmacro{hlpunct}%
  \usebibmacro{citaltitle+stitle}%
  \newcunit%\setunit{\addcomma\addspace}%
  \usebibmacro{date}%
  \newcunit
  \usebibmacro{byauthor}%
  \newcunit\newblock
  \usebibmacro{cbyeditor+others}%
  \newcunit\newblock
  \printfield{howpublished}%
  \newcunit\newblock
  \printfield{type}%
  \newcunit\newblock
  \printfield{version}%
  \newcunit\newblock
  \usebibmacro{cnotefield}%
  \newcunit\newblock
  \usebibmacro{institution+organization}%
  \newcunit\newblock
  \printlist{location}%
  \usebibmacro{caddendum}%
  \usebibmacro{fullpostnote}%
  \newcunit\newblock
  \usebibmacro{cite+doi+url}%
  \setunit{\shorthandpunct}%
  \usebibmacro{cms:shorthandintro}%
  \newcunit\newblock
  \usebibmacro{pageref}%
  \newcunit\newblock
  \ifboolexpr{%
    togl {cms@citerel}%
    and
    not test {\iffieldundef{related}}%
  }%
  {\usebibmacro{related:init}%
    \usebibmacro{related}%
    \newcunit}%
  {}%
  \usebibmacro{finentry}}

\DeclareBibliographyDriver{cite:inbook}{%
  \usebibmacro{bibindex}%
  \usebibmacro{author/editor}%
  \usebibmacro{hlpunct}%\newcunit\newblock
  \usebibmacro{ctitle+stitle}%
  \setunit{\addspace}\newblock%
  \usebibmacro{language+transtitle}%
  \setunit{\addcomma\addspace}%
  \usebibmacro{byauthor}%
  \setunit{\addcomma\addspace}%
  \usebibmacro{cpart+editor+translator}%
  \setunit{\addcomma\addspace}%
  \ifboolexpr{%
    test {\iffieldundef{crossref}}%
    or
    not test {\ifentryseen{\thefield{crossref}}}%
    or
    togl {cms@citecrossref}%
  }%
  {\ifboolexpr{%
      test {\iffieldundef{xref}}%
      or
      not test {\ifentryseen{\thefield{xref}}}%
      or
      togl {cms@citecrossref}%
    }%
  {\usebibmacro{chapincoll}%
  \usebibmacro{cmtitle+mstitle+vol+part+btitle+bstitle}%
  \newcunit
  \iffieldundef{edition}%
  {}%
  {\usebibmacro{edition}}%
  \newcunit
  \usebibmacro{bybookauthor}%
  \usebibmacro{cbyeditor+others}%
  \newcunit
  \usebibmacro{volume+or+volumes}%
  \newcunit\newblock
  \usebibmacro{cser+num}%
  \newcunit\newblock
  \usebibmacro{cnotefield}%
  \newcunit\newblock
  \usebibmacro{cpubl+loc+year}%
  \usebibmacro{caddendum}%
  \usebibmacro{volfullpostnote}%
  \newcunit\newblock
  \iftoggle{cms@isbn}%
  {\printfield{isbn}}%
  {}%
  \newcunit\newblock
  \usebibmacro{cite+doi+url}%
  \setunit{\shorthandpunct}%
  \usebibmacro{cms:shorthandintro}%
  \newcunit\newblock
  \usebibmacro{pageref}%
  \newcunit\newblock
  \ifboolexpr{%
    togl {cms@citerel}%
    and
    not test {\iffieldundef{related}}%
  }%
  {\usebibmacro{related:init}%
    \usebibmacro{related}%
    \newcunit}%
  {}%
  \usebibmacro{finentry}%
  \usebibmacro{cite:xref+finentry}}%
{\ifpunctmark{.}{\setunit{\addspace\bibsentence}}{\newcunit}% 16th ed.
      \usebibmacro{xrefprenote}% Volume fix
      \usebibmacro{xrefchapincoll}%
      \bibxrefcite{\thefield{xref}}% Removed \addspace from each.
      \usebibmacro{xrefpostnote}%
      \usebibmacro{finentry}}}%
  {\ifpunctmark{.}{\setunit{\addspace\bibsentence}}{\newcunit}% 16th ed.
    \usebibmacro{xrefprenote}% Volume fix
    \usebibmacro{xrefchapincoll}%
    \bibxrefcite{\thefield{crossref}}%
    \usebibmacro{xrefpostnote}%
    \usebibmacro{finentry}}}

\DeclareBibliographyDriver{cite:incollection}{%
  \usebibmacro{bibindex}%
  \usebibmacro{author/editor}%
  \usebibmacro{hlpunct}%
  \usebibmacro{ctitle+stitle}%
  \setunit{\addspace}\newblock%
  \usebibmacro{language+transtitle}%
  \setunit{\addcomma\addspace}%
  \usebibmacro{byauthor}%
  \setunit{\addcomma\addspace}%
  \usebibmacro{cpart+editor+translator}%
  \setunit{\addcomma\addspace}%
  \ifboolexpr{%
    test {\iffieldundef{crossref}}%
    or
    not test {\ifentryseen{\thefield{crossref}}}%
    or
    togl {cms@citecrossref}%
  }%
  {\ifboolexpr{%
      test {\iffieldundef{xref}}%
      or
      not test {\ifentryseen{\thefield{xref}}}%
      or
      togl {cms@citecrossref}%
    }%
    {\usebibmacro{chapincoll}%
      \usebibmacro{cmtitle+mstitle+vol+part+btitle+bstitle}%
      \newcunit
      \iffieldundef{edition}%
      {}%
      {\usebibmacro{edition}}%
      \newcunit
      \usebibmacro{bybookauthor}%
      \usebibmacro{cbyeditor+others}%
      \newcunit
      \usebibmacro{volume+or+volumes}%
      \newcunit\newblock
      \usebibmacro{cser+num}%
      \newcunit\newblock
      \usebibmacro{cnotefield}%
      \newcunit\newblock
      \usebibmacro{cpubl+loc+year}%
      \usebibmacro{caddendum}%
      \usebibmacro{volfullpostnote}%
      \newcunit\newblock
      \iftoggle{cms@isbn}%
      {\printfield{isbn}}%
      {}%
      \newcunit\newblock
      \usebibmacro{cite+doi+url}%
      \setunit{\shorthandpunct}%
      \usebibmacro{cms:shorthandintro}%
      \newcunit\newblock
      \usebibmacro{pageref}%
      \newcunit\newblock
      \ifboolexpr{%
        togl {cms@citerel}%
        and
        not test {\iffieldundef{related}}%
      }%
      {\usebibmacro{related:init}%
        \usebibmacro{related}%
        \newcunit}%
      {}%
      \usebibmacro{finentry}%
      \usebibmacro{cite:xref+finentry}}%
    {\ifpunctmark{.}{\setunit{\addspace\bibsentence}}{\newcunit}% 16th ed.
      \usebibmacro{xrefprenote}% Volume fix
      \usebibmacro{xrefchapincoll}%
      \bibxrefcite{\thefield{xref}}% Removed \addspace from each.
      \usebibmacro{xrefpostnote}%
      \usebibmacro{finentry}}}%
  {\ifpunctmark{.}{\setunit{\addspace\bibsentence}}{\newcunit}% 16th ed.
    \usebibmacro{xrefprenote}% Volume fix
    \usebibmacro{xrefchapincoll}%
    \bibxrefcite{\thefield{crossref}}%
    \usebibmacro{xrefpostnote}%
    \usebibmacro{finentry}}}

\DeclareBibliographyDriver{cite:inproceedings}{%
  \usebibmacro{bibindex}%
  \usebibmacro{author/editor}%
  \usebibmacro{hlpunct}%\newcunit\newblock
  \usebibmacro{ctitle+stitle}%
  \setunit{\addspace}\newblock%
  \usebibmacro{language+transtitle}%
  \setunit{\addcomma\addspace}%
  \usebibmacro{byauthor}%
  \setunit{\addcomma\addspace}%
  \usebibmacro{cpart+editor+translator}%
  \setunit{\addcomma\addspace}%
  \ifboolexpr{%
    test {\iffieldundef{crossref}}%
    or
    not test {\ifentryseen{\thefield{crossref}}}%
    or
    togl {cms@citecrossref}%
  }%
  {\ifboolexpr{%
      test {\iffieldundef{xref}}%
      or
      not test {\ifentryseen{\thefield{xref}}}%
      or
      togl {cms@citecrossref}%
    }%
    {\usebibmacro{chapincoll}%
      \usebibmacro{cmtitle+mstitle+vol+part+btitle+bstitle}%
      \newcunit\newblock
      \usebibmacro{cbyeditor+others}%
      \newcunit\newblock
      \usebibmacro{volume+or+volumes}%
      \newcunit\newblock
      \usebibmacro{cser+num}%
      \newcunit\newblock
      \usebibmacro{cnotefield}%
      \setunit{\addspace}\newblock%
      \printtext[parens]{%
        \usebibmacro{org+publ+loc+year}}%
      \usebibmacro{caddendum}%
      \usebibmacro{volfullpostnote}%
      \newcunit\newblock
      \iftoggle{cms@isbn}%
      {\printfield{isbn}}%
      {}%
      \newcunit\newblock
      \usebibmacro{cite+doi+url}%
      \setunit{\shorthandpunct}%
      \usebibmacro{cms:shorthandintro}%
      \newcunit\newblock
      \usebibmacro{pageref}%
      \newcunit\newblock
      \ifboolexpr{%
        togl {cms@citerel}%
        and
        not test {\iffieldundef{related}}%
      }%
      {\usebibmacro{related:init}%
        \usebibmacro{related}%
        \newcunit}%
      {}%
      \usebibmacro{finentry}%
      \usebibmacro{cite:xref+finentry}}%
    {\ifpunctmark{.}{\setunit{\addspace\bibsentence}}{\newcunit}% 16th ed.
      \usebibmacro{xrefprenote}% Volume fix
      \usebibmacro{xrefchapincoll}%
      \bibxrefcite{\thefield{xref}}%
      \usebibmacro{xrefpostnote}%
      \usebibmacro{finentry}}}%
  {\ifpunctmark{.}{\setunit{\addspace\bibsentence}}{\newcunit}% 16th ed.
    \usebibmacro{xrefprenote}% Volume fix
    \usebibmacro{xrefchapincoll}%
    \bibxrefcite{\thefield{crossref}}%
    \usebibmacro{xrefpostnote}%
    \usebibmacro{finentry}}}

\DeclareBibliographyDriver{cite:inreference}{%
  \usebibmacro{bibindex}%
  \usebibmacro{citaltitle+stitle}%
  \newcunit\newblock
  \ifthenelse{\iffieldundef{maintitle}\AND\iffieldundef{booktitle}}%
  {\iffieldundef{edition}%
    {}%
    {\usebibmacro{edition}}}%
  {}%
  \newcunit
  \usebibmacro{cpart+editor+translator}%
  \setunit*{\addcomma\addspace}%
  \usebibmacro{cmtitle+mstitle+vol+part+btitle+bstitle}%
  \newcunit
  \iffieldundef{edition}%
  {}%
  {\usebibmacro{edition}}%
  \newcunit
  \usebibmacro{bybookauthor}%
  \usebibmacro{cbyeditor+others}%
  \newcunit
  \usebibmacro{volume+or+volumes}%
  \newcunit\newblock
  \usebibmacro{cser+num}%
  \newcunit\newblock
  \usebibmacro{cnotefield}%
  \newcunit\newblock
  \usebibmacro{cpubl+loc+year}%
  \usebibmacro{caddendum}%
  \usebibmacro{inreffullpostnote}%
  \newcunit\newblock%setunit{\addspace}% 16th ed
  \ifnameundef{author}%
  {}%
  {\printtext{% 16th ed
      \bibstring{by}%
      \addspace%
      \printnames{author}}}%
  \newcunit\newblock
  \iftoggle{cms@isbn}%
  {\printfield{isbn}}%
  {}%
  \newcunit\newblock
  \usebibmacro{cite+doi+url}%
  \setunit{\shorthandpunct}%
  \usebibmacro{cms:shorthandintro}%
  \newcunit\newblock
  \usebibmacro{pageref}%
  \newcunit\newblock
  \ifboolexpr{%
    togl {cms@citerel}%
    and
    not test {\iffieldundef{related}}%
  }%
  {\usebibmacro{related:init}%
    \usebibmacro{related}%
    \newcunit}%
  {}%
  \usebibmacro{finentry}}

\DeclareBibliographyDriver{cite:jurisdiction}{%
  \iffieldequalstr{entrysubtype}{square}% FIXME?
  {\usebibmacro{bibindex}%
    \usebibmacro{clegis+news+title}%
    \setunit{\addspace}%
    \usebibmacro{language+transtitle}%
    \setunit{\addcomma\addspace}%
    \usebibmacro{byauthor}%
    \setunit{\addcomma\addspace}%
    \usebibmacro{cpart+editor+translator}%
    \newcunit%
    \usebibmacro{issuetitle}%
    \setunit{\addcomma\addspace}%
    \usebibmacro{cbyeditor+others}%
    \setunit{\addcomma\addspace}%
    \printfield[juridnum]{number}%
    \newcunit%
    \iffieldundef{year}%
    {}%
    {\printtext[brackets]{%
      \begingroup% Better ideas?
      \let\abx@bibmonth\blx@imc@bibsstring%
      \usebibmacro{date}\endgroup}}%
    \setunit*{\addspace}%
    \printfield[jourvol]{volume}%
    \setunit{\addnbspace}%
    \iffieldundef{shortjournal}%
    {}%
    {\printtext[shortjournal]{%
      \printfield[jtsnoformat]{shortjournal}}}%
    \iffieldundef{issue}%
    {\printfield[jurisdictionser]{series}}%
    {\setunit{\addspace}%
      \printfield{issue}}% Better ideas?
    \usebibmacro{juridpostnote}%
    \setunit{\addcomma\addspace}%
    \printfield{note}%
    \setunit{\addspace}%
    \printlist{location}%
    \setunit{\shorthandpunct}%
    \usebibmacro{cms:shorthandintro}% Moved before addendum
    \setunit{\addspace}\newblock
    \printfield{addendum}%
    \newcunit\newblock
    \iftoggle{cms@isbn}%
    {\printfield{issn}}%
    {}%
    \newcunit\newblock
    \usebibmacro{cite+doi+url}%
    \newcunit\newblock
    \usebibmacro{pageref}%
    \newcunit\newblock
    \ifboolexpr{%
      togl {cms@citerel}%
      and
      not test {\iffieldundef{related}}%
    }%
    {\usebibmacro{related:init}%
      \usebibmacro{related}%
      \newcunit}%
    {}%
    \usebibmacro{finentry}}
  {\iffieldequalstr{entrysubtype}{round}% FIXME?
    {\usebibmacro{bibindex}%
      \usebibmacro{clegis+news+title}%
      \setunit{\addspace}%
      \usebibmacro{language+transtitle}%
      \setunit{\addcomma\addspace}%
      \usebibmacro{byauthor}%
      \setunit{\addcomma\addspace}%
      \usebibmacro{cpart+editor+translator}%
      \newcunit%
      \usebibmacro{issuetitle}%
      \setunit{\addcomma\addspace}%
      \usebibmacro{cbyeditor+others}%
      \setunit{\addcomma\addspace}%
      \printfield[juridnum]{number}%
      \newcunit%
      \iffieldundef{year}%
      {}%
      {\printtext[parens]{%
        \begingroup% Better ideas?
        \let\abx@bibmonth\blx@imc@bibsstring%
        \usebibmacro{date}\endgroup}}%
      \setunit*{\addspace}%
      \printfield[jourvol]{volume}%
      \setunit{\addnbspace}%
      \iffieldundef{shortjournal}%
      {}%
      {\printtext[shortjournal]{%
        \printfield[jtsnoformat]{shortjournal}}}%
      \iffieldundef{issue}%
      {\printfield[jurisdictionser]{series}}%
      {\setunit{\addspace}%
        \printfield{issue}}% Better ideas?
      \usebibmacro{juridpostnote}%
      \setunit{\addcomma\addspace}%
      \printfield{note}%
      \setunit{\addspace}%
      \printlist{location}%
      \setunit{\shorthandpunct}%
      \usebibmacro{cms:shorthandintro}% Moved before addendum
      \setunit{\addspace}\newblock
      \printfield{addendum}%
      \newcunit\newblock
      \iftoggle{cms@isbn}%
      {\printfield{issn}}%
      {}%
      \newcunit\newblock
      \usebibmacro{cite+doi+url}%
      \newcunit\newblock
      \usebibmacro{pageref}%
      \newcunit\newblock
      \ifboolexpr{%
        togl {cms@citerel}%
        and
        not test {\iffieldundef{related}}%
      }%
      {\usebibmacro{related:init}%
        \usebibmacro{related}%
        \newcunit}%
      {}%
      \usebibmacro{finentry}}
    {\usebibmacro{bibindex}%
      \usebibmacro{clegis+news+title}%
      \setunit{\addspace}%
      \usebibmacro{language+transtitle}%
      \setunit{\addcomma\addspace}%
      \usebibmacro{byauthor}%
      \setunit{\addcomma\addspace}%
      \usebibmacro{cpart+editor+translator}%
      \newcunit%
      \usebibmacro{issuetitle}%
      \setunit{\addcomma\addspace}%
      \usebibmacro{cbyeditor+others}%
      \setunit{\addcomma\addspace}%
      \printfield[juridnum]{number}%
      \newcunit%
      \printfield[jourvol]{volume}%
      \setunit*{\addnbspace}%
      \iffieldundef{shortjournal}%
      {}%
      {\printtext[shortjournal]{%
        \printfield[jtsnoformat]{shortjournal}}}%
      \iffieldundef{issue}%
      {\printfield[jurisdictionser]{series}}%
      {\setunit{\addspace}%
        \printfield{issue}}% Better ideas?
      \setunit{\addspace}%
      \printlist{origpublisher}% Extra reporters, same pagination
      \usebibmacro{juridpostnote}%
      \setunit{\addcomma\addspace}%
      \printlist{origlocation}% Extra reporters, different pagination
      \setunit{\addcomma\addspace}%
      \printfield{note}%
      \setunit{\addspace}%
      \ifboolexpr{%
        test {\iffieldundef{year}}%
        and
        test {\iflistundef{location}}%
      }%
      {}%
      {\printtext[parens]{%
        \printlist{location}%
        \setunit*{\addspace}%
        \begingroup% Better ideas?
        \let\abx@bibmonth\blx@imc@bibsstring%
        \usebibmacro{date}\endgroup}}%
      \setunit{\shorthandpunct}%
      \usebibmacro{cms:shorthandintro}% Moved before addendum
      \setunit{\addspace}\newblock
      \printfield{addendum}%
      \newcunit\newblock
      \iftoggle{cms@isbn}%
      {\printfield{issn}}%
      {}%
      \newcunit\newblock
      \usebibmacro{cite+doi+url}%
      \newcunit\newblock
      \usebibmacro{pageref}%
      \newcunit\newblock
      \ifboolexpr{%
        togl {cms@citerel}%
        and
        not test {\iffieldundef{related}}%
      }%
      {\usebibmacro{related:init}%
        \usebibmacro{related}%
        \newcunit}%
      {}%
      \usebibmacro{finentry}}}}

\DeclareBibliographyDriver{cite:legal}{%
  \usebibmacro{bibindex}%
  \usebibmacro{author/editor}%
  \usebibmacro{hlpunct}%\newcunit\newblock
  \usebibmacro{clegis+news+title}%
  \setunit{\addspace}%
  \usebibmacro{language+transtitle}%
  \setunit{\addcomma\addspace}%
  \usebibmacro{byauthor}%
  \setunit{\addcomma\addspace}%
  \usebibmacro{cpart+editor+translator}%
  \newcunit%
  \usebibmacro{issuetitle}%
  \setunit{\addcomma\addspace}%
  \usebibmacro{cbyeditor+others}%
  \setunit{\addcomma\addspace}%
  \printfield[juridnum]{number}%
  \newcunit%
  \iffieldundef{year}%
  {}%
  {\printtext{%
    \begingroup% Better ideas?
    \let\abx@bibmonth\blx@imc@bibsstring%
    \usebibmacro{date}\endgroup}}%
  \newcunit%\setunit*{\addspace}%
  \printfield[jourvol]{volume}%
  \setunit*{\addnbspace}%
  \iffieldundef{shortjournal}%
  {}%
  {\printtext[shortjournal]{%
    \printfield[jtsnoformat]{shortjournal}}}%
  \setunit{\addspace}%
  \printfield{series}%
  \setunit{\addspace}%
  \printfield{issue}%
  \newcunit%
  \printfield{part}%
  \newcunit%
  \printfield{chapter}%
  \usebibmacro{juridpostnote}%
  \setunit{\addcomma\addspace}%
  \printfield{note}%
  \setunit{\addspace}%
  \printlist{location}%
  \setunit{\shorthandpunct}%
  \usebibmacro{cms:shorthandintro}% Moved before addendum
  \setunit{\addspace}\newblock%
  \printfield{addendum}%
  \newcunit\newblock
  \iftoggle{cms@isbn}%
  {\printfield{issn}}%
  {}%
  \newcunit\newblock
  \usebibmacro{cite+doi+url}%
  \newcunit\newblock
  \usebibmacro{pageref}%
  \newcunit\newblock
  \ifboolexpr{%
    togl {cms@citerel}%
    and
    not test {\iffieldundef{related}}%
  }%
  {\usebibmacro{related:init}%
    \usebibmacro{related}%
    \newcunit}%
  {}%
  \usebibmacro{finentry}}

\DeclareBibliographyDriver{cite:legislation}{%
  \iffieldequalstr{entrysubtype}{uk}% FIXME?
  {\usebibmacro{bibindex}%
    \usebibmacro{author/editor}%
    \usebibmacro{hlpunct}%\newcunit\newblock
    \usebibmacro{clegis+news+title}%
    \setunit{\addspace}%
    \usebibmacro{language+transtitle}%
    \setunit{\addcomma\addspace}%
    \usebibmacro{byauthor}%
    \setunit{\addcomma\addspace}%
    \usebibmacro{cpart+editor+translator}%
    \newcunit%
    \usebibmacro{issuetitle}%
    \setunit{\addcomma\addspace}%
    \usebibmacro{cbyeditor+others}%
    \setunit{\addcomma\addspace}%
    \printfield[juridnum]{number}%
    \setunit{\addcomma\addspace}%
    \printfield{note}% Needed here?
    \newcunit%
    \iffieldundef{year}%
    {}%
    {\printtext{%
      \begingroup% Better ideas?
      \let\abx@bibmonth\blx@imc@bibsstring%
      \usebibmacro{date}\endgroup}}%
    \newcunit%\setunit*{\addspace}%
    \printfield[jourvol]{volume}%
    \setunit*{\addnbspace}%
    \iffieldundef{shortjournal}%
    {}%
    {\printtext[shortjournal]{%
      \printfield[jtsnoformat]{shortjournal}}}%
    \setunit{\addspace}%
    \printfield{series}%
    \setunit{\addspace}%
    \printfield{issue}%
    \newcunit%
    \printfield{part}%
    \newcunit%
    \printfield{chapter}%
    \usebibmacro{juridpostnote}%
    \setunit{\addspace}%
    \printlist{location}%
    \setunit{\shorthandpunct}%
    \usebibmacro{cms:shorthandintro}% Moved before addendum
    \setunit{\addspace}\newblock%
    \printfield{addendum}%
    \newcunit\newblock
    \iftoggle{cms@isbn}%
    {\printfield{issn}}%
    {}%
    \newcunit\newblock
    \usebibmacro{cite+doi+url}%
    \newcunit\newblock
    \usebibmacro{pageref}%
    \newcunit\newblock
    \ifboolexpr{%
      togl {cms@citerel}%
      and
      not test {\iffieldundef{related}}%
    }%
    {\usebibmacro{related:init}%
      \usebibmacro{related}%
      \newcunit}%
    {}%
    \usebibmacro{finentry}}
  {\iffieldequalstr{entrysubtype}{hansard}% FIXME?
    {\usebibmacro{bibindex}%
      \usebibmacro{author/editor}%
      \usebibmacro{hlpunct}%\newcunit\newblock
      \usebibmacro{clegis+news+title}%
      \setunit{\addspace}%
      \usebibmacro{language+transtitle}%
      \setunit{\addcomma\addspace}%
      \usebibmacro{byauthor}%
      \setunit{\addcomma\addspace}%
      \usebibmacro{cpart+editor+translator}%
      \newcunit%
      \usebibmacro{issuetitle}%
      \setunit{\addcomma\addspace}%
      \usebibmacro{cbyeditor+others}%
      \setunit{\addcomma\addspace}%
      \printfield[juridnum]{number}%
      \setunit{\addcomma\addspace}%
      \printfield{note}% Needed here?
      \newcunit%
      \printfield[jourvol]{volume}%
      \setunit*{\addnbspace}%
      \iffieldundef{shortjournal}%
      {}%
      {\printtext[shortjournal]{%
        \printfield[jtsnoformat]{shortjournal}}}%
      \setunit{\addspace}%
      \printfield[hansardser]{series}%
      \setunit{\addspace}%
      \iffieldundef{year}%
      {}%
      {\printtext[parens]{%
        \begingroup% Better ideas?
        \let\abx@bibmonth\blx@imc@bibsstring%
        \usebibmacro{date}\endgroup}}%
      \usebibmacro{juridpostnote}%
      \setunit{\addspace}%
      \printlist{location}%
      \setunit{\shorthandpunct}%
      \usebibmacro{cms:shorthandintro}% Moved before addendum
      \setunit{\addspace}\newblock%
      \printfield{addendum}%
      \newcunit\newblock
      \iftoggle{cms@isbn}%
      {\printfield{issn}}%
      {}%
      \newcunit\newblock
      \usebibmacro{cite+doi+url}%
      \newcunit\newblock
      \usebibmacro{pageref}%
      \newcunit\newblock
      \ifboolexpr{%
        togl {cms@citerel}%
        and
        not test {\iffieldundef{related}}%
      }%
      {\usebibmacro{related:init}%
        \usebibmacro{related}%
        \newcunit}%
      {}%
      \usebibmacro{finentry}}
    {\usebibmacro{bibindex}%
      \usebibmacro{author/editor}%
      \usebibmacro{hlpunct}%\newcunit\newblock
      \usebibmacro{clegis+news+title}%
      \setunit{\addspace}%
      \usebibmacro{language+transtitle}%
      \setunit{\addcomma\addspace}%
      \usebibmacro{byauthor}%
      \setunit{\addcomma\addspace}%
      \usebibmacro{cpart+editor+translator}%
      \newcunit%
      \usebibmacro{issuetitle}%
      \setunit{\addcomma\addspace}%
      \usebibmacro{cbyeditor+others}%
      \setunit{\addspace}% FIXME?
      \printfield[juridnum]{number}%
      \setunit{\addcomma\addspace}%
      \printfield{note}% Needed here?
      \newcunit%
      \printfield[jourvol]{volume}%
      \setunit*{\addnbspace}%
      \iffieldundef{shortjournal}%
      {}%
      {\printtext[shortjournal]{%
        \printfield[jtsnoformat]{shortjournal}}}%
      \newcunit%
      \printfield{series}%
      \setunit{\addspace}%
      \printfield{issue}%
      \newcunit%
      \printfield{part}%
      \newcunit%
      \printfield{chapter}%
      \usebibmacro{juridpostnote}%
      \setunit{\addspace}%
      \ifboolexpr{%
        test {\iffieldundef{year}}%
        and
        test {\iffieldundef{usera}}%
        and
        test {\iflistundef{location}}%
      }%
      {}%
      {\printtext[parens]{%
          \printlist{location}%
          \setunit*{\addspace}%
          \printfield{usera}%
          \setunit*{\addspace}%
          \begingroup% Better ideas?
          \let\abx@bibmonth\blx@imc@bibsstring%
          \usebibmacro{date}\endgroup}}%
      \setunit{\shorthandpunct}%
      \usebibmacro{cms:shorthandintro}%
      \setunit{\addspace}\newblock%
      \printfield{addendum}%
      \newcunit\newblock
      \iftoggle{cms@isbn}%
      {\printfield{issn}}%
      {}%
      \newcunit\newblock
      \usebibmacro{cite+doi+url}%
      \newcunit\newblock
      \usebibmacro{pageref}%
      \newcunit\newblock
      \ifboolexpr{%
        togl {cms@citerel}%
        and
        not test {\iffieldundef{related}}%
      }%
      {\usebibmacro{related:init}%
        \usebibmacro{related}%
        \newcunit}%
      {}%
      \usebibmacro{finentry}}}}

\DeclareBibliographyDriver{cite:letter}{%
  \usebibmacro{bibindex}%
  \savefield{fullhash}{\bbx@lasthash}%
  \printtext[title]{%
    \printfield[noformat]{title}}%
  \setunit{\ctitleaddonpunct}%
  \printfield{titleaddon}%
  \setunit*{\addcomma\addspace}%
  \usebibmacro{letter+date}%
  \setunit{\addspace}%
  \usebibmacro{language+transtitle}%
  \newcunit\newblock%
  \usebibmacro{cpart+editor+translator}%
  \setunit*{\addcomma\addspace}%
  \ifboolexpr{%
    test {\iffieldundef{crossref}}%
    or
    not test {\ifentryseen{\thefield{crossref}}}%
    or
    togl {cms@citecrossref}%
  }%
  {\ifboolexpr{%
      test {\iffieldundef{xref}}%
      or
      not test {\ifentryseen{\thefield{xref}}}%
      or
      togl {cms@citecrossref}%
    }%
    {\usebibmacro{chapincoll}%
      \usebibmacro{cmtitle+mstitle+vol+part+btitle+bstitle}%
      \newcunit
      \iffieldundef{edition}%
      {}%
      {\usebibmacro{edition}}%
      \newcunit
      \usebibmacro{bybookauthor}%
      \usebibmacro{cbyeditor+others}%
      \newcunit
      \usebibmacro{volume+or+volumes}%
      \newcunit\newblock
      \usebibmacro{cser+num}%
      \newcunit\newblock
      \usebibmacro{cnotefield}%
      \newcunit\newblock
      \usebibmacro{cpubletter+loc+year}%
      \usebibmacro{caddendum}%
      \usebibmacro{volfullpostnote}%
      \newcunit\newblock
      \iftoggle{cms@isbn}%
      {\printfield{isbn}}%
      {}%
      \newcunit\newblock
      \usebibmacro{cite+doi+url}%
      \setunit{\shorthandpunct}%
      \usebibmacro{cms:shorthandintro}%
      \newcunit\newblock
      \usebibmacro{pageref}%
      \newcunit\newblock
      \ifboolexpr{%
        togl {cms@citerel}%
        and
        not test {\iffieldundef{related}}%
      }%
      {\usebibmacro{related:init}%
        \usebibmacro{related}%
        \newcunit}%
      {}%
      \usebibmacro{finentry}%
      \usebibmacro{cite:xref+finentry}}%
    {\ifpunctmark{.}{\setunit{\addspace\bibsentence}}{\newcunit}% 16th ed.
      \usebibmacro{xrefprenote}% Volume fix
      \usebibmacro{xrefchapincoll}%
      \bibxrefcite{\thefield{xref}}%
      \usebibmacro{xrefpostnote}%
      \usebibmacro{finentry}}}%
  {\ifpunctmark{.}{\setunit{\addspace\bibsentence}}{\newcunit}% 16th ed.
    \usebibmacro{xrefprenote}% Volume fix
    \usebibmacro{xrefchapincoll}%
    \bibxrefcite{\thefield{crossref}}%
    \usebibmacro{xrefpostnote}%
    \usebibmacro{finentry}}}

\DeclareBibliographyDriver{cite:manual}{%
  \usebibmacro{bibindex}%
  \usebibmacro{author+org}%
  \usebibmacro{hlpunct}%\setunit{\addcomma\addspace}\newblock%
  \usebibmacro{citaltitle+stitle}%
  \newcunit
  \usebibmacro{edition}%
  \newcunit
  \usebibmacro{byauthor}%
  \newcunit\newblock
  \usebibmacro{cser+num}%
  \newcunit\newblock
  \printfield{type}%
  \newcunit
  \usebibmacro{cnotefield}%
  \setunit{\addspace}\newblock%
  \printtext[parens]{%
  \usebibmacro{org+publ+loc+year}}%
  \usebibmacro{caddendum}%
  \usebibmacro{fullpostnote}%
  \newcunit\newblock
  \iftoggle{cms@isbn}%
  {\printfield{isbn}}%
  {}%
  \newcunit\newblock
  \usebibmacro{cite+doi+url}%
  \setunit{\shorthandpunct}%
  \usebibmacro{cms:shorthandintro}%
  \newcunit\newblock
  \usebibmacro{pageref}%
  \newcunit\newblock
  \ifboolexpr{%
    togl {cms@citerel}%
    and
    not test {\iffieldundef{related}}%
  }%
  {\usebibmacro{related:init}%
    \usebibmacro{related}%
    \newcunit}%
  {}%
  \usebibmacro{finentry}}

\DeclareBibliographyDriver{cite:misc}{%
  \usebibmacro{bibindex}%
  \usebibmacro{author/editor}%
  \usebibmacro{hlpunct}%
  \iffieldundef{entrysubtype}%
  {\usebibmacro{citaltitle+stitle}}%
  {\printfield{title}%
    \setunit{\subtitlepunct}%
    \printfield[noformat]{subtitle}%
    \setunit{\ctitleaddonpunct}%
    \printfield{titleaddon}%
    \setunit{\addspace}%
    \usebibmacro{language+transtitle}%
    \newcunit%
    \usebibmacro{unpubl+letter+date}}%
  \newcunit
  \usebibmacro{byauthor}%
  \newcunit\newblock
  \usebibmacro{cbyeditor+others}%
  \newcunit\newblock
  \printfield{howpublished}%
  \newcunit\newblock
  \printfield{type}%
  \newcunit\newblock
  \printfield{version}%
  \newcunit\newblock
  \printfield{note}%
  \newcunit\newblock
  \usebibmacro{institution+organization}%
  \newcunit\newblock
  \printlist{location}%
  \iffieldundef{entrysubtype}%
  {\newcunit\newblock
    \usebibmacro{date}}%
  {}%
  \usebibmacro{caddendum}%
  \usebibmacro{fullpostnote}%
  \newcunit\newblock
  \usebibmacro{cite+doi+url}%
  \setunit{\shorthandpunct}%
  \usebibmacro{cms:shorthandintro}%
  \newcunit\newblock
  \usebibmacro{pageref}%
  \newcunit\newblock
  \ifboolexpr{%
    togl {cms@citerel}%
    and
    not test {\iffieldundef{related}}%
  }%
  {\usebibmacro{related:init}%
    \usebibmacro{related}%
    \newcunit}%
  {}%
  \usebibmacro{finentry}}

\DeclareBibliographyDriver{cite:music}{%
  \usebibmacro{bibindex}%
  \usebibmacro{author/editor}%
  \usebibmacro{hlpunct}%
  \usebibmacro{citaltitle+stitle}%
  \newcunit
  \usebibmacro{byauthor}%
  \newcunit\newblock
  \usebibmacro{cpart+editor+translator}%
  \newcunit\newblock
  \usebibmacro{music+eventdate}%
  \newcunit\newblock
  \usebibmacro{chapinscore}%
  \usebibmacro{btitle+bstitle}%
  \newcunit
  \iffieldundef{edition}%
  {}%
  {\usebibmacro{edition}}%
  \newcunit
  \usebibmacro{bybookauthor}%
  \usebibmacro{cbyeditor+others}%
  \iffieldundef{maintitle}%
  {}%
  {\ifthenelse{\iffieldundef{volume}\AND\iffieldundef{part}}%
    {\ifthenelse{\iffieldundef{title}\AND\iffieldundef{booktitle}}%
      {\usebibmacro{cms-in:}}%
      {\bibstring{in}\setunit{addspace}}%
      \printtext[maintitle]{%
        \printfield[mtnoformat]{maintitle}%
        \setunit{\subtitlepunct}%
        \printfield[smtnoformat]{mainsubtitle}}%
      \setunit{\ctitleaddonpunct}%
      \printfield{maintitleaddon}}
    {\toggletrue{cms@usedvol}%
      \printfield{volume}%
      \printfield{part}%
      \setunit{\addspace}
      \bibstring{ofseries}%
      \setunit{\addspace}
      \printtext[maintitle]{%
        \printfield[mtnoformat]{maintitle}%
        \setunit{\subtitlepunct}%
        \printfield[smtnoformat]{mainsubtitle}}%
      \setunit{\ctitleaddonpunct}%
      \printfield{maintitleaddon}}}
  \newcunit
  \usebibmacro{volume+or+volumes}%
  \newcunit\newblock
  \printfield{version}%
  \newcunit\newblock
  \usebibmacro{cnotefield}%
  \newcunit\newblock
  \usebibmacro{music+origdate}%\printtext[eventdate]{\printeventdate}%
  \newcunit\newblock
  \printlist{publisher}%
  \newcunit\newblock
  \printfield{series}%
  \setunit{\addspace}%
  \printfield{number}%
  \newcunit\newblock
  \usebibmacro{date}%
  \newcunit
  \usebibmacro{institution+organization}%
  \newcunit\newblock
  \printlist{location}%
  \newcunit\newblock
  \printfield{type}%
  \usebibmacro{fullpostnote}%
  \newcunit\newblock
  \usebibmacro{caddendum}%
  \newcunit\newblock
  \usebibmacro{pubstate}% 16th ed.
  \newcunit\newblock
  \iftoggle{cms@isbn}%
  {\printfield{iswc}}%
  {}%
  \newcunit\newblock
  \usebibmacro{cite+doi+url}%
  \setunit{\shorthandpunct}%
  \usebibmacro{cms:shorthandintro}%
  \newcunit\newblock
  \usebibmacro{pageref}%
  \newcunit\newblock
  \ifboolexpr{%
    togl {cms@citerel}%
    and
    not test {\iffieldundef{related}}%
  }%
  {\usebibmacro{related:init}%
    \usebibmacro{related}%
    \newcunit}%
  {}%
  \usebibmacro{finentry}}

\DeclareBibliographyAlias{cite:mvbook}{cite:book}

\DeclareBibliographyAlias{cite:mvcollection}{cite:collection}

\DeclareBibliographyAlias{cite:mvproceedings}{cite:proceedings}

\DeclareBibliographyAlias{cite:mvreference}{cite:reference}

\DeclareBibliographyDriver{cite:online}{%
  \usebibmacro{bibindex}%
  \usebibmacro{author/editor}%
  \usebibmacro{hlpunct}%
  \usebibmacro{ctitle+stitle}%
  \setunit{\addspace}%
  \usebibmacro{language+transtitle}%
  \setunit{\addcomma\addspace}%
  \usebibmacro{byauthor}%
  \setunit{\addcomma\addspace}%
  \printlist{organization}% Rearranged for 16th ed.
  \setunit{\addcomma\addspace}%
  \usebibmacro{cnotefield}%
  \setunit{\addcomma\addspace}
  \usebibmacro{date}%
  \usebibmacro{fullpostnote}%
  \setunit{\addcomma\addspace}%
  \iffieldundef{urlyear}%
  {}%
  {\printurldate}% Date fix
  \newcunit\newblock
  \iftoggle{cms@doionly}%
  {\iffieldundef{doi}%
    {}%
    {\printfield{doi}%
      \clearfield{url}}}%
  {\printfield{doi}}%
  \newcunit\newblock
  \usebibmacro{eprint}%
  \newcunit\newblock
  \printfield{url}%
  \newcunit\newblock
  \usebibmacro{caddendum}%
  \setunit{\shorthandpunct}%
  \usebibmacro{cms:shorthandintro}%
  \newcunit\newblock
  \usebibmacro{pageref}%
  \newcunit\newblock
  \ifboolexpr{%
    togl {cms@citerel}%
    and
    not test {\iffieldundef{related}}%
  }%
  {\usebibmacro{related:init}%
    \usebibmacro{related}%
    \newcunit}%
  {}%
  \usebibmacro{finentry}}

\DeclareBibliographyDriver{cite:patent}{%
  \usebibmacro{bibindex}%
  \usebibmacro{author+holder}% +holder?
  \newcunit\newblock
  \usebibmacro{ctitle+stitle}%
  \setunit{\addspace}%
  \usebibmacro{language+transtitle}%
  \setunit{\addcomma\addspace}\newblock%
  \usebibmacro{cnotefield}%
  \setunit{\addspace}%
  \printtext[parens]{%
  \printfield{type}%
  \setunit*{\addspace}%
  \printfield{number}%
  \iflistundef{location}%
    {}%
    {\setunit*{\addspace}%
     \printtext[parens]{%
       \printlist[][-\value{listtotal}]{location}}}%
  \newcunit\newblock
  \printfield{version}%
  \newcunit
  \iffieldundef{origyear}%
  {\iffieldundef{year}%
    {}%
    {\bibstring{patentfiled}\setunit{\addspace}% Changed to filed
      \printdate}}%
  {\bibstring{patentfiled}\setunit{\addspace}%
    \usebibmacro{cmsorigdate}%
    \setunit{\finalandcomma\addspace\bibstring{and}%
      \addspace\bibstring{patentissued}\addspace}%
  \usebibmacro{date}}%
  \usebibmacro{caddendum}}%
  \usebibmacro{fullpostnote}%
  \newcunit\newblock
  \usebibmacro{cite+doi+url}%
  \setunit{\shorthandpunct}%
  \usebibmacro{cms:shorthandintro}%
  \newcunit\newblock
  \usebibmacro{pageref}%
  \newcunit\newblock
  \ifboolexpr{%
    togl {cms@citerel}%
    and
    not test {\iffieldundef{related}}%
  }%
  {\usebibmacro{related:init}%
    \usebibmacro{related}%
    \newcunit}%
  {}%
  \usebibmacro{finentry}}

\DeclareBibliographyDriver{cite:periodical}{%
  \iffieldequalstr{entrysubtype}{magazine}%
  {\usebibmacro{bibindex}%
  \usebibmacro{editor}%
  \usebibmacro{hlpunct}%\newcunit\newblock
  \usebibmacro{issuetitle}%
  \setunit{\addspace}%
  \usebibmacro{language+transtitle}%
  \setunit{\addcomma\addspace}%\newblock%
  \usebibmacro{cbyeditor+others}%
  \setunit{\addcomma\addspace}%
  \printfield{note}%
  \setunit{\addcomma\addspace}\newblock
  \usebibmacro{periodical+date+issue}%
  \usebibmacro{fullpostnote}%
  \newcunit\newblock
  \usebibmacro{caddendum}%
  \newcunit\newblock
  \iftoggle{cms@isbn}%
  {\printfield{issn}}%
  {}%
  \newcunit\newblock
  \usebibmacro{cite+doi+url}%
  \setunit{\shorthandpunct}%
  \usebibmacro{cms:shorthandintro}%
  \newcunit\newblock
  \usebibmacro{pageref}%
  \newcunit\newblock
  \ifboolexpr{%
    togl {cms@citerel}%
    and
    not test {\iffieldundef{related}}%
  }%
  {\usebibmacro{related:init}%
    \usebibmacro{related}%
    \newcunit}%
  {}%
  \usebibmacro{finentry}}%
  {\usebibmacro{bibindex}%
  \usebibmacro{editor}%
  \usebibmacro{hlpunct}%\newcunit\newblock
  \usebibmacro{issuetitle}%
  \setunit{\addspace}%
  \usebibmacro{language+transtitle}%
  \setunit{\addcomma\addspace}%
  \usebibmacro{byauthor}%
  \setunit{\addcomma\addspace}%
  \usebibmacro{cbyeditor+others}%
  \setunit{\addcomma\addspace}%
  \printfield{note}%
  \setunit{\addcomma\addspace}%
  \usebibmacro{cperiodical+issue+year+pages}%
  \usebibmacro{fullpostnote}%
  \newcunit\newblock
  \usebibmacro{caddendum}%
  \newcunit\newblock
  \iftoggle{cms@isbn}%
  {\printfield{issn}}%
  {}%
  \newcunit\newblock
  \usebibmacro{cite+doi+url}%
  \setunit{\shorthandpunct}%
  \usebibmacro{cms:shorthandintro}%
  \newcunit\newblock
  \usebibmacro{pageref}%
  \newcunit\newblock
  \ifboolexpr{%
    togl {cms@citerel}%
    and
    not test {\iffieldundef{related}}%
  }%
  {\usebibmacro{related:init}%
    \usebibmacro{related}%
    \newcunit}%
  {}%
  \usebibmacro{finentry}}}

\DeclareBibliographyDriver{cite:proceedings}{%
  \usebibmacro{bibindex}%
  \usebibmacro{editor}%
  \usebibmacro{hlpunct}%\setunit{\addcomma\addspace}\newblock%
  \usebibmacro{citaltitle+stitle}%
  \setunit{\addspace}
  \usebibmacro{cite:xref+date}%
  \newcunit
  \usebibmacro{cpart+editor+translator}%
  \newcunit
  \ifboolexpr{%
    test {\iffieldundef{crossref}}%
    or
    not test {\ifentryseen{\thefield{crossref}}}%
    or
    togl {cms@bookcitexref}%
  }%
  {\ifboolexpr{%
      test {\iffieldundef{xref}}%
      or
      not test {\ifentryseen{\thefield{xref}}}%
      or
      togl {cms@bookcitexref}%
    }%
  {\usebibmacro{cmtitle+mstitle+vol+part+title+stitle}%
  \newcunit
  \usebibmacro{cbyeditor+others}%
  \newcunit\newblock
  \usebibmacro{volume+or+volumes}%
  \newcunit\newblock
  \usebibmacro{cser+num}%
  \newcunit\newblock
  \usebibmacro{cnotefield}%
  \setunit{\addspace}\newblock%
  \printtext[parens]{%
  \usebibmacro{org+publ+loc+year}}%
  \usebibmacro{caddendum}%
  \usebibmacro{volfullpostnote}%
  \newcunit\newblock
  \iftoggle{cms@isbn}%
  {\printfield{isbn}}%
  {}%
  \newcunit\newblock
  \usebibmacro{cite+doi+url}%
  \setunit{\shorthandpunct}%
  \usebibmacro{cms:shorthandintro}%
  \newcunit\newblock
  \usebibmacro{pageref}%
  \newcunit\newblock
  \ifboolexpr{%
    togl {cms@citerel}%
    and
    not test {\iffieldundef{related}}%
  }%
  {\usebibmacro{related:init}%
    \usebibmacro{related}%
    \newcunit}%
  {}%
  \usebibmacro{finentry}%
  \usebibmacro{book:xref+finentry}}%
    {\ifpunctmark{.}% This seems to work.
      {\ifbibliography%
        {\setunit{\bibsentence}}{\addspace\bibsentence}}%
      {\ifbibliography{\unspace}{\addcomma\addspace}}% ?!?
      \usebibmacro{xrefprenote}% Volume fix
      \bookbibxrefcite{\thefield{xref}}% Removed \addspace from each.
      \usebibmacro{xrefpostnote}%
      \usebibmacro{finentry}}}%
  {\ifpunctmark{.}% This seems to work.
      {\ifbibliography%
        {\setunit{\bibsentence}}{\addspace\bibsentence}}%
      {\ifbibliography{\unspace}{\addcomma\addspace}}% ?!?
    \usebibmacro{xrefprenote}% Volume fix
    \bookbibxrefcite{\thefield{crossref}}%
    \usebibmacro{xrefpostnote}%
    \usebibmacro{finentry}}}

\DeclareBibliographyDriver{cite:reference}{%
  \usebibmacro{bibindex}%
  \usebibmacro{citaltitle+stitle}%
  \newcunit\newblock
  \ifthenelse{\iffieldundef{maintitle}\AND\iffieldundef{booktitle}}%
  {\iffieldundef{edition}%
    {}%
    {\usebibmacro{edition}}}%
  {}%
  \newcunit
  \usebibmacro{cpart+editor+translator}%
  \setunit*{\addcomma\addspace}%
  \usebibmacro{cmtitle+mstitle+vol+part+btitle+bstitle}%
  \newcunit
  \iffieldundef{edition}%
  {}%
  {\usebibmacro{edition}}%
  \newcunit
  \usebibmacro{bybookauthor}%
  \usebibmacro{cbyeditor+others}%
  \newcunit
  \usebibmacro{volume+or+volumes}%
  \newcunit\newblock
  \usebibmacro{cser+num}%
  \newcunit\newblock
  \usebibmacro{cnotefield}%
  \newcunit\newblock
  \usebibmacro{cpubl+loc+year}%
  \usebibmacro{caddendum}%
  \usebibmacro{volfullpostnote}%
  \newcunit\newblock
  \iftoggle{cms@isbn}%
  {\printfield{isbn}}%
  {}%
  \newcunit\newblock
  \usebibmacro{cite+doi+url}%
  \setunit{\shorthandpunct}%
  \usebibmacro{cms:shorthandintro}%
  \newcunit\newblock
  \usebibmacro{pageref}%
  \newcunit\newblock
  \ifboolexpr{%
    togl {cms@citerel}%
    and
    not test {\iffieldundef{related}}%
  }%
  {\usebibmacro{related:init}%
    \usebibmacro{related}%
    \newcunit}%
  {}%
  \usebibmacro{finentry}}

\DeclareBibliographyDriver{cite:report}{%
  \usebibmacro{bibindex}%
  \usebibmacro{author/editor}%
  \usebibmacro{hlpunct}%\setunit{\addcomma\addspace}\newblock
  \iffieldequalstr{entrysubtype}{unpublished}%
  {\usebibmacro{ctitle+stitle}}%
  {\usebibmacro{citaltitle+stitle}}%
  \newcunit
  \usebibmacro{byauthor}%
  \newcunit%
  \printfield{type}%
  \newcunit
  \printfield{series}%
  \setunit{\addnbspace}%
  \printfield{number}%
  \newcunit%
  \usebibmacro{cnotefield}%
  \setunit{\addspace}\newblock%
  \printtext[parens]{% 
  \usebibmacro{inst+loc+year}}%
  \usebibmacro{caddendum}%
  \usebibmacro{fullpostnote}%
  \newcunit\newblock
  \iftoggle{cms@isbn}%
  {\printfield{isrn}}%
  {}%
  \newcunit\newblock
  \usebibmacro{cite+doi+url}%
  \setunit{\shorthandpunct}%
  \usebibmacro{cms:shorthandintro}%
  \newcunit\newblock
  \usebibmacro{pageref}%
  \newcunit\newblock
  \ifboolexpr{%
    togl {cms@citerel}%
    and
    not test {\iffieldundef{related}}%
  }%
  {\usebibmacro{related:init}%
    \usebibmacro{related}%
    \newcunit}%
  {}%
  \usebibmacro{finentry}}

\DeclareBibliographyDriver{cite:review}{%
  \usebibmacro{bibindex}%
  \iffieldequalstr{entrysubtype}{magazine}%
  {\usebibmacro{cmag+news+author}}%
  {\usebibmacro{author/editor}}%
  \newcunit\newblock
  \printeventdate% 16th ed.
  \setunit{\addspace}%
  \printfield{nameaddon}% 16th ed.
  \newcunit\newblock
  \ifboolexpr{%
    test {\iffieldequalstr{relatedtype}{reviewof}}%
    and
    togl {cms@citerel}%
    }%
    {\usebibmacro{related:init}%
      \usebibmacro{related}}%
    {\printfield{title}%
      \setunit{\subtitlepunct}%
      \printfield[noformat]{subtitle}}%
  \setunit{\ctitleaddonpunct}%
  \printfield{titleaddon}%
  \setunit{\addspace}%
  \usebibmacro{language+transtitle}%
  \setunit{\addcomma\addspace}%\newblock%
  \usebibmacro{cpart+editor+translator}%
  \newcunit%
  \usebibmacro{issuetitle}%
  \setunit{\addcomma\addspace}%
  \usebibmacro{cbyeditor+others}%
  \setunit{\addcomma\addspace}%
  \printfield{note}%
  \setunit{\addcomma\addspace}%
  \iffieldequalstr{entrysubtype}{magazine}%
  {\usebibmacro{mag+news+date}}%
  {\usebibmacro{cjournal+issue+year+pages}}%
  \usebibmacro{fullpostnote}%
  \newcunit\newblock
  \usebibmacro{caddendum}%
  \newcunit\newblock
  \iftoggle{cms@isbn}%
  {\printfield{issn}}%
  {}%
  \newcunit\newblock
  \usebibmacro{cite+doi+url}%
  \setunit{\shorthandpunct}%
  \usebibmacro{cms:shorthandintro}%
  \newcunit\newblock
  \usebibmacro{pageref}%
  \newcunit\newblock
  \ifboolexpr{%
    togl {cms@citerel}%
    and
    not test {\iffieldequalstr{relatedtype}{reviewof}}%
    }%
  {\usebibmacro{related:init}%
    \usebibmacro{related}%
    \newcunit}%
  {}%
  \usebibmacro{finentry}}

\DeclareBibliographyDriver{cite:suppbook}{%
  \usebibmacro{bibindex}%
  \usebibmacro{author}%
  \usebibmacro{hlpunct}%\newcunit\newblock
  \usebibmacro{inforaft}%
  \setunit{\addspace}\newblock
  \usebibmacro{citaltitle+stitle}%
  \newcunit
  \iffieldundef{maintitle}%
  {\iffieldundef{edition}%
    {}%
    {\usebibmacro{edition}}}%
  {}%
  \newcunit
  \usebibmacro{bybookauthor}%
  \newcunit\newblock
  \usebibmacro{cmtitle+mstitle+vol+part+title+stitle}%
  \newcunit
  \iffieldundef{edition}%
  {}%
  {\usebibmacro{edition}}%
  \newcunit
  \usebibmacro{cbyeditor+others}%
  \newcunit
  \usebibmacro{volume+or+volumes}%
  \newcunit\newblock
  \usebibmacro{cser+num}%
  \newcunit\newblock
  \usebibmacro{cnotefield}%
  \newcunit\newblock
  \usebibmacro{cpubl+loc+year}%
  \clearfield{pages}% ?? For 16th ed.
  \usebibmacro{caddendum}%
  \usebibmacro{volfullpostnote}%
  \newcunit\newblock
  \iftoggle{cms@isbn}%
  {\printfield{isbn}}%
  {}%
  \newcunit\newblock
  \usebibmacro{cite+doi+url}%
  \setunit{\shorthandpunct}%
  \usebibmacro{cms:shorthandintro}%
  \newcunit\newblock
  \usebibmacro{pageref}%
  \newcunit\newblock
  \ifboolexpr{%
    togl {cms@citerel}%
    and
    not test {\iffieldundef{related}}%
  }%
  {\usebibmacro{related:init}%
    \usebibmacro{related}%
    \newcunit}%
  {}%
  \usebibmacro{finentry}}

\DeclareBibliographyAlias{cite:suppcollection}{cite:suppbook}

\DeclareBibliographyAlias{cite:suppperiodical}{cite:review}

\DeclareBibliographyDriver{cite:thesis}{%
  \usebibmacro{bibindex}%
  \usebibmacro{author/editor}%
  \usebibmacro{hlpunct}%\setunit{\addcomma\addspace}\newblock
  \usebibmacro{ctitle+stitle}%
  \setunit{\addspace}\newblock%
  \usebibmacro{language+transtitle}%
  \setunit{\addcomma\addspace}%
  \usebibmacro{byauthor}%
  \setunit{\addcomma\addspace}%
  \usebibmacro{cnotefield}%
  \setunit{\addspace}%
  \printtext[parens]{%
  \usebibmacro{type+inst+year}}%
  \usebibmacro{caddendum}%
  \usebibmacro{fullpostnote}%
  \newcunit\newblock
  \usebibmacro{cite+doi+url}%
  \setunit{\shorthandpunct}%
  \usebibmacro{cms:shorthandintro}%
  \newcunit\newblock
  \usebibmacro{pageref}%
  \newcunit\newblock
  \ifboolexpr{%
    togl {cms@citerel}%
    and
    not test {\iffieldundef{related}}%
  }%
  {\usebibmacro{related:init}%
    \usebibmacro{related}%
    \newcunit}%
  {}%
  \usebibmacro{finentry}}

\DeclareBibliographyDriver{cite:unpublished}{%
  \usebibmacro{bibindex}%
  \usebibmacro{author/editor}%
  \usebibmacro{hlpunct}%\setunit{\addcomma\addspace}\newblock
  \usebibmacro{ctitle+stitle}%
  \setunit{\addspace}%
  \usebibmacro{language+transtitle}%
  \setunit{\addcomma\addspace}%
  \usebibmacro{byauthor}%
  \newcunit\newblock%
  \usebibmacro{cbyeditor+others}%
  \setunit{\addspace}\newblock%
  \printtext[parens]{%
    \printfield{howpublished}%
    \newcunit\newblock
    \usebibmacro{cnotefield}%
    \newcunit\newblock
    \printfield{eventtitle}%
    \setunit{\ctitleaddonpunct}%
    \printfield{eventtitleaddon}%
    \newcunit%
    \printfield{venue}%
    \newcunit%
    \printlist{location}%
    \newcunit\newblock
    \iffieldundef{eventyear}%
    {\usebibmacro{date}}%
    {\printeventdate}}%
  \usebibmacro{caddendum}%
  \usebibmacro{fullpostnote}%
  \newcunit\newblock
  \usebibmacro{cite+doi+url}%
  \setunit{\shorthandpunct}%
  \usebibmacro{cms:shorthandintro}%
  \newcunit\newblock
  \usebibmacro{pageref}%
  \newcunit\newblock
  \ifboolexpr{%
    togl {cms@citerel}%
    and
    not test {\iffieldundef{related}}%
  }%
  {\usebibmacro{related:init}%
    \usebibmacro{related}%
    \newcunit}%
  {}%
  \usebibmacro{finentry}}

\DeclareBibliographyDriver{cite:video}{%
  \usebibmacro{bibindex}%
  \usebibmacro{author/editor}%
  \usebibmacro{hlpunct}%
  \usebibmacro{ctitle+stitle}%
  \setunit{\addspace}\newblock%
  \usebibmacro{language+transtitle}%
  \newcunit
  \usebibmacro{byauthor}%
  \newcunit
  \usebibmacro{cpart+editor+translator}%
  \newcunit
  \usebibmacro{chapinscore}%
  \usebibmacro{btitle+bstitle}%
  \newcunit
  \iffieldundef{edition}%
  {}%
  {\usebibmacro{edition}}%
  \newcunit
  \usebibmacro{bybookauthor}%
  \usebibmacro{cbyeditor+others}%
  \iffieldundef{maintitle}%
  {}%
  {\ifthenelse{\iffieldundef{volume}\AND\iffieldundef{part}}%
    {\ifthenelse{\iffieldundef{title}\AND\iffieldundef{booktitle}}%
      {\usebibmacro{cms-in:}}%
      {\bibstring{in}\setunit{\addspace}}%
      \printtext[maintitle]{%
        \printfield[mtnoformat]{maintitle}%
        \setunit{\subtitlepunct}%
        \printfield[smtnoformat]{mainsubtitle}}%
      \setunit{\ctitleaddonpunct}%
      \printfield{maintitleaddon}}
    {\toggletrue{cms@usedvol}%
      \printfield{volume}%
      \printfield{part}%
      \setunit{\addspace}
      \bibstring{ofseries}%
      \setunit{\addspace}
      \printtext[maintitle]{%
        \printfield[mtnoformat]{maintitle}%
        \setunit{\subtitlepunct}%
        \printfield[smtnoformat]{mainsubtitle}}%
      \setunit{\ctitleaddonpunct}%
      \printfield{maintitleaddon}}}
  \newcunit
  \usebibmacro{volume+or+volumes}%
  \newcunit\newblock
  \usebibmacro{cser+num}%
  \newcunit\newblock
  \usebibmacro{music+eventdate}%
  \newcunit\newblock
  \usebibmacro{cnotefield}%
  \newcunit\newblock
  \usebibmacro{cpubl+loc+year}%
  \newcunit\newblock
  \printfield{type}% Order of this and next?
  \usebibmacro{volfullpostnote}%
  \newcunit\newblock
  \usebibmacro{caddendum}%
  \newcunit\newblock
  \iftoggle{cms@isbn}%
  {\printfield{isan}}%
  {}%
  \newcunit\newblock
  \usebibmacro{cite+doi+url}%
  \setunit{\shorthandpunct}%
  \usebibmacro{cms:shorthandintro}%
  \newcunit\newblock
  \usebibmacro{pageref}%
  \newcunit\newblock
  \ifboolexpr{%
    togl {cms@citerel}%
    and
    not test {\iffieldundef{related}}%
  }%
  {\usebibmacro{related:init}%
    \usebibmacro{related}%
    \newcunit}%
  {}%
  \usebibmacro{finentry}}

%%%% List Formats %%%%

\DeclareListFormat{language}{%
  \ifthenelse{\value{listcount}=1}%
  {\bibleftbracket\bibstring{inlang}%\addspace - for inflected langs.
    \ifbibstring{#1}%
    {\bibstring{#1}}%
    {\ifbibstring{lang#1}%
      {\bibstring{lang#1}}%
      {#1}}%
    \ifthenelse{\value{listtotal}=1}%
    {\bibrightbracket}%
    {}}%
  {\ifthenelse{\value{listcount}=\value{listtotal}}%
    {\multilangdelim%
      \ifbibstring{#1}%
      {\bibstring{#1}}%
      {\ifbibstring{lang#1}%
        {\bibstring{lang#1}}%
        {#1}}%
      \bibrightbracket}%
    {\multilangdelim%
      \ifbibstring{#1}%
      {\bibstring{#1}}%
      {\ifbibstring{lang#1}%
        {\bibstring{lang#1}}%
        {#1}}}}%
  \usebibmacro{langlist:andothers}}

\DeclareListFormat{publisher}{%
  \ifthenelse{\value{listtotal}<2}%
  {#1\isdot}%
  {\ifthenelse{\value{listcount}=1}%
    {#1}%
    {\multipubsdelim #1\isdot}}}

\DeclareListFormat[jurisdiction]{location}{%
  \iffieldundef{entrysubtype}%
  {\usebibmacro{list:delim}{#1}%
    #1\isdot%
    \usebibmacro{list:andothers}}%
  {\ifthenelse{\value{listcount}<\value{listtotal}}%
    {\mkbibparens{#1}\addspace}%
    {\mkbibparens{#1\isdot}}}}%

\DeclareListFormat[jurisdiction]{origlocation}{%
  \ifthenelse{\value{listcount}<\value{listtotal}}%
  {#1\isdot\addcomma\addspace}%
  {#1\isdot}}

\DeclareListFormat[jurisdiction]{origpublisher}{%
  \ifthenelse{\value{listcount}<\value{listtotal}}%
  {\mkbibparens{#1}\addspace}%
  {\mkbibparens{#1\isdot}}}

\DeclareListFormat{periodplace}{\mkbibparens{#1}}

\DeclareListFormat{lista}{% 
  \ifthenelse{\value{listtotal}<2}%
  {\bibsstring{subverbo}\addspace\mkbibquote{#1\isdot}}%
  {\ifthenelse{\value{listcount}=1}%
    {\bibsstring{subverbis}\addspace\mkbibquote{#1\isdot}\addcomma}%
    {\ifthenelse{\value{listcount}<\value{listtotal}}%
      {\addspace\mkbibquote{#1\isdot}\addcomma}%
      {\addspace\mkbibquote{#1\isdot}}}}}

%%%% Field Formats -- Title, Citetitle, Lostitle %%%%

\DeclareFieldFormat{title}{\mkbibemph{#1}\isdot}

\DeclareFieldFormat{citetitle}{\mkbibemph{#1}\isdot}

\DeclareFieldFormat{lostitle}{\mkbibemph{#1}\isdot}

\DeclareFieldFormat
[article,inbook,incollection,inproceedings,online,thesis,unpublished]
{title}{%
  \iffieldundef{title}%
  {}%
  {\mkbibquote{#1\isdot}}}

\DeclareFieldFormat
[article,inbook,incollection,inproceedings,online,thesis,unpublished]
{citetitle}{%
  \iffieldundef{title}%
  {#1\isdot}%
  {\mkbibquote{#1\isdot}}}

\DeclareFieldFormat
[article,inbook,incollection,inproceedings,online,thesis,unpublished]
{lostitle}{%
  \iffieldundef{title}%
  {#1\isdot}%
  {\mkbibquote{#1\isdot}}}

\DeclareFieldFormat[artwork,image]{title}{%
  \iffieldundef{entrysubtype}%
  {\mkbibemph{#1}\isdot}%
  {#1\isdot}}

\DeclareFieldFormat[artwork,image]{citetitle}{%
  \iffieldundef{entrysubtype}%
  {\mkbibemph{#1}\isdot}%
  {#1\isdot}}

\DeclareFieldFormat[artwork,image]{lostitle}{%
  \iffieldundef{entrysubtype}%
  {\mkbibemph{#1}\isdot}%
  {#1\isdot}}

\DeclareFieldFormat[letter,patent]{title}{#1\isdot}

\DeclareFieldFormat[letter,patent]{citetitle}{#1\isdot}

\DeclareFieldFormat[letter,patent]{lostitle}{#1\isdot}

\DeclareFieldFormat{prenote}{\ifcapital{\MakeCapital{#1}}{#1}\isdot}

%% comprange code moved to .sty

\DeclareFieldFormat{postnote}{% Changed for page compression option
  \ifboolexpr{%
    togl {cms@comprange}%
    and
    test {\ifpages{#1}}%
  }%
  {\iffieldundef{pagination}%
    {\mkcomprange{#1}}%
    {\mkcomprange[{\mkpageprefix[pagination]}]{#1}}}%
  {\iffieldundef{pagination}%
    {#1}%
    {\mkpageprefix[pagination]{#1}}}}%

\DeclareFieldFormat[inreference]{postnote}{%
  \ifboolexpr{%
    togl {cms@comprange}%
    and
    test {\ifpages{#1}}%
  }%
  {\iffieldundef{pagination}%
    {\bibsstring{subverbo}\addspace\mkbibquote{#1}}%
    {\mkcomprange[{\mkpageprefix[pagination]}]{#1}}}%
  {\iffieldundef{pagination}%
    {\bibsstring{subverbo}\addspace\mkbibquote{#1}}%
    {\mkpageprefix[pagination]{#1}}}}%

\newrobustcmd*{\mkjuridprefix}[1]{%
  \ifboolexpr{% FIXME: Is this always right?
    test {\iftoggle{cms@fullnote}}%
    and
    test {\ifentrytype{jurisdiction}}%
    }%
  {\iffieldundef{issue}%
    {#1}%
    {\printtext{at}\addspace *#1}}%
  {\iffieldundef{issue}%
    {\printtext{at}\addspace #1}% FIXME: Make it a bibstring?
    {\ifentrytype{jurisdiction}%
      {\printtext{at}\addspace *#1}%
      {\printtext{at}\addspace #1}}}}%

\DeclareFieldFormat[jurisdiction,legal,legislation]{postnote}{%
  \ifboolexpr{%
    togl {cms@comprange}%
    and
    test {\ifpages{#1}}%
  }%
  {\iffieldundef{pagination}%
    {\mkcomprange[\mkjuridprefix]{#1}}%
    {\mkcomprange[{\mkpageprefix[pagination]}]{#1}}}%
  {\iffieldundef{pagination}%
    {\mkjuridprefix{#1}}%
    {\mkpageprefix[pagination]{#1}}}}%

\DeclareFieldFormat{pages}{%
  \ifboolexpr{%
    togl {cms@comprange}%
    and
    test {\ifpages{#1}}%
  }%
  {\iffieldundef{bookpagination}%
    {\mkcomprange{#1}\isdot}%
    {\mkcomprange[{\mkpageprefix[bookpagination]}]{#1}}}%
  {\iffieldundef{bookpagination}%
    {#1\isdot}%
    {\mkpageprefix[bookpagination]{#1}}}}%

\DeclareListFormat{edlang}{% Required for feminine forms in some
  \usebibmacro{list:delim}{% languages
    \ifbibstring{#1}%
    {\bibxstring{#1}}%
    {\ifbibstring{ed#1}%
      {\bibxstring{ed#1}}%
      {\ifcapital{\MakeCapital{#1}}{#1}}}}%
  \ifbibstring{#1}%
  {\bibstring{#1}}%
  {\ifbibstring{ed#1}%
    {\bibstring{ed#1}}%
    {\ifcapital{\MakeCapital{#1}}{#1}}}%
  \usebibmacro{list:andothers}}

\DeclareFieldFormat[suppbook,suppcollection]{title}{\mkbibemph{#1}\isdot}

\DeclareFieldFormat[suppbook,suppcollection]{citetitle}{%
  \usebibmacro{inforaft}%
  \addspace%
  \mkbibemph{#1}\isdot}

\DeclareFieldFormat[suppbook,suppcollection]{lostitle}{%
  \usebibmacro{inforaft}%
  \addspace%
  \mkbibemph{#1}\isdot}

\DeclareFieldFormat[customc]{title}{%
  \iffieldundef{nameaddon}%
  {\mkbibemph{\bibstring{see}}%
    \addspace%
    #1}%
  {#1}}

\DeclareFieldFormat[customc]{citetitle}{%
  \iffieldundef{nameaddon}%
  {\mkbibemph{\bibstring{see}}%
    \addspace%
    #1}%
  {\printfield{nameaddon}\addspace #1}}

\DeclareFieldFormat[misc]{title}{%
  \iffieldundef{entrysubtype}%
  {\mkbibemph{#1}\isdot}%
  {\ifcapital{\MakeCapital{#1\isdot}}{#1\isdot}}}

\DeclareFieldFormat[misc]{citetitle}{%
  \iffieldundef{entrysubtype}%
  {\mkbibemph{#1}\isdot}%
  {\ifcapital{\MakeCapital{#1\isdot}}{#1\isdot}}}

\DeclareFieldFormat[misc]{lostitle}{%
  \iffieldundef{entrysubtype}%
  {\mkbibemph{#1}\isdot}%
  {\ifcapital{\MakeCapital{#1\isdot}}{#1\isdot}}}

\DeclareFieldFormat[review,suppperiodical]{title}{%
  \ifcapital{\MakeCapital{#1\isdot}}{#1\isdot}}

\DeclareFieldFormat[review,suppperiodical]{citetitle}{%
  \ifcapital{\MakeCapital{#1\isdot}}{#1\isdot}}

\DeclareFieldFormat[review,suppperiodical]{lostitle}{%
  \ifcapital{\MakeCapital{#1\isdot}}{#1\isdot}}

\DeclareFieldFormat[report]{title}{%
  \iffieldequalstr{entrysubtype}{unpublished}%
  {\mkbibquote{#1\isdot}}%
  {\mkbibemph{#1}\isdot}}%

\DeclareFieldFormat[report]{citetitle}{%
  \iffieldequalstr{entrysubtype}{unpublished}%
  {\mkbibquote{#1\isdot}}%
  {\mkbibemph{#1}\isdot}}

\DeclareFieldFormat[report]{lostitle}{%
  \iffieldequalstr{entrysubtype}{unpublished}%
  {\mkbibquote{#1\isdot}}%
  {\mkbibemph{#1}\isdot}}

\DeclareFieldFormat[audio,music,video]{title}{%
  \iffieldundef{booktitle}%
  {\mkbibemph{#1}\isdot}%
  {\mkbibquote{#1\isdot}}}

\DeclareFieldFormat[audio,music,video]{citetitle}{%
  \iffieldundef{booktitle}%
  {\mkbibemph{#1}\isdot}%
  {\mkbibquote{#1\isdot}}}

\DeclareFieldFormat[audio,music,video]{lostitle}{%
  \iffieldundef{booktitle}%
  {\mkbibemph{#1}\isdot}%
  {\mkbibquote{#1\isdot}}}

\DeclareFieldFormat[jurisdiction,legal]{title}{#1\isdot}

\DeclareFieldFormat[legislation]{title}{%
  \iffieldequalstr{entrysubtype}{hearing}%
  {\mkbibemph{#1}\isdot}%
  {#1\isdot}}

\DeclareFieldFormat[jurisdiction]{citetitle}{\mkbibemph{#1}\isdot}

\DeclareFieldFormat[jurisdiction,legal]{lostitle}{#1\isdot}

\DeclareFieldFormat[legislation]{lostitle}{%
  \iffieldequalstr{entrysubtype}{hearing}%
  {\mkbibemph{#1}\isdot}%
  {#1\isdot}}

\DeclareFieldFormat[legal]{citetitle}{#1\isdot}

\DeclareFieldFormat[legislation]{citetitle}{%
  \iffieldequalstr{entrysubtype}{hearing}%
  {\mkbibemph{#1}\isdot}%
  {#1\isdot}}

%%%% Other Field Formats %%%%

\DeclareNumChars*{:}% For proper ibidem with multi-volume works.

\DeclareFieldFormat{letterday}{\mkbibcurdinal{#1}}

\DeclareFieldFormat{note}{%
  \ifcapital{\MakeCapital{#1}}{#1}}%

\DeclareFieldFormat
[audio,manual,music,patent,report,suppbook,suppcollection,thesis,video]
{type}{%
  \ifbibstring{#1}%
  {\bibstring{#1}}%
  {\ifcapital%
    {\MakeCapital{#1\isdot}}%
    {#1\isdot}}}

\DeclareFieldFormat[artwork,image]{type}{%
  \ifcapital%
  {\MakeCapital{#1}}%
  {#1}}

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

\DeclareFieldFormat{doi}{%
  \textrm{doi}\addcolon
  \ifhyperref
    {\href{http://dx.doi.org/#1}{\nolinkurl{#1}}}
    {\nolinkurl{#1}}}

\DeclareFieldFormat[music]{date}{% Generalize userd ???
  \ifthenelse{\iffieldundef{userd}\OR\NOT\iffieldundef{urlyear}%
  \OR\NOT\iffieldundef{eventyear}\OR\NOT\iffieldundef{origyear}}%
  {#1}%
  {\printfield{userd}\addspace #1}}

\DeclareFieldFormat[video]{date}{% Generalize userd ???
  \ifthenelse{\iffieldundef{userd}\OR\NOT\iffieldundef{urlyear}%
  \OR\NOT\iffieldundef{eventyear}}%
  {#1}%
  {\printfield{userd}\addspace #1}}

\DeclareFieldFormat{date}{% Generalize userd ???
  \ifthenelse{\iffieldundef{userd}\OR\NOT\iffieldundef{urlyear}}%
  {#1}%
  {\printfield{userd}\addspace #1}}

\DeclareFieldFormat{urldate}{% 16th ed.
  \iffieldundef{userd}%
  {\bibstring{urlseen}\addspace #1}%
  {\printfield{userd}\addspace #1}}

\DeclareFieldFormat[video]{urldate}{% 16th ed.
  \ifthenelse{\iffieldundef{userd}\OR\NOT\iffieldundef{eventyear}}%
  {\bibstring{urlseen}\addspace #1}%
  {\printfield{userd}\addspace #1}}

\DeclareFieldFormat[music]{urldate}{% 16th ed.
  \ifthenelse{\iffieldundef{userd}\OR\NOT\iffieldundef{eventyear}%
    \OR\NOT\iffieldundef{origyear}}%
  {\bibstring{urlseen}\addspace #1}%
  {\printfield{userd}\addspace #1}}

\DeclareFieldFormat[music]{origdate}{% 16th ed.
  \iftoggle{cms@reprint}% Date fix
  {#1}%
  {\ifthenelse{\iffieldundef{userd}\OR\NOT\iffieldundef{eventyear}}%
    {\bibstring{discrecorded}\addspace #1}% Can now match gender
    {\printfield{userd}\addspace #1}}}

\DeclareFieldFormat[music]{eventdate}{% 16th ed.
  \iffieldundef{userd}%
  {\bibstring{songrecorded}\addspace #1}% Can now match gender
  {\printfield{userd}\addspace #1}}

\DeclareFieldFormat[video]{eventdate}{% 16th ed.
  \iffieldundef{userd}%
  {\bibstring{broadcast}\addspace #1}%
  {\printfield{userd}\addspace #1}}

\DeclareFieldAlias{userd}{titleaddon}% 16th ed.

\DeclareFieldFormat{nameaddon}{\mkbibbrackets{#1\bibsentence}}% ?!

\DeclareFieldFormat[review,suppperiodical]{nameaddon}{#1\bibsentence}

\DeclareFieldFormat[customc]{nameaddon}{% For cross-refs
  \ifbibstring{#1}%
  {\mkbibemph{\bibstring{#1}}}%
  {#1}}

\DeclareFieldFormat{edition}{% New in 0.8
  \ifinteger{#1}
  {\mkbibordedition{#1}~\bibstring{edition}}%
  {\ifcapital
    {\MakeCapital{#1\isdot}}%
    {#1\isdot}}}

\DeclareFieldFormat{year}{% To cope with abbreviation n.d.
  \iftoggle{cms@fullnote}%
  {#1\bibsentence}%
  {#1\isdot}}% (?)

\DeclareFieldFormat[misc]{year}{#1\isdot}

\DeclareFieldFormat[article]{year}{% To cope with abbreviation n.d.
  \iffieldequalstr{entrysubtype}{magazine}%
  {#1\isdot}
  {#1\bibsentence}}

\DeclareFieldAlias[review]{year}[article]{year}

\DeclareFieldAlias[periodical]{year}[article]{year}

\DeclareFieldAlias[suppperiodical]{year}[article]{year}

\DeclareFieldFormat{usere}{[#1]} % Better than mkbibbrackets?

\DeclareFieldFormat{titleaddon}{%
  \ifcapital{\MakeCapital{#1\isdot}}{#1\isdot}}%\custpunctc?

\DeclareFieldAlias{booktitleaddon}{titleaddon}

\DeclareFieldAlias{maintitleaddon}{titleaddon}

\DeclareFieldFormat[jurisdiction,legal,legislation]{journaltitle}{%
  \iffieldundef{shortjournal}%
  {#1\isdot}%
  {\mkbibemph{#1}\isdot}}

\DeclareFieldFormat[jurisdiction,legal,legislation]{shortjournal}{#1\isdot}

\DeclareFieldFormat{journaltitle}{\mkbibemph{#1}\isdot}

\DeclareFieldFormat{issuetitle}{\mkbibquote{#1\isdot}}

\DeclareFieldFormat{shortjournal}{\mkbibemph{#1}\isdot}

\DeclareFieldFormat[periodical]{shorttitle}{\mkbibemph{#1}\isdot}

\DeclareFieldFormat{jourser}{%
  \ifinteger{#1}%
  {\mkbibordseries{#1}%
    \addnbspace%
    \bibstring{jourser}}%
  {\ifbibstring{#1}{\bibstring{#1}}{#1}}}%

\DeclareFieldFormat{jurisdictionser}{%
  \ifinteger{#1}%
  {\mkjuridordinal{#1}}%
  {\ifbibstring{#1}{\bibstring{#1}}{#1}}}%

\DeclareFieldFormat{legislationser}{%
  \iffieldequalstr{entrysubtype}{hansard}%
  {\ifinteger{#1}%
    {\addspace\mkbibparens{\mkjuridordinal{#1}\addspace\bibsstring{jourser}}}%
    {\ifbibstring{#1}%
      {\addspace\mkbibparens{\bibstring{#1}}}%
      {\addspace\mkbibparens{#1}}}}%
  {\iffieldequalstr{entrysubtype}{uk}%
    {\addspace #1\isdot}%
    {\addcomma\addspace #1\isdot}}}%

\DeclareFieldFormat{legalser}{\addspace #1\isdot}%

\DeclareFieldFormat{hansardser}{%
  \ifinteger{#1}%
  {\mkbibparens{\mkjuridordinal{#1}\addspace\bibsstring{jourser}}}%
  {\ifbibstring{#1}{\mkbibparens{\bibstring{#1}}}{\mkbibparens{#1}}}}%

\DeclareFieldFormat{journum}{% Revised for 0.9.5
  \ifboolexpr{%
    test {\ifnumerals{#1}}%
    and
    not test {\ifnumeral{#1}}%
  }%
  {\bibstring{numbers}\addspace #1}%
  {\bibstring{number}\addspace #1}}%

\DeclareFieldFormat{juridnum}{\bibcpstring{number}\addspace #1}%

\DeclareFieldFormat{jourvol}{#1}

\DeclareFieldFormat{sernum}{%
  \ifnumeral{#1}%
  {\addnbspace #1}%
  {\addcomma\addspace #1}}

\DeclareFieldFormat{series}{#1\isdot}

\DeclareFieldFormat{addendum}{%
  \ifcapital{\MakeCapital{#1\isdot}}{#1\isdot}}

\DeclareFieldFormat[jurisdiction,legal,legislation]{addendum}{%
  \ifcapital{\mkbibparens{\MakeCapital{#1\isdot}}}{\mkbibparens{#1\isdot}}}

% This works better here than in the entrytail macro -- userf use is
% no longer a problem, though the page breaking still isn't ideal.

\DeclareFieldFormat{annotation}{\par\nobreak \vskip \bibitemsep #1}

\DeclareFieldFormat{part}{% xref revision ???
  \ifnumerals{#1}%
  {\addcomma\addspace\bibstring{partvolume}~#1}%
  {\addcomma\addspace\ifcapital{\MakeCapital{#1}}{#1}}}

\DeclareFieldFormat{xrefpart}{% xref revision ???
  \ifnumerals{#1}%
  {\bibstring{partvolume}~#1}%
  {\ifcapital{\MakeCapital{#1}}{#1}}}

\DeclareFieldFormat[legal,legislation]{part}{%
  \ifnumerals{#1}%
  {\bibsstring{part}~#1}%
  {#1\isdot}}%

\DeclareFieldFormat[legal,legislation]{chapter}{%
  \ifthenelse{\iffieldequalstr{entrysubtype}{uk}\OR%
    \iffieldequalstr{entrysubtype}{hansard}}%
  {c\adddotspace #1}%
  {ch\adddotspace #1}}%

%% This tries to get hyperlinks from shortened cross-ref'd notes to %%
%% long notes working properly.  Used in short and shorthand cites. %%

\DeclareFieldFormat{cmshyperlink}{%
  \iffieldundef{crossref}%
  {\iffieldundef{xref}%
    {\bibhyperlink{\thefield{entrykey}}{#1}}%
    {\ifboolexpr{((
        test {\ifentrytype{book}}%
        or
        test {\ifentrytype{bookinbook}}%
        or
        test {\ifentrytype{collection}}%
        or
        test {\ifentrytype{proceedings}}%
        )
        and
        not togl {cms@bookcitexref}%
        )
        or
        ((
        test {\ifentrytype{inbook}}%
        or
        test {\ifentrytype{letter}}%
        or
        test {\ifentrytype{incollection}}%
        or
        test {\ifentrytype{inproceedings}}%
        )
        and
        not togl {cms@citecrossref}%
        )
      }%
      {\bibhyperlink{\thefield{xref}}{#1}}%
      {\bibhyperlink{\thefield{entrykey}}{#1}}}}%
  {\ifboolexpr{((
        test {\ifentrytype{book}}%
        or
        test {\ifentrytype{bookinbook}}%
        or
        test {\ifentrytype{collection}}%
        or
        test {\ifentrytype{proceedings}}%
        )
        and
        not togl {cms@bookcitexref}%
        )
        or
        ((
        test {\ifentrytype{inbook}}%
        or
        test {\ifentrytype{letter}}%
        or
        test {\ifentrytype{incollection}}%
        or
        test {\ifentrytype{inproceedings}}%
        )
        and
        not togl {cms@citecrossref}%
        )
      }%
      {\bibhyperlink{\thefield{crossref}}{#1}}%
      {\bibhyperlink{\thefield{entrykey}}{#1}}}}

\DeclareFieldAlias[review]{volume}[article]{volume}

\DeclareFieldAlias[suppperiodical]{volume}[article]{volume}

%%%% Related field formats from biblatex.def %%%%

\DeclareFieldFormat{related:origpubas}{#1}% This and next remove parens

\DeclareFieldFormat{related:origpubin}{#1}

\DeclareFieldFormat{relatedstring:default}{% For notes + bib
  \ifboolexpr{%
    test {\iffieldundef{relatedstring}}%
    or
    test {\iffieldbibstring{relatedstring}}%
  }%
  {#1}%
  {\ifcapital%
    {\MakeCapital{#1}}%
    {#1}}%
  \ifentrytype{jurisdiction}%
  {\newcunit}%
  {\printunit{\relatedpunct}}}%

\DeclareFieldFormat{relatedstring:reprintfrom}{% For notes + bib
  \ifboolexpr{%
    test {\iffieldundef{relatedstring}}%
    or
    test {\iffieldbibstring{relatedstring}}%
  }%
  {#1}%
  {\ifcapital%
    {\MakeCapital{#1}}%
    {#1}}%
}%\addspace

%%%% Commands, for users and internal %%%%

\newcommand*{\cbytypeeditor}{%
  \iffieldundef{editortype}%
    {\bibstring{cbytypeeditor}}%
    {\bibstring{cbytype\thefield{editortype}}}}%

\renewcommand*{\multicitedelim}{\addsemicolon\addspace}

\renewcommand*{\iffinalcitedelim}{%
  \ifnumequal{\value{textcitecount}}{\value{textcitetotal}-1}}

\renewcommand*{\subtitlepunct}{% Follows CMS16 spec.
  \ifboolexpr{%
    test {\ifterm}%
    and
    not test {\ifcsdef{@cmsst}}%
  }%
  {\addspace}%
  {\addcolon\addspace%
    \global\csundef{@cmsst}}%
}

\newcommand{\custpunct}{%
  \iftoggle{cms@fullnote}%
  {\iffieldequalstr{type}{plain}%
    {}%
    {\addcomma}}%
  {\iftoggle{cms@shortnote}%
    {\iffieldundef{postnote}%
      {\ifthenelse{\value{multicitecount} < \value{multicitetotal}}%
        {}%
        {\addperiod}}%
      {\addcomma}}%
    {\addperiod}}}

\newcommand{\custpunctb}{%
  \iftoggle{cms@fullnote}%
  {\iffieldequalstr{userb}{plain}%
    {}%
    {\addcomma}}%
  {\iftoggle{cms@shortnote}%
    {\iffieldundef{postnote}%
      {\ifthenelse{\value{multicitecount} < \value{multicitetotal}}%
        {}%
        {\addperiod}}%
      {\addcomma}}%
    {\addperiod}}}

\newcommand{\classicpunct}{% 16th ed.
  \ifthenelse{\(\iffieldequalstr{entrysubtype}{classical}\AND%
    \iffieldundef{labeltitle}\)\OR
    \ifentrytype{letter}}%
  {\setunit*{\addspace}}%
  {\setunit*{\addcomma\addspace}}}

\newcommand*{\reprintpunct}{%
  \iftoggle{cms@fullnote}%
  {\setunit*{\addsemicolon\addspace}}%
  {\setunit*{\addperiod\addspace}}}

\newcommand*{\encypunct}{% for named entries in an encyclopedia
  \iftoggle{cms@fullnote}%
  {\ifentrytype{book}%
    {\ifthenelse{\iffieldundef{addendum}\AND\iffieldundef{doi}\AND
        \iffieldundef{isbn}\AND\iffieldundef{url}}%
      {\ifthenelse{\value{multicitecount} < \value{multicitetotal}}%
        {}%
        {\addperiod}}%
      {\addcomma}}%
    {\ifnameundef{author}%
      {\ifthenelse{\iffieldundef{addendum}\AND\iffieldundef{doi}\AND
          \iffieldundef{isbn}\AND\iffieldundef{url}}%
        {\ifthenelse{\value{multicitecount} < \value{multicitetotal}}%
          {}%
          {\addperiod}}%
        {\addcomma}}%
      {}}}%
  {\ifentrytype{book}%
    {\addperiod}%
    {\ifnameundef{author}%
      {\addperiod}%
      {}}}}%

\newcommand*{\postvolpunct}{\addcolon}% For vol:page customization

\newcommand*{\parttrans}{%
  \iftoggle{cms@fullnote}%
  {\bibstring{cbytranslator}\addspace}%
  {\bibstring{bytranslator}\addspace}}%

\protected\def\partedit#1{%
  \ifcat\noexpand~\noexpand#1%
  \ifundef{\cms@tempb}{}{\appto{\cms@tempb}{#1}}%
  \def\cms@tempa{\futurelet\cms@tempa\partedit}%
  \else%
  \ifx\addnbspace#1%
  \ifundef{\cms@tempb}{}{\appto{\cms@tempb}{#1}}%
  \def\cms@tempa{\futurelet\cms@tempa\partedit}%
  \else%
  \ifx\addspace#1%
  \ifundef{\cms@tempb}{}{\appto{\cms@tempb}{#1}}%
  \def\cms@tempa{\futurelet\cms@tempa\partedit}%
  \else%
  \if#1H%
  \appto{\cms@tempb}{#1}%
  \def\cms@tempa{\futurelet\cms@tempa\partedit}%
  \else%
  \if#1h%
  \appto{\cms@tempb}{#1}%
  \def\cms@tempa{\futurelet\cms@tempa\partedit}%
  \else%
  \def\cms@tempa{\part@edit@i\lbx@initnamehook{#1}%
    \csuse{cms@tempb}#1\csundef{cms@tempb}}%
  \fi%
  \fi%
  \fi%
  \fi%
  \fi%
  \cms@tempa%
}%

\newcommand*{\part@edit@i}{%
  \iftoggle{cms@fullnote}%
  {\bibstring{cbyeditor}\addspace}%
  {\bibstring{byeditor}\addspace}}%

\newcommand*{\partcomp}{%
  \iftoggle{cms@fullnote}%
  {\bibstring{cbycompiler}\addspace}%
  {\bibstring{bycompiler}\addspace}}%

\newcommand*{\parteditandcomp}{%
  \iftoggle{cms@fullnote}%
  {\bibstring{cbyeditorcp}\addspace}%
  {\bibstring{byeditorcp}\addspace}}%

\newcommand*{\parttransandcomp}{%
  \iftoggle{cms@fullnote}%
  {\bibstring{cbytranslatorcp}\addspace}%
  {\bibstring{bytranslatorcp}\addspace}}%

\newcommand*{\partedittransandcomp}{%
  \iftoggle{cms@fullnote}%
  {\bibstring{cbyeditortrcp}\addspace}%
  {\bibstring{byeditortrcp}\addspace}}%

\newcommand*{\parteditandtrans}{%
  \iftoggle{cms@fullnote}%
  {\bibstring{cbyeditortr}\addspace}%
  {\bibstring{byeditortr}\addspace}}%

\newcommand*{\reprint}{%
  \iftoggle{cms@fullnote}%
  {\bibsstring{reprint}}%
  {\bibstring{reprint}}}%

\newcommand*{\multipubsdelim}{\addnbspace/\addspace}

\newcommand*{\multilocsdelim}{%
  \ifthenelse{\value{listcount}<\value{liststop}}%
    {\ifthenelse{\numexpr\value{listcount}+1<\value{liststop}}%
       {\addcomma\addspace}%
       {\ifthenelse{\value{liststop}>2}%
         {\addcomma\addspace\bibstring{and}\addspace}%
         {\addspace\bibstring{and}\addspace}}}%
       {}}%

\newcommand*{\multilangdelim}{%
  \ifthenelse{\value{listtotal}<3}%
  {\addspace\bibstring{and}\addspace}%
  {\ifthenelse{\value{listcount}<\value{listtotal}}%
    {\addcomma\addspace}%
    {\addcomma\addspace\bibstring{and}\addspace}}}%

\renewcommand*{\postnotedelim}{%
  \ifboolexpr{%
    test {\ifciteibid}%
    and
    (
    test {\ifentrytype{jurisdiction}}%
    or
    test {\ifentrytype{legal}}%
    or
    test {\ifentrytype{legislation}}%
    )
  }%
  {\addspace}%
  {\iftoggle{cms@shortnote}%
    {\iffieldequalstr{entrysubtype}{classical}%
      {\DeclareNumChars*{abcdeABCDE:}% Makes classical
        \iffieldpages{postnote}% test more accurate. See 17.253.
        {\addspace}%
        {\addcomma\addspace}\DeclareNumChars{.}}%
      {\addcomma\addspace}}% 16th ed -- no more volumes test.
    {\iftoggle{cms@fullnote}%
      {\ifthenelse{\(\ifentrytype{article}\OR
          \ifentrytype{review}\OR
          \ifentrytype{periodical}\OR
          \ifentrytype{suppperiodical}\)\AND\NOT
          \iffieldequalstr{entrysubtype}{magazine}}%
        {\addcolon\addspace}%
        {\addcomma\addspace}}%
      {\addcomma\addspace}}}}%

\newcommand*{\postnotewrapper}{%
  \iftoggle{cms@modpostnote}%
  {\ifboolexpr{%
      test {\iffieldstart{postnote}{,}}%
      or
      test {\iffieldstart{postnote}{\bibrangessep}}%
    }%
    {\addcomma}% w/ or w/o \addspace?
    {\ifboolexpr{%
        test {\iffieldstart{postnote}{;}}%
        or
        test {\iffieldstart{postnote}{:}}%
        or
        test {\iffieldstart{postnote}{.}}%
      }%
      {}{\postnotedelim}}}%
  {\postnotedelim}}%

\newrobustcmd*{\iffieldstart}[2]{% Philipp Lehman's code, from
  \begingroup%                     comp.text.tex
  \edef\@tempa{%
    \long\def\noexpand\iffieldstart@i####1\detokenize{#2}####2}%
  \@tempa\@nil{\endgroup\ifblank{##1}}%
  \savefield*{#1}{\@tempa}%
  \expandafter\iffieldstart@i\detokenize
  \expandafter\expandafter\expandafter{%
    \expandafter\@tempa\detokenize{#2}}\@nil}

\newcommand*{\editordelim}{%
  \ifboolexpr{%
    test {\iffieldequalstr{editortype}{none}}%
    and
    not togl {cms@fullnote}%
  }%
  {\newunit}%\addperiod\addspace
  {\newcunit}}%\addcomma\addspace

\newcommand*{\nameadelim}{%
  \ifboolexpr{%
    test {\iffieldequalstr{nameatype}{none}}%
    and
    not togl {cms@fullnote}%
  }%
  {\newunit}%\addperiod\addspace
  {\newcunit}}%\addcomma\addspace

\DeclareListFormat{cfromoriglanguage}{% Needed for notes, to provide
  \begingroup% final {by}.
  \blx@bibstringnormal%
  \usebibmacro{list:delim}{%
    \ifbibstring{from#1}%
      {\bibxlstring{cfrom#1}}%
      {\ifbibstring{clang#1}%
         {\bibxlstring{lang#1}}%
         {#1}}}%
  \ifbibstring{cfrom#1}%
  {\ifboolexpr{%
      test {\ifnumless{\value{listcount}}{\value{liststop}}}%
      or
      test {\ifmoreitems}%
     }%
     {\bibstring{from#1}}%
     {\bibstring{cfrom#1}}}%
    {\ifbibstring{lang#1}%
       {\biblstring{lang#1}}%
       {#1}}%
 \usebibmacro{list:andotherlangs}%
 \endgroup}

\newbibmacro*{list:andotherlangs}{% Final {by} after {andmore}
  \ifboolexpr{%
    test {\ifnumequal{\value{listcount}}{\value{liststop}}}%
    and
    test {\ifmoreitems}%
  }%
    {\ifnumgreater{\value{liststop}}{1}%
       {\finalandcomma}%
       {}%
     \printdelim{andmoredelim}\bibstring{andmore}\addspace\bibstring{by}}%
    {}}

\newcommand*{\lbx@cfromlang}{% Because the cbytranslator string can't
  \iffieldundef{userf}% have {by} in it unless there's an origlanguage.
  {\iflistundef{origlanguage}%
    {\unspace}%
    {\printlist[cfromoriglanguage]{origlanguage}}}%
  {\unspace}}%

\renewcommand*{\lbx@fromlang}{%
  \iffieldundef{userf}%
  {\iflistundef{origlanguage}%
    {\unspace}%
    {\printlist[lfromoriglanguage]{origlanguage}}}%
  {\unspace}}%

\renewcommand*{\lbx@lfromlang}{%
  \iffieldundef{userf}%
  {\iflistundef{origlanguage}%
    {\unspace}%
    {\printlist[lfromoriglanguage]{origlanguage}}}%
  {\unspace}}%

\renewcommand*{\lbx@sfromlang}{%
  \iffieldundef{userf}%
  {\iflistundef{origlanguage}%
    {\unspace}%
    {\printlist[sfromoriglanguage]{origlanguage}}}%
  {\unspace}}%

%%%% Formatting macros, called both by cbx and bbx %%%%

\newbibmacro*{finentry}{%{\finentry} To make annotated bibliography
  \togglefalse{cms@switchdates}%
  \ifbibliography
    {\usebibmacro{entrytail}}%
    {}%
  \finentry}

\newbibmacro*{book:xref+finentry}{% FIXME
  \ifthenelse{\iffieldundef{crossref}\OR\ifbibliography}%
  {\ifthenelse{\iffieldundef{xref}\OR\ifbibliography}%
    {}%
    {\iftoggle{cms@bookcitexref}%
      {\cms@citetracker@xref}%
      {\bibhypertarget{\thefield{xref}}%
        {\cms@citetracker@xref}}}}%
  {\iftoggle{cms@bookcitexref}%
    {\cms@citetracker@crossref}%
    {\bibhypertarget{\thefield{crossref}}%
      {\cms@citetracker@crossref}}}}%

\newbibmacro*{cite:xref+finentry}{% FIXME
  \ifthenelse{\iffieldundef{crossref}\OR\ifbibliography}%
  {\ifthenelse{\iffieldundef{xref}\OR\ifbibliography}%
    {}%
    {\iftoggle{cms@citecrossref}%
      {\cms@citetracker@xref}%
      {\bibhypertarget{\thefield{xref}}%
        {\cms@citetracker@xref}}}}%
  {\iftoggle{cms@citecrossref}%
    {\cms@citetracker@crossref}%
    {\bibhypertarget{\thefield{crossref}}%
      {\cms@citetracker@crossref}}}}%

\newbibmacro*{allshort+firstcite+xref}{%
  \ifboolexpr{%
    (
    togl {cms@citecrossref}%
    and
    togl {cms@bookcitexref}% 
    )
    or
    not togl {cms@allshort}%
  }%
  {}%
  {\ifciteseen%
    {}%
    {\iffieldundef{crossref}%
      {\iffieldundef{xref}%
        {}%
        {\cms@citetracker@xref}}%
      {\cms@citetracker@crossref}}}}%

\def\cms@citetracker@crossref{% cf. \blx@citetracker@global
  \ifbool{citetracker}%
    {\xifinlistcs\abx@field@crossref{blx@bsee@\the\c@refsection}%
       {}%
       {\listcsxadd{blx@bsee@\the\c@refsection}\abx@field@crossref}}%
    {}}%

\def\cms@citetracker@xref{% cf. \blx@citetracker@global
  \ifbool{citetracker}%
    {\xifinlistcs\abx@field@xref{blx@bsee@\the\c@refsection}%
       {}%
       {\listcsxadd{blx@bsee@\the\c@refsection}\abx@field@xref}}%
    {}}%


\newbibmacro*{entrytail}{% From reading.bbx, for annotated bibliography
  \newunit\newblock
  \iftoggle{cms@annotation}%
    {\usebibmacro{annotation}%
     \newunit\newblock}%
    {}}%

\newbibmacro*{author+holder}{%
  \ifnameundef{author}%
    {}%
    {\printnames{author}%
     \ifthenelse{\ifnameundef{holder}\OR%
                 \ifnamesequal{author}{holder}}%
       {}%
       {\setunit{\addspace}%
        \printtext[parens]{\printnames{holder}}}}}

\renewbibmacro*{byauthor}{%
  \ifthenelse{\ifuseauthor\OR%
              \ifnameundef{author}}%
    {}%
    {\bibstring{by}\addspace%
     \printnames[byauthor]{author}}}

\newbibmacro*{byauthorpunct}{%
  \ifthenelse{\ifuseauthor\OR\ifnameundef{author}}%
  {\addperiod\addspace}%
  {\newcunit}}

\renewbibmacro*{bybookauthor}{%
  \ifnameundef{bookauthor}%
    {}%
    {\ifnamesequal{author}{bookauthor}%
      {}%
      {\bibstring{by}\addspace\printnames[default]{bookauthor}%
     \newcunit\newblock}}}

\newbibmacro*{editorpunct}{%
  \ifthenelse{\(\iffieldundef{booktitle}\AND%
    \iffieldundef{maintitle}\AND\iffieldundef{issuetitle}\)%
    \OR\iffieldsequal{booktitle}{title}%  Changed these for crossrefed
    \OR\iffieldsequal{maintitle}{title}}% entries.  Create problems?
  {\ifentrytype{video}% Change for Video type?  Appears
    {\newcunit\newblock}% to treat italicized title as booktitle in
    {\newunit\newblock}}% available examples.  Added issuetitle 0.9.9c.
  {\newcunit\newblock}}

\newbibmacro*{edition}{%
  \printfield{edition}%
    \clearfield{edition}}%

\newbibmacro*{inforaft}{%
  \ifnameundef{introduction}%
  {\ifnameundef{afterword}%
    {\ifnameundef{foreword}%
      {\printfield{type}}%
      {\bibstring{forewordto}%
        \clearname{foreword}}}% 16th ed.
    {\bibstring{afterwordto}%
      \clearname{afterword}}}%
  {\bibstring{introductionto}%
    \clearname{introduction}}}

\newbibmacro*{langlist:andothers}{%
  \ifthenelse{\value{listcount}=\value{liststop}\AND%
              \ifmoreitems}%
    {\ifnum\value{liststop}>1 \finalandcomma\fi%
     \andmoredelim\bibstring{andmore}\bibrightbracket}%
    {}}%

\newbibmacro*{mag+news+author}{%
  \ifnameundef{author}%
  {\ifboolexpr{%
      test {\iffieldequals{journaltitle}{\bbx@lasthash}}%
      and
      not test {\iffirstonpage}%
      and
      togl {cms@namedash}%
    }%
    {\printtext{\bibnamedash}}%
    {\usebibmacro{journal+sub}%
      \setunit*{\addspace}%
      \printlist[periodplace]{location}%
      \savefield{journaltitle}{\bbx@lasthash}}}%
  {\ifuseauthor%
    {\ifthenelse{\(\ifentrytype{review}\OR\ifentrytype{suppperiodical}\)%
        \AND\NOT\iffieldundef{nameaddon}}%
      {\savefield{nameaddon}{\cms@tempn}\clearfield{nameaddon}%
        \usebibmacro{author}\restorefield{nameaddon}{\cms@tempn}}%
      {\usebibmacro{author}}}%
    {}}}%

\newbibmacro*{cmag+news+author}{%
  \ifnameundef{author}%
  {}% 16th ed.
  {\ifuseauthor%
    {\ifthenelse{\(\ifentrytype{review}\OR\ifentrytype{suppperiodical}\)%
        \AND\NOT\iffieldundef{nameaddon}}%
      {\savefield{nameaddon}{\cms@tempn}\clearfield{nameaddon}%
        \usebibmacro{author}\restorefield{nameaddon}{\cms@tempn}}%
      {\usebibmacro{author}}}%
    {}}}%

\newbibmacro*{type+inst+year}{%
  \printfield{type}%
  \newcunit
  \printlist{institution}%
  \setunit*{\addcomma\addspace}%
  \usebibmacro{date}}%  Instead of cmsyear

\newbibmacro*{institution+organization}{%
  \iflistundef{organization}%
  {\iflistundef{institution}%
    {}%
    {\printlist{institution}}}%
  {\printlist{organization}%
    \newcunit%
    \printlist{institution}}}

\newbibmacro*{bibauthor+org}{%
  \ifnameundef{author}%
  {\ifnameundef{editor}%
    {\iflistundef{organization}%
      {}%
      {\ifboolexpr{%
          test {\iflistequals{organization}{\bbx@lasthash}}%
          and
          not test {\iffirstonpage}%
          and
          togl {cms@namedash}%
        }%
        {\printtext{\bibnamedash}}%
        {\printlist{organization}%
          \savelist{organization}{\bbx@lasthash}}}}%
    {\usebibmacro{editor}}}%
  {\usebibmacro{author/editor}}}

\newbibmacro*{author+org}{%
  \ifnameundef{author}%
  {\ifnameundef{editor}%
    {\iflistundef{organization}%
      {}%
      {\printlist{organization}}}%
    {\usebibmacro{editor}}}%
  {\usebibmacro{author/editor}}}

\newbibmacro*{cbytypestrg}[2]{%
  \iffieldundef{#1type}%
    {\bibstring{cby#2}}%
    {\bibstring{cby\thefield{#1type}}}}%

\newbibmacro*{cbyeditor}{%
  \ifnameundef{editor}%
    {}%
    {\usebibmacro{cbytypestrg}{editor}{editor}%
     \setunit{\addspace}%
     \printnames[byeditor]{editor}%
     \newcunit}%
  \usebibmacro{cbyeditorx}}

\newbibmacro*{cbyeditorx}{%
  \ifnameundef{editora}%
    {}%
    {\usebibmacro{cbytypestrg}{editora}{editor}%
     \setunit{\addspace}%
     \printnames[byeditora]{editora}%
     \newcunit}%
  \ifnameundef{editorb}%
    {}%
    {\usebibmacro{cbytypestrg}{editorb}{editor}%
     \setunit{\addspace}%
     \printnames[byeditorb]{editorb}%
     \newcunit}%
  \ifnameundef{editorc}%
    {}%
    {\usebibmacro{cbytypestrg}{editorc}{editor}%
     \setunit{\addspace}%
     \printnames[byeditorc]{editorc}%
     \newcunit}}

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

\newbibmacro*{cbycompiler}{%
  \ifnameundef{namec}%
    {}%
    {\bibstring{cbycompiler}\addspace%
     \printnames[bycompiler]{namec}}}

\newbibmacro*{cbyredactor}{%
  \ifnameundef{redactor}%
    {}%
    {\bibstring{cbyredactor}\addspace%
     \printnames[byredactor]{redactor}}}

\newbibmacro*{cwithcommentator}{%
  \ifnameundef{commentator}%
    {}%
    {\bibsstring{withcommentator}\addspace%
     \printnames[withcommentator]{commentator}}}

\newbibmacro*{cwithannotator}{%
  \ifnameundef{annotator}%
    {}%
    {\bibsstring{withannotator}\addspace%
     \printnames[withannotator]{annotator}}}

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

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

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

\newbibmacro*{cbyeditor+others}{%
  \ifthenelse{\NOT\ifnameundef{editor}\AND%
    \(\iffieldundef{editortype}\OR%
    \iffieldequalstr{editortype}{editor}\)}%
  {\def\@tempa{cbyeditor}%
    \ifnamesequal{editor}{translator}%
    {\edef\@tempa{\@tempa tr}%
      \clearname{translator}}%
    {}%
    \ifnamesequal{editor}{namec}%
    {\edef\@tempa{\@tempa cp}%
      \clearname{namec}}%
    {}%
    \ifnamesequal{editor}{commentator}%
    {\edef\@tempa{\@tempa co}%
      \clearname{commentator}}%
    {\ifnamesequal{editor}{annotator}%
      {\edef\@tempa{\@tempa an}%
        \clearname{annotator}}%
      {}}%
    \ifnamesequal{editor}{introduction}%
    {\edef\@tempa{\@tempa in}%
      \clearname{introduction}}%
    {\ifnamesequal{editor}{foreword}%
      {\edef\@tempa{\@tempa fo}%
        \clearname{foreword}}%
      {\ifnamesequal{editor}{afterword}%
        {\edef\@tempa{\@tempa af}%
          \clearname{afterword}}%
        {}}}%
    \bibstring{\@tempa}\addspace%
    \printnames[byeditor]{editor}%
    \clearname{editor}%
    \newcunit%
    \usebibmacro{cbyeditorx}}%
  {\usebibmacro{cbyeditor}}%
  \usebibmacro{cbytranslator+others}}

\newbibmacro*{cbytranslator+others}{%
  \ifnameundef{translator}%
    {}%
    {\def\@tempa{cbytranslator}%
      \ifnamesequal{translator}{namec}%
      {\edef\@tempa{\@tempa cp}%
        \clearname{namec}}%
      {}%
     \ifnamesequal{translator}{commentator}%
       {\edef\@tempa{\@tempa co}%
        \clearname{commentator}}%
       {\ifnamesequal{translator}{annotator}%
          {\edef\@tempa{\@tempa an}%
           \clearname{annotator}}%
          {}}%
     \ifnamesequal{translator}{introduction}%
       {\edef\@tempa{\@tempa in}%
        \clearname{introduction}}%
       {\ifnamesequal{translator}{foreword}%
          {\edef\@tempa{\@tempa fo}%
           \clearname{foreword}}%
          {\ifnamesequal{translator}{afterword}%
             {\edef\@tempa{\@tempa af}%
              \clearname{afterword}}%
             {}}}%
     \bibstring{\@tempa}\addspace%
     \printnames[bytranslator]{translator}%
     \clearname{translator}%
     \newcunit}%
  \usebibmacro{cbycompiler+others}}

\newbibmacro*{cbycompiler+others}{%
  \ifnameundef{namec}%
    {}%
    {\def\@tempa{cbycompiler}%
     \ifnamesequal{namec}{commentator}%
       {\edef\@tempa{\@tempa co}%
        \clearname{commentator}}%
       {\ifnamesequal{namec}{annotator}%
          {\edef\@tempa{\@tempa an}%
           \clearname{annotator}}%
          {}}%
     \ifnamesequal{namec}{introduction}%
       {\edef\@tempa{\@tempa in}%
        \clearname{introduction}}%
       {\ifnamesequal{namec}{foreword}%
          {\edef\@tempa{\@tempa fo}%
           \clearname{foreword}}%
          {\ifnamesequal{namec}{afterword}%
             {\edef\@tempa{\@tempa af}%
              \clearname{afterword}}%
             {}}}%
     \bibstring{\@tempa}\addspace%
     \printnames[bycompiler]{namec}%
     \clearname{namec}%
     \newcunit}%
  \usebibmacro{cbyothers}}

\newbibmacro*{cbyothers}{%
  \usebibmacro{cbytranslator}%
  \setunit*{\addcomma\addspace}%
  \usebibmacro{cbycompiler}%
  \setunit*{\addcomma\addspace}%
  \usebibmacro{cbyredactor}%
  \setunit*{\addcomma\addspace}%
  \usebibmacro{cwithcommentator}%
  \setunit*{\addcomma\addspace}%
  \usebibmacro{cwithannotator}%
  \setunit*{\addcomma\addspace}%
  \usebibmacro{cwithintroduction}%
  \setunit*{\addcomma\addspace}%
  \usebibmacro{cwithforeword}%
  \setunit*{\addcomma\addspace}%
  \usebibmacro{cwithafterword}}

\newbibmacro*{part+editor+translator}{%
  \ifnameundef{namea}%
  {\ifnameundef{nameb}%
    {}%
    {\bibstring{bytranslator}\addspace%
      \printnames[bytranslator]{nameb}}}%
  {\ifthenelse{\iffieldundef{nameatype}\OR%
      \iffieldequalstr{nameatype}{editor}}%
    {\ifnamesequal{namea}{nameb}%
      {\bibstring{byeditortr}\addspace%
        \printnames[byeditor]{namea}}%
      {\bibstring{byeditor}\addspace%
        \printnames[byeditor]{namea}%
        \ifnameundef{nameb}%
        {}%
        {\newunit%
          \bibstring{bytranslator}\addspace%
          \printnames[bytranslator]{nameb}}}}%
    {\usebibmacro{bytypestrg}{namea}{editor}%
      \setunit{\addspace}%
      \printnames[byeditor]{namea}%
      \ifnameundef{nameb}%
      {}%
      {\newunit%
        \bibstring{bytranslator}\addspace%
        \printnames[bytranslator]{nameb}}}}}

\newbibmacro*{cpart+editor+translator}{%
  \ifnameundef{namea}%
  {\ifnameundef{nameb}%
    {}%
    {\bibstring{cbytranslator}\addspace%
      \printnames[bytranslator]{nameb}}}%
  {\ifthenelse{\iffieldundef{nameatype}\OR%
      \iffieldequalstr{nameatype}{editor}}%
    {\ifnamesequal{namea}{nameb}%
      {\bibstring{cbyeditortr}\addspace%
        \printnames[byeditor]{namea}}%
      {\bibstring{cbyeditor}\addspace% Need this \space here?
        \printnames[byeditor]{namea}%
        \ifnameundef{nameb}%
        {}%
        {\newcunit%
          \bibstring{cbytranslator}\addspace%
          \printnames[bytranslator]{nameb}}}}%
    {\usebibmacro{cbytypestrg}{namea}{editor}%
      \setunit{\addspace}%
      \printnames[byeditor]{namea}%
      \ifnameundef{nameb}%
      {}%
      {\newcunit%
        \bibstring{cbytranslator}\addspace%
        \printnames[bytranslator]{nameb}}}}}

\newbibmacro*{cms-in:}{% Fix for 0.9a compat.
  \iftoggle{cms@origpublished}%
  {}% Removed the cms@crspace test -- fixed a bug I had introduced
  {\bibstring{in}%
    \setunit{\addspace}}}

\newbibmacro*{bibxref-in:}{%
  \iffieldundef{volume}%
  {\ifcsdef{cbx@incollvol}%
    {\restorefield{volume}{\cbx@incollvol}\toggletrue{cms@xrefvol}%
      \ifcsdef{cbx@incollpart}%
      {\restorefield{part}{\cbx@incollpart}}%
      {}%
      \ifthenelse{\ifentrytype{mvbook}\OR\ifentrytype{mvcollection}\OR%
        \ifentrytype{mvproceedings}\OR\ifentrytype{mvreference}}%
      {\printfield{volume}%
        \clearfield{volume}%
        \global\let\cbx@incollvol\undefined% Volume fix
        \printfield{part}%
        \clearfield{part}%
        \global\let\cbx@incollpart\undefined% Volume fix
        \setunit{\addspace}%
        \bibstring{ofseries}%
        \setunit{\addspace}}%
      {\bibstring{in}\setunit{\addspace}}}%
    {\iffieldundef{part}%
      {\ifcsdef{cbx@incollpart}%
        {\restorefield{part}{\cbx@incollpart}\toggletrue{cms@xrefpart}}%
        {}}%
      {}%
      \ifthenelse{\ifentrytype{mvbook}\OR\ifentrytype{mvcollection}\OR%
        \ifentrytype{mvproceedings}\OR\ifentrytype{mvreference}}%
      {\printfield[xrefpart]{part}%
        \clearfield{part}%
        \global\let\cbx@incollpart\undefined% Volume fix
        \setunit{\addspace}%
        \bibstring{ofseries}%
        \setunit{\addspace}}%
      {\bibstring{in}\setunit{\addspace}}}}%
  {\iffieldundef{part}%
    {\ifcsdef{cbx@incollpart}%
      {\restorefield{part}{\cbx@incollpart}\toggletrue{cms@xrefpart}}%
      {}}%
    {}%
    \ifthenelse{\ifentrytype{mvbook}\OR\ifentrytype{mvcollection}\OR%
      \ifentrytype{mvproceedings}\OR\ifentrytype{mvreference}}%
    {\printfield{volume}%
      \clearfield{volume}%
      \global\let\cbx@incollvol\undefined% Volume fix
      \printfield{part}%
      \clearfield{part}%
      \global\let\cbx@incollpart\undefined% Volume fix
      \setunit{\addspace}%
      \bibstring{ofseries}%
      \setunit{\addspace}}%
    {\bibstring{in}\setunit{\addspace}}}}%

\newbibmacro*{chapincoll}{%
  \iffieldundef{chapter}%
  {}%
  {\printfield{chapter}\addspace%
    \clearfield{chapter}}}%

\newbibmacro*{xrefchapincoll}{%
  \iffieldundef{chapter}%
  {\printtext{\relax}}%
  {\printfield{chapter}\addspace%
    \clearfield{chapter}}}%

\newbibmacro*{chapinscore}{%
  \iffieldundef{chapter}%
  {\ifboolexpr{%
      test {\ifentrytype{music}}% 16th ed.
      and
      not test {\iffieldundef{booktitle}}%
      and
      not togl {cms@origpublished}%
    }%
    {\bibstring{on}\setunit{\addspace}}%
    {}}%
  {\printfield{chapter}\clearfield{chapter}%
    \iffieldundef{booktitle}%
    {}%
    {\addspace\bibstring{of}\setunit{\addspace}}}}%

\newbibmacro*{caddendum}{% New macros for 16th ed. field exclusion
  \ifboolexpr{%
    togl {cms@addendum}%
    and
    not test {\iffieldundef{addendum}}%
  }%
  {\newcunit\printfield{addendum}}%
  {}}%

\newbibmacro*{cnotefield}{%
  \iftoggle{cms@notefield}%
  {\printfield{note}}%
  {}}%

\newbibmacro*{cser+num}{%
  \iftoggle{cms@bookseries}%
  {\printfield{series}%
    \printfield[sernum]{number}}%
  {}}%

\newbibmacro*{ser+num}{%
  \printfield{series}%
  \printfield[sernum]{number}}

\newbibmacro*{music+origdate}{%
  \iftoggle{cms@reprint}% 16th ed.
  {}%
  {\iffieldundef{origyear}%
    {}%
    {\usebibmacro{cmsorigdate}}}}% Date fix

\newbibmacro*{music+eventdate}{%
  \iffieldundef{eventyear}%
  {}%
  {\printeventdate}}% Date fix

\newbibmacro*{ctitle+stitle}{% New test here for related entries.
  \iffieldundef{title}%
  {}%
  {\printtext[title]{%:\thefield{entrytype}]{%(Changed for 0.7 to work)
      \printfield[tnoformat]{title}%
      \setunit{\subtitlepunct}%
      \printfield[stnoformat]{subtitle}}}%
  \setunit{\ctitleaddonpunct}%
  \printfield{titleaddon}}%
%  \setunit{\addspace}}%
%  \usebibmacro{language+transtitle}%
%  \setunit*{\addcomma}\newblock}

\newbibmacro*{citaltitle+stitle}{% New test, as above.
  \iffieldundef{title}%
  {}%
  {\printtext[title]{%:\thefield{entrytype}]{%(Changed for 0.7 to work)
      \printfield[tnoformat]{title}%
      \setunit{\subtitlepunct}%
      \printfield[stnoformat]{subtitle}}}%
  \setunit{\ctitleaddonpunct}%
  \printfield{titleaddon}%
  \setunit{\addspace}%
  \usebibmacro{language+transtitle}%
  \newcunit\newblock}

\newbibmacro*{title+stitle}{%
  \printtext[title]{%:\thefield{entrytype}]{%(Changed for 0.7 to work)
    \printfield[noformat]{title}%
    \setunit{\subtitlepunct}%
    \printfield[noformat]{subtitle}}%
  \setunit{\ptitleaddonpunct}%
  \printfield{titleaddon}}%
%  \setunit{\addspace}}%
%  \usebibmacro{language+transtitle}%
%  \newunit\newblock}

\newbibmacro*{italtitle+stitle}{%
  \printtext[title]{%:\thefield{entrytype}]{%(Changed for 0.7 to work)
    \printfield[noformat]{title}%
    \setunit{\subtitlepunct}%
    \printfield[noformat]{subtitle}}%
  \setunit{\ptitleaddonpunct}%
  \printfield{titleaddon}%
  \setunit{\addspace}%
  \usebibmacro{language+transtitle}%
  \newunit\newblock}

\newbibmacro*{mag+news+title}{%
  \printtext[title]{%:\thefield{entrytype}]{%(Changed for 0.7 to work)
       \printfield[noformat]{title}%
       \setunit{\subtitlepunct}%
       \printfield[noformat]{subtitle}}%
     \setunit{\ptitleaddonpunct}%
     \ifboolexpr{%
       test {\iffieldequalstr{relatedtype}{reviewof}}%
       and
       togl {cms@related}%
     }%
     {\usebibmacro{related:init}%
       \usebibmacro{related}}%
     {\printfield{titleaddon}}%
     }%\newcunit\newblock}

\newbibmacro*{cmag+news+title}{%
  \printtext[title]{%:\thefield{entrytype}]{%(Changed for 0.7 to work)
       \printfield[noformat]{title}%
       \setunit{\subtitlepunct}%{\addcolon\addspace}%
       \printfield[noformat]{subtitle}}%
     \setunit{\ctitleaddonpunct}%
     \ifboolexpr{%
       test {\iffieldequalstr{relatedtype}{reviewof}}%
       and
       togl {cms@citerel}%
     }%
     {\usebibmacro{related:init}%
       \usebibmacro{related}}%
     {\printfield{titleaddon}}%
     }%\newcunit\newblock}

\newbibmacro*{clegis+news+title}{%
  \ifthenelse{\iffieldundef{title}\AND\iffieldundef{subtitle}\AND%
    \iffieldundef{titleaddon}}%
  {}%
  {\printtext[title]{%:\thefield{entrytype}]{%(Changed for 0.7 to work)
      \printfield[noformat]{title}%
      \setunit{\subtitlepunct}%
      \printfield[noformat]{subtitle}}%
    \setunit{\ctitleaddonpunct}%
    \printfield{titleaddon}%
  }}%\newcunit\newblock}

\newbibmacro*{language+transtitle}{%
  \iffieldundef{usere}%
  {\printlist[][-\value{listtotal}]{language}}%
  {\printfield{usere}}}

\newbibmacro*{issuetitle}{%
  \iffieldundef{issuetitle}%
  {}%
  {\ifthenelse{\ifentrytype{article}\OR%
      \ifentrytype{review}\OR%
      \ifentrytype{suppperiodical}}% This test is for
    {\usebibmacro{cms-in:}}% periodical entries
    {}%
    \printtext[issuetitle]{%
      \printfield[itnoformat]{issuetitle}%
      \iftoggle{cms@origpublished}% Complications due to \smartof
      {}%
      {\setunit{\subtitlepunct}%
        \printfield[sitnoformat]{issuesubtitle}}}}}

\newbibmacro*{btitle+bstitle}{%
  \iffieldundef{booktitle}%
  {}%
  {\ifthenelse{\ifentrytype{audio}\OR\ifentrytype{music}\OR%
      \ifentrytype{video}}%
    {}%
    {\usebibmacro{cms-in:}}%
    \printtext[booktitle]{%
      \printfield[btnoformat]{booktitle}%
      \setunit{\subtitlepunct}%
      \printfield[sbtnoformat]{booksubtitle}}%
    \setunit{\ctitleaddonpunct}%
    \printfield{booktitleaddon}%
    \setunit*{\addcomma\addspace}}}

\newbibmacro*{publ+loc+year}{% Revised for reprint
  \ifboolexpr{%
    togl {cms@reprint}%
    and
    not test {\ifentrytype{video}}%
  }%
  {\bibstring{reprint}%
    \newcunit}%
  {}%
  \printlist{location}%
  \iflistundef{publisher}%
  {\setunit*{\addcomma\addspace}}%
  {\setunit*{\addcolon\addspace}}%
  \printlist{publisher}%
  \setunit*{\addcomma\addspace}%
  \usebibmacro{date}%
}

\newbibmacro*{origpubl+loc+year}{% 16th ed.
  \printlist{origlocation}%
  \iflistundef{origpublisher}%
  {\setunit*{\addcomma\addspace}}%
  {\setunit*{\addcolon\addspace}}%
  \printlist{origpublisher}%
  \setunit*{\addcomma\addspace}%
  \usebibmacro{cmsorigdate}%
}

\newbibmacro*{howpubl+loc+year}{% Revised for reprint
  \usebibmacro{cmsorigdate}%
  \reprintpunct%
  \iftoggle{cms@reprint}%
  {\reprint\newcunit}%
  {}%
  \printlist{location}%
  \iffieldundef{howpublished}%
  {\setunit*{\addcomma\addspace}}%
  {\setunit*{\addcolon\addspace}}%
  \printfield{howpublished}%
  \setunit*{\addcomma\addspace}%
  \usebibmacro{date}%
}

\newbibmacro*{inst+loc+year}{% Revised for reprint
  \usebibmacro{origpubl+loc+year}%{cmsorigdate}% 16th ed.
  \reprintpunct%
  \iftoggle{cms@reprint}%
  {\reprint\newcunit}%
  {}%
  \printlist{location}%
  \iflistundef{institution}%
  {\setunit*{\addcomma\addspace}}%
  {\setunit*{\addcolon\addspace}}%
  \printlist{institution}%
  \setunit*{\addcomma\addspace}%
  \usebibmacro{date}%
}%

\newbibmacro*{cpubl+loc+year}{% Revised for reprint
  \ifboolexpr{%
    test {\iflistundef{location}}%
    and
    test {\iflistundef{publisher}}%
    and
    test {\iffieldundef{year}}%
    and
    not togl {cms@reprint}%
  }%
  {}%
  {\setunit{\addspace}%
    \printtext[parens]{%
      \usebibmacro{origpubl+loc+year}%{cmsorigdate}%\printfield{origyear}%
      \setunit*{\addsemicolon\addspace}%
      \ifboolexpr{%
        togl {cms@reprint}%
        and
        not test{\ifentrytype{video}}%
      }%
      {\bibsstring{reprint}%
        \newcunit}%
      {}%
      \printlist{location}%
      \iflistundef{publisher}%
      {\setunit*{\addspace}}%
      {\setunit*{\addcolon\addspace}}%
      \printlist{publisher}%
      \setunit{\addcomma\addspace}%
      \usebibmacro{date}}}}%

\newbibmacro*{cpubletter+loc+year}{%
  \ifboolexpr{%
    test {\iflistundef{location}}%
    and
    test {\iflistundef{publisher}}%
    and
    test {\iffieldundef{year}}%
  }%
  {}%
  {\setunit{\addspace}%
    \printtext[parens]{%
      \printlist{location}%
      \iflistundef{publisher}%
      {\setunit*{\addspace}}%
      {\setunit*{\addcolon\addspace}}%
      \printlist{publisher}%
      \setunit{\addcomma\addspace}%
      \usebibmacro{date}}}}% Changed for 0.9

\newbibmacro*{originally+published+as}{% Punctuation fix now in 
  \iffieldundef{userf}%                  \origfullcite for 0.8e. 
  {\iffieldundef{reprinttitle}%
    {}%
    {\usebibmacro{begrelated}%
      \bibstring{reprintfrom}% ?
      \origpublcite{\thefield{reprinttitle}}%
      \usebibmacro{endrelated}%
      \newunit}}%
  {\usebibmacro{begrelated}%
    \iflistundef{origlanguage}%
    {\bibstring{origpub}%
      \origfullcite{\thefield{userf}}%
      \usebibmacro{endrelated}%
      \newunit}%
    {\iftoggle{cms@postposit}%
      {\bibstring{origedition}%
        \setunit{\addspace}%
        \printlist[edlang]{origlanguage}%
        \addcolon%
        \origfullcite{\thefield{userf}}%
        \usebibmacro{endrelated}%
        \newunit}%
      {\printlist[edlang]{origlanguage}%
        \setunit{\addspace}%
        \bibstring{origedition}%
        \origfullcite{\thefield{userf}}%
        \usebibmacro{endrelated}%
        \newunit}}}}

\newbibmacro*{org+publ+loc+year}{% What was wrong with \ifthenelse here?
  \usebibmacro{origpubl+loc+year}%{cmsorigdate}% 16th ed.
  \reprintpunct%
  \iftoggle{cms@reprint}% Revised for reprint
  {\reprint\newcunit}%
  {}%
  \printlist{location}%
  \iflistundef{organization}%
  {\iflistundef{publisher}%
    {\setunit*{\addcomma\addspace}}%
    {\setunit*{\addcolon\addspace}}}%
  {\setunit*{\addcolon\addspace}}%
  \printlist{organization}%
  \setunit*{\addcomma\addspace}%
  \printlist{publisher}%
  \setunit*{\addcomma\addspace}%
  \usebibmacro{date}}

\newbibmacro*{year+in+parens}{%
  \iffieldundef{volume}%
  {noformat}%
  {parens}}

\newbibmacro*{cjournal+issue+year+pages}{%
  \usebibmacro{cjournal+ser+vol+num}%
  \ifboolexpr{% 16th ed.
    test {\iffieldundef{issue}}%
    and
    test {\iffieldundef{year}}%
    and
    not togl {cms@switchdates}%
  }%
  {\iffieldundef{number}%
    {\ifthenelse{\iffieldundef{pagination}\AND%
        \iffieldundef{bookpagination}}%
      {\setunit{\postvolpunct}}%
      {\setunit{\addcolon\addspace}}}%
    {\addcomma\addspace}}%
  {\ifthenelse{\iffieldundef{volume}\AND\iffieldundef{number}}% 16th ed.
    {\newcunit%
      \iffieldundef{issue}%
      {\usebibmacro{number+or+month}}%
      {\printfield{issue}%
        \setunit{\addspace}%
        \usebibmacro{cmsyear}}%
      \addcomma\addspace}%
    {\setunit{\addspace}%
    \printtext[parens]{% parens is the default here
      \iffieldundef{issue}%
      {\usebibmacro{number+or+month}}%
      {\printfield{issue}%
        \setunit{\addspace}%
        \usebibmacro{cmsyear}}}}}}

\newbibmacro*{cperiodical+issue+year+pages}{% For periodicals,
  \usebibmacro{cperiodical+ser+vol+num}% subtype article
  \ifboolexpr{% 16th ed.
    test {\iffieldundef{issue}}%
    and
    test {\iffieldundef{year}}%
    and
    not togl {cms@switchdates}%
  }%
  {\iffieldundef{number}%
    {\ifthenelse{\iffieldundef{pagination}\AND%
        \iffieldundef{bookpagination}}%
      {\setunit{\postvolpunct}}%
      {\setunit{\addcolon\addspace}}}%
    {\addcomma\addspace}}%
  {\ifthenelse{\iffieldundef{volume}\AND\iffieldundef{number}}% 16th ed.
    {\newcunit%
      \iffieldundef{issue}%
      {\usebibmacro{number+or+month}}%
      {\printfield{issue}%
        \setunit{\addspace}%
        \usebibmacro{cmsyear}}%
      \addcomma\addspace}%
    {\setunit{\addspace}%
    \printtext[parens]{% parens is the default here
      \iffieldundef{issue}%
      {\usebibmacro{number+or+month}}%
      {\printfield{issue}%
        \setunit{\addspace}%
        \usebibmacro{cmsyear}}}}}}

\newbibmacro*{letter+date}{% New for 0.9
  \iflistundef{origlocation}%
  {}%
  {\printlist{origlocation}%
    \newcunit\newblock}%
  \iftoggle{cms@switchdates}%
  {\ifthenelse{\iffieldundef{year}\AND\iffieldundef{month}\AND%
      \iffieldundef{yeardivision}}%
    {}%
    {\cms@datelong{}}}%
  {\ifthenelse{\iffieldundef{origyear}\AND\iffieldundef{origmonth}\AND%
      \iffieldundef{origyeardivision}}%
    {}%
    {\cms@datelong{orig}}}}

\newbibmacro*{unpubl+letter+date}{% For Misc entries
  \iflistundef{origlocation}%
  {}%
  {\printlist{origlocation}%
    \newcunit\newblock}%
  \iftoggle{cms@switchdates}%
  {\ifthenelse{\iffieldundef{year}\AND\iffieldundef{month}\AND%
      \iffieldundef{yeardivision}}%
    {}%
    {\cms@datelong{}}}%
  {\ifthenelse{\iffieldundef{origyear}\AND\iffieldundef{origmonth}\AND%
      \iffieldundef{origyeardivision}}%
    {\printdate}% For interviews and other dated non-letters.
    {\cms@datelong{orig}}}}

\newbibmacro*{pubstate}{%
  \iftoggle{cms@reprint}%
  {\iftoggle{cms@switchdates}%
    {\iffieldundef{year}%
      {}%
      {\printtext{% 16th ed.
          \usebibmacro{choosepubstring}%
          \printdate}}}%
    {\iffieldundef{origyear}%
      {}%
      {\printtext{% 16th ed.
          \usebibmacro{choosepubstring}%
          \printorigdate}}}}%
  {}}%

\newbibmacro*{choosepubstring}{%
  \ifthenelse{\ifentrytype{video}\OR%
    \ifentrytype{music}}%
  {\bibstring{origreleaseyear}}%
  {\bibstring{origpubyearalt}}}%

\renewbibmacro*{date}{% New for 0.9
  \iftoggle{cms@switchdates}%
  {\printorigdate}%
  {\printdate}}

\newbibmacro{cite:xref+date}{%
  \ifboolexpr{%
    togl {cms@omitxrefdate}%
    or
    togl {cms@bookcitexref}%
    or
    test {\iffieldundef{crossref}}%
    or
    test {\iffieldundef{maintitle}}%
    or
    ((
    test {\iffieldundef{year}}%
    or
    togl {cms@switchdates}%
    )
    and
    (test {\iffieldundef{origyear}}%
    or
    not togl {cms@switchdates}%
    ))
    or
    not test {\ifentryseen{\thefield{crossref}}}%
  }%
  {\ifboolexpr{%
      togl {cms@omitxrefdate}%
      or
      togl {cms@bookcitexref}%
      or
      test {\iffieldundef{xref}}%
      or
      test {\iffieldundef{maintitle}}%
      or
      ((
      test {\iffieldundef{year}}%
      or
      togl {cms@switchdates}%
      )
      and
      (test {\iffieldundef{origyear}}%
      or
      not togl {cms@switchdates}%
      ))
      or
      not test {\ifentryseen{\thefield{xref}}}%
    }%
    {}%
    {\printtext[parens]{\usebibmacro{date}}}}%
  {\printtext[parens]{\usebibmacro{date}}}}

\newbibmacro*{cmsorigdate}{% New for 0.9
  \iftoggle{cms@switchdates}%
  {\printdate}%
  {\printorigdate}}

\newbibmacro*{cmsyear}{%
  \iftoggle{cms@switchdates}%
  {\printorigdateextra}% \printfield{origyear}
  {\printdateextra}}% \printfield{year}

\newbibmacro*{number+or+month}{%
  \iffieldundef{number}%
  {\usebibmacro{date}}%
  {\iftoggle{cms@numbermonth}%
    {\usebibmacro{date}}%
    {\usebibmacro{cmsyear}}}}

\newcommand*{\cms@datelong}[1]{% Modified for 17th ed.
  \begingroup
  \protected\def\mkbibdatelong##1##2##3{%
    \iffieldundef{##3}%
    {}%
    {\iftoggle{cms@ukord}%
      {\mkbibordinal{\thefield{##3}}}%
      {\stripzeros{\thefield{##3}}}%
      \iffieldundef{##2}{}{\nobreakspace}}%
    \iffieldundef{##2}%
    {}%
    {\mkbibmonth{\thefield{##2}}%
      \iffieldundef{##1}{}{\space}}%
    \iffieldbibstring{##1}%
    {\bibstring{\thefield{##1}}}%
    {\cmsdateeraprintpre{##1}\stripzeros{\thefield{##1}}}}%
  \cms@mkbibrangetrunc{long}{#1}%
  \endgroup}%

\newrobustcmd*{\letterdatelong}{% For users: 17th ed.
  \ifboolexpr{%
    test {\ifdefstring{\blx@languagename}{american}}%
    or
    test {\ifdefstring{\blx@languagename}{english}}% i.e., no babel
  }%
  {\iftoggle{cms@switchdates}%
    {\cms@datelong{}}%
    {\cms@datelong{orig}}}%
  {\iftoggle{cms@switchdates}%
    {\printdate}%
    {\printorigdate}}}%

\newbibmacro*{cjournal+ser+vol+num}{%
  \usebibmacro{journal+sub}%
  \setunit*{\addspace}%
  \printlist[periodplace]{location}%
  \setunit*{\addspace}%
  \iffieldundef{series}%
    {}%
    {\newcunit%
      \printfield[jourser]{series}%
      \newcunit}%\setunit*{\addspace}?
  \printfield[jourvol]{volume}%
  \setunit{\addcomma\addspace}% need * here?
  \printfield[journum]{number}%
  \setunit{\addcomma\addspace}%
  \printfield{eid}%
  \newunit}%

\newbibmacro*{cperiodical+ser+vol+num}{% For periodical entries,
  \ifboolexpr{% article subtype
    not test {\iffieldundef{shorttitle}}%
    and
    ((
    test {\ifcitation}%
    and
    togl {cms@citejtabb}%
    )
    or
    (
    test {\ifbibliography}%
    and
    togl {cms@bibjtabb}%
    ))
  }%
  {\clearlist{location}\printtext[shorttitle]{%
      \printfield[tnoformat]{shorttitle}}}%
  {\printtext[title]{%
      \printfield[tnoformat]{title}%
      \setunit{\subtitlepunct}%
      \printfield[stnoformat]{subtitle}}}%
  \setunit*{\addspace}%
  \printlist[periodplace]{location}%
  \setunit*{\addspace}%
  \iffieldundef{series}%
    {}%
    {\newcunit%
      \printfield[jourser]{series}%
      \newcunit}%\setunit*{\addspace}?
  \printfield[jourvol]{volume}%
  \setunit{\addcomma\addspace}% need * here?
  \printfield[journum]{number}%
  \setunit{\addcomma\addspace}%
  \printfield{eid}%
  \newunit}

\newbibmacro*{journal+sub}{%
  \iffieldundef{journaltitle}%
    {}%
    {\ifboolexpr{%
        not test {\iffieldundef{shortjournal}}%
        and
        ((
        test {\ifcitation}%
        and
        togl {cms@citejtabb}%
        )
        or
        (
        test {\ifbibliography}%
        and
        togl {cms@bibjtabb}%
        ))
      }%
      {\clearlist{location}\printtext[shortjournal]{%
          \printfield[jtsnoformat]{shortjournal}}}%
      {\printtext[journaltitle]{%
          \printfield[jtnoformat]{journaltitle}%
          \setunit{\subtitlepunct}%
          \printfield[sjtnoformat]{journalsubtitle}}}}}%

\newbibmacro*{cite+doi+url}{% 16th ed.
  \iftoggle{cms@url@innotes}%
  {\ifboolexpr{% Fix printing of urldate when url=false
      togl {cms@url}%
      and
      not test {\iffieldundef{urlyear}}%
      }%
    {\printurldate}% Date fix
    {}%
    \newcunit\newblock
    \iftoggle{cms@doionly}%
    {\iffieldundef{doi}%
      {}%
      {\printfield{doi}%
        \clearfield{url}}}%
    {\ifboolexpr{%
        togl {cms@doi}%
        and
        not test {\iffieldundef{doi}}%
      }%
      {\printfield{doi}}%
      {}}%
    \newcunit\newblock
    \ifboolexpr{%
      togl {cms@eprint}%
      and
      not test {\iffieldundef{eprint}}%
    }%
    {\usebibmacro{eprint}}%
    {}%
    \newcunit\newblock
    \ifboolexpr{%
      togl {cms@url}%
      and
      not test {\iffieldundef{url}}%
    }%
    {\printfield{url}}%
    {}}%
  {}}%

\newbibmacro*{chap+pag}{%
  \printfield{chapter}%
  \setunit*{\addcomma\addspace}%
  \printfield{pages}}

\newbibmacro*{mag+news+date}{% 16th ed.
  \iftoggle{cms@fullnote}%
  {\usebibmacro{mag+date+issue}}%
  {\ifnameundef{author}%
    {\usebibmacro{date+issue}}%
    {\usebibmacro{mag+date+issue}}}}

\newbibmacro*{date+issue}{%
  \iffieldundef{issue}%
  {\iffieldundef{number}%
    {\usebibmacro{date}}%
    {\iftoggle{cms@numbermonth}% For exclusion of month
      {\usebibmacro{date}}%
      {\usebibmacro{cmsyear}}%
      \setunit{\addcomma\addspace}%
      \printfield[journum]{number}}}%
  {\printfield{issue}%
    \setunit{\addspace}%
    \usebibmacro{cmsyear}}}

\newbibmacro*{mag+date+issue}{%
  \usebibmacro{journal+sub}%
  \setunit*{\addspace}%
  \printlist[periodplace]{location}%
  \newcunit\newblock
  \printfield{usera}% For network ID and possible section of newspaper.
  \newcunit\newblock
  \usebibmacro{date+issue}}

\newbibmacro*{periodical+date+issue}{% For periodical type &
  \ifboolexpr{% magazine subtype
    not test {\iffieldundef{shorttitle}}%
    and
    ((
    test {\ifcitation}%
    and
    togl {cms@citejtabb}%
    )
    or
    (
    test {\ifbibliography}%
    and
    togl {cms@bibjtabb}%
    ))
  }%
  {\clearlist{location}\printtext[shorttitle]{%
      \printfield[tnoformat]{shorttitle}}}%
  {\printtext[title]{%
      \printfield[tnoformat]{title}%
      \setunit{\subtitlepunct}%
      \printfield[stnoformat]{subtitle}}}%
  \setunit*{\addspace}%
  \printlist[periodplace]{location}%
  \newcunit\newblock
  \printfield{usera}% For network ID and possible section of newspaper.
  \newcunit\newblock
  \usebibmacro{date+issue}}

\newbibmacro*{cmtitle+mstitle+vol+part+title+stitle}{%
  \iffieldundef{maintitle}%
  {}%
  {\ifthenelse{\iffieldundef{volume}\AND\iffieldundef{part}}%
    {\iffieldundef{title}%
      {\usebibmacro{cms-in:}}%
      {\bibstring{in}\setunit{\addspace}}%
      \printtext[maintitle]{%
        \printfield[mtnoformat]{maintitle}%
        \setunit{\subtitlepunct}%
        \printfield[smtnoformat]{mainsubtitle}}%
      \setunit{\ctitleaddonpunct}%
      \printfield{maintitleaddon}}%
    {\toggletrue{cms@usedvol}%
      \printfield{volume}%
      \printfield{part}%
      \setunit{\addspace}%
      \bibstring{ofseries}%
      \setunit{\addspace}%
      \printtext[maintitle]{%
        \printfield[mtnoformat]{maintitle}%
        \setunit{\subtitlepunct}%
        \printfield[smtnoformat]{mainsubtitle}}%
      \setunit{\ctitleaddonpunct}%
      \printfield{maintitleaddon}}}}

\newbibmacro*{cmtitle+mstitle+vol+part+btitle+bstitle}{%
  \usebibmacro{btitle+bstitle}%
  \iffieldundef{maintitle}%
  {}%
  {\ifthenelse{\(\iffieldundef{volume}\AND\iffieldundef{part}\)\OR%
      \(\iffieldundef{booktitle}\AND\NOT\ifentrytype{bookinbook}\)}%
    {\iffieldundef{booktitle}% Fix for origpublin ???
      {\usebibmacro{cms-in:}}%
      {\bibstring{in}\setunit{\addspace}}%
      \printtext[maintitle]{%
        \printfield[mtnoformat]{maintitle}%
        \setunit{\subtitlepunct}%
        \printfield[smtnoformat]{mainsubtitle}}%
      \setunit{\ctitleaddonpunct}%
      \printfield{maintitleaddon}%
      \toggletrue{cms@vol}}% InIn fix
    {\toggletrue{cms@usedvol}%
      \printfield{volume}%
      \printfield{part}%
      \setunit{\addspace}%
      \bibstring{ofseries}%
      \setunit{\addspace}%
      \printtext[maintitle]{%
        \printfield[mtnoformat]{maintitle}%
        \setunit{\subtitlepunct}%
        \printfield[smtnoformat]{mainsubtitle}}%
      \setunit{\ctitleaddonpunct}%
      \printfield{maintitleaddon}}}}

\newbibmacro*{backref+check}{%
  \ifbibliography%
  {\backtrackerfalse}%
  {}}%

\newbibmacro*{cite:postnote}{%
  \iftoggle{cms@loccit}%
  {}%
  {\usebibmacro{postnote}}}

\newbibmacro*{semel:postnote}{% Fix to print postnote only once
  \printfield{postnote}% Old form broke \ifloccit
  \global\let\cms@pnsaved\abx@field@postnote%
  \global\let\abx@field@postnote\undefined%
  \AtNextCitekey{\ifciteibid{}{\global\let\cms@pnsaved\undefined}}}%

\renewbibmacro*{postnote}{%
  \iftoggle{cms@fullnote}%
  {\global\togglefalse{cms@shortnote}%
    \global\togglefalse{cms@fullnote}}%
  {\iftoggle{cms@printshhand}%
    {\iffieldundef{postnote}%
      {\iffieldundef{shorthand}%
        {\global\togglefalse{cms@printshhand}%
          \global\togglefalse{cms@shortnote}%
          \global\togglefalse{cms@fullnote}}%
        {\setunit{\shorthandpunct}%
          \usebibmacro{cms:shorthandintro}%
          \global\togglefalse{cms@printshhand}%
          \global\togglefalse{cms@shortnote}%
          \global\togglefalse{cms@fullnote}}}%
      {\iffieldundef{shorthand}%
        {\postnotewrapper%delim%
          \usebibmacro{semel:postnote}%
          \global\togglefalse{cms@printshhand}%
          \global\togglefalse{cms@shortnote}%
          \global\togglefalse{cms@fullnote}}%
        {\postnotewrapper%delim%
          \usebibmacro{semel:postnote}%
          \setunit{\shorthandpunct}%
          \usebibmacro{cms:shorthandintro}%
          \global\togglefalse{cms@printshhand}%
          \global\togglefalse{cms@shortnote}%
          \global\togglefalse{cms@fullnote}}}}%
    {\iffieldundef{postnote}%
      {\global\togglefalse{cms@shortnote}%
        \global\togglefalse{cms@fullnote}}%
      {\postnotewrapper%delim%
        \usebibmacro{semel:postnote}%
        \global\togglefalse{cms@shortnote}%
        \global\togglefalse{cms@fullnote}}}}}%

\newbibmacro*{fullpostnote}{%
  \iffieldundef{postnote}%
  {\iffieldundef{chapter}%
    {\iffieldundef{pages}%
      {}%
      {\postnotedelim%
        \printfield{pages}}}%
    {\postnotedelim%
      \printfield{chapter}}}%
  {\postnotewrapper%delim% Don't need \ifbibliography test w/ following
    \usebibmacro{semel:postnote}}}

\newbibmacro*{juridpostnote}{%
  \iftoggle{cms@fullnote}%
  {\iffieldundef{issue}%
    {\iffieldundef{shortjournal}%
      {\setunit{\addcomma\addspace}}%
      {\ifthenelse{\iffieldundef{part}\AND\iffieldundef{chapter}}%
        {\setunit{\addspace}}%
        {\ifpunctmark{*}{\setunit{\addspace}}{\newcunit}}}%
      \printfield{pages}%
      \iffieldundef{postnote}%
      {}%
      {\ifthenelse{\ifentrytype{legislation}\OR\ifentrytype{legal}}%
        {\newcunit}%
        {\setunit*{\addcomma\addspace}}%
        \usebibmacro{semel:postnote}}}%
    {\iffieldundef{postnote}%
      {\iffieldundef{pages}%
        {}%
        {\newcunit%
          \printfield{pages}}}%
      {\newcunit%
        \usebibmacro{semel:postnote}}}}%
  {\iffieldundef{issue}%
    {\iffieldundef{postnote}%
      {\iffieldundef{pages}%
        {}%
        {\iffieldundef{shortjournal}%
          {\setunit{\addcomma\addspace}}%
          {\ifthenelse{\iffieldundef{part}\AND\iffieldundef{chapter}}%
            {\setunit{\addspace}}%
            {\ifpunctmark{*}{\setunit{\addspace}}{\newcunit}}}%
          \printfield{pages}}}%
      {\iffieldundef{shortjournal}%
        {\setunit{\addcomma\addspace}}%
        {\ifthenelse{\iffieldundef{part}\AND\iffieldundef{chapter}}%
          {\setunit{\addspace}}%
          {\ifpunctmark{*}{\setunit{\addspace}}{\newcunit}}}%
        \usebibmacro{semel:postnote}}}% See below for alternate test here
    {\iffieldundef{postnote}%
      {\iffieldundef{pages}%
        {}%
        {\newcunit%
          \printfield{pages}}}%
      {\newcunit%
        \usebibmacro{semel:postnote}}}%
    \global\togglefalse{cms@fullnote}%
    \global\togglefalse{cms@shortnote}}}%

\newbibmacro*{volfullpostnote}{%
  \iftoggle{cms@postvol}%
  {\ifboolexpr{(
      test {\iffieldundef{volume}}%
      and
      test {\iffieldundef{part}}%
      )
      or
      togl {cms@usedvol}%
    }%
    {\usebibmacro{fullpostnote}}%
    {\iffieldundef{postnote}%
      {\iffieldundef{chapter}%
        {\iffieldundef{pages}%
          {\newcunit\printfield{volume}%
            \printfield{part}}%
          {\iffieldundef{part}%
            {\ifthenelse{\iffieldnums{pages}\AND%
                \iffieldundef{bookpagination}\AND\iffieldnums{volume}}%
              {\newcunit\printfield[default]{volume}%
                \postvolpunct%
                \printfield{pages}}%
              {\newcunit\printfield{volume}%
                \addcomma\addspace%
                \printfield{pages}}}%
            {\newcunit\printfield{volume}%
              \printfield{part}%
              \addcomma\addspace%
              \printfield{pages}}}}%
        {\newcunit\printfield{volume}%
          \printfield{part}%
          \newcunit
          \printfield{chapter}}}%
      {\iffieldundef{part}%
        {\ifthenelse{\iffieldnums{postnote}\AND%
            \iffieldundef{pagination}\AND\iffieldnums{volume}}%
          {\newcunit\printfield[default]{volume}%
            \postvolpunct%
            \usebibmacro{semel:postnote}}%
          {\newcunit\printfield{volume}%
            \addcomma\addspace%
            \usebibmacro{semel:postnote}}}%
        {\newcunit\printfield{volume}%
          \printfield{part}%
          \addcomma\addspace%
          \usebibmacro{semel:postnote}}}}}%
  {\usebibmacro{fullpostnote}}%
  \global\togglefalse{cms@usedvol}}%

\newbibmacro*{volume+or+volumes}{% Volume fix (modified)
  \ifboolexpr{ (
    test {\iffieldundef{maintitle}}%
    or
    togl {cms@vol}%
    )
    and
    not togl {cms@postvol}%
    and
    not togl {cms@usedvol}%
  }%
  {\global\togglefalse{cms@vol}%
    \ifthenelse{\iffieldundef{volume}\AND\iffieldundef{part}}%
    {\printfield{volumes}}%
    {\printfield{volume}%
      \printfield{part}}}%
  {\ifboolexpr{%
      togl {cms@hidevolumes}%
      and
      (
      not test {\iffieldundef{volume}}%
      or
      not test {\iffieldundef{part}}%
      or
      togl {cms@usedvol}%
      )
    }%
    {\global\togglefalse{cms@vol}}%
    {\global\togglefalse{cms@vol}%
      \printfield{volumes}}}}

\newbibmacro*{crossref:volume+postnote}{%
  \ifcsdef{cbx@incollpgn}%
  {\restorefield{pagination}{\cbx@incollpgn}}%
  {}%
  \ifcsdef{cbx@incollbkpgn}%
  {\restorefield{bookpagination}{\cbx@incollbkpgn}}%
  {}%
  \iffieldundef{volume}% Volume fix (unfinished)
  {\ifcsdef{cbx@incollvol}%
    {\restorefield{volume}{\cbx@incollvol}%
      \ifcsdef{cbx@incollpart}{\restorefield{part}{\cbx@incollpart}}{}%
      \iffieldundef{postnote}%
      {\ifcsdef{cbx@incollpages}%
        {\restorefield{pages}{\cbx@incollpages}%
          \usebibmacro{pages+cref+print}}%
        {\iffieldundef{pages}%
          {\newcunit\printfield{volume}\printfield{part}}%
          {\usebibmacro{pages+cref+print}}}}%
      {\usebibmacro{postnote+cref+print}}}%
    {\iffieldundef{part}%
      {\ifcsdef{cbx@incollpart}%
        {\restorefield{part}{\cbx@incollpart}%
          \iffieldundef{postnote}%
          {\ifcsdef{cbx@incollpages}%
            {\restorefield{pages}{\cbx@incollpages}%
              \usebibmacro{pages+cref+print}}%
            {\iffieldundef{pages}%
              {\newcunit\printfield{volume}\printfield{part}}%
              {\usebibmacro{pages+cref+print}}}}%
          {\usebibmacro{postnote+cref+print}}}%
        {\ifcsdef{cbx@incollpages}%
          {\restorefield{pages}{\cbx@incollpages}%
            \usebibmacro{fullpostnote}}%
          {\usebibmacro{fullpostnote}}}}%
      {\iffieldundef{postnote}%
        {\ifcsdef{cbx@incollpages}%
          {\restorefield{pages}{\cbx@incollpages}%
            \usebibmacro{pages+cref+print}}%
          {\iffieldundef{pages}%
            {\newcunit\printfield{volume}\printfield{part}}%
            {\usebibmacro{pages+cref+print}}}}%
        {\usebibmacro{postnote+cref+print}}}}}%
  {\iffieldundef{part}%
    {\ifcsdef{cbx@incollpart}%
      {\restorefield{part}{\cbx@incollpart}}%
      {}}%
    {}%
    \iffieldundef{maintitle}% More elaborate test ???
    {\iffieldundef{postnote}%
      {\ifcsdef{cbx@incollpages}%
        {\restorefield{pages}{\cbx@incollpages}%
          \usebibmacro{pages+cref+print}}%
        {\iffieldundef{pages}%
          {\newcunit\printfield{volume}\printfield{part}}%
          {\usebibmacro{pages+cref+print}}}}%
      {\usebibmacro{postnote+cref+print}}}%
    {\ifboolexpr{%
        test {\ifcsdef{cbx@incollvol}}%
        and
        (
        not test {\iffieldequalcs{volume}{cbx@incollvol}}%
        or
        togl {cms@xrefvol}% Necessary ???
        )
      }%
      {\restorefield{volume}{\cbx@incollvol}%
        \iffieldundef{part}%
        {\ifcsdef{cbx@incollpart}{\restorefield{part}{\cbx@incollpart}}{}}%
        {\ifboolexpr{%
            test {\ifcsdef{cbx@incollpart}}%
            and
            (
            not test {\iffieldequalcs{part}{cbx@incollpart}}%
            or
            togl {cms@xrefpart}%
            )
          }%
          {\clearfield{part}\restorefield{part}{\cbx@incollpart}}%
          {\clearfield{part}}}%
        \iffieldundef{postnote}%
        {\ifcsdef{cbx@incollpages}%
          {\restorefield{pages}{\cbx@incollpages}%
            \usebibmacro{pages+cref+print}}%
          {\iffieldundef{pages}%
            {\newcunit\printfield{volume}\printfield{part}}%
            {\usebibmacro{pages+cref+print}}}}%
        {\usebibmacro{postnote+cref+print}}}%
      {\ifboolexpr{%
          test {\ifcsdef{cbx@incollpart}}%
          and
          (
          not test {\iffieldequalcs{part}{cbx@incollpart}}%
          or
          togl {cms@xrefpart}%
          )
        }%
        {\iffieldundef{postnote}%
          {\ifcsdef{cbx@incollpages}%
            {\restorefield{pages}{\cbx@incollpages}%
              \printfield{part}\newcunit\printfield{pages}}%
            {\iffieldundef{pages}%
              {\printfield{part}}%
              {\printfield{part}\newcunit\printfield{pages}}}}%
          {\printfield{part}\newcunit\usebibmacro{semel:postnote}}}%
        {\ifcsdef{cbx@incollpages}%
          {\restorefield{pages}{\cbx@incollpages}%
            \usebibmacro{fullpostnote}}%
          {\usebibmacro{fullpostnote}}}}}}}%

\newbibmacro*{pages+cref+print}{% Reusable chunk for above
  \iffieldundef{part}%
  {\ifthenelse{\iffieldnums{pages}\AND%
      \iffieldundef{bookpagination}\AND\iffieldnums{volume}}%
    {\newcunit\printfield[default]{volume}%
      \postvolpunct%
      \printfield{pages}}%
    {\newcunit\printfield{volume}%
      \addcomma\addspace%
      \printfield{pages}}}%
  {\newcunit\printfield{volume}%
    \printfield{part}%
    \addcomma\addspace%
    \printfield{pages}}}

\newbibmacro*{postnote+cref+print}{% Reusable chunk for above
  \iffieldundef{part}%
  {\ifthenelse{\iffieldnums{postnote}\AND%
      \iffieldundef{pagination}\AND\iffieldnums{volume}}%
    {\newcunit\printfield[default]{volume}%
      \postvolpunct%
      \usebibmacro{semel:postnote}}%
    {\newcunit\printfield{volume}%
      \addcomma\addspace%
      \usebibmacro{semel:postnote}}}%
  {\newcunit\printfield{volume}%
    \printfield{part}%
    \addcomma\addspace%
    \usebibmacro{semel:postnote}}}

\newbibmacro*{inreffullpostnote}{%
  \global\togglefalse{cms@usedvol}%
  \iffieldundef{postnote}%
  {\iffieldundef{chapter}%
    {\iffieldundef{pages}%
      {\newcunit%\addcomma\addspace% Change to axe spurious comma
        \printlist[][-\value{listtotal}]{lista}}%
      {\postnotedelim%
        \printfield{pages}}}%
    {\postnotedelim%
      \printfield{chapter}}}%
  {\postnotewrapper%delim%
    \usebibmacro{semel:postnote}}}

\newbibmacro*{xrefprenote}{%
  \ifboolexpr{% Kludgy fix for spurious idem
    test {\ifdefvoid{\blx@idemtracker}}%
    or
    test {\ifbibliography}%
  }%
  {}{\blx@idemtracker}%
  \iffieldundef{volume}{}{\savefield{volume}{\cbx@incollvol}}%
  \iffieldundef{pages}{}{\savefield{pages}{\cbx@incollpages}}%
  \iffieldundef{part}{}{\savefield{part}{\cbx@incollpart}}%
  \iffieldundef{pagination}{}{\savefield{pagination}{\cbx@incollpgn}}%
  \iffieldundef{bookpagination}{}{\savefield{bookpagination}%
    {\cbx@incollbkpgn}}% The next line saves the child's backrefs
  \iflistundef{pageref}{}{\savelist{pageref}{\cbx@incollpgref}}}%

\newbibmacro*{xrefpostnote}{%
  \iftoggle{cms@xrefurl}%
  {\ifbibliography%
    {\usebibmacro{bib+doi+url}}%
    {\usebibmacro{cite+doi+url}}}%
  {}%
  \ifcsdef{cbx@incollpgref}% Here we print and clear the child's
  {\restorelist{pageref}{\cbx@incollpgref}% backrefs
  \newunit%
  \usebibmacro{pageref}%
  \global\let\cbx@incollpgref\undefined}%
  {}%
  \togglefalse{cms@xrefvol}%
  \togglefalse{cms@xrefpart}%
  \global\togglefalse{cms@usedvol}%
  \global\let\cbx@incollvol\undefined% Volume fix
  \global\let\cbx@incollpages\undefined%
  \global\let\cbx@incollpart\undefined%
  \global\let\cbx@incollpgn\undefined%
  \global\let\cbx@incollbkpgn\undefined}%

\newbibmacro*{hlpunct}{%
  \iftoggle{cms@headlessnote}%
  {\iftoggle{cms@origpublished}{\setunit{\addspace}}{}}%
  {\newcunit\newblock}}

\newbibmacro*{journalprenote}{%
  \iffieldundef{prenote}%
  {\bibsentence}%
  {\usebibmacro{prenote}}}

\newbibmacro*{choose+surname}{%
  \ifboolexpr{%
    test {\ifciteseen}%
    and
    not togl {cms@noneshort}%
    }%
  {}%
  {\printnames{labelname}\savefield{fullhash}{\bbx@lasthash}%
    \ifthenelse{\iffieldequalstr{labelnamesource}{shortauthor}\OR%
      \iffieldequalstr{labelnamesource}{author}}%
    {\clearname{author}}%
    {\iffieldequalstr{labelnamesource}{shorteditor}%
      {\ifnameundef{namea}%
        {\newcunit\usebibmacro{editstrg}}%
        {\newcunit\usebibmacro{parteditstrg}}}%%
      {\iffieldequalstr{labelnamesource}{editor}%
        {\newcunit\usebibmacro{editstrg}}%
        {\iffieldequalstr{labelnamesource}{translator}%
          {\newcunit\usebibmacro{transstrg}}%
          {\iffieldequalstr{labelnamesource}{namea}%
            {\newcunit\usebibmacro{parteditstrg}}%
            {\iffieldequalstr{labelnamesource}{nameb}%
              {\newcunit\usebibmacro{parttransstrg}}%
              {\iffieldequalstr{labelnamesource}{namec}%
                {\newcunit\usebibmacro{compilestrg}}%
                {}}}}}}}}}%

\newbibmacro*{clear+labelname}{%
  \iffieldequalstr{labelnamesource}{shortauthor}%
  {\clearname{author}\clearname{shortauthor}}%
  {\iffieldequalstr{labelnamesource}{shorteditor}%
    {\ifnameundef{namea}%
      {\clearname{editor}\clearname{shorteditor}}%
      {\clearname{namea}\clearname{shorteditor}}}%
    {\clearname{\thefield{labelnamesource}}}}}

\@ifpackagelater{biblatex}{2012/11/20}% for biblatex 2.4
{\DeclareLabelname{\field{shortauthor} \field{author}%
    \field{shorteditor} \field{namea} \field{editor}%
    \field{nameb} \field{translator} \field{namec}}}%
{\DeclareLabelname{shortauthor,author,shorteditor,namea,%
    editor,nameb,translator,namec}}

\DeclareLabeltitle[legislation]{%
  \field{shorttitle}%
  \field{titleaddon}%
  \field{title}}%

\DeclareDataInheritance{collection}{suppcollection}{%
  \inherit{title}{title}
  \inherit{subtitle}{subtitle}
  \inherit{titleaddon}{titleaddon}}

\DeclareDataInheritance{mvbook}{incollection}{%
  \inherit{title}{maintitle}
  \inherit{subtitle}{mainsubtitle}
  \inherit{titleaddon}{maintitleaddon}
  \noinherit{shorttitle}
  \noinherit{sorttitle}
  \noinherit{indextitle}
  \noinherit{indexsorttitle}
}

\DeclareDataInheritance{book,collection}{letter}{%
  \inherit{title}{booktitle}
  \inherit{subtitle}{booksubtitle}
  \inherit{titleaddon}{booktitleaddon}
  \noinherit{shorttitle}
  \noinherit{sorttitle}
  \noinherit{indextitle}
  \noinherit{indexsorttitle}
}

\DeclareDataInheritance{book}{incollection}{%
  \inherit{title}{booktitle}
  \inherit{subtitle}{booksubtitle}
  \inherit{titleaddon}{booktitleaddon}
  \noinherit{shorttitle}
  \noinherit{sorttitle}
  \noinherit{indextitle}
  \noinherit{indexsorttitle}
}

\DeclareDataInheritance{mvbook,mvcollection}{letter}{%
  \inherit{title}{maintitle}
  \inherit{subtitle}{mainsubtitle}
  \inherit{titleaddon}{maintitleaddon}
  \noinherit{shorttitle}
  \noinherit{sorttitle}
  \noinherit{indextitle}
  \noinherit{indexsorttitle}
}

\DeclareDataInheritance{*}{*}{%
  \noinherit{namea}
  \noinherit{nameb}
  \noinherit{nameatype}
  \noinherit{sortyear}
  \noinherit{sortname}
  \noinherit{sorttitle}
  \noinherit{urlyear}
  \noinherit{urlmonth}
  \noinherit{urlday}
  \noinherit{urlyeardivision}
  \noinherit{urlhour}
  \noinherit{urlminute}
  \noinherit{doi}
  \noinherit{eprint}
  \noinherit{eprinttype}
  \noinherit{url}}

\DeclareDataInheritance{mvbook,mvcollection,mvproceedings,mvreference}%
{*}{% ???
  \noinherit{year}
  \noinherit{month}
  \noinherit{day}
  \noinherit{yeardivision}
  \noinherit{endyear}
  \noinherit{endmonth}
  \noinherit{endday}
  \noinherit{endyeardivision}
  \noinherit{origyear}
  \noinherit{origmonth}
  \noinherit{origday}
  \noinherit{origyeardivision}
  \noinherit{origendyear}
  \noinherit{origendmonth}
  \noinherit{origendday}
  \noinherit{origendyeardivision}}

\DeclareSortingTemplate{cms}{% Updated for biblatex > 3.7
  \sort{
    \field{presort}
  }
  \sort[final]{
    \field{sortkey}
  }
  \sort{
    \field{sortname}
    \field{author}
    \field{namea}
    \field{editor}
    \field{nameb}
    \field{translator}
    \field{namec}
    \field{sorttitle}
    \field{journaltitle}
    \field{organization}
    \field{title}
  }
  \sort{
    \field{sorttitle}
    \field{title}
  }
  \sort{
    \field{sortyear}
    \field{year}
  }
  \sort{
    \field[padside=left,padwidth=4,padchar=0]{volume}
    \literal{0000}
  }
}

\DeclareSortExclusion{misc,online}{organization}
\DeclareSortExclusion{inreference,mvreference,reference}{%
  author,editor,namea,nameb,namec,translator}

\DeclareSortingTemplate{shortjournal}{%
  \sort{
    \field{shortjournal}
  }
}

\newbibmacro*{compilestrg}{%
  \ifthenelse{\value{namec}>1\OR\ifandothers{namec}}%
  {\bibstring{compilers}}%
  {\bibstring{compiler}}%
  \clearname{namec}}%

\newbibmacro*{transstrg}{%
  \ifthenelse{\value{translator}>1\OR\ifandothers{translator}}%
    {\ifnamesequal{translator}{namec}%
      {\bibstring{transcompilers}%
        \clearname{namec}}%
      {\bibstring{translators}}}%
    {\ifnamesequal{translator}{namec}%
      {\bibstring{transcompiler}%
        \clearname{namec}}%
      {\bibstring{translator}}}%
    \clearname{translator}}%

\newbibmacro*{parttransstrg}{%
  \ifthenelse{\value{nameb}>1\OR\ifandothers{nameb}}%
    {\ifnamesequal{nameb}{namec}%
      {\bibstring{transcompilers}%
        \clearname{namec}}%
      {\bibstring{translators}}}%
    {\ifnamesequal{nameb}{namec}%
      {\bibstring{transcompiler}%
        \clearname{namec}}%
      {\bibstring{translator}}}%
    \clearname{nameb}}%

\newbibmacro*{editstrg}{% Test added for 0.9
  \ifthenelse{\iffieldundef{editortype}\OR%
    \iffieldequalstr{editortype}{editor}}%
  {\ifthenelse{\value{editor}>1\OR\ifandothers{editor}}%
    {\ifthenelse{\ifnamesequal{editor}{translator}\AND%
        \ifnamesequal{editor}{namec}}%
      {\bibstring{editortranscompilers}%
        \clearname{translator}%
        \clearname{namec}}%
      {\ifnamesequal{editor}{namec}%
        {\bibstring{editorcompilers}%
          \clearname{namec}}%
        {\ifnamesequal{editor}{translator}%
          {\bibstring{editortranslators}%
            \clearname{translator}}%
          {\bibstring{editors}}}}}%
    {\ifthenelse{\ifnamesequal{editor}{translator}\AND%
        \ifnamesequal{editor}{namec}}%
      {\bibstring{editortranscompiler}%
        \clearname{translator}%
        \clearname{namec}}%
      {\ifnamesequal{editor}{namec}%
        {\bibstring{editorcompiler}%
          \clearname{namec}}%
        {\ifnamesequal{editor}{translator}%
          {\bibstring{editortranslator}%
            \clearname{translator}}%
          {\bibstring{editor}}}}}}%
  {\ifthenelse{\value{editor}>1\OR\ifandothers{editor}}%
    {\bibstring{\thefield{editortype}s}}%
    {\bibstring{\thefield{editortype}}}}%
  \clearname{editor}}%

\newbibmacro*{parteditstrg}{%
  \ifthenelse{\iffieldundef{nameatype}\OR%
    \iffieldequalstr{nameatype}{editor}}%
  {\ifthenelse{\value{namea}>1\OR\ifandothers{namea}}%
    {\ifthenelse{\ifnamesequal{namea}{nameb}\AND%
        \ifnamesequal{namea}{namec}}%
      {\bibstring{editortranscompilers}%
        \clearname{nameb}%
        \clearname{namec}}%
      {\ifnamesequal{namea}{namec}%
        {\bibstring{editorcompilers}%
          \clearname{namec}}%
        {\ifnamesequal{namea}{nameb}%
          {\bibstring{editortranslators}%
            \clearname{nameb}}%
          {\bibstring{editors}}}}}%
    {\ifthenelse{\ifnamesequal{namea}{nameb}\AND%
        \ifnamesequal{namea}{namec}}%
      {\bibstring{editortranscompiler}%
        \clearname{nameb}%
        \clearname{namec}}%
      {\ifnamesequal{namea}{namec}%
        {\bibstring{editorcompiler}%
          \clearname{namec}}%
        {\ifnamesequal{namea}{nameb}%
          {\bibstring{editortranslator}%
            \clearname{nameb}}%
          {\bibstring{editor}}}}}}%
  {\ifthenelse{\value{namea}>1\OR\ifandothers{namea}}%
    {\bibstring{\thefield{nameatype}s}}%
    {\bibstring{\thefield{nameatype}}}}%
  \clearname{namea}}%

\newbibmacro*{clearorigin}{%
  \toggletrue{cms@origcite}%
  \ifthenelse{\ifuseauthor\AND\NOT\ifnameundef{author}}%
  {\ifnameundef{bookauthor}%
    {\savefield{fullhash}{\bbx@lasthash}%
      \clearname{author}}%
    {\ifnamesequal{author}{bookauthor}%
      {\clearname{bookauthor}%
        \savefield{fullhash}{\bbx@lasthash}%
        \clearname{author}}%
      {\savefield{fullhash}{\bbx@lasthash}%
        \clearname{author}}}}%
  {\clearname{author}}}%

\newbibmacro*{clearpublin}{%
  \toggletrue{cms@origcite}%
  \ifthenelse{\ifuseauthor\AND\NOT\ifnameundef{author}}%
  {\ifnameundef{bookauthor}%
    {\savefield{fullhash}{\bbx@lasthash}%
      \clearname{author}}%
    {\ifnamesequal{author}{bookauthor}%
      {\clearname{bookauthor}%
        \savefield{fullhash}{\bbx@lasthash}%
        \clearname{author}}%
      {\savefield{fullhash}{\bbx@lasthash}%
        \clearname{author}}}}%
  {\clearname{author}}%
  \ifthenelse{\ifentrytype{collection}\OR\ifentrytype{proceedings}\OR%
    \ifentrytype{mvcollection}\OR\ifentrytype{mvproceedings}}%
  {}%
  {\clearname{namea}%
    \clearname{nameb}}%
  \clearfield{nameaddon}%
  \ifthenelse{\(\ifentrytype{periodical}\OR\ifentrytype{mvbook}\OR%
    \ifentrytype{mvcollection}\OR\ifentrytype{mvproceedings}\OR%
    \ifentrytype{mvreference}\OR\ifentrytype{collection}\OR%
    \ifentrytype{proceedings}\OR\ifentrytype{reference}\OR%
    \ifentrytype{suppbook}\OR\ifentrytype{suppcollection}\)\OR%
    \(\(\ifentrytype{audio}\OR\ifentrytype{music}\OR%
    \ifentrytype{video}\)\AND\iffieldundef{booktitle}\)}%
  {}%
  {\clearfield{title}%
    \clearfield{subtitle}%
    \clearfield{titleaddon}%
    \clearfield{usere}%
    \clearlist{language}%
    \ifentrytype{music}%
    {\clearfield{note}\clearfield{howpublished}\clearfield{eventyear}%
      \clearfield{eventmonth}}%
    {}}%
  \ifentrytype{letter}%
  {\iftoggle{cms@switchdates}%
    {\clearfield{year}\clearfield{month}\clearfield{yeardivision}}%
    {\clearfield{origyear}\clearfield{origmonth}\clearfield{origyeardivision}}%
    \clearfield{origlocation}}%
  {}%
  \clearfield{reprinttitle}%
}

%%%% Related macros from biblatex.def %%%%

\renewcommand*{\begrelateddelim}{%
  \ifcitation{\newcunitpunct}%
  {\ifboolexpr{%
      togl {cms@fullnote}%
      or
      togl {cms@shortnote}%
    }%
    {\newcunitpunct}%
    {\newunitpunct}}}%

\newcommand*{\begrelateddelimreviewof}{%
  \ifcitation{\newcunitpunct}%
  {\ifboolexpr{%
      togl {cms@fullnote}%
      or
      togl {cms@shortnote}%
    }%
    {\newcunitpunct}%
    {\newunitpunct}}}

\newbibmacro*{related:reviewof}[1]{%
  \iftoggle{cms@shortnote}%
  {\entrydata{#1}{%
      \ifboolexpr{%
        togl {cms@allshort}%
        or
        test {\ifbibliography}%
      }%
      {\printtext[bibhyperref]{%
          \printfield[citetitle]{labeltitle}}}%
      {\printtext[cmshyperlink]{%
          \printfield[citetitle]{labeltitle}}}}}%
  {\entrydata*{#1}{%
      \let\newunit\newcunit%
      % \bibstring{reviewof}%
      \iffieldundef{title}%
      {}%
      {\printtext[title]{%
          \printfield[tnoformat]{title}%
          \setunit{\subtitlepunct}%
          \printfield[stnoformat]{subtitle}}}%
      \newcunit%
      \ifnameundef{author}%
      {\newcunit%
        \ifbibliography%
        {\usebibmacro{byeditor+others}}%
        {\usebibmacro{cbyeditor+others}}}%
      {\bibstring{by}\addspace%
        \printnames[byauthor]{author}%
        \ifbibliography%
        {\newcunit\usebibmacro{byeditor+others}}%
        {\newcunit\usebibmacro{cbyeditor+others}}}%
      \setunit{\ctitleaddonpunct}%
      \printfield{titleaddon}}}}%

\renewbibmacro*{related:origpubas}[1]{%
  \entrydata*{#1}{%
    \usebibmacro{at+every+item}%
    \usebibmacro{cite:origfull}}}%

\renewbibmacro*{related:reprintfrom}[1]{%
  \entrydata*{#1}{%
    \usebibmacro{at+every+item}%
    \nopunct% ???
    \usebibmacro{cite:origpubl}}}%

\renewbibmacro*{related:bytranslator}[1]{%
  \entrydata{#1}{%
    \usebibmacro{at+every+item}%
    \renewbibmacro*{name:hook}[1]{%
      \ifnumequal{\value{listcount}}{1}%
      {\begingroup
        \mkrelatedstringtext{%
          \lbx@initnamehook{##1}}%
        \endgroup}%
      {}}%
    \printnames[bytranslator]{translator}%
    \setunit*{\addspace\bibstring[\mkrelatedstringtext]{astitle}\addspace}%
    \clearname{translator}%
    \usebibmacro{cite:origfull}}}%

\renewbibmacro*{related:default}[1]{%
  \entrydata*{#1}{%
    \usedriver%
      {\ifnameundef{savedauthor}%
         {\ifnameundef{savededitor}%
            {}%
            {\ifnamesequal{editor}{savededitor}%
               {\clearname{editor}}%
               {}}}%
         {\ifnamesequal{author}{savedauthor}%
            {\clearname{author}}%
            {}}%
          \usebibmacro{at+every+item}%
          \renewbibmacro*{related:init}{}%
          \DeclareNameAlias{sortname}{default}%
          \renewbibmacro*{pageref}{}%
          \toggletrue{cms@fullnote}%
          \togglefalse{cms@shortnote}}%
      {cite:\thefield{entrytype}}}}%

\renewbibmacro*{related:multivolume}[1]{%
  \entrydata*{#1}{%
    \usebibmacro{at+every+item}%
    \ifthenelse{\iffieldundef{volume}\AND\iffieldundef{part}}%
    {}%
    {\printtext{%
        \printfield{volume}%
        \printfield{part}}%
      \setunit{\addcolon\addspace}}%
    \usebibmacro{ctitle+stitle}%
    \ifboolexpr{%
      test {\ifnamesequal{author}{savedauthor}}%
      or
      test {\ifnameundef{author}}%
    }%
    {}%
    {\usebibmacro{bytypestrg}{author}{author}%
      \setunit{\addspace}%
      \printnames[byauthor]{author}%
      \newcunit\newblock}%
    \ifboolexpr{%
      test {\ifnamesequal{namea}{savednamea}}%
      or
      test {\ifnameundef{namea}}%
    }%
    {\ifboolexpr{%
        test {\ifnamesequal{editor}{savededitor}}%
        or
        test {\ifnameundef{editor}}%
      }%
      {\ifboolexpr{%
          test {\ifnamesequal{nameb}{savednameb}}%
          or
          test {\ifnameundef{nameb}}%
        }%
        {}%
        {\bibstring{cbytranslator}\addspace%
          \printnames[bytranslator]{nameb}\newcunit}}%
      {\usebibmacro{cbyeditor+others}%
        \newcunit}}%
    {\usebibmacro{cpart+editor+translator}%
      \newcunit}%
    \usebibmacro{date}}}%

\renewbibmacro*{related:origpubin}[1]{%
  \entrydata*{#1}{%
    \usebibmacro{at+every+item}%
    \usebibmacro{cmsyear}%
    \ifboolexpr{%
      test {\iflistsequal{publisher}{savedpublisher}}%
      or
      test {\iflistundef{publisher}}%
    }%
    {}%
    {\midsentence% Why is this kludge necessary?
      \setunit{\addspace\bibstring[\mkrelatedstringtext]{bypublisher}\space}%
      \printlist{publisher}%
      \setunit{\addcomma\space}%
      \iflistsequal{location}{savedlocation}%
      {}%
      {\printlist{location}}}}}

\DeclareFieldFormat{title:hook}{%
  \begingroup
  \mkrelatedstringtext{%
    \lbx@inittitlehook{#1}}%
  \endgroup
  \mkbibemph{#1}}

\DeclareFieldFormat{ititle:hook}{%
  \begingroup
  \mkrelatedstringtext{%
    \lbx@inittitlehook{#1}}%
  \endgroup
  \iffieldundef{issuesubtitle}%
  {\mkbibquote{#1}}%
  {\mkbibquote{#1\subtitlepunct\printfield{issuesubtitle}}}}

\DeclareFieldFormat{chapter:hook}{%
  \begingroup
  \mkrelatedstringtext{%
    \lbx@inittitlehook{\bibxstring{chapter}}%
    \bibstring{chapter}~#1\addspace\bibstring{in}}%
  \endgroup}%

\DeclareFieldFormat{avchapter:hook}{%
  \begingroup
  \mkrelatedstringtext{%
    \lbx@inittitlehook{\bibxstring{chapter}}%
    \bibstring{chapter}~#1}
  \endgroup}%

\DeclareFieldFormat{sitnoformat}{#1}
\DeclareFieldFormat{sjtnoformat}{#1}
\DeclareFieldFormat{stnoformat}{#1}
\DeclareFieldFormat{sbtnoformat}{#1}
\DeclareFieldFormat{smtnoformat}{#1}
\DeclareFieldFormat{itnoformat}{#1}
\DeclareFieldFormat{jtnoformat}{#1}
\DeclareFieldFormat{jtsnoformat}{#1}
\DeclareFieldFormat{tnoformat}{#1}
\DeclareFieldFormat{btnoformat}{#1}
\DeclareFieldFormat{mtnoformat}{#1}

% \providetoggle{cms@otherlang}

% \apptocmd\blx@opt@autolang@other%
% {\toggletrue{cms@otherlang}}%
% {\blx@info@noline{Patching 'autolang=other' option}}
% {\PackageWarningNoLine{biblatex-chicago}%
%   {Upgrading biblatex to >v2.7a recommended,\MessageBreak
%     especially if you are using the "related"\MessageBreak
%     functionality}}

\newbibmacro*{cms:titlehook}{% Needed for full drivers in reprintfrom
  \ifthenelse{\iffieldundef{chapter}\OR\NOT\(\ifentrytype{audio}\OR%
    \ifentrytype{inbook}\OR\ifentrytype{incollection}\OR%
    \ifentrytype{inproceedings}\OR\ifentrytype{letter}\OR%
    \ifentrytype{music}\OR\ifentrytype{video}\)}%
  {\iffieldundef{issuetitle}%
    {\iffieldundef{title}%
      {\iffieldundef{booktitle}%
        {\iffieldundef{maintitle}%
          {\iffieldundef{journaltitle}%
            {}%
            {\DeclareFieldAlias{jtnoformat}{title:hook}%
              \DeclareFieldAlias{sjtnoformat}{title}%
              \DeclareFieldAlias{journaltitle}{default}%
              \DeclareFieldAlias{shortjournal}{series}%
              \DeclareFieldAlias{jtsnoformat}{title:hook}}}%
          {\DeclareFieldAlias{mtnoformat}{title:hook}%
            \DeclareFieldAlias{smtnoformat}{title}%
            \DeclareFieldAlias{maintitle}{default}}}%
        {\DeclareFieldAlias{btnoformat}{title:hook}%
          \DeclareFieldAlias{sbtnoformat}{title}%
          \DeclareFieldAlias{booktitle}{default}}}%
      {\DeclareFieldAlias{tnoformat}{title:hook}%
        \DeclareFieldAlias{stnoformat}{citetitle}%
        \DeclareFieldAlias[video]{title}{default}%
        \DeclareFieldAlias[audio]{title}{default}%
        \DeclareFieldAlias[music]{title}{default}%
        \DeclareFieldAlias{title}{default}%
        \DeclareFieldAlias[periodical]{shorttitle}{series}}}%
    {\DeclareFieldAlias{itnoformat}{ititle:hook}%
      \DeclareFieldAlias{issuetitle}{default}}}%
  {\ifthenelse{\ifentrytype{audio}\OR\ifentrytype{music}\OR%
      \ifentrytype{video}}%
    {\iffieldundef{title}%
      {\DeclareFieldAlias{chapter}{avchapter:hook}}%
      {\DeclareFieldAlias{tnoformat}{title:hook}%
        \DeclareFieldAlias{stnoformat}{citetitle}%
        \DeclareFieldAlias[video]{title}{default}%
        \DeclareFieldAlias[audio]{title}{default}%
        \DeclareFieldAlias[music]{title}{default}}}%
    {\DeclareFieldAlias{chapter}{chapter:hook}}}}%

\newbibmacro*{cite:origfull}{%
  \printtext[cmshypertarget]{%
    \usedriver
    {\DeclareNameAlias{sortname}{default}\clearfield{postnote}%
      \clearname{author}\clearfield{userf}\clearfield{shorthand}%
      \toggletrue{cms@fullnote}\toggletrue{cms@headlessnote}%
      \frenchspacing}%
    {cite:\thefield{entrytype}}}}

\newbibmacro*{cite:origpubl}{%
  \printtext[cmshypertarget]{%
    \usedriver
    {\DeclareNameAlias{sortname}{default}\clearfield{postnote}%
      \usebibmacro{clearpublin}\clearfield{shorthand}%
      \toggletrue{cms@fullnote}\toggletrue{cms@headlessnote}%
      \toggletrue{cms@origpublished}\frenchspacing%
      \usebibmacro{cms:titlehook}}%
    {cite:\thefield{entrytype}}}}

\newbibmacro*{at+every+item}{%
  \iffieldequalstr{pubstate}{reprint}%
  {\toggletrue{cms@reprint}}%
  {\togglefalse{cms@reprint}}%
  \ifboolexpr{%
    test {\iffieldundef{origyear}}%
    or
    test {\iffieldundef{year}}%
    or
    not test {\iffieldint{year}}%
    or
    togl {cms@switchdates}%
  }%
  {}%
  {\ifboolexpr{% Needed for open-ended ranges
      test {\iffieldundef{endyear}}%
      or
      not test {\iffieldnum{endyear}}%
    }%
    {\ifthenelse{\thefield{origyear}>\thefield{year}}%
      {\toggletrue{cms@switchdates}}%
      {}}%
    {\ifthenelse{\thefield{origyear}>\thefield{endyear}}%
      {\toggletrue{cms@switchdates}}%
      {}}}}%

\endinput
