rmarkdown中的包含在子目录中的in_header文件中不起作用。

huangapple go评论53阅读模式
英文:

rmarkdown includes don't work when in_header files in subdir

问题

yaml内容中的in_header: pre.sty添加到文件时,只有当pre.sty存在于与rmarkdown文件相同的目录中时,文件才会按预期包含。然而,当将pre.sty移动到子目录并使用in_header: etc\pre.sty时,会出现错误:

在资源路径中找不到文件 etc\pre.sty
错误:pandoc文档转换失败,错误代码99
执行已停止

是否有一种方法可以包含存储在子目录中的标头文件,或者是否这似乎是一个错误?我尝试了不同的方法,但没有成功。

最小示例:

---
output: 
  bookdown::pdf_document2:
    # will be generated by includes s
    toc: no
    fig_align: center
    fig_height: 4
    fig_width: 6
    latex_engine: xelatex
    keep_tex: true
    includes:
      in_header: pre.sty
fontsize: 11pt
---

最小示例1 - 当`pre.sty`存储在与rmarkdown文件相同的目录中时,此示例有效。

最小示例:

---
output: 
  bookdown::pdf_document2:
    # will be generated by includes s
    toc: no
    fig_align: center
    fig_height: 4
    fig_width: 6
    latex_engine: xelatex
    keep_tex: true
    includes:
      in_header: etc\pre.sty
fontsize: 11pt
---

最小示例2 - 当`pre.sty`存储在`etc`子目录中时,此示例无效。

pre.sty文件的内容:

\usepackage{booktabs}
英文:

Adding in_header: pre.sty to the yaml content includes the file as expected when pre.sty exists in the same directory as the rmarkdown file. However, using in_header: etc\pre.sty along with moving pre.sty to a subdirectory fails with error:

File etc\pre.sty not found in resource path
Error: pandoc document conversion failed with error 99
Execution halted

is there a way to incorporate header files stored in subdirectories or does this appear to be a bug? I have attempted variations on the approach, but none have been successful.

Minimal example:

---
output: 
  bookdown::pdf_document2:
    # will be generated by includes s
    toc: no
    fig_align: center
    fig_height: 4
    fig_width: 6
    latex_engine: xelatex
    keep_tex: true
    includes:
      in_header: pre.sty
fontsize: 11pt
---

Min example 1 - this works when pre.sty is stored in same dir as rmarkdown.

Minimal example:

---
output: 
  bookdown::pdf_document2:
    # will be generated by includes s
    toc: no
    fig_align: center
    fig_height: 4
    fig_width: 6
    latex_engine: xelatex
    keep_tex: true
    includes:
      in_header: etc\pre.sty
fontsize: 11pt
---

Min example 2 - this does not work when pre.sty is stored in the etc subdir.

Contents of pre.sty

\usepackage{booktabs}

答案1

得分: 1

使用斜杠:etc/pre.sty

英文:

Use the forward slash: etc/pre.sty.

huangapple
  • 本文由 发表于 2023年2月14日 09:45:52
  • 转载请务必保留本文链接:https://go.coder-hub.com/75442757.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定