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
Related
I am creating a report in MS Word and am using a RMarkdown document. I have managed to use a reference.docx file where I adjusted the styles of titles, headers, text, and figure captions to my need. Now I would like to make sure some lines, paragraphs and pictures are kept together on the same page. Is there a way to do this?
Here's my sample code
---
title: "Test"
output:
word_document:
reference_docx: reference.docx
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
Here is some text.
### I Use This as Figure Caption Above the Figure
(Index, 2015=100, seasonally adjusted series)
![Source: World Bank](https://previews.123rf.com/images/lovjane/lovjane1610/lovjane161000009/64921112-hand-drawn-sun-with-face-and-eyes-alchemy-medieval-occult-mystic-symbol-of-sun-vector-illustration-.jpg){ width=10cm }
The last 3 lines are the ones I would like to be kept together in my MS-Word output file, i.e. Caption+(Comment)+Figure.
You can include certain properties in your style definitions - that's the best way. You'll want to test this in the Word environment to get a feel for how these work as they can be confusing.
For all paragraphs that should stay together on the same page (as long as the total length does not exceed the space available on the page):
Paragraph dialog box (P-dlg)/Line and Page Breaks tab (LPB-tab)/Keep with Next
In the Word object model corresponds to: Paragraph.KeepWithNext = true/false
For the last paragraph in this group, make sure to remove this property. This means a separate style for the last paragraph!
To force lines to stay together:
P-dlg/LPB-tab/Keep lines together
In the Word object model corresponds to: Paragraph.KeepTogether = true/false
The same commands will apply to any pictures formatted in-line with the text. You may want to define separate styles for pictures if they need special alignment or spacing.
For pictures with text-wrap formatting the trick to keeping them together with specific text is to lock the anchor to the Range of that text. This cannot be part of a style, however.
I'm sure this is already out there but I can't seem to find it. How can I change the font size and spacing for the title in an R markdown document compiled as a pdf?
Thanks!
I'm not sure exactly how you want the document to look, but here are some ways to control spacing and fontsize with Latex tags. In the rmd document below:
The initial \vspace{5cm} adds space above the first line of the title. \vspace{0.5cm} adds space between the two lines of the title.
\LARGE and \Large give different font sizes on different lines of the title.
| at the beginning of each line of the title allows a multi-line title.
If you want a separate cover page, \newpage at the beginning of the main document will start the main document text on a new page after the title page.
---
title: |
| \vspace{5cm} \LARGE My Title is really long and takes up several lines of text
| \vspace{0.5cm} \Large My Title is really long and takes up several lines of text
author: "eipi10"
date: "5/16/2017"
output: pdf_document
---
\newpage
Document text here.
For a smaller title section, the following may be helpful. It builds on eipi10's answer but with two modifications:
the vspace{} commands include negative values to shrink white space
the fontsize code uses the more cumbersome begin{} and end{} syntax because, with simpler code like \normalsize{}, I found extraneous braces appeared around the title, name, etc.
---
title: \vspace{-0.75cm} \begin{normalsize} My Title \end{normalsize} \vspace{-0.5cm}
author: \begin{normalsize} My Name \end{normalsize}
date: \begin{normalsize} 5/16/2017 \end{normalsize}
output: pdf_document
---
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.
This is my first questions on StackOverflow, so please let me know if I'm doing anything wrong.
I'm using R to generate a lot of very large PDF documents. My data is about 580,000 observations, and breaks down in to 32 categories with each category containing 70 answers to between 20 and 300 questions. Currently I use two for loops (I try to avoid for loops, but for creating these pdfs it was the only way that worked). The first goes through and creates a pdf for the category with a title page, then the second adds a page for each graph showing the results of that question. I'm using ggplot2 & the "pdf" function.
The script works great, creating 32 pdfs (one for each category) with a custom title page and pages for all the questions in that category. I would like to add a Table of Contents after the title page. I know how to add a page with labels and page numbers, but I need one that links to each question.
I've searched this site and Google, but haven't found any way to do this in R. This question: Adding a table of contents to PDF with R plots talks about using RPython. I've also come across sources mentioning "hyperref", LaTex, Pandoc, and Knitr. I know how to use Kintr in an Rmarkdown doc, but that doesn't work for what I'm trying to do. I'm not really sure how to work with any of the others, so solutions with using them went over my head.
Is there not a way to work with creating a Table of Contents or just hyperlinks to PDF pages inside R, without going to those other languages?
Have you tried just clicking on the section names in the table of contents? By default, these seem to be hyperlinked, although there isn't any colouration that hints at it.
To help you see what might be happening, add / change your YAML header to add the following:
output:
pdf_document:
keep_tex: true
toc: true
toc_depth: 3
That will get the intermediate .tex file kept. If you open that up after knitting, you should already see references to hyperref in it.
I then find my table of contents being defined as:
{
\hypersetup{linkcolor=black}
\setcounter{tocdepth}{3}
\tableofcontents
}
which produces a hyperlinked TOC, but with "black" hyperlinks!
If you want to change the colour and see them show up, you can open the tex file in RSudio and simply change the "black" to "blue" and have RStudio run "Compile PDF" and you should see them showing up.
If you want your page numbers hyperlinked rather than the description, add the following into your YAML:
header-includes:
- \hypersetup{linktocpage}
Share & Enjoy!
I just remembered I left this open and thought I'd go back and post how I ended up solving it, well sorta. Instead of an R script, I used a R Markdownfile to create a combined pdf, which included all sections with their subsequent questions as different levels. I was able to create a pdf for each section individually with a linked clickable Table of Contents including all of its questions(pages) and different header levels for title pages.
The key was pandoc.header, which allowed me to create the headers, which show in the TOC. I think neither the for loops, nor the ggplot, which was created for each page, is relevant. Here is an overview of the .rmd :
title:
author:
output:
pdf_document:
toc: true
```{r results = "asis", message=FALSE, warning=FALSE, echo=FALSE, fig.height = 11, fig.width = 8}
for(i in 1:length(categories){
pandoc.header(paste("Category ",category_num, ": ", category discription), level = 1)
category title page
for(i in 1:numberofquestions){
pandoc.header(paste("Question ",question_num, ": ", subtitle1), level = 2)
print(ggplot())
}}
```
The only inconvenient part is that each page must have a header to be linked to and I really didn't like the title pages having one, but it looks like I can manually edit that out with what dsz posted.
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