3.8 R package vignette

Thehtml_vignette format provides a lightweight alternative tohtml_document suitable for inclusion in packages to be released to CRAN. It reduces the size of a basic vignette from 600Kb to around 10Kb. The format differs from a conventional HTML document as follows:

  • Never uses retina figures
  • Has a smaller default figure size
  • Uses a custom lightweight CSS stylesheet

To usehtml_vignette, you specify it as the output format and add some additional vignette related settings via the\Vignette*{} macros:

---title:"Your Vignette Title"output: rmarkdown::html_vignettevignette:>  %\VignetteEngine{knitr::rmarkdown}  %\VignetteIndexEntry{Your Vignette Title}  %\VignetteEncoding{UTF-8}---

Note that you should change thetitle field and the\VignetteIndexEntry{} to match the title of your vignette.

Most options forhtml_document (Section3.1) also work forhtml_vignette, exceptfig_retina andtheme, which have been set tonull internally in this format.

Thehtml_vignette template includes a basic CSS theme. To override this theme, you can specify your own CSS in the document metadata as follows:

output:  rmarkdown::html_vignette:css: mystyles.css

The default figure size is 3x3. Because the figure width is small, usually you will be able to put two images side-by-side if you set the chunk optionfig.show='hold', e.g.,

```{r, fig.show='hold'}plot(1:10)plot(10:1)```

If you want larger figure sizes you can change thefig_width andfig_height in the document output options or alternatively override the default options on a per-chunk basis.