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.
Is there a way to code this in the YAML section or need this to be done in a R chunk section?
To add an image in markdown you must stop text editing, and you do this with the command [Alt text] precedeed by a ! Then you have to add the path to the image in brackets. The path to the image is the path from your directory to the image.
To transform your markdown file into an HTML, PDF, or Word document, click the “Knit” icon that appears above your file in the scripts editor. A drop down menu will let you select the type of output that you want. When you click the button, rmarkdown will duplicate your text in the new file format.
To break a line in R Markdown and have it appear in your output, use two trailing spaces and then hit return .
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With