2
我有一個很長的.txt文件,其中包含我想在我的Rmarkdown文件中使用的包和設置。我還想根據R計算的輸出向報頭添加語句。在這種特殊情況下,我想補充一點,位於另一個目錄titlegraphic,像這樣:在Rmarkdown和knitr中使用in_header和header_includes
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),它們工作正常。但是當我同時使用它們時,標題包含的內容似乎被覆蓋。下面的文件給出了一個例子,在檢查生成的.tex文件時,我發現\usepackage{fancyhdr}
在標題中,但沒有提及'\ titlegraphic'表達式。
header.txt
\usepackage{fancyhdr}
example.Rmd
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