♣33♣knitr and LATEX

It is hard to beat R-Markdown when the document needs limited customization and when R-output is omnipresent. When the balance is more toward the text, it might be a good option to do the opposite: instead of working from R-Markdown and R and calling LATEX to create the finished product, it might make more sense to work in LATEX and call R from there.

This gives us the unrivalled power of LATEX to typeset articles, presentations, and books and neatly include R-code and/or output generated from R. This book is compiled this way.

LATEX is a markup language (just as R-Markdown itself for that matter) that is extremely versatile – and Turing complete. It is often said that LATEX produces neat and professional looking output without any effort but that producing a confusing document requires effort in LATEX. This is quite the opposite of a regular WYSIWYG text editor.

This is only one of the many advantages of LATEX. There are many more advantages, but probably the most compelling advantages are that it is the de facto standard for scientificwriting, allows for high automation and – since it is Turing complete – will always bemore capable than any text editor.1 For example, in this book all references to title, figures, and tables are done automatically; and we can really customize how the reference looks like. That experience is more close to a programming language than to a document editor.

Explaining the finer details of working with LATEX is a book in itself ...

Get The Big R-Book now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.