R markdown format title - pdf output
10,115
Solution 1
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.
Solution 2
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{}
andend{}
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
---
Comments
-
Jordan almost 2 years
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!
-
gaelgarcia about 6 yearsIs there a way to do exactly this but for HTML output?
-
samcarter_is_at_topanswers.xyz almost 3 years
\LARGE
is a switch and does not take an argument, so it should be{\LARGE ...}
. Without starting a new paragraph after it, the spacing to the following line will be wrong. -
samcarter_is_at_topanswers.xyz almost 3 years
\normalsize{...}
is incorrect syntax. Such font commands are switches and don't take an argument, so it would have to be{\normalsize ...}
. However as you correctly observed, this will result in incorrect spacing if no new paragraph is started afterwards. -
eipi10 almost 3 yearsThanks, I've updated my answer, but without the braces (which show up in the rendered version).