svmiller / stevetemplates

My collection of R Markdown templates, as an R package.
http://svmiller.com/stevetemplates
128 stars 22 forks source link

xelatex in beamer yaml #4

Closed ian-adams closed 3 years ago

ian-adams commented 3 years ago

For whatever reason, replacing the latex_engine: pdflatex with the xelatex option recommended in the template makes it so I can't knit the presentation.

However, if I change the yaml to the following structure (moving latex_engine out from under the output), it knits fine and with the appropriate font changes (I've commented out the original latex_engine call):


output: stevetemplates::beamer: keep_tex: TRUE

latex_engine: pdflatex # use xelatex here instead! I recommend it, but this is minimal reprex

dev: cairo_pdf # I typically comment this out  if latex_engine: pdflatex
slide_level: 3 # I prefer this, but I won't force it on you.
fig_width: 7
fig_height: 6
#toc: false

latex_engine: xelatex title: The Effect of Body-Worn Camera Activation and Review Policies on Perceived Fairness subtitle: Technology, Policy, and Organizational Justice author: Ian T. Adams date: "r paste0('JOB TALK LOCATION, ',format(Sys.time(), '%B %d, %Y'))" institute: University of Utah

titlegraphic: "img/public-affairs.png"

scaletg: .5 # Optional, proportional (0, 1) to paper width. Defaults to .3

fontsize: 10pt make149: TRUE mainfont: "Open Sans" # Try out some font options if xelatex titlefont: "Titillium Web" # Try out some font options if xelatex

specify color as six-digit RGB (no pound sign)

primarycolor: "CC0000" secondarycolor: "808080"

Not sure if this is a "me" problem, or if there's something else going on, but thought I'd drop a note on it.

svmiller commented 3 years ago

What error are you getting? Is it a LaTeX error or a Pandoc error or an R error?

ian-adams commented 3 years ago

Using the minimal example, and changing only the latex_engine...Upon knitting, it throws the following latex error:

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

! name = serif, rootname = serif, pointsize = 
! mktexmf: empty or non-existent rootfile!

! mktexmf: empty or non-existent rootfile!

! kpathsea: Running mktexmf serif.mf

! The command name is C:\Users\adams\AppData\Roaming\TinyTeX\bin\win32\mktexmf
! Cannot find serif.mf.

! Cannot find serif.mf.

! kpathsea: Running mktextfm serif

! The command name is C:\Users\adams\AppData\Roaming\TinyTeX\bin\win32\mktextfm

! kpathsea: Appending font creation commands to missfont.log.

Error: LaTeX failed to compile millerbeamertest.tex. See https://yihui.org/tinytex/r/#debugging for debugging tips. See millerbeamertest.log for more info.
In addition: Warning message:
package 'tibble' was built under R version 4.1.1 
Execution halted
svmiller commented 3 years ago

I encountered this in the morning when I saw your issue and ran the reprex myself. I think those errors are LaTeX's way of saying, given what's fed to it (e.g. my template), if you're using xelatex, you must supply something to mainfont: and titlefont: that it recognizes. This much will depend on what fonts you have installed, but even putting something super vanilla in those two fields (e.g. "Times New Roman") should be enough to compile.

ian-adams commented 3 years ago

Yup, that was it, thank you. Apparently "trillium web" wasn't installed, but reprex works smooth now. Thanks again for the work.