2

I've created several vignettes for a package, with figures I want to reference in the text. Using the template for a .Rmd vignette, I can do this by using bookdown::html_document2 as follows in my yaml header:

output: 
  bookdown::html_document2:
    base_format: rmarkdown::html_vignette
    fig_caption: yes
    toc: true

Yet, when I build the associated pkgdown site, I don't get figure numbers or cross-references, done with \@ref(fig:chunk_name).

Is there some magic I can add to my _pkgdown.yml file to have it use the bookdown output format?

Edit: Not sure if this has anything to do with this issue, but my figure chunk labels are of the form topic-figure rather than topic_figure. E.g.,

```{r, plastic1-HE3D}
#| echo=FALSE,
#| fig.cap="3D HE plot for the plastic MLM"
knitr::include_graphics("fig/plastic-HE3D.png")
```
user2554330
  • 37,248
  • 4
  • 43
  • 90
user101089
  • 3,756
  • 1
  • 26
  • 53

1 Answers1

2

A solution that seems to work is suggested in https://github.com/r-lib/pkgdown/issues/2201

Essentially, add pkgdown: as_is: true to the yaml headers of vitnettes:

output: 
  bookdown::html_document2:
    base_format: rmarkdown::html_vignette
    fig_caption: yes
    toc: true
    toc_depth: 2
pkgdown:
  as_is: true
user101089
  • 3,756
  • 1
  • 26
  • 53