I have an Rmarkdown document which I'm outputting to Word and I'm trying to insert a company logo to the top of the page, above the header that includes the title and author.
I haven't found a solution to this. I've tried using pandoc_args to --include-in-header, but this wasn't successful. I'm not confident that I was using it correctly though.
Is it possible to include an image above the header?
---
title: "Untitled"
author: "r.bot"
date: "Thursday, January 1, 2015"
output:
word_document:
fig_caption: yes
fig_height: 5
fig_width: 5
reference_docx: template.docx
pandoc_args: [
"--include-in-header", "C:\\path\\to\\file.png"
]
---
This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see <http://rmarkdown.rstudio.com>.
This is possible using image headers in a Word template. In Word 2010 go: insert header -> image and add the image of choice. Save this document as template_image.docx in the same folder as the .Rmd file.
Then, in the YAML header:
---
title: "Untitled"
author: "Simon"
date: "Thursday, May 21, 2015"
output:
word_document:
fig_caption: yes
fig_height: 5
fig_width: 5
reference_docx: template_image.docx
---
Knit the .Rmd file and the output should include the image.
Related
How do I use \label and \ref to link sections in rmarkdown when outputting to pdf please. I have tried various permutations from https://bookdown.org/yihui/bookdown/cross-references.html and https://bookdown.org/yihui/rmarkdown-cookbook/cross-ref.html with no success.
One attempt
---
title: "Untitled"
output: pdf_document
---
See Section \#ref(sec:label).
# Section One (\#sec:label)
which gives
You can modify your document as follows:
---
title: "Untitled 1"
date: "28 de junio de 2020"
link-citations: yes
output:
pdf_document:
includes:
keep_tex: yes
number_sections: yes
toc_depth: 2
---
\section{This is the first section} \label{section1}
You will be some in \ref{section1}
Then you can see how numbers appear, just add \label{} to your sections and use \ref{} to call. Also, I suggest using \section{}, and modify YAML as I included. Hoping this can help.
I am using below code to add a company logo in r markdown in a pdf version and
the output is fine.
I need to add 2 logo's on each page - one for my client and other for our
company.
Is is possible to add 2 logo's in a pdf using r markdown.
---
title: "Complaints Text Model"
author: "ANALYTICS TEAM"
date: '`r format(Sys.Date(), "%B %d, %Y")`'
output:
pdf_document:
toc: yes
header-includes:
- \usepackage{fancyhdr}
always_allow_html: yes
---
\addtolength{\headheight}{1.0cm}
\pagestyle{fancyplain}
\rhead{\includegraphics[height=1.2cm]{D:/D Drive Data/Shivi/R Project/my company.png}}
\renewcommand{\headrulewidth}{0pt}
One can be on one side of the page and other logo on the other side.
All you need to do is imitate your syntax for the left header:
\rhead{\includegraphics[height=1.2cm]{D:/D Drive Data/Shivi/R Project/my company.png}}
\lhead{\includegraphics[height=1.2cm]{D:/D Drive Data/Shivi/R Project/client.png}}
I can't get ioslides to render latex equation. A simple example is:
---
title: "Title"
author: "Author"
date: "Tuesday, November 03, 2015"
output: ioslides_presentation
runtime: shiny
---
## slide 1
$\sum_{i=1}^n X_i$
The equation is rendered as \(\sum_{i=1}^n X_i\
Note that I'm able to get the proper rendering if I create the file as RPresentation but not as ioslides.
ioslides needs to know that it has to use mathjax
---
title: "Title"
author: "Author"
date: "Tuesday, November 03, 2015"
output:
ioslides_presentation:
mathjax: "http://example.com/mathjax/MathJax.js?config=TeX-AMS-MML_HTMLorMML"
runtime: shiny
---
## slide 1
$\sum_{i=1}^n X_i$
The equation is rendered as \(\sum_{i=1}^n X_i\
So it turned out I needed to change the reference to MathJax in the deck header to:
output:
ioslides_presentation:
mathjax: "http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"
Note that I previously had the following reference to MathJax (which did not work):
output:
ioslides_presentation:
mathjax: "http://example.com/mathjax/MathJax.js?config=TeX-AMS-MML_HTMLorMML"
I am using the following options to produce a pdf document with knitr:
---
title: "Test"
author: "Paulo Miramor"
date: "13-07-2015"
output: pdf_document
toc: yes
---
I would like to change the header of the table of contents (which is "Contents"), since I am producing a document in Portuguese. Is there any way to customize it?
Thanks to #Molx and #Chris in the comments I could find a solution.
Solution 1
Add \renewcommand{\contentsname}{Índice} to the document so that the .Rmd header is:
---
title: "Test"
author: "Paulo Miramor"
date: "13-07-2015"
output: pdf_document
header-includes:
- \renewcommand{\contentsname}{Whatever}
toc: yes
---
With this solution the header is Whatever you put inside \contentsname argument.
Solution 2
Add lang: portuguese to the document so that the .Rmd header is:
---
title: "Test"
author: "Paulo Miramor"
date: "13-07-2015"
output: pdf_document
lang: portuguese
toc: yes
---
Using this solution the header was a translation of "Contents" to Portuguese. This should work if your TeX installation supports the language.
Is it possible to add an institution and logo to the YAML front matter in R markdown version 2?
I'm looking for something like this
---
title: "My report"
author: "me"
institution: "Swansea University"
logo: "logo.png"
output:
pdf_document:
toc: yes
---
The answer is to use a template file, but it needs a bit of tweaking for the logo bit:
---
title: "My report"
author: "me"
output:
pdf_document:
toc: yes
includes:
in_header: style.tex
---
Prepare the document "style.tex" in the same folder as your markdown file and make sure you have changed you working directory in R to this folder.
Add the following lines to your "style.tex" file:
\institute{My institute}
\pgfdeclareimage[width=2cm]{logo}{logo.png}
\usebackgroundtemplate{\pgfuseimage{logo}}
Thanks to:
Inserting logo into beamer presentation using R Markdown