在bookdown/rmarkdown中使用简短的作者引用

Jak*_*son 8 latex bibtex knitr r-markdown bookdown

在我的报告中,我引用了AERA,APA和NCME的教育和心理测试标准.

@Book{standards,
  title = {{Standards for Educational and Psychological Testing}},
  author = {{American Educational Research Association} and {American Psychological Association} and {National Council on Measurement in Education}},
  shortauthor = {AERA},
  publisher = {American Educational Research Association},
  address = {Washington, DC},
  year = {2014}
}
Run Code Online (Sandbox Code Playgroud)

根据APA样式指南第6版,应该使用可识别的创作组织缩写.我第一次在文中引用这本书,它应该是这样的:

这里有一些填充文本(美国教育研究协会[AERA],美国心理学会和国家教育测量委员会,2014年).这里有一些填充文本(AERA et al.,2014).

但是,我的引用目前显示如下:

这里有一些填充文本(美国教育研究协会,美国心理学会和国家教育测量委员会,2014年).这里有一些填充文本(American Educational Research Association et al.,2014).

有没有办法在预订中实施这些引用?这里有一个最低限度可重复的例子:https://github.com/wjakethompson/bookdown-citations

Mic*_*per 3

我开发了一个部分有效的解决方案。该解决方案打印长作者和缩短版本,但仅适用于单个作者,并且由于它使用 LaTeX 来实现定制,因此它仅适用于 PDF 输出

根据您提供的示例,我创建了一个参考书目,test.bib如下所示:

@Book{standards2,
  title = {{Standards for Educational and Psychological Testing}},
  author = {{American Educational Research Association}},
  shortauthor = {AERA},
  publisher = {American Educational Research Association},
  address = {Washington, DC},
  year = {2014}
}
Run Code Online (Sandbox Code Playgroud)

header.tex还会创建一个文件。这定义了一个新的 LaTeX 命令\citefull,该命令以以下格式打印出引文(author [shortauthor], year)。该方法大致基于此处的答案。文件内容如下:

\DeclareCiteCommand{\citefull}
  {\boolfalse{citetracker}%
   \boolfalse{pagetracker}%
   \DeclareNameAlias{labelname}{first-last}%
   \usebibmacro{prenote}}
  {\ifciteindex
     {\indexnames{labelname}}
     {}%
   (\printnames{author}
   [\printnames{shortauthor}],
   {\printdate})
   }

  {\usebibmacro{postnote}}

% Adds a comma between the author and year
\renewcommand*{\nameyeardelim}{\addcomma\space}
Run Code Online (Sandbox Code Playgroud)

以下是 Rmarkdown 文件。进行了更改以使用 biblatex 作为引文包。要获得完整的引用,\citefull{}可以使用该命令。

---
output: 
  pdf_document:
    includes:
      in_header:  header.tex
    citation_package: biblatex
bibliography: test.bib
biblio-style: authoryear

---

\citefull{standards2}

[@standards2]
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述


补充笔记

正如我所说,这是一个部分解决方案,因为它不适用于多个作者,而且我必须承认我对自定义 LaTeX 引用的知识还没有延伸到那么远!希望有人能够扩展这个答案,从而改进这个功能。

我尝试使用此处解释的解决方案,但由于它需要在 biblatex 之前加载 LaTeX 包,因此需要更改 pandoc .tex 模板。我觉得这比使用头文件不太理想。

即使我确实编辑了原始模板,我仍然在使该解决方案正常工作时遇到问题。我遇到了一个错误 \DeclareLanguageMappingSuffix,无法找出我把事情搞砸的地方。

我希望这些注释可以帮助任何考虑探索更好解决方案的人。