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'm not getting a pdf output from my rnotebook.
My header in my "index.Rmd" is:
---
title: "some title"
author: "me"
date: "`r Sys.Date()`"
site: bookdown::bookdown_site
documentclass: book
bibliography: [book.bib, packages.bib]
biblio-style: apalike
link-citations: yes
description: "Notes on a Leasing Company busines risk and opportunities."
---
I'm rendering the book in the console with the following code:
bookdown::render_book("index.rmd", output_format = "bookdown::pdf_book")
Output is:
Error: Functions that produce HTML output found in document targeting latex output.
Please change the output type of this document to HTML. Alternatively, you can allow
HTML output in non-HTML formats by adding this option to the YAML front-matter of
your rmarkdown file:
always_allow_html: yes
Note however that the HTML output will not be visible in non-HTML formats.
How do I go about changing the output type?
My file "_output.yml" file is:
toc:
before: |
<li>A Minimal Book Example</li>
after: |
<li>Published with bookdown</li>
download: ["pdf", "epub"]
bookdown::pdf_book:
includes:
in_header: preamble.tex
latex_engine: xelatex
citation_package: natbib
keep_tex: yes
bookdown::epub_book: default
R gurus,
I am struggling to design a letterhead template in Rmarkdown for a massive mail merge project.
What I ideally need is something like following:
Question is if the header can be defined in YAML? The code might look something like following:
---
output:
pdf_document:
fig_caption: false
logo: logo.png
institute: UNIVERSITY OF CALIFORNIA
name: Prof. Jones
address: Mathematics Search Committee
Department of Mathematics
University of California
Berkeley, California 12345
email: pj#uc.ac
latex_engine: pdflatex
fontfamily: mathpazo
fontsize: 11pt
# spacing: double
endnote: no
---
---
title: "Prof. Jones \nDepartment \nUniversity \nState \nEmail"
output: pdf_document
editor_options:
chunk_output_type: console
header-includes:
- \usepackage{titling}
- \usepackage{graphicx}
- \usepackage{fancyhdr}
- \pagestyle{fancy}
- \pretitle{\begin{flushright}\LARGE\includegraphics[width=8cm]{logo.jpg}\\[\bigskipamount]}
- \posttitle{\end{flushright}}
---
Add your logo to where it has {logo.jpg} and the width might need altering as well.
Bit of a workaround using double space and \n to add a line break to the heading to create the address.
flushright right aligns the logo and title then.
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.
I'm trying to follow this pandoc example to add multiple authors to an Rmarkdown file in the yaml metadata block. The pdf will generate in RStudio (Version 0.98.932), but there is no author information.
---
title: 'This is the title: it contains a colon'
author:
- name: Author One
affiliation: University of Somewhere
- name: Author Two
affiliation: University of Nowhere
date: "`r format(Sys.time(), '%d %B %Y')`"
tags: [nothing, nothingness]
abstract: |
This is the abstract.
It consists of two paragraphs.
output: pdf_document
---
I'd also like to customize the heading a bit more and add a subtitle. Possible?
I just found out that it is possible to add subtitles to R markdown PDF output. I am using R 3.2.2 and RStudio 0.99.473 in Ubuntu 14.04.
---
title: 'This is the title: it contains a colon'
subtitle: 'This is the subtitle'
output: pdf_document
---
The default latex template in rmarkdown does not support author affiliations or subtitles. It does support multiple authors however, the correct yaml syntax is
---
title: 'This is the title: it contains a colon'
author:
- Author One
- Author Two
date: "`r format(Sys.time(), '%d %B %Y')`"
tags: [nothing, nothingness]
abstract: |
This is the abstract.
It consists of two paragraphs.
output:
pdf_document:
template: NULL
---
If you want to customize your header, the best approach is to modify the latex template, found here to suit your needs. Then copy it to your local directory and pass it to the header in the template field.
As explained in the main answer, the default R Markdown template does not support author affiliations. While users can edit the template file to add their own custom YAML fields, there are easier some workarounds you can use for PDF or HTML outputs.
HTML Outputs
You can use the recently released radix template. First you must install the package:
install.packages("radix")
Once installed, you must set the
---
title: "Radix for R Markdown"
description: |
Scientific and technical writing, native to the web
date: May 4, 2018
author:
- name: "JJ Allaire"
url: https://github.com/jjallaire
affiliation: RStudio
affiliation_url: https://www.rstudio.com
- name: "Rich Iannone"
url: https://github.com/rich-iannone
affiliation: RStudio
affiliation_url: https://www.rstudio.com
output: radix::radix_article
---
Your content
PDF Outputs
You can use premade templates, and there are some good examples within the rticles package. First we must install the package:
install.packages("rticles")
Once Installed, you can use one of the templates, such as the Journal of Statistical Software:
---
author:
- name: FirstName LastName
affiliation: University/Company
address: >
First line
Second line
email: \email{name#company.com}
url: http://rstudio.com
- name: Second Author
affiliation: Affiliation
title:
formatted: "A Capitalized Title: Something about a Package \\pkg{foo}"
# If you use tex in the formatted title, also supply version without
plain: "A Capitalized Title: Something about a Package foo"
# For running headers, if needed
short: "\\pkg{foo}: A Capitalized Title"
abstract: >
The abstract of the article.
keywords:
# at least one keyword must be supplied
formatted: [keywords, not capitalized, "\\proglang{Java}"]
plain: [keywords, not capitalized, Java]
preamble: >
\usepackage{amsmath}
output: rticles::jss_article
---
If you render a pdf, LaTex use authors' footnote for affiliations (i.e. converting numbering in symbles). Try
---
title: 'This is the title: it contains a colon'
subtitle: 'This is the subtitle'
author:
- Author One^[University of Somewhere]
- Author Two^[University of Nowhere]
date: "`r format(Sys.time(), '%d %B %Y')`"
tags: [nothing, nothingness]
abstract: |
This is the abstract.
It consists of two paragraphs.
output: pdf_document
---
I've found a solution to your subtitle part of the question here: https://stackoverflow.com/a/41444545/14027216
You can add subtitle by adding subtitle: to your code and multiple subtitles can be added as follow:
---
title: 'This is the title: it contains a colon'
subtitle: |
| 'subtitle 1'
| 'subtitle 2'
author:
- name: Author One
affiliation: University of Somewhere
- name: Author Two
affiliation: University of Nowhere
date: "`r format(Sys.time(), '%d %B %Y')`"
tags: [nothing, nothingness]
abstract: |
This is the abstract.
It consists of two paragraphs.
output: pdf_document
---
You can add more than two subtitles, but I don't know the maximum amount. Each subtitle will be displayed in new line.
I've also had this problem. Following the suggestion from #tmpname12345 I modified the latex template (default.tex) and the html template (default.html) to render subtitles. This pull request is on github rstudio/rmarkdown if you want the code quickly, and looks like it will be standard in rmarkdown next time they push to CRAN.
Add to the answer by Ze Grisi, i just discovered adding html heading tags into the yaml works to adjust the font in the title and subtitle. Note the quotation marks are no longer needed.
---
title: 'This is the title: it contains a colon'
subtitle: <h1>This is the subtitle</h1>
output: pdf_document
---
For a more dramatic effect add an underline to the subtitle
---
title: 'This is the title: it contains a colon'
subtitle: <h1><u>This is the subtitle</u></h1>
output: pdf_document
---
Using a solution for latex here enter link description here by #greg. I put the latex code into rmarkdown yaml header with some changes and it does the job.
---
title: 'Some Title'
author: Author One$^1$ \and
Author Two$^2$ \and
Author Three$^3$
date: $^1$Organization 1 \newline
$^2$Organization 2 \newline
$^3$Organization 3
\newline
\newline
\today
output:
---
The trick is to put the affiliations into date tag.