I'm running R 4.1 on LSAF 5.4 by SAS Institute. LSAF is a locked down environment, there's no internet access, Latex is limited to the styles that can be installed using the TinyTex pre-built package (cf. Recommended LaTeX packages - #2 by cderv).
LSAF cannot deal with .Rmd files natively. A workaround is to specify the RMarkdown code in one long string in an R program. The string can be processed by
knit(text = Rmd_code,output = mdFile)
The mdFile created this way can be processed using pandoc.
pandoc(mdFile, format=c('html','docx','pdf'))
So far, so good. But I'd also like to change the font in the PDF output to sans-serif. I've tried to include a YAML header but it isn't recognized:
---
output:
pdf_document:
latex_engine: xelatex
mainfont: Helvetica
---
I get no error messages but the output is also unaltered. Am I missing something?
What does work for the most part is to include some Latex in my RMarkdown code:
\selectfont
\sffamily
\renewcommand{\rmdefault}{phv}
The \sffamily
command should select sans-serif as the font but only works on the body of the text. \renewcommand{\rmdefault}{phv}
works for headers only. {phv}
selects the Helvetica font family (see Font typefaces - Overleaf, Online LaTeX Editor). Code junks still use the default font.
I'd prefer to be able to just specify a mainfont
and have that used throughout. Can anyone help me out?
A second related question, how can I determine which fonts are available from the pre-built TinyTex package? (I don't really like Helvetica!)