rmarkdown::render()
. Each stage is explained in further detail below..Rmd
document is the original format of the document. It contains a combination of YAML (metadata), text (narratives), and code chunks.knit()
function in knitr(Xie 2020d) is used to execute all code embedded within the .Rmd
file, and prepare the code output to be displayed within the output document. All these results are converted into the correct markup language to be contained within the temporary .md
file..md
file is processed by Pandoc, a multipurpose tool designed to convert files from one markup language to another. It takes any parameters specified within the YAML frontmatter of the document (e.g., title
, author
, and date
) to convert the document to the output format specified in the output
parameter (such as html_document
for HTML output)..md
file into an intermediate .tex
file. This file is then processed by LaTeX to form the final PDF document. As we mentioned in Section 1.2, the rmarkdown package calls the latexmk()
function in the tinytex package (Xie 2020e), which in turn calls LaTeX to compile .tex
to .pdf
.rmarkdown::render()
= knitr::knit()
+ Pandoc (+ LaTeX for PDF output only)..md
file could be compiled by other Markdown renderers. Below are two examples:.md
output to a JavaScript library, which renders the Markdown content in the web browser..Rmarkdown
document format, which is knitted to .markdown
, and this Markdown document is usually rendered to HTML by an external site generator.