我已经构建了一个 for 循环来自动生成一系列 PDF 文件,但它说:
output file: test_chinese.knit.md
"C:/PROGRA~2/Pandoc/pandoc" +RTS -K512m -RTS test_chinese.utf8.md --to latex --from markdown+autolink_bare_uris+ascii_identifiers+tex_math_single_backslash --output 1TEST.tex --template "C:\Users\adminstor\Documents\R\win-library\3.4\rmarkdown\rmd\latex\default-1.17.0.2.tex" --highlight-style tango --pdf-engine pdflatex --variable graphics=yes --variable "geometry:margin=1in" --variable "compact-title:yes"
This is pdfTeX, Version 3.14159265-2.6-1.40.19 (MiKTeX 2.9.6650 64-bit)
entering extended mode
! Argument of \CJK@XX has an extra }.
<inserted text>
\par
l.30 breaklinks=true}
Error: Failed to compile 1TEST.tex. See 1TEST.log for more info.
In addition: Warning messages:
1: running command '"pdflatex" -halt-on-error -interaction=batchmode "1TEST.tex"' had status 1
2: running command '"pdflatex" -halt-on-error -interaction=batchmode "1TEST.tex"' had status 1
不得不提一下:.rmd 文件可以在没有 for 循环的情况下成功运行。
我构建的 for 循环是:
for (i in 1:5){
cat(i, '\n')
rmarkdown::render("test_chinese.Rmd",
encoding = 'UTF-8',
params = list(file_number = i),
output_file = paste0(i, "TEST.pdf"),
output_format = 'pdf_document')
}
由于我正在生成一个中文文件,所以 TeX 模板是带有 TinyTex 的 CTeX 模板。
这是我的会话信息():
> sessionInfo()
R version 3.4.4 (2018-03-15)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)
Matrix products: default
locale:
[1] LC_COLLATE=Chinese (Simplified)_China.936 LC_CTYPE=Chinese (Simplified)_China.936 LC_MONETARY=Chinese (Simplified)_China.936
[4] LC_NUMERIC=C LC_TIME=Chinese (Simplified)_China.936
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] rvest_0.3.2 xml2_1.2.0 knitr_1.20 rmarkdown_1.10
loaded via a namespace (and not attached):
[1] Rcpp_0.12.16 magrittr_1.5 devtools_1.13.6 R6_2.2.2 stringr_1.3.1 httr_1.3.1 highr_0.6 tools_3.4.4
[9] xfun_0.3 tinytex_0.8 postr_0.0.0 git2r_0.23.0 withr_2.1.2 selectr_0.4-1 htmltools_0.3.6 yaml_2.2.0
[17] rprojroot_1.3-2 digest_0.6.15 rsconnect_0.8.8 curl_3.2 memoise_1.1.0 evaluate_0.11 stringi_1.1.7 compiler_3.4.4
[25] rticles_0.5 backports_1.1.2
期待您的帮助!
感谢大家。