Changing font in PDF produced by rmarkdown

前端 未结 2 1207
死守一世寂寞
死守一世寂寞 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.

    0 讨论(0)
  • 2020-12-04 14:08

    Just a quick example. add these lines to your RMD main text area and see the effects.

    \fontfamily{cmr}
    \fontsize{12}{22}
    \fontseries{b}
    \selectfont
    

    Hope this may help

    0 讨论(0)
提交回复
热议问题