%% Copyright 2020 Philip Kime %% %% This work may be distributed and/or modified under the %% conditions of the LaTeX Project Public License, either version 1.3 %% of this license or (at your option) any later version. %% The latest version of this license is in %% http://www.latex-project.org/lppl.txt %% and version 1.3 or later is part of all distributions of LaTeX %% version 2005/12/01 or later. %% %% This work has the LPPL maintenance status `maintained'. %% %% The Current Maintainer of this work is Philip Kime. \ProvidesFile{apa.cbx}[2020/04/06\space v9.8\space APA biblatex citation style] \RequireBiber[3] %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % (APA 8.19) labelyear postfix is not emphasised or italic % Dashes between labelyear and non-numeric year (or pseudo-year) \newcommand{\apashortdash}{-} \DeclareFieldFormat{extradate}{\iffieldnums{labelyear}{\mknumalph{#1}}{\apashortdash\mknumalph{#1}}} % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % (APA 8.11) requires comma separator between authors and years \DeclareDelimFormat{nameyeardelim}{\addcomma\space} \DeclareDelimFormat[textcite]{nameyeardelim}{\addcomma\space} % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % (APA 8.17) No comma before "et al" if there is only one name % preceding it \DeclareDelimFormat{andothersdelim}{\ifnum\value{listcount}>2 \finalandcomma\fi\addspace} % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % (APA 8.17) ampersand separator in parenthetical cites \newtoggle{apa:inpcite} \DeclareDelimFormat[parencite]{finalnamedelim} {\ifnum\value{liststop}>2 \finalandcomma\fi\addspace\&\space} \DeclareCiteCommand{\parencite}[\mkbibparens] {\usebibmacro{cite:init}% \usebibmacro{prenote}% \toggletrue{apa:inpcite}} {\usebibmacro{citeindex}% \usebibmacro{cite}% \usebibmacro{cite:post}} {} {\usebibmacro{postnote}% \togglefalse{apa:inpcite}} \DeclareCiteCommand*{\parencite}[\mkbibparens] {\usebibmacro{cite:init}% \usebibmacro{prenote}% \toggletrue{apa:inpcite}} {\usebibmacro{citeindex}% \usebibmacro{citeyear}% \usebibmacro{cite:post}% \togglefalse{apa:inpcite}} {} {\usebibmacro{postnote}} % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % (APA 8.10) Suffices are not shown in citations % (APA 8.17) 3+ authors have "et al." % (APA 8.20) Initials only for primary author and only when not unique across all *primary* authors \newbibmacro*{labelname:doname}[8]{% \ifboolexpr{test {\ifnumcomp{\value{listcount}}{>}{1}} or test {\ifuniqueprimaryauthor}} {\setcounter{uniquename}{0}} {}% \ifcase\value{uniquename}% \ifuseprefix {\usebibmacro{name:family}{#1}{#3}{#5}{\relax}} {\usebibmacro{name:family}{#1}{#3}{\relax}{\relax}}% \or \ifuseprefix {\usebibmacro{name:given-family}{#1}{#4}{#5}{\relax}} {\usebibmacro{name:given-family}{#1}{#4}{\relax}{\relax}}% \or \ifuseprefix {\usebibmacro{name:given-family}{#1}{#3}{#5}{\relax}} {\usebibmacro{name:given-family}{#1}{#3}{\relax}{\relax}}% \fi \usebibmacro{name:andothers}} \DeclareNameFormat{labelname}{% \usebibmacro{labelname:doname}% {\namepartfamily}% {\namepartfamilyi}% {\namepartgiven}% {\namepartgiveni}% {\namepartprefix}% {\namepartprefixi}% {\namepartsuffix}% {\namepartsuffixi}} % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%% % (APA 8.21) Groups as names % SHORTAUTHOR brackets in parencites \DeclareNameFormat{sabrackets}{% \mkbibbrackets{% \usebibmacro{labelname:doname}% {\namepartfamily}% {\namepartfamilyi}% {\namepartgiven}% {\namepartgiveni}% {\namepartprefix}% {\namepartprefixi}% {\namepartsuffix}% {\namepartsuffixi}}} \DeclareFieldFormat{shorthand}{\ifciteseen {#1} {\mkbibbrackets{#1}}} % %%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % (APA 8.21) Deal with SHORTAUTHOR fields % (APA 8.12) Multiple same author cites in a compact citation call do not % need to be repeated but the full years must be repeated with % their extradate postfixes % (APA 8.15) Cite ORIGYEAR/YEAR if ORIGYEAR present % (APA 10.1:11) Reprints have original year in citation \def\citeresetapa{\global\let\cbx@apa@names\@empty} \citeresetapa \def\cbx@apa@ifnamesaved{% \xifinlist{\thefield{fullhash}}{\cbx@apa@names} {\@firstoftwo} {\@secondoftwo}} \newbibmacro*{cite:author}{% \iffieldequals{fullhash}{\cbx@lasthash} % Multiple cites in one command {\setunit{\compcitedelim}% \usebibmacro{cite:plabelyear+extradate}}% % Single cite {\ifnameundef{labelname} % No author/editor {\usebibmacro{cite:noname}% \savefield{fullhash}{\cbx@lasthash}} % Normal cite {\ifnameundef{shortauthor} {\printnames{labelname}}% {\cbx@apa@ifnamesaved {\printnames{shortauthor}} {\ifnameundef{groupauthor} {\printnames[labelname]{author}} {\printnames[labelname]{groupauthor}}% \addspace\printnames[sabrackets]{shortauthor}}}% \savefield{fullhash}{\cbx@lasthash}}}% \setunit{\multicitedelim}} % Using fullhash instead of namehash otherwise we may omit namelist for % lists which are equal only because of minnames truncation i.e: % % X and Y and Z (2009) % X and W and V (2010) % % which have the same namehash due to minnames visibility truncation to 1 % would be printed incorrectly as % \cite{one, two} -> X, Y & Z 2009, 2010 \newbibmacro*{cite}{% \iffieldequals{fullhash}{\cbx@lasthash} % Multiple cites in one command {\setunit{\compcitedelim}% \usebibmacro{cite:plabelyear+extradate}}% % Single cite {\ifnameundef{labelname} % No author/editor {\usebibmacro{cite:noname}% \setunit{\printdelim{nameyeardelim}}% \usebibmacro{cite:plabelyear+extradate}% \savefield{fullhash}{\cbx@lasthash}} % Normal cite {\ifnameundef{shortauthor} {\printnames{labelname}}% {\cbx@apa@ifnamesaved {\printnames{shortauthor}} {\ifnameundef{groupauthor} {\printnames[labelname]{author}} {\printnames[labelname]{groupauthor}}% \addspace\printnames[sabrackets]{shortauthor}}}% \setunit{\printdelim{nameyeardelim}}% \usebibmacro{cite:plabelyear+extradate}% \savefield{fullhash}{\cbx@lasthash}}}% \setunit{\multicitedelim}} \newbibmacro*{textcite}{% \iffieldequals{fullhash}{\cbx@lasthash} % Compact cite - more than one thing for same author {\setunit{\compcitedelim}% \usebibmacro{cite:plabelyear+extradate}} % New cite {% \ifbool{cbx:parens} {\bibcloseparen\global\boolfalse{cbx:parens}} {}% \setunit{\compcitedelim}% \ifnameundef{labelname} % No author/editor {\iffieldundef{shorthand}% % Cite using title {\usebibmacro{cite:noname}% \setunit{\ifbool{cbx:np}% {\printdelim{nameyeardelim}}% {\global\booltrue{cbx:parens}\addspace\bibopenparen}}% \usebibmacro{cite:plabelyear+extradate}} % Cite using shorthand {\usebibmacro{cite:shorthand}}} % Normal cite with author/editor % Normal full cite {\ifnameundef{shortauthor}% % Normal full cite {\printnames{labelname}} % Cite using short author {\cbx@apa@ifnamesaved {\printnames{shortauthor}} {\ifnameundef{groupauthor} {\printnames[labelname]{author}} {\printnames[labelname]{groupauthor}}}}% % Year \setunit{\ifbool{cbx:np} {\printdelim{nameyeardelim}} {\global\booltrue{cbx:parens}\addspace\bibopenparen}}% % Put the shortauthor inside the year brackets if necessary \ifnameundef{shortauthor} {} {\cbx@apa@ifnamesaved {} {\printnames{shortauthor}\setunit{\printdelim{nameyeardelim}}}}% % Actual year printing \usebibmacro{cite:plabelyear+extradate}% % Save name hash for checks later \savefield{fullhash}{\cbx@lasthash}}}} \newbibmacro*{cite:plabelyear+extradate}{% \iffieldundef{labelyear}{} {\printtext[bibhyperref]{% \clearfield{labelmonth}% don't want months in citations \clearfield{labelday}% don't want days in citations \clearfield{labelendmonth}% don't want months in citations \clearfield{labelendday}% don't want days in citations \iffieldsequal{labelyear}{labelendyear}% Don't want no-op year ranges {\clearfield{labelendyear}} {}% \iffieldundef{origyear} {} {\printorigdate% \setunit*{\addslash}}% \iffieldundef{related} {} {\iffieldequalstr{relatedtype}{reprintfrom} {\entrydata*{\thefield{related}}{\printlabeldateextra}% \setunit*{\addslash}} {}}% \printlabeldateextra}}} \newbibmacro*{cite:shorthand}{% \ifciteseen {\printfield{shorthand}} {\printnames{labelname}% \setunit{\printdelim{nameyeardelim}}% \printfield{title}\space\printfield{shorthand}}} % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % (APA 8.14) Fall back to title for citations without authors % (APA 11) Bizarre and special rules for legal information \DeclareFieldFormat{citetitle}{\mkbibquote{#1}} \DeclareFieldFormat[book,manual,report,preiodical,legmaterial,jurisdiction]{citetitle}{\mkbibemph{#1}} \DeclareFieldFormat[legislation,legadminmaterial,legal]{citetitle}{#1} \newbibmacro*{cite:noname}{% \iffieldundef{labeltitle} {\ifthenelse{\ifentrytype{legmaterial}\OR% \ifentrytype{legadminmaterial}} {\let\blx@tempa\bibcplstring% \textcite default \let\blx@tempb\bibcplstring% \textcite default \iftoggle{apa:inpcite} {\iffieldequalstr{type}{execorder}{\let\blx@tempb\bibcpsstring}{}% \iffieldequalstr{type}{resolution}{\let\blx@tempa\bibcpsstring}{}% \iffieldequalstr{type}{report}{\let\blx@tempa\bibcpsstring\let\blx@tempb\bibcpsstring}{}} {}% \iffieldundef{source}{}{\blx@tempa{\thefield{source}}}% \setunit{\addspace}% \iffieldundef{type}{}{\blx@tempb{\thefield{type}}}% \setunit{\addspace}% \printfield[legmaterialnum]{number}} {\ifentrytype{constitution}{\usebibmacro{cite:noname:const}}{}}} {\printfield[citetitle]{labeltitle}}} % CONSTITUTION entrytypes are messier \newbibmacro*{cite:noname:const}{% \iftoggle{apa:inpcite} {\bibcpsstring{\thefield{source}}% \setunit{\addspace}% \bibcpsstring{\thefield{type}}% \setunit{\addspace}% \iffieldundef{amendment}{}{\bibsstring{amendment}% \setunit{\addspace}% \printfield{amendment}% \setunit{\addcomma\addspace}% \ifkeyword{repealed} {\biblcsstring{repealed}% \setunit{\addspace}% \printeventdate} {}}% \setunit{\addspace}% \iffieldundef{article}{}{\bibsstring{article}\setunit{\addspace}\printfield{article}}% \setunit{\addcomma\addspace}\newblock \iffieldundef{section}{}{\bibsstring{section}\setunit{\addspace}\printfield{section}}% \setunit{\addcomma\addspace}\newblock \iffieldundef{part}{}{\bibsstring{paragraph}\setunit{\addspace}\printfield{part}}} {}% \iftoggle{apa:intcite} {\iffieldundef{amendment}{}{\bibcplstring{amendment}% \setunit{\addspace}% \printfield{amendment}% \setunit{\addspace}% \biblcsstring{tothe}}% \iffieldundef{article}{}{\bibcplstring{article}\setunit{\addspace}\printfield{article}}% \setunit{\addcomma\addspace}% \iffieldundef{part}{}{\biblstring{paragraph}% \setunit{\addspace}% \printfield{part}% \setunit{\addcomma\addspace}% \biblcsstring{ofthe}}% \setunit{\addcomma\addspace}% \iffieldundef{section}{}{\bibcplstring{section}% \setunit{\addspace}% \printfield{section}% \setunit{\addcomma\addspace}% \biblcsstring{ofthe}} \setunit{\addspace}% \bibcplstring{\thefield{source}}% \setunit{\addspace}% \bibcplstring{\thefield{type}}% \setunit{\addspace}% \ifkeyword{repealed} {\biblclstring{repealed}\setunit{\addspace}\printeventdate} {}} {}} % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % (APA 10.2:32) Raw field cite formats \DeclareFieldFormat{citefield}{% \ifcurrentfield{edition} {\ifinteger{#1} {\mkbibordedition{#1}~\bibstring{edition}} {#1\isdot}} {\ifcurrentfield{shorthand} {\mkbibemph{#1}} {#1}}} % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % (APA 8.11) No parens round year for cites when the cite is in % parentheses. Use new command \nptextcite for such cites. \DeclareDelimFormat[nptextcite]{finalnamedelim} {\ifnum\value{liststop}>2 \finalandcomma\fi\addspace\&\space} \DeclareMultiCiteCommand{\nptextcites}{\nptextcite}{\setunit{\multicitedelim}} \DeclareCiteCommand{\nptextcite} {\usebibmacro{cite:init}% \usebibmacro{prenote}} {\usebibmacro{citeindex}% \global\booltrue{cbx:np}% \usebibmacro{textcite}% \usebibmacro{cite:post}% \global\boolfalse{cbx:np}}% {} {\iffieldundef{postnote} {} {\printdelim{nameyeardelim}% \printfield{postnote}}} % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % No shorthand % \newbibmacro*{citeyear}{% \iffieldundef{labelyear} {\usebibmacro{cite:init}} {\iffieldequals{fullhash}{\cbx@lasthash} {\setunit{\compcitedelim}% \usebibmacro{cite:plabelyear+extradate}} {\usebibmacro{cite:plabelyear+extradate}% \savefield{fullhash}{\cbx@lasthash}}}% \setunit{\multicitedelim}} % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Fullcite should use "&" % Also need to reset the global booleans which are normally done at % every bib item but since these aren't bib items, they are not reset \DeclareDelimFormat[fullcite,fullcitebib]{finalnamedelim} {\ifnum\value{liststop}>2 \finalandcomma\fi\addspace\&\space} \DeclareCiteCommand{\fullcite} {\usebibmacro{prenote}} {\usedriver {\DeclareNameAlias{sortname}{default}% \global\boolfalse{bbx:in}% \global\let\blx@related@loop\@empty} {\thefield{entrytype}}% \usebibmacro{cite:post}} {\multicitedelim} {\usebibmacro{postnote}} \DeclareCiteCommand{\fullcitebib} {\list{} {\setlength{\leftmargin}{\bibhang}% \setlength{\itemindent}{-\leftmargin}% \setlength{\itemsep}{\bibitemsep}% \setlength{\parsep}{\bibparsep}}\item} {\usedriver {\DeclareNameAlias{sortname}{default}% \global\boolfalse{bbx:in}} {\thefield{entrytype}}% \finentry \usebibmacro{cite:post}} {\item} {\endlist} % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \newbool{cbx:parens} % boolean to say we're inside parens \newbool{cbx:np} % boolean to say we're using a non-parentheses text cite \newbibmacro*{textcite:postnote}{% \usebibmacro{postnote}% \ifbool{cbx:parens} {\bibcloseparen\global\boolfalse{cbx:parens}} {}} \newbibmacro*{cite:init}{% \global\boolfalse{cbx:parens}% \global\undef\cbx@lasthash} \newbibmacro*{cite:post}{% \xifinlist{\thefield{fullhash}}{\cbx@apa@names} {} {\listxadd{\cbx@apa@names}{\thefield{fullhash}}}} \newbibmacro*{cite:labelyear}{% \printfield{labelyear}} \newbibmacro*{cite:extradate}{% \printfield{extradate}} \newbibmacro*{cite:labelyear+extradate}{% \iffieldundef{labelyear} {} {\printfield{labelyear}% \printfield{extradate}}} \DeclareCiteCommand{\citeyear} {\boolfalse{citetracker}% \boolfalse{pagetracker}% \usebibmacro{prenote}} {\usebibmacro{cite:plabelyear+extradate}} {\multinamedelim} {\usebibmacro{postnote}} \DeclareCiteCommand{\cite} {\usebibmacro{cite:init}% \usebibmacro{prenote}} {\usebibmacro{citeindex}% \usebibmacro{cite}% \usebibmacro{cite:post}} {} {\usebibmacro{postnote}} \DeclareCiteCommand*{\cite} {\usebibmacro{cite:init}% \usebibmacro{prenote}} {\usebibmacro{citeindex}% \usebibmacro{citeyear}% \usebibmacro{cite:post}} {} {\usebibmacro{postnote}} \DeclareCiteCommand{\footcite}[\mkbibfootnote] {\bibsentence \usebibmacro{cite:init}% \usebibmacro{prenote}} {\usebibmacro{citeindex}% \usebibmacro{cite}% \usebibmacro{cite:post}} {} {\usebibmacro{postnote}} \DeclareMultiCiteCommand{\textcites}{\textcite}{\setunit{\compcitedelim}} \DeclareMultiCiteCommand{\cites}{\cite}{\setunit{\multicitedelim}} \DeclareMultiCiteCommand{\parencites}[\mkbibparens]{\parencite} {\setunit{\multicitedelim}} \DeclareMultiCiteCommand{\footcites}[\mkbibfootnote]{\footcite} {\setunit{\multicitedelim}} \DeclareMultiCiteCommand{\footcitetexts}[\mkbibfootnotetext] {\footcitetext}{\setunit{\multicitedelim}} \DeclareMultiCiteCommand{\smartcites}[\iffootnote\mkbibparens\mkbibfootnote] {\smartcite}{\setunit{\multicitedelim}} \newtoggle{apa:intcite} \DeclareCiteCommand{\textcite} {\usebibmacro{cite:init}% \usebibmacro{prenote}% \toggletrue{apa:intcite}} {\usebibmacro{citeindex}% \usebibmacro{textcite}% \usebibmacro{cite:post}% \togglefalse{apa:intcite}} {} {\usebibmacro{textcite:postnote}} \DeclareCiteCommand{\citeauthor} {\usebibmacro{cite:init}% \usebibmacro{prenote}} {\usebibmacro{citeindex}% \usebibmacro{cite:author}% \usebibmacro{cite:post}} {} {\usebibmacro{postnote}} \endinput