Creating Pretty Documents from R Markdown

Creating tiny yet beautiful documents and vignettes from R Markdown. The package provides the 'html_pretty' output format as an alternative to the 'html_document' and 'html_vignette' engines that convert R Markdown into HTML pages. Various themes and syntax highlight styles are supported.

documents, like this page?

Themes for R Markdown

With the powerful rmarkdown package, we could easily create nice HTML document by adding some meta information in the header, for example

title: Nineteen Years Later
author: Harry Potter
date: July 31, 2016
    theme: lumen

The html_document engine uses the Bootswatch theme library to support different styles of the document. This is a quick and easy way to tune the appearance of your document, yet with the price of a large file size (> 700KB) since the whole Bootstrap library needs to be packed in.

For package vignettes, we can use the html_vignette engine to generate a more lightweight HTML file that is meant to minimize the package size, but the output HTML is less stylish than the html_document ones.

So can we do BOTH, a lightweight yet nice-looking theme for R Markdown?

The prettydoc Engine

The answer is YES! (At least towards that direction)

The prettydoc package provides an alternative engine, html_pretty, to knit your R Markdown document into pretty HTML pages. Its usage is extremely easy: simply replace the rmarkdown::html_document or rmarkdown::html_vignette output engine by prettydoc::html_pretty in your R Markdown header, and use one of the built-in themes and syntax highlighters. For example

title: Nineteen Years Later
author: Harry Potter
date: July 31, 2016
    theme: cayman
    highlight: github

You can also create documents from prettydoc templates in RStudio.

Step 1: Click the "New File" button and choose "R Markdown".

Step 1

Step 2: In the "From Template" tab, choose one of the built-in templates.

Step 2

Options and Themes

The options for the html_pretty engine are mostly compatible with the default html_document (see the documentation) with a few exceptions:

  1. Currently the theme option can take the following values. More themes will be added in the future.
    • cayman: Modified from the Cayman theme.
    • tactile: Modified from the Tactile theme.
    • architect: Modified from the Architect theme.
    • leonids: Modified from the Leonids theme.
    • hpstr: Modified from the HPSTR theme.
  2. The highlight option takes value from github and vignette.
  3. Options code_folding, code_download and toc_float are not applicable.

Related Projects

  • tufte provides the Tufte style for R Markdown documents.
  • BiocStyle provides standard formatting styles for Bioconductor PDF and HTML documents.
  • rmdformats by Julien Barnier contains HTML formats and templates for R Markdown documents, with some extra features such as automatic table of contents, lightboxed figures, and dynamic crosstab helper.
  • markdowntemplates by Bob Rudis is a collection of alternative R Markdown templates.
  • prettyjekyll by Florian Privé uses prettydoc to convert R Markdown documents to Jekyll Markdown for blog posting.


Here are some screenshots of the HTML pages generated by prettydoc with different themes and syntax highlighters.

Cayman (demo page)

Cayman Theme

Tactile (demo page)

Tactile Theme

Architect (demo page)

Architect Theme

Leonids (demo page)

Leonids Theme

HPSTR (demo page)



Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.


0.4.1 by Yixuan Qiu, a year ago

Report a bug at

Browse source code at

Authors: Yixuan Qiu [aut, cre] , Jason Long [ctb] (the Cayman , Tactile and Architect themes) , Renyuan Zou [ctb] (the Leonids theme) , Michael Rose [ctb] (the HPSTR theme) , JJ Allaire [ctb] (pandoc template for rmarkdown) , Hadley Wickham [ctb] (the html_vignette() function) , Yihui Xie [ctb] (the html_vignette() function) , Steve Matteson [ctb] (the Open Sans fonts) , Emily Eisenberg [ctb] (the KaTeX library) , Sophie Alpert [ctb] (the KaTeX library)

Documentation:   PDF Manual  

Apache License (>= 2.0) license

Imports rmarkdown

Suggests knitr, KernSmooth

System requirements: pandoc (>= 1.12.3)

Imported by CBDA, chronicle, geneticae, sdcMicro.

Suggested by BIOMASS, BoSSA, CornerstoneR, DisImpact, ERP, ICDS, IRexamples, PP, RGCxGC, RSpectra, RcppNumerical, SingleCaseES, StratifiedSampling, SuperLearner, UCSCXenaTools, VCA, VFP, bootPLS, cSEM, clustermole, configr, contribution, corrplot, detectRUNS, dlookr, dlstats, doseminer, emojifont, ezcox, fitHeavyTail, gamclass, ggbreak, ggfun, ggplotify, ggrepel, ggstar, gprofiler2, graphsim, imputeFin, insee, markerpen, meme, metaboData, nCov2019, nlpred, phangorn, plotbb, portfolioBacktest, qra, recosystem, rfishdraw, riskParityPortfolio, roperators, rwebstat, sageR, scatterpie, scholar, seqmagick, shadowtext, showtext, sim1000G, sparseIndexTracking, spectralGraphTopology, sptotal, stubthat, tcpl, tidytree, tmt, vistime, wgaim, ymlthis.

See at CRAN