我需要针对特定情况更改命令\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}