Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rework \textcite and \nptextcite #103

Merged
merged 4 commits into from
Apr 30, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Two-pass \textcite (#94)
  • Loading branch information
moewew committed Apr 29, 2020
commit 6dc4318933012cf1bc8499187e9cd45b369644a6
59 changes: 48 additions & 11 deletions tex/latex/biblatex-apa/cbx/apa.cbx
Original file line number Diff line number Diff line change
Expand Up @@ -212,19 +212,21 @@
\savefield{fullhash}{\cbx@lasthash}}}%
\setunit{\multicitedelim}}

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

\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
{\ifbool{cbx:parens}
{\bibcloseparen\global\boolfalse{cbx:parens}}
{}%
\setunit{\textcitedelim}%
\ifnameundef{labelname}
% No author/editor
{\iffieldundef{shorthand}%
% Cite using title
{\usebibmacro{cite:noname}%
Expand Down Expand Up @@ -254,11 +256,13 @@
{}
{\cbx@apa@ifnamesaved
{}
{\printnames{shortauthor}\setunit{\printdelim{nameyeardelim}}}}%
{\printnames{shortauthor}%
\setunit{\printdelim{nameyeardelim}}}}%
% Actual year printing
\usebibmacro{cite:plabelyear+extradate}%
% Save name hash for checks later
\savefield{fullhash}{\cbx@lasthash}}}}
\savefield{fullhash}{\cbx@lasthash}}%
\stepcounter{textcitecount}}}

\newbibmacro*{cite:plabelyear+extradate}{%
\iffieldundef{labelyear}{}
Expand Down Expand Up @@ -534,7 +538,6 @@
{}
{\usebibmacro{postnote}}

\DeclareMultiCiteCommand{\textcites}{\textcite}{\setunit{\compcitedelim}}
\DeclareMultiCiteCommand{\cites}{\cite}{\setunit{\multicitedelim}}
\DeclareMultiCiteCommand{\parencites}[\mkbibparens]{\parencite}
{\setunit{\multicitedelim}}
Expand All @@ -547,7 +550,7 @@

\newtoggle{apa:intcite}

\DeclareCiteCommand{\textcite}
\DeclareCiteCommand{\cbx@textcite}
{\usebibmacro{cite:init}%
\usebibmacro{prenote}%
\toggletrue{apa:intcite}}
Expand All @@ -558,6 +561,40 @@
{}
{\usebibmacro{textcite:postnote}}

\DeclareCiteCommand{\textcite}[\cbx@textcite@init\cbx@textcite]
{\gdef\cbx@savedkeys{}%
\citetrackerfalse%
\pagetrackerfalse%
\DeferNextCitekeyHook%
\usebibmacro{cite:init}}
{\ifthenelse{\iffirstcitekey\AND\value{multicitetotal}>0}
{\protected@xappto\cbx@savedcites{()(\thefield{multipostnote})}%
\global\clearfield{multipostnote}}
{}%
\xappto\cbx@savedkeys{\thefield{entrykey},}%
\iffieldequals{namehash}{\cbx@lasthash}
{}
{\stepcounter{textcitetotal}%
\savefield{namehash}{\cbx@lasthash}}}
{}
{\protected@xappto\cbx@savedcites{%
[\thefield{prenote}][\thefield{postnote}]{\cbx@savedkeys}}}

% textcite has nested \DeclareCiteCommand definitions for textcite and we want to use
% the normal textcite context
\DeclareDelimcontextAlias{cbx@textcite}{textcite}

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

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

\let\cbx@textcites@init\cbx@textcite@init
\pretocmd{\cbx@textcites@init}{\UseNextMultiCiteHook}{}{}

\DeclareCiteCommand{\citeauthor}
{\usebibmacro{cite:init}%
\usebibmacro{prenote}}
Expand Down