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.

  • 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

Try this:

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


#' \end{document}
| improve this answer | |

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.

| improve this answer | |

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.