【问题标题】:RMarkdown PDF "LaTeX3 error: Erroneous variable"RMarkdown PDF“LaTeX3 错误:错误变量”
【发布时间】:2017-09-07 22:09:17
【问题描述】:

几个月以来,我一直在通过 RMarkdown 创建 PDF 报告,但今天在新机器上安装 MikTex、R 以及 rmarkdown 和 tidyverse 软件包后,在尝试编写 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

我能够通过下面的简单示例重新创建错误:

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!

当我直接在 RStudio 中编织 Test.Rmd 而不是使用带有 render() 的单独 .R 文件时,我也看到了错误。我也尝试使用 lualatex pdf 引擎并收到与上述相同的错误。我可以使用 RStudio 中内置的 RMarkdown PDF 示例生成 PDF。

Sourceforge 上的This post 似乎相关,但没有用,因为解决方案是更新 fontspec 包,而我已经在使用更新的 fontspec 包。

会话信息

> 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

非常感谢任何帮助或建议!

【问题讨论】:

  • 我无法重现此内容。但是,您可以使用render("Test.rmd", output_file="Text.tex") 并在生成的Test.tex 上手动运行xelatex。这会重现错误吗?如果是,请尝试基于Test.tex 制作一个最小示例,然后将其发布在此处或在 TeX/LaTeX stackexchange 上。
  • 试过latex_engine="pdflatex" resp。 latex_engine: pdflatex?
  • @jaySf,这对我有用。我应该自己尝试过,但我避免使用该解决方案,因为我需要选择特定的字体。
  • @RalfStubner,您的方法生成了以下文件:drive.google.com/drive/folders/…
  • 这个的tex文件在哪里?这真的是由knitr 制作的吗?日志文件显示latex 2.09模式(我不记得我上次遇到那个......)但没有遇到上面的错误。

标签: r latex r-markdown xelatex


【解决方案1】:

MikTex 的卸载/重新安装将几个软件包恢复为过时版本(如果 MikTex 安装程序提示用户在安装后更新软件包会很有帮助)。在这种情况下,我的 fontspec 包已恢复为 2.6a(请参阅上面 Sourceforge 链接中概述的潜在问题)。运行 MikTex Update 以更新我所有已安装的软件包后。我能够成功生成所需的 PDF 输出。

【讨论】:

  • 删除并重新安装 MikTeX 也为我解决了这个问题。感谢您的提示!
猜你喜欢
  • 2014-11-05
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-10-27
  • 2017-05-27
  • 2014-10-12
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多