从 biblatex 获取没有页码的 apa 风格引文 ibid

从 biblatex 获取没有页码的 apa 风格引文 ibid

皮德里特尔已经在这里问过了我需要 apa 格式的 ibid。moewe 的回答已经接近我需要的了。只缺少一个额外的方面。当使用 ibid 并且之前的引用引用同一页时,该页不应打印。

答案1

答案从 biblatex 获取 apa 风格引文的 ibid基于 的旧版本biblatex-apa

这是从那里更新到当前版本biblatex-apa(2020/05/30 v9.13)的解决方案加上该选项的代码ibidpage,可以直接从中获取authoryear-ibid.cbx(基本上下面涉及的所有代码loccit都是该选项的代码)。

\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
    {\global\booltrue{cbx:loccit}}
    {}}


\renewbibmacro*{cite}{%
  \global\boolfalse{cbx:loccit}%
  \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
      {\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}}}

\renewbibmacro*{textcite}{%
  \global\boolfalse{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}
       {\bibcloseparen\global\boolfalse{cbx:parens}}
       {}%
     \setunit{\textcitedelim}%
     \ifnameundef{labelname}
     % No author/editor
       {\iffieldundef{shorthand}%
    % Cite using title
         {\usebibmacro{cite:noname}%
          \setunit{\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{\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}}}}%
  % Print prenote (belongs to first cite)
        \ifnumequal{\value{citecount}}{1}
           {\usebibmacro{prenote}}
           {}%
  % 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}}%
    \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.)

相关内容