8

Is there any way to insert a fully formatted citation in RMarkdown in-text. For example, something like this: You enter the citation key

@watson1953

and it renders (as a latex PDF) as

Watson, J. D., & Crick, F. H. C. (1953). Molecular structure of nucleic acids: A structure for deoxyribose nucleic acid. Nature, 171(737-738), 3-12.

But it does it in exact location of the citation key. The bibliography at the end of the document should also be suppressed.

Is there any way to do this? I couldn't find anything either here or through searching google.

  • Rmarkdown uses csl (citation style language). Just find a style that suits your need; here is the main repo : https://www.zotero.org/styles – scoa Mar 05 '17 at 09:25
  • After downloading the csl and placing it in your root folder, add the following to your yaml: csl: yourcsl.csl – Nick Oct 10 '17 at 07:30
  • scoa and Nick: your comments are not in any way related to the question asked. – Johannes Titz Jan 19 '18 at 13:47
  • Have a look at this solution using the `bibtex` package: https://stackoverflow.com/a/68874049/6757392 – Tfsnuff Aug 21 '21 at 14:57

2 Answers2

1

Use visual markdown editing mode in RStudio 1.4.

Once you’ve inserted a citation, place the cursor over it to see a preview of it along with a link to the source if one is available:

citation

Cyrus Yip
  • 479
  • 5
  • 9
0

I assume you're using RStudio, which uses Pandoc to render R Markdown documents. You need to put the citation tag inside brackets, like [@watson1953]. If you put a citation without [ ], it will render an in-line citation.

According to the Pandoc User's Guide - Citations:

Citations go inside square brackets and are separated by semicolons. Each citation must have a key, composed of ‘@’ + the citation identifier from the database, and may optionally have a prefix, a locator, and a suffix. [...]

[...]

You can also write an in-text citation, as follows:

@smith04 says blah.

@smith04 [p. 33] says blah.

, emphasis mine.

Leo
  • 187
  • 1
  • 9