在R markdown中使用高级cite命令例如biblatex / natbib中的citetitle,citeauthor,footcite 附录

问题描述

natbibbiblatex都提供了多种插入引文的命令。

但是,R markdown中似乎只有少数几个可用:

Citing commands available in R markdown

通常,您想使用更高级的命令,例如仅引用作者并隐瞒年份。

是否可以在R markdown文档中添加和使用以下cite命令?

\citetitle{key} Returns the title of the source.
\citeauthor{key} Returns the author(s) of the cited source.
\footcite{key} Creates a footnote within the document.
\fullcite{key} Creates a complete quote like in the bibliography
\footfullcite{key} Creates a complete citation,as in the bibliography,in a footnote.

附录

上面打印的表格的代码(自SO,unfortunately,does not allow to include md-tables起)

| Description                                                  | R markdown                                                   | natbib Command   | biblatex Command                   |
| ------------------------------------------------------------ | ------------------------------------------------------------ | ---------------- | ---------------------------------- |
| *Classical Citation:* Author,year,and brackets <br />(with round or square brackets depending on the citation style) | `[@key]`                                                     | `\citep{key}`    | `\parencite[Praefix][Suffix]{key}` |
| *In-text Citation:* Author (year)<br />(without square brackets or with brackets depending on the citation style) | `@key`                                                       | `\citet{key}`    | `\cite[Prefix][Suffix]{key}`       |
| *Year only/suppress Author:* (year)                          | `[-@key]`                                                    | `\citeyear{key}` | `\citeyear{key}`                   |
| Include item in bibliography without citing it in the document | [Unused References (nocite)](https://rmarkdown.rstudio.com/authoring_bibliographies_and_citations.html) | `\nocite{key}`   | `\nocite{key}`                     |

相关的SO问题: author only & add possessive 's to in-text citationMore flexible citation formats

解决方法

视情况而定。如果您只生成 PDF 文档,那么您可以使用 natbib 或 biblatex directly 并使用原始的 LaTeX 命令。

---
output:
  pdf_document:
    citation_package: biblatex
---

Show just the author of citation with ID "rick": \citeauthor{rick}

但这适用于 PDF 输出


其他格式很棘手。 R Markdown 使用 citeproc 处理器,该处理器根据 Citation Style Language (CSL) 中编写的定义处理和样式化引文。有些事情可以通过这种方式控制,例如一致地使用脚注作为参考。 CSL 不支持其他选项,例如仅作者引用。

理论上,您可以使用 pandocfiltersLua filters 来破解您自己的插件,扩展引用语法。但这可能比它的价值更麻烦。