I am creating a presentation with Rstudio using knitr and I want to use the types of the slides to generate a table of contents slide in the beginning. So if I have the following code:
Some fun lecture
========================================================
author: some guy
date: in the future
Table of content slide
========================================================
Here I want the table of content based on the following slide types
Some stuff 1
========================================================
type:section
Some very important stuff
More detail on stuff 1
========================================================
type:subsection
Did not get enough of stuff 1!? Here is more :D
Stuff 2
========================================================
type:section
There are other kinds of stuff?
Prompt slide
========================================================
type:prompt
Do not display prompt or alert types in TOC
So basically I want a table of content slide after the title slide looking something like:
Some stuff 1
More detail on stuff 1
Stuff 2
Is this available by default or do I need some extra CSS style in the beginning to handle this?
To generate a table of contents, include a document header with the option "toc:true" at the beginning of the document. Level 1 headings are indicated by #, level 2 headings by ##, and so on. Below is an example . The "prompt" option is only relevant for R code chunks. R code chunks are not listed in the table of contents.
This will, however, only produce a html document. If you want a Latex-like presentation with individual slides, you can replace html_document with beamer_presentation. In the beamer presentation, only level 1 headings are listed in the table of contents.
---
title: "Sample Document"
author: "Author"
output:
html_document:
toc: true
---
# Some stuff 1
Some very important stuff
## More detail on stuff 1
Did not get enough of stuff 1!? Here is more :D
# Stuff 2
There are other kinds of stuff?
```{r, prompt=TRUE}
summary(iris[, "Sepal.Length"])
```
For more info on Beamer presentations in Rmarkdown, see http://rmarkdown.rstudio.com/beamer_presentation_format.html. A similar question has been answered here.
Related
I am trying to generate summaries of my data into PowerPoint presentations that would automatically generate my data into slides. I am having trouble creating multiple text blocks in Rmarkdown using a template PowerPoint presentation file.
---
title: "my title"
author: ""
date: '2022-03-24'
output:
powerpoint_presentation:
reference_doc: my_template5.pptx
slide_level: 1
always_use_html: true
---
I am able to get my title slide to work as i want by editing the master slide in my template, and when I knit rmarkdown, the result is as expected.
However, Rmarkdown PowerPoint only accepts either 2 columns, blank, or one column of content. Here is a list of the layouts that Rmarkdown accepts:
Title, Title and Content, Section Header, Two Content, Comparison, Content with Caption, and Blank
I am trying to create a single slide for each row of my dataframe (any given dataframe) that gives a summary. I want to divide this into multiple blocks as shown in the slide below
I cannot think of a way to go around these limitations with two columns of content in a slide. Any comments or guidance will be greatly appreciated
I am writing a beamer presentation in rmarkdown and converting it to pdf with knitr. I want to define sections at the header1 level, e.g. # Introduction, and then have a slide titled something else e.g. ## Introducing my brilliant research. Having the header1 level define sections is nice as the names of the sections can be displayed in the slide header in certain beamer themes, and this is why I include it.
But I do not want rmarkdown to insert a slide that simply says the name of the section between sections, which at the moment it is doing. Is there a way to not print a slide with the section name between sections? I thought slide_level would control this behavior but it does not seem to (or perhaps I am using it wrong).
A minimal reproducible example of my problem can be obtained with this code:
---
title: "Test Pres"
author: "Professor Genius Researcher"
date: "24 February 2017"
output:
beamer_presentation:
slide_level: 2
theme: "Singapore"
colortheme: "rose"
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = FALSE)
```
# Markdown Intro
## R Markdown
This is an R Markdown presentation. 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>.
When you click the **Knit** button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document.
# Using Bullets
## Slide with Bullets
- Bullet 1
- Bullet 2
- Bullet 3
# Including Chunks
## Slide with R Output
```{r cars, echo = TRUE}
summary(cars)
```
## Slide with Plot
```{r pressure}
plot(pressure)
```
At the moment, this code produces slides that say Markdown Intro, Using Bullets, and Including Chunks. I would like those slides labeling the sections omitted. Is this possible?
Create a new Latex template where you remove this part from the preamble:
\AtBeginSection[]
{
....
}
Place this latex template in the same folder as your .Rmd file and refer to it in the Rmd Yaml front matter using template: mytemplate.tex as explained here.
I'm creating a RMarkdown document that I want to export in MS Word with RStudio.
I want a table of contents and numbered headings. Here is my sample markdown document:
---
title: "Test"
author: "Ben"
date: "`r format(Sys.time(), '%d/%m/%Y')`"
output:
word_document:
toc: yes
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
# Header 1
## Header 2
## Header 2
### Header 3
This produces the following word doc:
That's a good start. Following this tutorial, I edited the heading styles of the output document in Word to make them numbered.
I also changed the Table of contents title heading so that it's based on normal text and not another heading, otherwise the table of contents title gets numbered as well.
I saved the modified document in a template folder and added it as reference in the markdown header:
---
title: "Test"
author: "Ben"
date: "`r format(Sys.time(), '%d/%m/%Y')`"
output:
word_document:
toc: yes
reference_docx: "../templates/word-styles-reference-01.docx"
---
Here is the output:
Now, I want a page break after my table of contents, so I followed this other tutorial and changed my Heading 6 so that it is white, very small, based on the normal style and adds a page break afterwards.
The new markdown file looks like this:
---
title: "Test"
author: "Ben"
date: "`r format(Sys.time(), '%d/%m/%Y')`"
output:
word_document:
toc: yes
reference_docx: "../templates/word-styles-reference-01.docx"
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
###### Page break after table of contents
# Header 1
## Header 2
## Header 2
### Header 3
And here is the output:
I now have my page break but the Heading 6 title is numbered by Word and thus my first title is numbered 2.
In the end, it's either:
a word question: how do I modify the style of Heading 6 so it's not numbered?
an R question: how can I add a page break without using word headings?
Following on from the Blockquote debate. I found the following solution:
R Markdown
add a block quote with a space
>
Word template
The block quote is formatted as Block Text style in Word.
Edit the Block Text style
small font (I use size 3)
change the paragraph settings
no space before/after
tick "page break before"
There is a few needs for you : first, page break AND unumbered title (see steps 3 & 4), then, maybe you want to adress the size of your titles (see bonus steps) and maybe there is a necessary last stuff to indicate to MS word (see steps 6). In every case, you should manage your word template properly for made a page-break with header 6 and I guess you've miss a step (I translate from the French interface of MS word, maybe there is a few differences in the English version) :
1) First, open your 'reference_docx' in MS word (which is, for you : "../templates/word-styles-reference-01.docx"). It's a good idea to save a copy of that by security.
2) Define a style for header 6 by right-clicking on it in the 'ribon of styles', then select 'modify'.
3) In the dedicated windows for indicate your 'header 6 style' (first case will be 'name : Title 6'), click on 'Format' button ==> then 'numbering' (or 'numbers') ==> then select 'none' ==> Then validate your choice.
4) In the same dedicated windows for modifying styles of 'title 6', click again on 'Format' ==> then on the 'paragraph' button ==> then the second tab named 'chaining' (or 'linking', in french 'enchaƮnement') ==> click on 'page break before' ==> then validate.
5) Validate your modifications and save your reference word document.
Try at this point to knit your rmardkown to a word output. In your Rmarkdown document, you should made your first notes page with this : ###### [and a space].
Note that if you properly manage your word_template, you gain access to the possibility of a page break with an unumbered title like that : "###### NOTES^[Page left empty.]", wich is better if your page break is a "notes-pages" and not a page-break. If your page-break is only a single 'note-page', you can't define a police-size of 1 for the title.
Bonus step : If you want ONLY a page-break without title, you should define a size of 1 for the police of the title 6. Indicate this in the first screen of 'modifying your title 6' (the one wich begin by 'name : Title 6', after you right-click on your title 6 and then 'modifying'). If you want a note page with a title like 'Notes', you can't define a police size of 1 for your page break.
If the 'title style 6' don't working for made an unumbered page-break, go in the final step (good luck).
5) It's sometimes necessary to go in the list-tools which is in the 'paragraph' ribbon (left to your 'styles ribon') and click on the symbol with a list of '1 / a / i' (the one for define a 'list of several levels') ==> then click on 'define a new list of several levels' ==>
define precisely every title(s) styles with this tools, by clicking on every number of titles at the left (1 to 6 cause you're working in rmarkdown so you had only 6 choices of titles), then click on 'plus' (or 'more') ==> then indicate precisely what you want for this title in the right-part of the 'list of several levels' panel (typically you want to 'restart the list' with every levels, and the page-break 'title 6' maybe need to adress that, you maybe want to center or made indentation for your titles at every steps of the list).
Congratulations, you are free for ms word for a while (except that your titles are in the microsoft blue, and you should write your title in black by playing with every single styles by clicking on 'modifying' for every of them, you should had the same police styles in most of your titles, etc.). Microsoft torture is so elaborate...
As suggested by Frost_Maggot in the comments,
Maybe try modifying a different style in Word that is shared with R
Markdown. If you are not using block quotes in your R markdown this
might relate to quote in the MS Word stylings?
This indeed works for me as I don't use the quote style in my document.
I am trying to add section slides to a beamer presentation written in rmarkdown using the latex command \section{}. However, it gets inserted between a \begin{frame} & \end{frame} automatically during the conversion, which causes the compilation to fail. Is there any way to stop this happening so that the section slide can be added without having to manually edit the tex file?
Here is my rmarkdown code:
---
title: "Beamer presentation"
output: beamer_presentation
---
\section{Section one}
which gets converted to:
\title{Beamer presentation}
\begin{document}
\frame{\titlepage}
\begin{frame}
\section{Section one}
\end{frame}
\end{document}
Slides and section slides are both defined by markdown headings, a series of # character at the beggining of a line, the number of # indicating the hierarchical level of the title.
By default [the level that defines frames] is the highest header level in the
hierarchy that is followed immediately by content, and not another
header, somewhere in the document.
All title of higher level than this one will become section titles.
From the rmarkdown documentation ; See also the pandoc documentation on slideshows.
For instance :
# Section title
## Frame title
Frame content
### Subtitle inside a frame
I am using rmarkdown to make beamer presentations in RStudio. I would want to get slide tickers on the top of presentation. Dresden theme should support those tickersDresden
So is it possible to get those tickers by using rmarkdown? When I knit pdf I get presentation without slide tickers.
Example code:
---
title: "Example"
output: beamer_presentation
theme: Dresden
---
# R Markdown
This is an R Markdown presentation. 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>.
When you click the **Knit** button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document.
# Slide with Bullets
- Bullet 1
- Bullet 2
- Bullet 3
# Slide with R Code and Output
```{r}
summary(cars)
```
# Slide with Plot
```{r, echo=FALSE}
plot(cars)
```
I think the slide_level option might be what you are looking for:
The slide_level option defines the heading level that defines individual slides. By default this is the highest header level in the hierarchy that is followed immediately by content, and not another header, somewhere in the document. This default can be overridden by specifying an explicit slide_level
documentation source
For example with the slide_level: 2:
---
title: "Example"
output:
beamer_presentation:
slide_level: 2
theme: Dresden
---
gives you the following output
However you need to provide a lower level of the heading for the slide title, e.g.
# R Markdown
## Description
This is an R Markdown presentation. 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>.
When you click the **Knit** button a document will be generated that
includes both content as well as the output of any embedded R code
chunks within the document.
Edit To get the output same as in the image you have attached, you section your presentation in the following way:
---
title: "Example"
output:
beamer_presentation:
slide_level: 3
theme: Dresden
---
# Section 1
## Subsection 1
### Title A
### Title B
## Subsection 2
### Title A
## Subsection 3
### Title A
### Title B
### Title C
# Section 2
## Subsection 1
### Title A
### Title B
and the following presentation heading is generated: