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.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…