user1981275
user1981275

Reputation: 13372

Rmarkdown theme not applied in vignette using R CMD build

I'm trying to make a html package vignette with a specific theme, from example the hpstr theme from prettydoc (`https://github.com/yixuan/prettydoc/blob/master/vignettes/hpstr.Rmd).

If I build the vignette manually:

rmarkdown::render('vignettes/hpstr.Rmd', output_format='prettydoc::html_pretty')

the theme is applied correctly. However, when I use a standard build process, e.g.:

git clone https://github.com/yixuan/prettydoc.git
cd prettydoc
R CMD build .
R CMD INSTALL prettydoc_0.2.1.tar.gz

and then, in R:

> library('prettydoc')
> vignette('hpstr')

the theme is not rendered at all, it looks like a regular html_output.

The yml at the top of the vignette looks as follows:

---
title: "Creating Pretty Documents from R Markdown"
subtitle: "The HPSTR Theme"
author: "Yixuan Qiu"
date: "`r Sys.Date()`"
output:
  prettydoc::html_pretty:
    theme: hpstr
    highlight: github
vignette: >
  %\VignetteIndexEntry{Creating Pretty Documents from R Markdown - The HPSTR Theme}
  %\VignetteEngine{knitr::rmarkdown}
  %\VignetteEncoding{UTF-8}
---

and in the DESCRIPTION file the vignette builder is specified:

VignetteBuilder: knitr, rmarkdown

So it looks like the vignette builder is some other than rmarkdown::render.

How can I apply the theme automatically with R CMD build ?

Upvotes: 3

Views: 974

Answers (1)

Ralf Stubner
Ralf Stubner

Reputation: 26823

This can happen if pandoc is either not installed at system level or to old, while RStudio ships with its own version of pandoc. Therefore rendering in RStudio succeeds whereas it fails with R CMD build. Possible solutions:

  • Install or update pandoc at system level
  • Make the pandoc shipped with RStudio available at system level
  • Build the package in RStudio (suggested by @YihuiXie)

Upvotes: 2

Related Questions