2

Goal: I want to cite using the biblatex-apa style, with the extension that (ibid.) is added, when the same source is quoted multiple times.


Note: This is a follow-up question to Getting ibid for numeric citations from biblatex

Also, I know that ibidem is explicitly not a part of the APA citation style and by some is even considered as old-fashioned or outdated, but every institution has their own requirements, and since biblatex-apa meets my requirements in every other aspect, I would like to add this little extension to it instead of using another style.

In the thread linked above, they do something similar with the numeric-comp-style, but copying the suggested code to my preamble does not help in my case. Since I am not experienced enough for this kind of "LaTeX Hacking", how would an equivalent code as the one suggested in the thread above look for biblatex-apa?

My minimal working document looks like this:

\documentclass[12pt,a4paper]{scrartcl}

% Bibliography entries:
\begin{filecontents}{literatur.bib}
@booklet{one,
author = {Author One},
title = {Testtitle 1.},
date = {2018},
}
@booklet{two,
author = {Author Two},
title = {Testtitle 2.},
date = {2018},
}
\end{filecontents}

\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc} 
\usepackage{lmodern}
\usepackage[ngerman]{babel}   
\usepackage[backend=biber,style=apa,sortlocale=de_DE]{biblatex}
\DeclareLanguageMapping{ngerman}{ngerman-apa}
\addbibresource{literatur.bib}

\begin{document}
First citation should be normal \parencite{one}, second time with ibidem 
\parencite{one}, but after a second citation \parencite{two} it should 
appear as usual \parencite{one}.    
\printbibliography
\end{document}

This is what I get:

Document without ibidem

...and this is what i would like to get:

Document with ibidem

Note that (ebd.) ist just the german version of (ibid.).

Thank you a lot for any help and suggestions. :)

2

This needs a bit of code, but the actual changes to the original defintions from .cbx are not that big.

First we need to define a macro to print the ibidem, cite:ibid (copied from authoryear-ibid.cbx). We also request the ibidem tracker with ibidtracker=constrict and page tracking (to avoid a "ibid." at the beginning of a page) with pagetracker.

Then it is just a matter of inserting the conditional \ifthenelse{\ifciteibid\AND\NOT\iffirstonpage} in the right place in the cite and textcite macros and adding a call to cite:ibid.

\documentclass[12pt,a4paper]{scrartcl}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{lmodern}
\usepackage[ngerman]{babel}
\usepackage[backend=biber, style=apa, pagetracker, ibidtracker=constrict]{biblatex}
\addbibresource{biblatex-examples.bib}

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

\newbibmacro*{cite:ibid}{%
  \printtext[bibhyperref]{\bibstring[\mkibid]{ibidem}}}

\renewbibmacro*{cite}{%
  \ifthenelse{\ifciteibid\AND\NOT\iffirstonpage}
    {\usebibmacro{cite:ibid}}
    {\iffieldequals{fullhash}{\cbx@lasthash}
     % Multiple cites in one command
      {\setunit{\compcitedelim}%
       \usebibmacro{cite:plabelyear+extradate}}%
     % Single cite
      {\ifthenelse{\ifnameundef{labelname}\OR\iffieldequalstr{entrytype}{patent}}
     % No author/editor
         {\usebibmacro{cite:noname}%
          \setunit{\printdelim{nameyeardelim}}%
          \usebibmacro{cite:plabelyear+extradate}%
          \savefield{fullhash}{\cbx@lasthash}}
     % Normal cite
        {\ifnameundef{shortauthor}
           {\printnames[labelname][-\value{listtotal}]{labelname}}%
           {\cbx@apa@ifnamesaved
             {\printnames{shortauthor}}
             {\printnames[labelname][-\value{listtotal}]{author}%
              \addspace\printnames[sabrackets]{shortauthor}}}%
         \setunit{\printdelim{nameyeardelim}}%
         \usebibmacro{cite:plabelyear+extradate}%
         \savefield{fullhash}{\cbx@lasthash}}}}%
   \setunit{\multicitedelim}}

\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}%
      \ifthenelse{\ifnameundef{labelname}\OR\iffieldequalstr{entrytype}{patent}}
    % No author/editor or patent
       {\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][-\value{listtotal}]{labelname}}
    % Cite using short author
         {\cbx@apa@ifnamesaved
           {\printnames{shortauthor}}
           {\printnames[labelname][-\value{listtotal}]{author}}}%
    % 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
        \ifthenelse{\ifciteibid\AND\NOT\iffirstonpage}
          {\usebibmacro{cite:ibid}}
          {\usebibmacro{cite:plabelyear+extradate}}%
    % Save name hash for checks later
        \savefield{fullhash}{\cbx@lasthash}}}}
\makeatother

\begin{document}
First citation should be normal \parencite{sigfridsson}, second time with ibidem
\parencite{sigfridsson}, but after a second citation \parencite{geer} it should
appear as usual \parencite{sigfridsson}.

\cite{nussbaum}

First citation should be normal \textcite{sigfridsson}, second time with ibidem
\textcite{sigfridsson}, but after a second citation \textcite{geer} it should
appear as usual \textcite{sigfridsson}.

\printbibliography
\end{document}

First citation should be normal (Sigfridsson & Ryde, 1998), second time with ibidem (ebd.), but after a second citation (Geer, 1985) it should appear as usual (Sigfridsson & Ryde, 1998). Nussbaum, 1978 First citation should be normal Sigfridsson und Ryde (1998), second time with ibidem Sigfridsson und Ryde (ebd.), but after a second citation Geer (1985) it should appear as usual Sigfridsson und Ryde (1998).

  • Very nice - thank you for the great explanation and answer! :) – Pidrittel Sep 4 '18 at 12:29
  • 1
    @Pidrittel If the chapter starts on a new page the page tracking already takes care of that. You can use the command \citereset to reset ibidem tracking (and a bit more if applicable) at a certain point. With the citereset option (p. 52 of the documentation) you can automatically execute that command at the beginning of a \chapter or \section. The biblatex-apa feature to show the full list of authors at a first citation can be reset with \citeresetapa, but there is no option to have this applied automatically at each section. – moewe Sep 4 '18 at 12:40
  • 1
    @Pidrittel The code I posted should not influence whether or not "ibid" tracking is turned on or off in floats. (i) Can you reproduce a similar problem when you just use the standard style style=authoryear-ibid instead of the complicated code? (ii) Please ask a new question with a short example document (MWE/MWEB) that shows the issue, include a screenshot of the output you get and explain what you would like to see instead. If you can reproduce the issue with style=authoryear-icomp use that. – moewe Sep 12 '18 at 14:49
  • 1
    @Pidrittel Good. I remember that when you first commented a few days ago I threw together a very small MWE and there the tracking was disabled in floats, so I'm not just asking to annoy you, this really should not happen and an MWE is the only way to find out if there is a bug and how to fix it. – moewe Sep 12 '18 at 14:56
  • 1
    @Pidrittel Ah yes, just today I learned that H makes float environments behave very weirdly. If you need a deeper investigation into this issue, please open a new question. – moewe Sep 22 '18 at 20:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.