Search code examples
rbookdown

How do I include Graphs/Plots/Charts in epub generated by bookdown?


I tried generating the epub for the bookdown demo, and the resulting epub did not contain the graphs and charts. I was able to see the graphs and charts in the generated PDF.

https://bookdown.org/yihui/bookdown-demo/ I ran bookdown::render_book('index.Rmd', 'all') to generate the supported formats.

On expanding the epub and looking into the generated code I see that media folder is not inside the EPUB folder and the link for the image expects this. Changing <img xmlns="http://www.w3.org/1999/xhtml" alt="Here is a nice figure!" width="80%" src="media/file0.png" />

to <img xmlns="http://www.w3.org/1999/xhtml" alt="Here is a nice figure!" width="80%" src="../media/file0.png" />

resolves this.

Is there a setting to control the location of the media folder?

System information OS: macOS Sierra 10.12.6 RStudio Server 1.0.153 R: 3.4.2 MacTex


Solution

  • This issue has been fixed in the current development version of bookdown:

    devtools::install_github('rstudio/bookdown')