【问题标题】:Issues with figures when rendering rmarkdown/bookdown to pdf将 rmarkdown/bookdown 渲染为 pdf 时的数字问题
【发布时间】:2022-07-27 18:40:29
【问题描述】:

在过去 3 天里,RMarkdown 发生了一些事情。将 RStudio 生成的默认 .rmd 文件渲染为 PDF 文件时,创建的绘图在绘图轴之外没有边距,并且轴比例和标题不可见。渲染为 .html 或 Word 格式时,数字应为应有的样子。今天我重新安装了 R 和 RStudio 并更新了所有的库(update.packages()),问题仍然存在。这首先出现在一个 bookdown 项目中,所以我检查了 bookdown 生成的 .png 文件,它们都有相同的问题 - 没有轴比例或标题,并且轴边距在数字范围内。

更新:我卸载/重新安装了 miktex 并且正确编译了 pdf。当我删除 MikTex 并改用 tinytex 时,轴再次被切断。如果我使用 MikTex 而不是 tinytex,每个 rmarkdown 块都会生成一个错误,即 MikTex 数据库被另一个程序锁定(没有其他应用程序正在运行,所以它很可能在后台运行)并导致大约 1-2 分钟的延迟和总编译时间接近 45 分钟(在这个问题之前大约是 5 分钟,仍然很慢)。因此,tinytex 及其生成 .png 文件的方式似乎存在问题。我不知所措。 有什么想法吗?

当前版本

R $version.string
[1] "R version 4.1.3 (2022-03-10)"
RStudio version
[1] ‘2022.2.1.461’

【问题讨论】:

    标签: pdf r-markdown figure


    【解决方案1】:

    没有回答,但确认

    figure_latex 文件夹中的 PDF 图像文件也缺少我的轴/标题
    在我重新安装 tinytex 后不久发生(没有安装 miktex,直接从 R 渲染)

    rmarkdown::render("test.Rmd",output_format='pdf_document')

    在jaml中
    输出:
    pdf_document:
    keep_tex: 真

    plot(1:10,xlab='as 1',ylab='as 2')
    

    运行它:

    "C:/PROGRA~1/Pandoc/pandoc" +RTS -K512m -RTS test.knit.md --to latex --from markdown+autolink_bare_uris+tex_math_single_backslash --output test.tex --lua-filter " C:\Users...\R\rmarkdown\rmarkdown\lua\pagebreak.lua" --lua-filter "C:\Users...\R\rmarkdown\rmarkdown\lua\latex-div.lua" --自包含 --highlight-style tango --pdf-engine pdflatex --variable graphics --variable "geometry:margin=1in"

    html 工作正常

    【讨论】:

      猜你喜欢
      • 2021-05-25
      • 1970-01-01
      • 2022-01-01
      • 2020-11-12
      • 2018-11-30
      • 1970-01-01
      • 1970-01-01
      • 2021-11-20
      • 2018-08-21
      相关资源
      最近更新 更多