I've found several suggestions for adding whitespace to R Markdown documents including <br>
, \newpage
and some other things.
These don't work for my HTML output, maybe there's a better way. I'd like to do two things in the example below:
(1) Add extra whitespace between the title and the first header
(2) Add extra whitespace between the first and second paragraphs
Let's go with the default R Markdown document shown below. How would I accomplish this extra white space for HTML output?
---
title: "Here is the title"
output: html_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
## R Markdown
FIRST PARAGRAPH This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see <http://rmarkdown.rstudio.com>.
SECOND PARAGRAPH you click the **Knit** button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:
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. Another fix is putting a backslash `\` just in front of the newline, resulting in a blank line in the html.
Add Line Breaks in R Markdown To break a line in R Markdown and have it appear in your output, use two trailing spaces and then hit return .
Or, since markdown allows raw HTML, you can simply add <div style="line-height: 2em;"> ... </div> as the first respectively last line of your . Rmd document. This makes the double-space self-contained and has the added advantage that you can skip over parts of the document that should be single-spaced after all.
A simple solution to add a line of white space is to use $~$
This adds a line of white space and has worked reliably for me with html output.
# R Markdown
Some text
$~$
More text after a white space
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With