knitr: can I cite an article in a figure caption using the fig.cap chunk option?

后端 未结 1 607
南旧
南旧 2020-12-31 18:29

I\'d like to cite an article in my figure caption. I\'ve tried using the Rmarkdown/pandoc [@citekey] and the latex \\\\citep{citekey} forms in the

相关标签:
1条回答
  • 2020-12-31 18:50

    The bookdown package extends the functionality of rmarkdown and provides some useful tools. Text-references can be used to address this problem. As described by the package author, text references can be used:

    You can assign some text to a label and reference the text using the label elsewhere in your document.

    This works really well with citations, as shown below:

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

    You'll notice that the output format has been adjusted to bookdown::tufte_handout2 which allows the bookdown features to work. You can find a full list of the output formats here.

    Read more about text references here: https://bookdown.org/yihui/bookdown/markdown-extensions-by-bookdown.html#text-references

    0 讨论(0)
提交回复
热议问题