6

The header option lets you insert TeX code in the preamble after \documentclass{article}, but what if I want to change the default paper size or the default font size?

For this, I would need to insert text between \documentclass and {article}, for instance: \documentclass[a4paper,10pt]{article}.

Update: I forgot to mention that I am using spin() to generate the PDF document via LaTeX.

migrated from stackoverflow.com Jul 3 '14 at 8:14

This question came from our site for professional and enthusiast programmers.

  • 3
    This is obviously a question about r, why migrated into tex? – kohske Jul 3 '14 at 9:03
  • @kohske Seconded - the question and its answers are immaterial to anyone interested in LaTeX outside of how it relates to R Markdown/YAML. – DHW Dec 24 '17 at 4:01
3

Try this:

#' \documentclass[a4paper, 10pt]{article}
#' \begin{document}

mean(1:10)
plot(1:10)

#' \end{document}
7

There is support for specifying certain options in the YAML header; a relevant page on the R Markdown website lists the following options:

  • lang: Document language
  • fontsize: Font size
  • documentclass: Document class
  • classoption: Options for \documentclass
  • geometry: Options for \geometry
  • mainfont, sansfont, monofont, mathfont: For Xe(La)TeX and Lua(La)TeX
  • linkcolor, urlcolor, citecolor: Options for \hyperref

You may find it useful to check out the default LaTeX template used here.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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