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.
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 bookdown to render a PDF book using the documentclass "scrreprt" from koma script. This works so far, however the book is in German
and the table of contents has a title "Contents" instead of a german "Inhaltsverzeichnis".
The "header" of my index.rmd:
---
title: "Mein Buchtitel"
author: "Jens Laufer"
date: "`r Sys.Date()`"
documentclass: scrreprt
---
The output of table of contents looks like this:
I tried also to add a preamble.tex in index.Rmd:
---
title: "Mein Buchtitel"
author: "Jens Laufer"
date: "`r Sys.Date()`"
documentclass: scrreprt
output:
bookdown::pdf_book:
includes:
in_header: preamble.tex
---
preamble.tex
\renewcommand{\contentsname}{Inhaltsverzeichnis}
However this doesn't help.
Any ideas? Thanks!
You can set the variable toc-title in the YAML metadata, e.g.,
toc-title: "Table of Contents"
See the Pandoc Manual for more info: https://pandoc.org/MANUAL.html
I could fix the problem by changing the preamble.tex to this:
\usepackage[ngerman]{babel}
\selectlanguage{ngerman}
I am using RMarkdown to write my MSc thesis, in a language different than English. The thesis shall be rendered in .docx format. Reading around SO, I found that it is possible to provide some pandoc arguments among which toc-title could address my issue. Nevertheless I was not able to do it. My current YAML header is:
output:
word_document:
reference_docx: stile_tesi.docx
toc: yes
fig_caption: true
#pandoc_args: [
# "--toc-title", "INDICE"
#]
Thanks in advance
---
title: "Untitled"
output:
word_document:
toc: yes
toc-title: "INDICE"
---
Important: Watch out the correct indention!
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.
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