exams::tex2image 编译失败,没有日志

问题描述 投票:0回答:1

我正在尝试编译一个 R Markdown 文件,该文件使用 exam::tex2image 从 Latex 方程式生成图像。

不幸的是,编译失败,错误消息说一个不存在的日志文件。

源代码:

---
output: 
  pdf_document:
    keep_tex: true
---

```{r 2sls, echo=FALSE, results="hide"}
exams::tex2image("2+2=4")
```

标准输出:

❯ R -e "options(tinytex.verbose = TRUE);rmarkdown::render('README.Rmd', clean=F)"
> options(tinytex.verbose = TRUE);rmarkdown::render('README.Rmd', clean=F)


processing file: README.Rmd
  |..........................................                     |  67% (2sls)This is pdfTeX, Version 3.141592653-2.6-1.40.25 (TeX Live 2023/Arch Linux) (preloaded format=pdflatex)
 restricted \write18 enabled.
entering extended mode
Quitting from lines 8-9 (README.Rmd) 
Error: LaTeX failed to compile tex2image.tex. See https://yihui.org/tinytex/r/#debugging for debugging tips. See tex2image.log for more info.
                                                                                                 
Execution halted
r latex r-markdown r-exams tinytex
1个回答
0
投票

你的代码对我来说工作正常(使用 TeX Live 2022/Debian)所以它可能是你的 LaTeX 设置中的某些东西导致了问题,可能是缺少样式文件或类似的东西。

为了调试问题,我会以交互方式运行示例并为临时目录设置

tdir
参数:

exams::tex2image("2 + 2 = 4", tdir = "/path/to/tempdir/")

注意之前临时目录要为空。然后

tex2image()
将在临时目录中创建一个临时LaTeX文件,然后在其上运行
tinytex::latexmk()
(或
tools::texi2dvi()
)。如果有问题,您也可以手动运行 LaTeX 以生成 .log 文件或应用其他调试策略。

© www.soinside.com 2019 - 2024. All rights reserved.