One Little Thing: The Docco Style with knitr::rocco()

A two-column HTML layout to show prose and code side by side

Yihui Xie 2021-06-03

Miles McBain learned the Docco style in knitr by chance when he meant to ask about getParseData(). This HTML style is lesser known but one of my personal favorite styles. I have used it in a few package vignettes such as the highr vignette. The style is based on Docco, and the code was mainly contributed by Weicheng Zhu in 2013. To render an R Markdown document to this style, you may call:

knitr::rocco('test.Rmd')

Note that the R Markdown document should be an old-fashioned one, i.e., to be rendered via the markdown package instead of Pandoc, which means the Knit button in RStudio will not work.

Features of this Docco style include (see a demo):

If you want to build a package vignette with this style, you can add the following vignette metadata to your Rmd file to specify the vignette engine to be knitr::docco_classic:

<!--
%\VignetteEngine{knitr::docco_classic}
%\VignetteIndexEntry{Your vignette title}
-->