I have recently discovered that you can write scientific and non-scientific documents (articles, books, thesis, pamphlets, etc) using R Markdown. There seem to have very nice features. Some examples:

  • First and foremost, it integrates directly with a statistical software (e.g. R Rtudio). As such, you are not using two software (e.g. R Studio and TeXstudio).

  • It integrates very nicely with computer code (providing syntax highlighting), and other natural Markdown features

  • It integrates amazingly with HTML and other online type of interfaces, and as such, you are writing something which provides a more general platform that TeX, which is mainly (but not uniquely) devoted to pdf.

  • It also allows the creation of presentations.

  • It accepts math code, has a very simply bibliographic system, and its own TikZ-equivalent fancy graph packages.

Now, after using (La)TeX for around 3 years, I am very satisfied with it. Yet, a natural question is whether I should start exploring R Markdown, not the least because I also use R, and because R is in many dimensions taken over other (non-free) software (e.g. Stata, Matlab). As the few examples I gave you above show, R Markdown seems to me, in the end, a direct competitor of TeX.

So, what are the benefits of using TeX over R Markdown? (imagine you were to convince a newcomer to document typesetting to use TeX instead of R Markdown).

Note: this is a serious question, without any attempt to offend anyone in this community. I think this is a key issue, if one wants to engage in the debate over typesetting system comparison. I am very interested in hearing what other people's experience are on this.

closed as primarily opinion-based by Henri Menke, Thruston, Stefan Pinnow, Mensch, Andrew May 4 '17 at 2:33

Many good questions generate some degree of opinion based on expert experience, but answers to this question will tend to be almost entirely based on opinions, rather than facts, references, or specific expertise. If this question can be reworded to fit the rules in the help center, please edit the question.

  • 1
    it may be serious but I fear that it any answer would be "primarily opinion based" which is a standard close reason built into this site. – David Carlisle May 3 '17 at 15:51
  • 6
    since for pdf generation R markdown is just a latex-generation tool and all the typesetting is via latex, the wording of your question is slightly misleading I think. It is hardly competing with TeX since its output is tex. – David Carlisle May 3 '17 at 15:54
  • 3
    For those that do not use R (and R markdown) there's apparently no advantage of R over TeX/LaTeX ;-) I also find it weird to introduce another layer of 'language' and I am unsure that R markdown supports anything that can be done with TeX and friends – user31729 May 3 '17 at 16:05
  • there are other (more general) convertors from markdown to tex, notably pandoc. oh that bib link you give suggests that it uses this is using pandoc – David Carlisle May 3 '17 at 16:15
  • 3
    @closevoters I'm so glad this question wasn't closed before Fran had a chance to answer. That answer shows that this question can in fact be answered in a way that is informative and useful to the site. – Alan Munn May 4 '17 at 2:47

As you know, a R markdown file can produce several formats but make a PDF is done via LaTeX exportation with pandocas David pointed, so in this case is equivalent to write what RStudio call a R Sweave file (with .Rnw extension, i.e., a R noweb file, that mean LaTeX with Sweave/knitr chunks).

The advantages of write R markdown file (.Rmd) over write a R Sweave file (.Rnw) are:

  1. Simplicity of markdown syntax. A great advantage for people untrained with LaTeX code.

  2. Easier exportation to other formats. Since markdown syntax is simpler than LaTeX, this could be less troublesome that export a complex LaTeX code where some parts have no equivalence in another markup languages as HTML.

But there are also some disadvantages:

  1. Yet another markdown syntax. Markdown's success is poisoned by itself from the beginning, producing uncountable markdown flavors and there are not undisputed standards in the horizon. When I write some markdown code often I am not completely sure if some code will work in R markdown or it was specific of another flavor. Certainly, R markdown have one of the more (the most?) complete and versatile syntax, (as you can switch to original markdown specification, full pandoc markdown, flavored GitHub markdown, MultiMarkdown, PHP markdown, or any custom variant allowing only some of the all possible extensions, as allow/disallow autolinks, etc.) but versatility is against simplicity, adding considerable some confusion on how and when you can write some markdown code and obtain the desired result in PDF.

The same could be said in some extent of TeX flavors and their extensions via \usepackage, \inputs or document classes, but LaTeX and most common packages are enough populars to be considered de facto standards.

  1. Even with all extensions, markdown syntax is rather limited compared with LaTeX. Fortunately, it allow insertion of LaTeX code and LaTeX packages in the YAML header, but then is no longer a simple syntax, and moreover, even using this it could be hard obtained the desired result. For instance, try to make R markdown to produce a PDF with two columns, where tables and figures are floats taking exactly the width of the columns, what is fairly simple in LaTeX. Or try to manage with master/slave documents in markdown.

  2. LaTeX/PDF ouput. Pandoc make a very good work in LaTeX conversion but is not always the code that you would write manually nor the desired PDF ouput. If you ended keeping the LaTeX source for editing it, then could be nothing better start writing yourself a clean .Rnw file.

  • 1
    +1 Additionally on (2), depending on how much you depend on particular LaTeX packages, especially those required for specific fields, markdown just becomes a burden, and inserting LaTeX code usually removes the output flexibility of pandoc conversion. – Alan Munn May 3 '17 at 22:26
  • 2
    @AlanMunn Certainly. Inline raw TeX commands are passed unchanged to LaTeX, ConTeXt and markdown ouputs, but ignored in the others formats. This limitation annoyed me more than once. – Fran May 4 '17 at 1:45
  • Thanks for the answer. Considering the apparent (and surely increasing) popularity of R markdown for typesetting, do you see areas in which TeX can learn from it? – luchonacho May 4 '17 at 7:22
  • @luchonacho It's Markdown who has to learn something yet. TeX is frozen, cannot learn any more, but people use to say that is Turing complete to point that in theory can do anything, Needless to mention that actually with lua and LaTeX 3 this more true now. In fact LaTeX actually can write basic markdown inside LaTeX documents or Wikipedia-like markup (see packages wiki and and nicetext in the same link), to simplify typesetting of some parts, while maintain all the power of LaTeX. – Fran May 4 '17 at 20:32

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