Search code examples
rr-markdownrmdformats

RMarkdown using readthedown template. self_contained: true seems do not work


I'm referring to the template readthedown provided by the package rmdformats version 1.0.4 executed by R 4.2.1 on Windows 11

I'm running an old script with the following YAML section

---
title: "Title"
subtitle: "SubTitle"
author: "Author"
date: "(`r format(Sys.time(), '%d %b, %Y')`)"
output:
  rmdformats::readthedown:
    toc_depth: 5
    self_contained: true
    thumbnails: false
    lightbox: true
    gallery: true
    highlight: tango
    css: custom.css
---

The compilation process reach the end without errors but generating the output file (Ex. report.html) and a related folder named for Ex. report_files that contain all the images generated run-time by the rmarkdown chunks.

A few version updates ago the image folder was not generated

The statement self_contained: true it seems by masked or unused.


Solution

  • If you have the global option cache set as TRUE in your setup chunk, either remove that option (then it will default to FALSE) or set the option as FALSE.

    Having cache set as TRUE is a possible reason to generate the folder containing necessary images.

    Therefore, if you run the following reprex, you will see that no extra folder is created in your working directory.

    Reprex

    ---
    title: "Title"
    subtitle: "SubTitle"
    author: "Author"
    date: "(`r format(Sys.time(), '%d %b, %Y')`)"
    output:
      rmdformats::readthedown:
        toc_depth: 5
        self_contained: true
        thumbnails: false
        lightbox: true
        gallery: true
        highlight: tango
    ---
    
    ```{r setup, include=FALSE}
    ## Global options
    knitr::opts_chunk$set(cache = FALSE)
    ```
    
    ## Some Plots
    
    ```{r}
    plot(rnorm(50), runif(50))
    ```
    
    ```{r}
    plot(rnorm(50), runif(50))
    ```
    
    ```{r}
    plot(rnorm(50), runif(50))
    ```