Search code examples
rlatexr-markdownbeamer

Problem with using Google Font to produce beamer PDF


thank you for any friendly comments in advance.

I use xelatex engine to generate PDF of Beamer, the work environment is R Markdown and I specify the YAML as below:

---
title: Presentation for Research Planning - Literature Review and Academic Writing
subtitle: 
author: 
institute:
#titlegraphic: 
fontsize: 11pt
output:
 beamer_presentation:
    template: C:\Users\Desktop\R Files\svm-latex-beamer.tex
    keep_tex: true
    latex_engine: xelatex # pdflatex also works here
    dev: cairo_pdf # I typically comment this out  if latex_engine: pdflatex
    slide_level: 3
make149: true
mainfont: "Titillium Web"  # Try out some font options if xelatex
titlefont: "Palatino Linotype" # Try out some font options if xelatex
---

The template I use is downloaded from http://svmiller.com/blog/2019/08/r-markdown-template-beamer-presentations/

mainfont: "Titillium Web" This is what I downloaded from Google and installed.

titlefont: "Palatino Linotype" This is already in my system, so I don't need to install it. And this font works.

After installment and before I post here, I have checked that the new font is in my local system. I have updated my Tinytex package and restarted my computer as well. But still doesn't work, errors come up as:

! Package fontspec Error: The font "Titillium Web" cannot be found.

! kpathsea:make_tex: Invalid filename `Titillium Web', contains ' '

error: LaTeX failed to compile presentation_sample.tex. See https://yihui.org/tinytex/r/#debugging for debugging tips. See presentation_sample.log for more info.

I have no idea, but I really want to add some cool fonts to my slides! BTW, my R version is:

sessionInfo()

R version 3.6.3 (2020-02-29)

Platform: x86_64-w64-mingw32/x64 (64-bit)

Running under: Windows 10 x64 (build 18363)


Solution

  • if the font is correctly installed, your document should work fine. However you can work around the installation problem by placing TitilliumWeb-Regular.ttf into the same folder as your .rmd file and then call it via

    mainfont: "TitilliumWeb-Regular.ttf"  # Try out some font options if xelatex