R markdown format title - pdf output - r

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
---

Related

Force the title and subtitle to appear on the same slide of a pptx output in Quarto R

I want to be able to create a PowerPoint output in R (using quarto, qmd) but I've been having some difficulties in the actual format of the powerpoint.
When I execute the following code:
---
title: "My presentation"
subtitle: "January 2023"
author: "Me"
format: pptx
reference-doc: template6.pptx
mainfont: Open Sans
sansfont: Open Sans
---
# Title
## Subtitle
I receive a pptx output with two separate slides, as shown:
What I am looking for is something like in the picture bellow:
A title, in a certain color (and larger size) and bellow a subtitle with another color (with a smaller size).
I've tried messing around with the template, but I didn't find anything close to it.
I know adding it manually would solve the problem, but I'm really adamant about keeping this process as most "automatic" as possible.
Can anyone help?
You can use the slide-level option in your document's YAML header.
So in your case, using:
---
title: "My presentation"
subtitle: "January 2023"
author: "Me"
format: pptx
reference-doc: template6.pptx
mainfont: Open Sans
sansfont: Open Sans
slide-level: 1
---
ensures that new slides are created when a heading is level 1 but not for any subheadings. Alternatively, you can turn off new slide creation via headings by using slide-level: 0 and create new slides manually using horizontal rules (e.g. using three dashes ---).
From the documentation:
slide-level
Specifies that headings with the specified level create slides.
Headings above this level in the hierarchy are used to divide the
slide show into sections; headings below this level create subheads
within a slide. Valid values are 0-6. If a slide level of 0 is
specified, slides will not be split automatically on headings, and
horizontal rules must be used to indicate slide boundaries. If a slide
level is not specified explicitly, the slide level will be set
automatically based on the contents of the document.

write multiple text blocks in powerpoint Rmarkdown

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

Is it possible to insert codes (e.g. `r Sys.Date()`) above bookdown gitbook table of content?

I'd like to include the title, author, and date (which I already specified in the YAML metadata) above the table of content of a bookdown::gitbook document. I want to do this because I'd like to have those three components always visible even when I scroll down. I know that we may add items before the TOC using the HTML tag <li>. However, I use `r Sys.Date()` to get the date in the YAML metadata, and when I use the same thing to insert above the TOC, it shows the literal code and not the date as I wanted. Moreover, the title & author of my document also use R markdown parameters like `r params$title` and `r params$author` (with params values that are passed by an Rscript that calls the render function), and they are also rendered as the literal code. So, I wonder if it is even possible to include code chunks above the TOC. If not, any ideas how I can get what I wanted to do?
This is more or less the YAML metadata that I have now:
---
title: `r params$title`
author: '[`r params$author`](mailto:`r params$author`#domain.com)'
date: "Generated on `r Sys.Date()`"
output:
bookdown::gitbook:
config:
toc:
before: |
<li>`r params$title`<br/>`r params$author`<br/>Generated on `r Sys.Date()`</li>
...
Thanks in advance!

Split the title onto multiple lines?

In an R markdown document (html and presentations), is it possible to manually split the title onto multiple lines? I tried playing with pipes which produces orrendous output.
---
title: 'A title I want to split on two lines'
author:
date:
output:
ioslides_presentation
---
Examples for adding an abtract show the use of pipes | to break lines and include paragraphs. This works as well for the title and other yaml elements. For an abstract or title:
---
abstract: |
What works for the abstract.
Works for the title, too!
title: |
| title
| subtitle
output: pdf_document
---
For an HTML output just us the <br> tag while if your output is a PDF or PDF presentation standard LaTeX code to break line given by \\ should work.
Example
---
title: 'A title I want to <br> split on two lines'
author:
date:
output:
ioslides_presentation
---
For PDF
Just to rule out possibilities, I've tried to put \\ or \newline, both do not split, so for PDF seems to be a little bit tricky. \linebreak stop knitr parsing. Maybe another user can solve this question for knitr PDFs.
For PDF output, experimentation revealed that the following works:
---
title: 'A title I want to \nsplit on two lines'
author:
date:
output: pdf_document
---
That is two spaces followed by \n.

Add sections to beamer presentation using rmarkdown and knitr

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

Resources