HTML formats and templates for 'rmarkdown' documents, with some extra features such as automatic table of contents, lightboxed figures, dynamic crosstab helper.
This R package provides ready-to-use HTML output formats and templates for RMarkdown documents. The goal is to produce clean documents "out of the box", with or without the RStudio IDE.
The package provides several HTML output formats. You can click on an image to see a real HTML output sample.
material
formatFormat taken from the Material design theme for Bootstrap 3. Document is split into pages at each <h1>
header, and the table of contents allows an animated navigation between these pages (you can use the cards: false
preamble parameter to disable the splitting and display all the cards at once).
readthedown
formatAdapted from the corresponding readtheorg
theme of the org-html-themes project, fully responsive with dynamic table of contents and collapsible navigation.
html_clean
formatSimple and clean template with dynamic table of contents, very similar to the one from the great knitrBootstrap package by Jim Hester.
html_docco
formatSimple template, no table of contents. CSS heavily inspired from the default one of the docco project.
Some extra features are available depending on the format :
readthedown
is fully responsive, with collapsible navigationhtml_clean
and readthedown
provide an automatic and dynamic table of contentshtml_clean
and html_docco
provide automatic thumbnails for figures with lightbox displayThe package also provides a create.doc()
function as well as RStudio document
templates to easily generate an empty and ready to use rmarkdown file with
several configuration directives.
Finally, it also provides the pilltabs()
helper function, which allows to display a crosstab dynamically. See one of the output samples for a live example.
You can install the latest stable release from CRAN :
install.packages("rmdformats")
Or the latest development snapshot from GitHub :
install.packages(remotes) # if necessaryremotes::install_github("juba/rmdformats")
Choose File
> New File...
> R Markdown...
, then select From Template
.
You should then be able to create a new document from one of the package
templates.
The create.doc()
function allows you to create a new directory with a clean
ready-to-use RMarkdown file. create.doc()
gets two main arguments :
dirname
is the name of the folder and RMarkdown file to be createdformat
is the format name ("html_clean"
or "html_docco"
)By default, a Makefile
file will be created in the new folder for direct
rendering from the command line.
Rendering from within RStudio should be quite simple : just click the Knit
button.
You can render your document into HTML directly from within R with the
render()
function from the rmarkdown
package :
library(rmarkdown)render("mydocument.Rmd")
If you created your .Rmd
file with the create.doc()
function, you can then
generate HTML or PDF files with :
make html
make pdf
You can also clean out any generated files and cache with :
make clean
create.doc()
is heavily inspired by the create.project()
function of the ProjectTemplate packagehtml_docco
format is heavily inspired from the default one of the docco project.readthedown
is adapted from the corresponding readtheorg
theme of the org-html-themes project, which is itself inspired by the Read the docs Sphinx theme.material
has been taken from the Material design theme for Bootstrap 3 project and its presentation pagermarkdown
HTML templateThe html_clean
styling and features are very similar to the ones from the great
knitrBootstrap package by Jim
Hester.
template.yaml
files (thanks @thomaselove)material
(thanks @antuki)make html
(thanks @gdevenyi)cards
argument to the material template
(thanks @Maiae)mathjax: null
in preamble (thanks @jflycn)material
material
HTML templatelightbox
, thumbnails
and gallery
options for images display (thanks @noamross)use_bookdown
argument for section numbering and cross references (thanks @rdiaz02)readthedown
HTML template