如果数据库条目类型为 @online,则更新 \parencite 命令

如果数据库条目类型为 @online,则更新 \parencite 命令

我需要针对特定​​情况更改命令\parencite,但我完全不知道如何重写它。有人能帮我吗?

我的数据库条目如下:

@online{ref1,
   author = {{A Company}},
   title = "Page Title",
   year = "no date",
   url = {https://url.xy},
   urldate = "2017-10-14"
}

如果我现在使用\parencite,我会得到

一些文本(一家公司,无日期)。

但我需要的是

一些文本(A 公司,在线)。

因此基本上,我需要根据以下标准覆盖 \parencite:

  • 如果数据库条目为@online 并且“年份”中未指定“日期”,则打印(作者,在线)。
  • 如果有同一作者的多个条目,且用@online 声明且不带日期,则打印(作者(a),online)。
  • 在其他情况下,请像以前一样使用 APA 引用样式
  • 对参考书目没有影响!

梅威瑟:

\documentclass[a4paper,10pt]{article}
\usepackage[utf8]{inputenc}
\usepackage[german]{babel}

\usepackage[style=apa]{biblatex}
\usepackage{csquotes}
\DeclareLanguageMapping{ngerman}{ngerman-apa}
\addbibresource{references.bib}
\NewBibliographyString{from}
\NewBibliographyString{retrieved}
\DefineBibliographyStrings{ngerman}{
   retrieved = {Abgerufen am},
   from = {von},
   nodate = {{}},
}
\DeclareFieldFormat[online]{title}{\mkbibemph{#1}}

\begin{filecontents}{\sample.bib}
    @online{ref1,
       author = {{A Company}},
       title = "Title",
       year = "no date",
       url = {https://url.xy},
       urldate = "2017-11-15"
    }

    @online{ref2,
       author = {{A Company}},
       title = "Page Title",
       year = "no date",
       url = {https://url.xy},
       urldate = "2017-10-14"
    }
 \end{filecontents}
 \begin{document}
 There is some text \parencite{ref1} and some other \parencite{ref2}.
 \printbibliography
 \end{document} 

答案1

强制警告:对 的任何更改都biblatex-apa将导致样式不再符合 APA 标准。请谨慎操作,并且仅在必要时才进行。

我假设您的文本是nswissgerman按照评论中讨论的方式编写的。

cite:plabelyear+extradate打印引文中的年份。修改宏后,它不再打印nodate年份,而是跳过年份,打印条目类型(本例中为在线)。

year = {no date}如果没有日期,则无需写或类似内容。year如果没有,则根本不要给出biblatex。其余部分可以自行解决。

\documentclass[a4paper,10pt]{article}
\usepackage[utf8]{inputenc}
\usepackage[nswissgerman]{babel}

\usepackage[style=apa]{biblatex}
\usepackage{csquotes}
\addbibresource{\jobname.bib}
\NewBibliographyString{from}
\NewBibliographyString{retrieved}
\DefineBibliographyStrings{nswissgerman}{
  retrieved = {Abgerufen am},
  from      = {von},
  nodate    = {{}ohne Datum},
}

\DeclareFieldFormat{extradate:special}{\bibhyperref{\mkbibparens{\mknumalph{#1}}}}
\newbibmacro*{cite:plabelyear+extradate}{%
  \iffieldundef{labelyear}{}
    {\iffieldequalstr{labelyear}{nodate}
       {\setunit{\addspace}%
        \printfield[extradate:special]{extradate}%
        \setunit{\addcomma\space}%
        \printfield{entrytype}}
       {\printtext[bibhyperref]{%
           \clearfield{labelmonth}% don't want months in citations
           \clearfield{labelday}% don't want days in citations
           \clearfield{labelendmonth}% don't want months in citations
           \clearfield{labelendday}% don't want days in citations
           \iffieldsequal{labelyear}{labelendyear}% Don't want no-op year ranges
             {\clearfield{labelendyear}}
             {}%
           \iffieldundef{origyear}{}
             {\ifboolexpr{ test {\iforigdatecirca} or test {\iforigdateuncertain} }
               {\mkbibbrackets{\printorigdate}}
               {\printorigdate}%
              \setunit*{\addslash}}%
          \ifboolexpr{ test {\iflabeldatecirca} or test {\iflabeldateuncertain} }
            {\mkbibbrackets{\printlabeldateextra}}
            {\printlabeldateextra}}%
        \iffieldundef{issue}
          {}
          {\addcomma\addspace\printfield{issue}}}}}

\DeclareFieldFormat[online]{title}{\mkbibemph{#1}}
\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@online{ref1,
  author = {{A Company}},
  title = "Title",
  url = {https://url.xy},
  urldate = "2017-11-15"
}

@online{ref2,
  author = {{A Company}},
  title = "Page Title",
  url = {https://url.xy},
  urldate = "2017-10-14"
}
\end{filecontents}
\begin{document}
There is some text \parencite{ref1} and some other \parencite{ref2}.
\printbibliography
\end{document} 

在此处输入图片描述

相关内容