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

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

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时,会出现错误:

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

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

最小示例:

  1. ---
  2. output:
  3. bookdown::pdf_document2:
  4. # will be generated by includes s
  5. toc: no
  6. fig_align: center
  7. fig_height: 4
  8. fig_width: 6
  9. latex_engine: xelatex
  10. keep_tex: true
  11. includes:
  12. in_header: pre.sty
  13. fontsize: 11pt
  14. ---
  15. 最小示例1 - `pre.sty`存储在与rmarkdown文件相同的目录中时,此示例有效。

最小示例:

  1. ---
  2. output:
  3. bookdown::pdf_document2:
  4. # will be generated by includes s
  5. toc: no
  6. fig_align: center
  7. fig_height: 4
  8. fig_width: 6
  9. latex_engine: xelatex
  10. keep_tex: true
  11. includes:
  12. in_header: etc\pre.sty
  13. fontsize: 11pt
  14. ---
  15. 最小示例2 - `pre.sty`存储在`etc`子目录中时,此示例无效。

pre.sty文件的内容:

  1. \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:

  1. File etc\pre.sty not found in resource path
  2. Error: pandoc document conversion failed with error 99
  3. 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:

  1. ---
  2. output:
  3. bookdown::pdf_document2:
  4. # will be generated by includes s
  5. toc: no
  6. fig_align: center
  7. fig_height: 4
  8. fig_width: 6
  9. latex_engine: xelatex
  10. keep_tex: true
  11. includes:
  12. in_header: pre.sty
  13. fontsize: 11pt
  14. ---
  15. Min example 1 - this works when pre.sty is stored in same dir as rmarkdown.

Minimal example:

  1. ---
  2. output:
  3. bookdown::pdf_document2:
  4. # will be generated by includes s
  5. toc: no
  6. fig_align: center
  7. fig_height: 4
  8. fig_width: 6
  9. latex_engine: xelatex
  10. keep_tex: true
  11. includes:
  12. in_header: etc\pre.sty
  13. fontsize: 11pt
  14. ---
  15. Min example 2 - this does not work when pre.sty is stored in the etc subdir.

Contents of pre.sty

  1. \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:

确定