Knitr: can I cite an article as a graphic using the fig.cap chunk option?

I would like to cite an article in my chart. I tried using Rmarkdown / pandoc [@citekey] and latex forms \\citep{citekey} in the fig.cap chunk option fig.cap no luck.

Here is an example of reproducibility:

 --- output: rmarkdown::tufte_handout references: - id: Nobody06 title: 'My Article' author: - family: Nobody given: Jr issued: year: 2006 --- Some text [@Nobody06]. ```{r figure, fig.cap="A figure [@Nobody06]"} library(ggplot2) qplot(1:10, rnorm(10)) ``` # References 

This leads to a correct quote in the text block, but either [@Nobody06] (when I use the RMarkdown form) or (?) (When I use the Latex form) in the picture header.

Here is the screenshot: screencap .

I also tried using the link in the .bib and .bibtex as follows: with the same results:

 @misc{Nobody06, author = "Nobody Jr", title = "My Article", year = "2006" } 

After updating the versions of dev Rmarkdown ( rstudio/ rmarkdown@c22ee06 ) and knitr ( yihui/ knitr@b510ced ) I get (?) yihui/ knitr@b510ced in the text block and in the picture header. I see Some text [@Nobody06]. displayed as Some text \citep{Nobody06}. in the .tex file using the dev version, but it is Some text (Nobody 2006). in the release version.

Does anyone know if quotes can be used in the fig.cap field?

 R version 3.2.2 (2015-08-14) Platform: x86_64-pc-linux-gnu (64-bit) Running under: Ubuntu 14.04.3 LTS locale: [1] LC_CTYPE=en_AU.UTF-8 [2] LC_NUMERIC=C [3] LC_TIME=en_AU.UTF-8 [4] LC_COLLATE=en_AU.UTF-8 [5] LC_MONETARY=en_AU.UTF-8 [6] LC_MESSAGES=en_AU.UTF-8 [7] LC_PAPER=en_AU.UTF-8 [8] LC_NAME=C [9] LC_ADDRESS=C [10] LC_TELEPHONE=C [11] LC_MEASUREMENT=en_AU.UTF-8 [12] LC_IDENTIFICATION=C attached base packages: [1] stats graphics grDevices utils [5] datasets methods base other attached packages: [1] ggplot2_1.0.1.9003 loaded via a namespace (and not attached): [1] Rcpp_0.12.1 digest_0.6.8 [3] plyr_1.8.3 grid_3.2.2 [5] gtable_0.1.2 formatR_1.2.1 [7] magrittr_1.5 evaluate_0.8 [9] scales_0.3.0 stringi_0.5-5 [11] rmarkdown_0.8.1 labeling_0.3 [13] tools_3.2.2 stringr_1.0.0 [15] munsell_0.4.2 yaml_2.1.13 [17] colorspace_1.2-6 htmltools_0.2.6 [19] knitr_1.11 
+5
source share

Source: https://habr.com/ru/post/1234285/


All Articles