57

Is there a way to do it by adding latex code in the text or does the solution lie in (R)Markdown?

No sign of a solution here: http://rmarkdown.rstudio.com/pdf_document_format.html

At present I'm bodging a solution by adding my monospace signature to the bottom of the 1st page, to force the next section to start on page 2: https://github.com/Robinlovelace/Creating-maps-in-R/blob/master/intro-spatial-rl.pdf

RobinLovelace
  • 4,799
  • 6
  • 29
  • 40

5 Answers5

47

Another easy way to do this is to just use HTML tags. Adding <br> will give a single line break and I've used that when, for whatever reason, using the (two-space indentation) is ignored.

Zoë Clark
  • 1,334
  • 2
  • 13
  • 25
  • 5
    Another fix is putting a backslash `\\` just in front of the newline, resulting in a blank line in the html. I also find that two-spaces followed by newline does not work. – bdemarest Sep 04 '15 at 21:34
47

To create vertical space (Markdown to PDF), I use &nbsp;

This command works like \vspace{12pt} for latex.

NotYourIPhone Siri
  • 715
  • 1
  • 8
  • 11
22

You can use latex inside your Rmd file. To have a page break, just add \newpage.

example.Rmd

Title
====================

This is a test Rmd document. 

\newpage

Second page
====================

This text is on the second page

You make a pdf using render("example.Rmd", output_format='pdf_document')

Hope it helps,

alex

alko989
  • 7,688
  • 5
  • 39
  • 62
  • Wow it's that simple. Having just found that you can also add footnotes (see discussion here http://rmarkdown.rstudio.com/markdown_document_format.html ) I'm beginning to think (R)Markdown is the format to rule them all. – RobinLovelace Jun 26 '14 at 16:17
16

You can also use inline LaTeX to create a 1-inch vertical space like this:

text text text

$$\\[1in]$$

text text text 

Note that you have to leave a blank line before and after the $$\\[1in]$$

David Lovell
  • 852
  • 6
  • 17
0

\pagebreak can be used the whitespace of an RMarkdown document. Alternatively, cat("\n\n\\pagebreak\n") can be used within an R script.

Example:

Here I insert some text into an RMarkdown document.


  cat("  \n## And here I am demonstrating text within an R script. \n")
  
  cat("  \n### More text. \n")

  cat("  \n### Add page break... \n")
  
  cat("\n\n\\pagebreak\n")

  cat("  \n### Item on new page. \n")

PapL
  • 3
  • 2