Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

R markdown format title - pdf output

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!

like image 660
Jordan Avatar asked May 16 '17 18:05

Jordan


People also ask

How do I save an R Markdown as a PDF?

To transform your markdown file into an HTML, PDF, or Word document, click the “Knit” icon that appears above your file in the scripts editor. A drop down menu will let you select the type of output that you want. When you click the button, rmarkdown will duplicate your text in the new file format.

What output format can be generated from R Markdown?

There are two types of output formats in the rmarkdown package: documents, and presentations.

How do you make a header in R Markdown?

We can insert headings and subheadings in R Markdown using the pound sign # . There are six heading/subheading sizes in R Markdown. The number of pound signs before your line of text determines the heading size, 1 being the largest heading and 6 being the smallest.

How do you bold a title in R Markdown?

**text** is used to make the title bold and <br> to break the line.


2 Answers

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:

  1. 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.
  2. \LARGE and \Large give different font sizes on different lines of the title.
  3. | at the beginning of each line of the title allows a multi-line title.
  4. 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.
like image 172
eipi10 Avatar answered Oct 21 '22 01:10

eipi10


For a smaller title section, the following may be helpful. It builds on eipi10's answer but with two modifications:

  1. the vspace{} commands include negative values to shrink white space
  2. 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
---
like image 20
Omar Wasow Avatar answered Oct 21 '22 01:10

Omar Wasow