changing rmarkdown "table of contents" default title - r

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!

Related

How to have `pkgdown` use figure numbers and cross-references in vignettes?

I've created several vignettes for a package, with figures I want to reference in the text.
Using the template for a .Rmd vignette, I can do this by using bookdown::html_document2 as follows in my yaml header:
output:
bookdown::html_document2:
base_format: rmarkdown::html_vignette
fig_caption: yes
toc: true
Yet, when I build the associated pkgdown site, I don't get figure numbers or cross-references,
done with \#ref(fig:chunk_name).
Is there some magic I can add to my _pkgdown.yml file to have it use the bookdown output format?
Edit: Not sure if this has anything to do with this issue, but my figure chunk labels are of the form topic-figure rather than topic_figure.
E.g.,
```{r, plastic1-HE3D}
#| echo=FALSE,
#| fig.cap="3D HE plot for the plastic MLM"
knitr::include_graphics("fig/plastic-HE3D.png")
```
A solution that seems to work is suggested in https://github.com/r-lib/pkgdown/issues/2201
Essentially, add pkgdown: as_is: true to the yaml headers of vitnettes:
output:
bookdown::html_document2:
base_format: rmarkdown::html_vignette
fig_caption: yes
toc: true
toc_depth: 2
pkgdown:
as_is: true

How to set position of list of figure (lof) in R bookdown YAML

I have a R bookdown whose YAML looks like this:
---
title: "My title"
toc: False
lof: True
author: "the author"
output:
bookdown::pdf_document2:
keep_tex: yes
---
By default it generates a pdf file with the list of figures at the beginning just after the title.
Is there a way to have this list at the end, after the references?
Remove lof: True and add \listoffigures after your references.

How to reference sections in rmarkdown with pdf output

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.

Why my r-markdown docx output "reference_docx: headingfive.docx" did not work?

R shows this:
Warning: Error in : pandoc document conversion failed with error 1
[No stack trace available]
output:
word_document:
fig_caption: yes
toc: true
toc_depth: 2
reference_docx: headingfive.docx
It should be fig_caption: true, not fig_caption: yes.
---
output:
word_document:
fig_caption: true
toc: true
toc_depth: 2
reference_docx: headingfive.docx
---
The aruments that word_document accepts can be seen by checking ?rmarkdown::word_document. This help page says that fig_caption is logical.
EDIT(based on your comment):
It seems that the flie "headingfive.docx" does not exist or you're in the wrong directory.
If you dont have the file yet you can check out these two links to see how its created:
https://www.r-bloggers.com/r-markdown-how-to-insert-page-breaks-in-a-ms-word-document/
How to add a page break in word document generated by RStudio & markdown
Finally youll have to make sure that the file "headingfive.docx" is in R's working directory(at least that's where it needs to be on Ubuntu).

How to change table of content header in knitr?

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.

Resources