Search code examples
rlatexr-markdownodt

R Markdown - no ODT and LaTeX options as an output


I found R markdown/knitr useful tool to document my work and generate summary document.

I work with .Rmd (R markdown) files in RStudio. It seems that knitr provide appropriate functionality to generate .odt (Open Document Text) and .tex (LaTeX) documents from .Rmd.

However, R studio allows to choose .docx, .html and .pdf formats only.

R Markdown output formats in RStudio

New R Markdown wizard in RStudio

I would like to avoid MS Word format since I prefer open standards and working under Linux.

Is it possible to add .odt and .tex options to Rstudio menu?


Solution

  • It doesn't seem possible to output odt directly in RStudio, but you can always use knitr::knit to produce a markdown document and pandoc to produce the odt:

    library(knitr)
    knit("myDoc.Rmd")
    system("pandoc myDoc.md -o myDoc.odt")
    

    You may have to adjust the pandoc options and adapt the template to get a nice looking result.

    As for latex, you can keep the tex sources when compiling to pdf with the following option in your yaml front matter:

    ---
    output:
      pdf_document:
        keep_tex: true
    ---