我有一个很长的.txt文件,其中包含要在Rmarkdown文件中使用的软件包和设置。我还想根据R计算的输出将语句添加到标题中。在这种特殊情况下,我想添加位于另一个目录中的标题图形,如下所示:
working directory
|--- reports
|----| my_report.Rmd
|--- www
|----| image.png
因此,Rmarkdown文件的标题如下所示:
output:
beamer_presentation:
keep_tex: true
includes:
in_header: header.txt
header-includes:
- \titlegraphic{\includegraphics[width=0.3\paperwidth]{`r paste0("dirname(getwd()),"image.png")`}}
如果仅包含其中一个语句(in_header或header-includes),则它们可以正常工作。但是当我同时使用它们时,header-includes的内容似乎被覆盖了。下面的文件中给出了一个示例,在检查生成的.tex文件时,我发现该文件\usepackage{fancyhdr}
位于标头中,但未提及`\ titlegraphic'表达式。
header.txt
\usepackage{fancyhdr}
例子.md
title: Example 1
output:
beamer_presentation:
keep_tex: true
includes:
in_header: header.txt
header-includes:
\titlegraphic{\includegraphics[width=0.3\paperwidth]{`r paste0("just_an_example_","logo.png")`}}
---
### This is a test
我认为您可以将所有内容放入header-includes
:
---
title: Example 1
output:
beamer_presentation:
keep_tex: true
header-includes:
- \titlegraphic{\includegraphics[width=0.3\paperwidth]{`r paste0("just_an_example_","logo.png")`}}
- \input{header.txt}
---
它行得通吗?我无法完全复制您的示例。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句