Insert a logo in upper right corner of R markdown pdf document

后端 未结 5 1493
挽巷
挽巷 2020-12-01 03:21

I am getting started with R markdown and I would like to create a new report having our company image logo.png in the upper right corner of each page.

I

5条回答
  •  一个人的身影
    2020-12-01 03:29

    You can use the includes option in the yaml to specify a custom addition to your latex header. The yaml part would look like

    ---
    output: 
        pdf_document:
          keep_tex: true
          includes:
              in_header: header.tex
    ---
    

    and you need to save a separate file called header.tex with the following defining your company logo like so:

    \usepackage{fancyhdr}
    \pagestyle{fancy}
    \rhead{\includegraphics[width = .05\textwidth]{logo.png}}
    

    Here I used the fancyhdr latex package to add the logo, but there are other potential solutions. See here for more options.

提交回复
热议问题