0

So, I am using biblatex for referencing in APA-style.

An issue I'm having with narrative citations is that I often have to use possessive of the author(s). (E.g. Einstein and Bohr's (1920) report blabla...)

The \textcite[pre][post]{bibid} command, which is used for narrative citations, only takes two input strings, a before and after the citation:

pre, Einstein and Bohr (1920, post)

What I want is to redefine the command to include a third optional argument for inserting text behind the authors:

\textcite[pre][mid][post]{bibid}

I am thinking something along the line of:

\renewcommand{\textcite}[3][bibid]{#1, \citeauthor{bibid}#2 \citeyear[#3]{bibid}}

Resulting in

pre, Einstein and Bohrmid (1920, post)

So, how can I create such a command, and without loosing the auto-complete of the bibtex key? I still want to get a list of keys when I start typing the key in the command.

Since I use possessive far more often than the pre and post text, I want the command to take the mid insert as the only optional argument, without the pre and post arguments.

5
  • Could you explain why a solution like \citeauthor[pre][]{bibid}'s (\citeyear[post]{bibid}) is not sufficient? Mar 10, 2020 at 13:23
  • It just might be the simplest option, but I was hoping there could be a more concise way to do it. Especially if there are multiple literary sources cited, it could easily become a rather long chain of commands. Mar 10, 2020 at 13:45
  • Could you edit your question to display precisely the output you would like to achieve? Maybe in the same fashion that shows the Okhee Lee et al. reference (which obviously is not what you want) Mar 10, 2020 at 17:05
  • Is this what you were looking for: Author name of \textcite as possessive?
    – Ross
    Mar 11, 2020 at 0:25
  • @FelixEmanuel Sorry, I wrote this in the last min before leaving work yesterday. I've elaborated on and specified more what I am trying to achieve. Mar 11, 2020 at 11:25

1 Answer 1

2

Citation commands defined with biblatex's \DeclareCiteCommand always have the same argument structure

\<commandname>[<prenote>][<postnote>]{<keys>}

The argument structure is pretty much hard-coded into \DeclareCiteCommand and can not be changed.

Of course you don't have to use <prenote> and <postnote> as pre- and post-notes, so you could convert for example the <prenote> argument to a genitive marker (see below), but fundamentally, you can't change the argument structure.

There is one trick to work around this: In Optional argument within another optional argument in biblatex \cite Audrey shows a way to add a virtual argument in round brackets to the postnote argument.

We could do the same for the prenote. So that you can then use \textcite as

\textcite[(mid)pre][post]{key}
\textcite[(mid)][post]{key}
\textcite[pre][post]{key}
\textcite[post]{key}
\textcite{key}

The redefinition of the textcite bibmacro is the original (cf. apa.cbx, ll. 215-261) with the two lines

        \csuse{cbx@prenote@genitivemarker}%
        \global\undef\cbx@prenote@genitivemarker

added to print the genitive marker in the right place. We also add our new bibmacro split:prenote to \DeclareCiteCommand{\textcite}.

\documentclass{article}
\usepackage[style=apa]{biblatex}
\usepackage[colorlinks]{hyperref}

\makeatletter
\newrobustcmd*{\splitroundarg}[3]{\splitroundarg@i{#1}{#2}#3&}

\def\splitroundarg@i#1#2{%
  \@ifnextchar(%)
    {\splitroundarg@ii{#1}{#2}}
    {\splitroundarg@ii{#1}{#2}()}}

\def\splitroundarg@ii#1#2(#3)#4&{%
  #1{#3}%
  #2{#4}}

\newrobustcmd*{\mkgenitivemarker}[1]{%
  \ifblank{#1}
    {\undef\cbx@prenote@genitivemarker}
    {\def\cbx@prenote@genitivemarker{#1}}}

\newrobustcmd*{\mkrealprenote}[1]{%
  \ifblank{#1}
    {\undef\abx@field@prenote}
    {\def\abx@field@prenote{#1}}}

\newcommand*{\splitgenmarkerrealprenote}{\splitroundarg{\mkgenitivemarker}{\mkrealprenote}}

\newbibmacro*{split:prenote}{%
  \iffieldundef{prenote}
    {}
    {\usefield{\splitgenmarkerrealprenote}{prenote}}}

\DeclareCiteCommand{\textcite}
  {\usebibmacro{cite:init}%
   \usebibmacro{split:prenote}%
   \usebibmacro{prenote}%
   \toggletrue{apa:intcite}}
  {\usebibmacro{citeindex}%
   \usebibmacro{textcite}%
   \usebibmacro{cite:post}%
   \togglefalse{apa:intcite}}
  {}
  {\usebibmacro{textcite:postnote}}


\renewbibmacro*{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}}}}%
        \csuse{cbx@prenote@genitivemarker}%
        \global\undef\cbx@prenote@genitivemarker
  % 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}}}}
\makeatother

\addbibresource{biblatex-examples.bib}
\begin{document}

\textcite[('s)][]{sigfridsson}

\textcite[('s)][380]{sigfridsson}

\textcite[cf.][380]{sigfridsson}

\textcite[380]{sigfridsson}

\textcite{sigfridsson}

\printbibliography
\end{document}

Sigfridsson and Ryde’s (1998)//Sigfridsson and Ryde’s (1998, p. 380)//cf., Sigfridsson and Ryde (1998, p. 380)//Sigfridsson and Ryde (1998, p. 380)//Sigfridsson and Ryde (1998)


As mentioned above you could also repurpose the prenote argument for \textcite. But then you can't use normal prenotes any more.

\documentclass{article}
\usepackage[style=apa]{biblatex}
\usepackage[colorlinks]{hyperref}

\DeclareCiteCommand{\textcite}
  {\usebibmacro{cite:init}%
   \toggletrue{apa:intcite}}
  {\usebibmacro{citeindex}%
   \usebibmacro{textcite}%
   \usebibmacro{cite:post}%
   \togglefalse{apa:intcite}}
  {}
  {\usebibmacro{textcite:postnote}}

\makeatletter
\renewbibmacro*{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}}}}%
        \ifnumequal{\value{citecount}}{1}
          {\thefield{prenote}}
          {}%
  % 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}}}}
\makeatother

\addbibresource{biblatex-examples.bib}
\begin{document}
\textcite['s][]{sigfridsson}

\textcite['s][380]{sigfridsson}

\textcite[380]{sigfridsson}

\textcite{sigfridsson}

\printbibliography
\end{document}

Or you repurpose the postnote

\documentclass{article}
\usepackage[style=apa]{biblatex}
\usepackage[colorlinks]{hyperref}

\DeclareCiteCommand{\textcite}
  {\usebibmacro{cite:init}%
   \usebibmacro{prenote}%
   \toggletrue{apa:intcite}}
  {\usebibmacro{citeindex}%
   \usebibmacro{textcite}%
   \usebibmacro{cite:post}%
   \togglefalse{apa:intcite}}
  {}
  {\ifbool{cbx:parens}
    {\bibcloseparen\global\boolfalse{cbx:parens}}
    {}}

\makeatletter
\renewbibmacro*{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}}}}%
        \ifnumequal{\value{citecount}}{1}
          {\thefield{postnote}}
          {}%
  % 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}}}}
\makeatother

\addbibresource{biblatex-examples.bib}
\begin{document}
\textcite['s]{sigfridsson}

\textcite[cf.]['s]{sigfridsson}

\textcite{sigfridsson}

\printbibliography
\end{document}

All of the above solutions should retain your editor's capabilities for cite key autocompletion. Autocompletion is not a LaTeX feature, it is a feature of your editor. Usually editors have hard-coded lists of citation commands, where they will offer cite key autocompletion.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .