简体   繁体   中英

Changing font and/or margin in RStudio -> RMarkdown -> YAML -> knitr -> pandoc -> LaTex -> PDF

Can someone give me an example of a YAML header that successfully passes command line args / options to pandoc? The documentation and examples I've found, indicate that I can do this by setting the margin in the YAML header for an PDF output file with: geometry: margin=0.5in . But I can't seem to get it to work.

After much trial an error, I was able to get the following to work

output:
  pdf_document:
    keep_tex: yes
    latex_engine: xelatex
  word_document: default
  html_document: default
geometry: margin=0.5in 
mainfont: Arial
fontsize: 12pt

But with these caveats:

  • The geometry and mainfont tags must be at the top level of the YAML options, even though they only apply to the PDF_document type of output.
  • The mainfont: Arial tag only seems to work with the xelatex engine. I was not able to find a list of valid font names, but just lucked out with Arial
  • The fontsize only seems to work on the included tables, not the main text.

If anyone can point me to a more definitive description of what YAML header option gets passed to Pandoc and LaTex, I'd appreciate it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM