There is a suggestion on the RStudio blog that one can convert an R Markdown document into the EPUB format. But I can't find any documentation on how to do this. I suspect I may have to use pandoc arguments, but as someone new to R Markdown I am finding this a bit confusing. And silly ideas of mine such as the YAML metadata below don't work. All help appreciated. It would be particularly great if I could do this via the YAML metadata section of the R Markdown file.
---
title: "An epub"
output: epub_document
---
With the bookdown
package installed, you can specify a version of the following output format in the yaml header:
output:
bookdown::epub_book:
number_sections: true
There are a number of other options. See Epub options. A quirk of my version of Reader for Mac (2.0.02.15180) is that $p$ appears as pp
, and $\alpha$ appears as α\alpha
. With Calibre, it imports without problem.
An alternative is to make a new RMarkdown custom format (until some kind soul makes a custom format for EPub that they're willing to share!). All the documentation you should need to make this happen is here:
http://rmarkdown.rstudio.com/developer_custom_formats.html
It's technically true that you can add Pandoc arguments to coerce one of the existing output documents to spit out an EPub book. For instance, try this:
output:
html_document:
pandoc_args: ["--to", "epub"]
You'll find that the .html
that's emitted is actually an EPub book! But it's unlikely to look nice or work correctly, because all of the knitr options and Pandoc options set by html_document
are designed to produce HTML documents, not books.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With