Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

R Markdown add White Space to HTML Output

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:
like image 244
stackinator Avatar asked Mar 03 '18 22:03

stackinator


People also ask

How do I add a white space in rmarkdown?

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.

How do you insert a line space in R Markdown?

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 .

How do you double space on a RMD?

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.


1 Answers

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
like image 56
Hernando Avatar answered Sep 16 '22 20:09

Hernando