I am trying to generate pdf from rmarkdown file using xelatex as latex engine. The file generates pdf while using pdflatex as latex engine. But, if I use xelatex, the file is giving the following error.
`! LaTeX Error: Option clash for package fontspec.
Error: LaTeX failed to compile cvGeneration.tex. See https://yihui.org/tinytex/r/#debugging for debugging tips. See cvGeneration.log for more info. Execution halted`
When I checked the log file I got the following few lines only.
*`! LaTeX Error: Option clash for package fontspec. See the LaTeX manual or LaTeX Companion for explanation. Type H for immediate help. ...
l.65 ...Package[\eu@zf@math]{fontspec}[2008/08/09]
The package fontspec has already been loaded with options: [] There has now been an attempt to load it with options [no-math] Adding the global options: ,no-math to your \documentclass declaration may fix this. Try typing to proceed.`*
Can anyone tell me why this problem is generating particularly for xelatex? I am trying to implement xelatex, since it supports UTF-8 character. Thanks In advance.
My YAML header is given below:
params:
cvName: RJ MIMI
name: "`r params$cvName`"
address:
www:
phone:
email:
linkedin:
headcolor: "00008B"
date: "`r format(Sys.time(), '%B')`"
output:
vitae::hyndman:
keep_tex: true
latex_engine: xelatex
header_includes:
- \ExecuteBibliographyOptions{useprefix=true}
- renewcommand{\bibfont}{\normalfont\fontsize{10}{12.4}\sffamily}
This is pretty far down the road, however, the easiest way to get past the
fontspec
error is to setdefaultfontfeatures
. (fontspec
is the default in RMarkdown.)I don't have all that is going into your code here, update your
header_includes
to:This may still give you warnings because it's not right, but it works.