In such cases, the production of the output document will take longer than usual, and you will see messages in the console that aren’t easily interpreted but that are regarding the download of necessary LaTeX packages. Fortunately for the R Markdown writer, this is done automatically when you knit a document that includes packages that aren’t already installed locally. When writing in R Markdown, you can include LaTeX code inline with your markdown text–you just need to be sure the necessary packages are loaded in the preamble.įinally, as is the case with R, you do need to download the LaTeX packages you use. In such cases, you include the package in your preamble/header, which is what you see with the additions to the YAML in the examples below.Īs with HTML, the document body contains a mixture of the actual copy content plus LaTeX commands that function in a similar way to HTML tags. This is important because, as with an R script, if there is a command you want to use that isn’t part of the base distribution of LaTeX, you need to include the package with your document. It also specifies which LaTeX packages will be used in the document. The preamble basically sets the document defaults, such as page dimensions, font size, header/footer formatting, etc. For instance, R Markdown templates will often come bundled with a header.tex document that contains specifications for the preamble. In LaTeX, this first section is known as the preamble, but when working in R Markdown, the general term ‘header’ is often used. LaTeX documents are similar to HTML pages in that they begin with a section containing important data about document formatting and style, followed by the document body. I want to provide a quick explanation of this before diving into the examples. Some of the examples below are lines of LaTeX that can be included within your R Markdown document body, and some require additions to the YAML. This post is an aggregation of a Twitter thread I posted that received pretty positive feedback.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |