Both natbib
and biblatex
offer a great variety of commands to insert citations.
However, only a few of them seem to be available in R markdown:
Description | R markdown | natbib Command | biblatex Command |
---|---|---|---|
Classical Citation: Author, year, and brackets (with round or square brackets depending on the citation style) | [@key] |
\citep{key} |
\parencite[Prefix][Suffix]{key} |
In-text Citation: Author (year) (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[Prefix][Suffix]{key} |
Include item in bibliography without citing it in the document | Unused References (nocite) | \nocite{key} |
\nocite{key} |
Often one would like to use more advanced commands, e.g. to cite the authors only and suppress the year.
Are there ways to add and use the following cite commands in R markdown documents to be compiled in several output formats, in particular PDF & HTML?
\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.
Related SO Qs: author only & add possessive 's to in-text citation; More flexible citation formats
Depends. If you are only producing PDF documents, then you can use natbib or biblatex directly and use the original LaTeX commands.
---
output:
pdf_document:
citation_package: biblatex
---
Show just the author of citation with ID "rick": \citeauthor{rick}
But this works with PDF output only.
Other formats are tricky. R Markdown uses a citeproc processor which handles and styles citations based on definitions written in Citation Style Language (CSL). Some things can be controlled this way, e.g. consistent use of footnotes for references. Other options, like author-only citations, are not supported by the CSL.
You could, in theory, use pandocfilters or Lua filters to hack your own plugin, extending the citation syntax. But that's probably more trouble than it's worth.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With