代码之家  ›  专栏  ›  技术社区  ›  Florian

使用in_header和header_includes in Rmarkdown和knitr

  •  8
  • Florian  · 技术社区  · 9 年前

    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")`}}
    

    标题包含的内容似乎被覆盖 下面的文件中给出了一个示例,在检查生成的.tex文件时,我发现 \usepackage{fancyhdr} 在标题中,但没有提到“\ titlegraphic”表达式。


    标题.txt

    \usepackage{fancyhdr}
    

    示例: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
    
    1 回复  |  直到 9 年前
        1
  •  15
  •   F. Privé    9 年前

    我想你能做的就是把一切都放进去 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}
    ---
    

    它有效吗?我不能完全复制你的例子。