2017-07-25 3 views
2

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 

答えて

2

私はあなたが何ができるかを考える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} 
--- 

動作しますか?あなたの例を完全に再現することはできません。

関連する問題