I have been searching the internet for hours but I think I am looking in the wrong direction. Hopefully this is the right place for asking, otherwise please point me in the right direction :)

I write markdown documents. I use latex inside these documents for equations and figures. I save these as .txt and use pandoc to convert to .pdf and such,

pandoc example.txt -o example.pdf --bibligraphy library.bib

to be precise. I have now started using knitr as well. I played around with it for a bit and tried to create more markdown .txt documents with latex embedded (as described above) as well as R code chunks. I then converted this to .pdf using pandoc but this didn't produce the desired result.

My question: are there any tools that will allow me to write markdown, latex and Rcode (knitr) in the same document and convert to proper pdf (and .docx) versions?

  • It would reallly help to know how the results differed from your desired results. Jun 17, 2015 at 4:56
  • 1
    Do you want to typeset these R code chunks, or do you want to execute them and typeset their output (graphs?)? Jun 17, 2015 at 8:05
  • There is a workaround if you use org-mode instead of markdown. It supports embedded Latex and R code snippets, and its syntax is similar to markdown and easy to learn. Documents can be directly exported to pdf from within Emacs.
    – Tymric
    Jun 17, 2015 at 19:22
  • @SteveBarnes It just didn't look nice. I sorry that is very vague, but what happened was that the R code/R markdown wansn't understood by pandoc as such an it turned it nonsense.
    – rosannavh
    Jun 19, 2015 at 2:21
  • 1
    @rosannav I have added a note and link on how to do R in ipython. Unless you tell ipython that a cell is R with the magic it will be assumed to be either python or Markdown. Jun 19, 2015 at 5:14

1 Answer 1


I suggest taking a look at the ipython notebook.

It lets you mix via your browser

  • Markdown
  • Formulae with MathJax
  • Python code
  • R code
  • Several other programming languages
  • Bash Scripts
  • The results of all of the above including graphs etc
  • Syntax highlighted code in 100s of other languages

It allows export as html and pdf as well as sharing as notebooks.

  • Free and open source.
  • Cross Platform.

You will need to install r2py and use the rmagic command as explained here.

  • Thanks heaps! I'm going to look into that
    – rosannavh
    Jun 19, 2015 at 2:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.