Rmarkdownファイルで使用するパッケージと設定を含む長い.txtファイルがあります。また、R計算の出力に基づいて、ヘッダーにステートメントを追加したいと考えています。この特定のケースでは、私はこのように、別のディレクトリに配置されてtitlegraphicを追加したい:の一つだけならばRmarkdownとknitrのin_headerとheader_includesの両方を使用
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")`}}
:
working directory
|--- reports
|----| my_report.Rmd
|--- www
|----| image.png
のでRmarkdownファイルのヘッダーは次のようになります。ステートメントが含まれていれば(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