TransWikia.com

Getting ibid without page numbers for apa-style citations from biblatex

TeX - LaTeX Asked by Björn Engel on January 8, 2021

As Pidrittel asked already here I need ibid in apa-style. The answer by moewe is already close to what I need. Just one additional aspect is missing. When an ibid is used and the citation before quotes the same page, the page shall not be printed.

One Answer

The answer to Getting ibid for apa-style citations from biblatex was based on an older version of biblatex-apa.

This is the solution from there updated to a current version of biblatex-apa (2020/05/30 v9.13) plus the code for the ibidpage option, which can be taken directly from authoryear-ibid.cbx (basically all the code that involves loccit below is code for that option).

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

makeatletter
newbool{cbx:loccit}

DeclareBibliographyOption[boolean]{ibidpage}[true]{%
  ifstrequal{#1}{true}
    {ExecuteBibliographyOptions{loccittracker=constrict}}
    {ExecuteBibliographyOptions{loccittracker=false}}}

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

newbibmacro*{cite:ibid}{%
  printtext[bibhyperref]{bibstring[mkibid]{ibidem}}%
  ifloccit
    {globalbooltrue{cbx:loccit}}
    {}}


renewbibmacro*{cite}{%
  globalboolfalse{cbx:loccit}%
  ifthenelse{ifciteibidANDNOTiffirstonpage}
    {usebibmacro{cite:ibid}}
    {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}}%
             addspaceprintnames[sabrackets]{shortauthor}}}%
          setunit{printdelim{nameyeardelim}}%
         usebibmacro{cite:plabelyear+extradate}%
         savefield{fullhash}{cbx@lasthash}}}%
      setunit{multicitedelim}}}

renewbibmacro*{textcite}{%
  globalboolfalse{cbx:loccit}%
  iffieldequals{fullhash}{cbx@lasthash}
% Compact cite - more than one thing for same author
    {setunit{compcitedelim}%
     usebibmacro{cite:plabelyear+extradate}}
% New cite
    {ifbool{cbx:parens}
       {bibcloseparenglobalboolfalse{cbx:parens}}
       {}%
     setunit{textcitedelim}%
     ifnameundef{labelname}
     % No author/editor
       {iffieldundef{shorthand}%
    % Cite using title
         {usebibmacro{cite:noname}%
          setunit{globalbooltrue{cbx:parens}addspacebibopenparen}%
          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{globalbooltrue{cbx:parens}addspacebibopenparen}%
  % Put the shortauthor inside the year brackets if necessary
        ifnameundef{shortauthor}
         {}
         {cbx@apa@ifnamesaved
           {}
           {printnames{shortauthor}%
            setunit{printdelim{nameyeardelim}}}}%
  % Print prenote (belongs to first cite)
        ifnumequal{value{citecount}}{1}
           {usebibmacro{prenote}}
           {}%
  % Actual year printing
        ifthenelse{ifciteibidANDNOTiffirstonpage}
          {usebibmacro{cite:ibid}}
          {usebibmacro{cite:plabelyear+extradate}}%
  % Save name hash for checks later
        savefield{fullhash}{cbx@lasthash}}%
    stepcounter{textcitecount}}}

letbibmacro{orig:postnote}{postnote}

renewbibmacro*{postnote}{%
  ifbool{cbx:loccit}
    {}
    {usebibmacro{orig:postnote}}}
makeatother

ExecuteBibliographyOptions{ibidpage=true}

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}

autocite[3]{sigfridsson}

autocite[4]{sigfridsson}

autocite[4]{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}

(Sigfridsson & Ryde, 1998, S. 3)//(ebd., S. 4)//(ebd.)

Correct answer by moewe on January 8, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP