Changing font in PDF produced by rmarkdown

前端 未结 2 1319
死守一世寂寞
死守一世寂寞 2020-12-04 13:14

I am producing reports using rmarkdown. When knitting a PDF

---
title: \"Untitled\"
output: pdf_document
---

I would like to specify the fo

2条回答
  •  醉酒成梦
    2020-12-04 13:53

    The indentation in YAML options is meaningful. As the instructions point out "note that these options do not appear underneath the output section but rather appear at the top level along with title, author, etc.)". So,

    ---
    output:
      pdf_document:
        latex_engine: xelatex
        sansfont: Calibri Light
    ---
    

    will produce an unused argument error, while

    ---
    output:
      pdf_document:
        latex_engine: xelatex
    sansfont: Calibri Light
    ---
    

    will do the job. In addition, LaTeX commands inserted after YAML seem to override it: so

    ---
    output:
      pdf_document:
        latex_engine: xelatex
        sansfont: Calibri Light
    ---
    \fontsize{12}{22}
    \fontseries{b}
    \selectfont
    

    produces the PDF with default font, not Calibri, however, the font option is passed fine.

提交回复
热议问题