7

I've been creating PDF reports via RMarkdown for a couple months now, but after installing MikTex, R and the rmarkdown and tidyverse packages on a new machine today, I received the following error message when attemping to knit a PDF:

"C:/PROGRA~2/Pandoc/pandoc" +RTS -K512m -RTS Test.utf8.md --to latex --from markdown+autolink_bare_uris+ascii_identifiers+tex_math_single_backslash --output test.pdf --template "C:\Users\drewm\Documents\R\win-library\3.4\rmarkdown\rmd\latex\default-1.17.0.2.tex" --highlight-style tango --latex-engine xelatex --variable graphics=yes --variable "geometry:margin=1in" 
! Undefined control sequence.
<argument> \LaTeX3 error: 
                           Erroneous variable \c__fontspec_shape_n_n_tl used!
 l.3806 \emfontdeclare{ \emshape, \eminnershape }

pandoc.exe: Error producing PDF
Error: pandoc document conversion failed with error 43
In addition: Warning message:
running command '"C:/PROGRA~2/Pandoc/pandoc" +RTS -K512m -RTS Test.utf8.md --to latex --from markdown+autolink_bare_uris+ascii_identifiers+tex_math_single_backslash --output test.pdf --template "C:\Users\drewm\Documents\R\win-library\3.4\rmarkdown\rmd\latex\default-1.17.0.2.tex" --highlight-style tango --latex-engine xelatex --variable graphics=yes --variable "geometry:margin=1in"' had status 43

I was able to recreate the error with the simple example below:

Test.R

library(rmarkdown)
library(knitr)

setwd(C:/something)

render("Test.rmd", output_format=pdf_document(latex_engine="xelatex"), output_file="test.pdf")

Test.Rmd

---
title: "Habits"
output:
  pdf_document:
    latex_engine: xelatex
---

Hello World!

I also see the error when I knit Test.Rmd directly in RStudio instead of using a separate .R file with render(). I also tried using the lualatex pdf engine and received the same error as above. I am able to generate PDFs using the RMarkdown PDF example built into RStudio.

This post on Sourceforge seems relevant, but not useful since the solution was to update the fontspec package and I'm already using an updated fontspec package.

Session Info

> sessionInfo()
R version 3.4.1 (2017-06-30)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 15063)

Matrix products: default

locale:
[1] LC_COLLATE=English_United States.1252 
[2] LC_CTYPE=English_United States.1252   
[3] LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C                          
[5] LC_TIME=English_United States.1252    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] knitr_1.17    rmarkdown_1.6

loaded via a namespace (and not attached):
 [1] compiler_3.4.1  backports_1.1.0 magrittr_1.5    rprojroot_1.2  
 [5] tools_3.4.1     htmltools_0.3.6 yaml_2.1.14     Rcpp_0.12.12   
 [9] stringi_1.1.5   stringr_1.2.0   digest_0.6.12   evaluate_0.10.1

Any help or advice is greatly appreciated!

Drew Monger
  • 111
  • 1
  • 7
  • I cannot reproduce this. However, you can use `render("Test.rmd", output_file="Text.tex")` and run run `xelatex` manually on the produced `Test.tex`. Does this reproduce the error? If yes, try to make a minimal example based on `Test.tex` and either post it here or over at the TeX/LaTeX stackexchange. – Ralf Stubner Sep 08 '17 at 06:14
  • Tried `latex_engine="pdflatex"` resp. `latex_engine: pdflatex`? – jay.sf Sep 08 '17 at 08:56
  • @jaySf, that worked for me. I should've tried that myself, but I was avoiding that solution because I need to select a specific font. – Drew Monger Sep 08 '17 at 10:55
  • @RalfStubner, your method produced the following files: https://drive.google.com/drive/folders/0ByceePgSfH6KbFFiX2RlLWVCR00?usp=sharing – Drew Monger Sep 08 '17 at 11:56
  • Where is the tex file for this? Was this really produced from `knitr`? The log file indicates `latex 2.09` mode (I do not remember the last time I encountered that ...) but no error as encountered above. – Ralf Stubner Sep 08 '17 at 12:03
  • Sorry, just uploaded the tex file. Those are the output files after running xelatex manually via command line. – Drew Monger Sep 08 '17 at 12:31

1 Answers1

4

The uninstall/reinstall of MikTex reverted several of the packages to outdated versions (it would be helpful if the MikTex installer prompted the user to update packages after installation). In this case, my fontspec package was reverted to 2.6a (see potential issue outlined in Sourceforge link above). After running MikTex Update to update all my installed packages. I was able to successfully produce the PDF output desired.

Drew Monger
  • 111
  • 1
  • 7