I want to breakdown the authors' names into two lines in Rmarkdown beamer presentation. My YAML is as follows:
---
title: "***"
author:
- Author One
- Author Two
date: "`r format(Sys.time(), '%d %B %Y')`"
fontsize: 14pt
output:
beamer_presentation:
fig_height: 5
fig_width: 8
highlight: tango
theme: metropolis
incremental: true
---
But still, the authors' names printed on the same line. How can I break into two?
If you use the TeX command \newline after the first author this will render on a second line.
---
title: "***"
author:
- Author One\newline
- Author Two
date: "`r format(Sys.time(), '%d %B %Y')`"
fontsize: 14pt
output:
beamer_presentation:
fig_height: 5
fig_width: 8
highlight: tango
theme: metropolis
incremental: true
---
Related
So I decided to convert my html R markdown file to a pdf knitr and I noticed that half my code output won't show. I replicated a small example here:
---
title: "Test"
author: "Brandon Morgan"
date: "1/19/2021"
output:
pdf_document:
df_print: paged
fig_caption: yes
fig_height: 6
fig_width: 7
highlight: tango
toc: yes
toc_depth: 4
html_document:
code_folding: hide
csl: biomed-central.csl
fig_caption: yes
fig_height: 6
number_sections: yes
theme: sandstone
toc: yes
toc_float: yes
---
# TEST
## Data
```{r}
data = iris
head(data)
```
Here's my html knitr output:
Here's my pdf knitr output:
Notice how head(data) does not show for pdf output
quick fix: remove df_print: paged. I can't tell you why it would not produce the result you want at the moment.
---
title: "Test"
author: "Brandon Morgan"
date: "1/19/2021"
output:
pdf_document:
fig_caption: yes
fig_height: 6
fig_width: 7
toc: yes
toc_depth: 4
html_document:
code_folding: hide
csl: biomed-central.csl
fig_caption: yes
fig_height: 6
number_sections: yes
theme: sandstone
toc: yes
toc_float: yes
---
# TEST
## Data
```{r echo=FALSE, results=TRUE}
data = iris
head(data)
```
I am working in a book, using R and the Tufte library.
I am using the following YAML for each .Rmd Chapter:
---
title: "Chapter 2: A First Linear Program"
header-includes:
\usepackage{longtable}
\usepackage{caption}
output:
tufte::tufte_handout:
citation_package: natbib
latex_engine: xelatex
highlight: monochrome
tufte::tufte_html: default
tufte::tufte_book:
citation_package: natbib
latex_engine: xelatex
---
\pagestyle{headings}
```{r setup, include=FALSE}
library(tufte)
library(tint)
library(knitr)
library(gridExtra)
knitr::opts_chunk$set(echo = TRUE)
knitr::opts_chunk$set(tidy = F)
knitr::opts_chunk$set(cache = TRUE)
knitr::opts_chunk$set(width = 30)
```
And the following one is the YAML for the index .Rmd file:
---
title: "Operations Research Using R<br />"
author: "Timothy R. Anderson"
date: "`r Sys.Date()`"
site: bookdown::bookdown_site
documentclass: book
bibliography: ["Master4Bookdowns.bib"]
---
# Preface {-}
I have tried different options like adding the sansfont and mainfont in YAML:
output:
tufte::tufte_handout:
citation_package: natbib
latex_engine: xelatex
highlight: monochrome
sansfont: Calibri Light
mainfont: Calibri Light
But it didn't change the font inside the chunk, only the text outside.
Here a simpler example document showing my attempt to change monofont as suggested in the comments:
---
title: "Chapter 2: A First Linear Program"
header-includes:
\usepackage{longtable}
\usepackage{caption}
output:
tufte::tufte_handout:
citation_package: natbib
latex_engine: xelatex
toc: TRUE
number_sections: true
highlight: monochrome
monofont: Times New Roman
tufte::tufte_html: default
tufte::tufte_book:
citation_package: natbib
latex_engine: xelatex
---
\pagestyle{headings}
```{r setup, include=FALSE}
library(tufte)
library(tint)
library(knitr)
library(gridExtra)
knitr::opts_chunk$set(echo = TRUE)
knitr::opts_chunk$set(tidy = F)
knitr::opts_chunk$set(cache = TRUE)
knitr::opts_chunk$set(width = 30)
```
This is an example, where we can see that text in the book is affected by the use of command
monofont: Times New Roman in the YAML. However, we can see that next chunk, the oucome when generating the tuffte_handout pdf is using a different font and also using multiple colors (no only black as in the main body).
```{r base_case_no_pipes_step_4}
model0d <- c("example", 6 + 2 <= 2000)
#fabrication
model0e <- c("example", 8 + 6 <= 2000)
#assembly
```
You have to bring the YAML headers to the right level:
monofont et al. are top-level headers
highlight is below the output format, not below output
The following example uses "Times New Roman" for the code block and XeLaTeX's default font (Latin Modern) for the main text. You can change that with mainfont. In addition, there is no syntax highlighting:
---
title: "Chapter 2: A First Linear Program"
header-includes:
- \usepackage{longtable}
- \usepackage{caption}
monofont: Times New Roman
output:
tufte::tufte_handout:
citation_package: natbib
latex_engine: xelatex
toc: TRUE
number_sections: true
highlight: monochrome
tufte::tufte_html: default
tufte::tufte_book:
citation_package: natbib
latex_engine: xelatex
---
\pagestyle{headings}
```{r setup, include=FALSE}
library(tufte)
library(tint)
library(knitr)
library(gridExtra)
knitr::opts_chunk$set(echo = TRUE)
knitr::opts_chunk$set(tidy = F)
knitr::opts_chunk$set(cache = TRUE)
knitr::opts_chunk$set(width = 30)
```
This is an example, where we can see that text in the book is affected by the use of command
monofont: Times New Roman in the YAML. However, we can see that next chunk, the oucome when generating the tuffte_handout pdf is using a different font and also using multiple colors (no only black as in the main body).
```{r base_case_no_pipes_step_4}
model0d <- c("example", 6 + 2 <= 2000)
#fabrication
model0e <- c("example", 8 + 6 <= 2000)
#assembly
```
Result:
Using bookdown to output a .pdf document the YAML within the index.Rmd looks like this currently:
---
title: "My title"
author:
- 'me'
output:
bookdown::pdf_document2:
includes:
in_header: latex/preamble.tex
keep_tex: yes
site: bookdown::bookdown_site
documentclass: book
geometry: "left=3.5cm, right=2.5cm, top=2.5cm, bottom=2.5cm"
fontsize: 12pt
linestretch: 1.5
bibliography: [packages.bib, referencias.bib]
linkcolor: NavyBlue
biblio-style: apalike
link-citations: yes
toc-depth: 2
lof: True
lot: True
---
How can I control fontsize and linestretch of code chunks independently from the main text? This answer provides a solution to control font size, but not line spacing.
It's is the same idea as here but now we just alter the source hook:
```{r setup, include=FALSE}
def.source.hook <- knitr::knit_hooks$get("source")
knitr::knit_hooks$set(source = function(x, options) {
x <- def.source.hook(x, options) # apply default source hook
ifelse(!is.null(options$linestretch), # if linestretch is not NULL, apply linestretch
paste0("\\linespread{", options$linestretch,"}\n", x, "\n\n\\linespread{1}"), # reset linestretch after the chunk!
x)
})
```
Now you can copy and paste the ifelse statement from the other answer into this hook as well and you can control both.
Full example:
---
title: "Linestretch"
date: "20 December 2018"
header-includes:
- \usepackage{lipsum}
output:
bookdown::pdf_document2:
keep_tex: true
linestretch: "`r (lstr <- 1.5)`"
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(eval = F)
def.source.hook <- knitr::knit_hooks$get("source")
knitr::knit_hooks$set(source = function(x, options) {
x <- def.source.hook(x, options)
x <- ifelse(!is.null(options$linestretch),
paste0("\\linespread{", options$linestretch,"}\n", x, "\n\n\\linespread{", lstr,"}"),
x)
ifelse(!is.null(options$size),
paste0("\\", options$size,"\n\n", x, "\n\n \\normalsize"),
x)
})
```
## R Markdown
\lipsum[30]
```{r, linestretch = 1, size="Large"}
head(mtcars)
head(mtcars)
```
\lipsum[30]
I am trying to make an R Markdown doc with tabs and a table of contents under each tab
Here is my header:
---
title: "Palliative/Comfort Care/Hospice Patients Report"
output:
html_document:
toc: true
toc_floating: true
theme: "cerulean"
date: "`r format(Sys.time(), '%B %d, %Y')`"
pdf_document: default
---
Followed by:
# {.tabset}
## tab1
## tab 2
I have seen people that are able to create an index based on the titles that you have on your R markdown document like in this picture
If somebody could let me know how would I have to modify this code so it creates that left index table?
---
title: "Untitled"
author: "Juan Lozano"
date: "October 19, 2018"
output: html_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
## Title 1
Text Text Text Text Text
```{r cars}
summary(cars)
```
## Title 2
Text Text Text Text Text
As #hrbrmstr 's link indicates there are many YAML customisations possible:
This is the sort of thing I usually use:
---
title: "Untitled"
author: "john Smith"
date: "today ;)"
output:
html_notebook:
fig_caption: yes
number_sections: yes
toc: yes
toc_float: yes
html_document:
fig_caption: yes
number_sections: yes
toc: yes
toc_float: yes
df_print: paged
bibliography: /path/to/library.bib
---