Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

adding horizontal rule to html rmarkdown doc hides sections of text

I am making an Rmarkdown document that knits to an HTML page. Instead of separating some text sections with headers or bullets, I just want to draw horizontal lines between them.

According to http://rmarkdown.rstudio.com/authoring_basics.html this would be called a "horizontal rule" and I can do that with three or more ---. However when I actually try to do this, various sections disappear from the html doc. Here is a very simple example of my code:

---
title: "formatting issue"
author: "rrr"
output: 
  html_document:
    toc: true
    toc_depth: 2
    toc_float: true
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```

# bla {.tabset}  

## tab 1  

---  
**text1**  
bla  

---
**text2**  
bla

---
**text3**  
bla  

---  

## tab 2  

bla

## tab 3  

bla

# bla  

bla bla bla bla

Notice that text sections text1 text2 and text3 do not all show up when you knit to html. When I mess around with it, I just end up with different ones missing or not, but I can't get them all to show up or figure out why.

like image 371
rrr Avatar asked Aug 02 '17 16:08

rrr


People also ask

How do I add a horizontal rule in R markdown?

Horizontal rules You can create a horizontal rule ( <hr /> ) by placing 3 or more hyphens, asterisks, or underscores on a single line by themselves. You can also place spaces between them.

What does ## do in R markdown?

headers - Place one or more hashtags at the start of a line that will be a header (or sub-header). For example, # Say Hello to markdown . A single hashtag creates a first level header. Two hashtags, ## , creates a second level header, and so on.

How do you break a line 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 .


1 Answers

The horizontal break needs to be surrounded by a leading and following new line, like this:

## heading
much interesting text ...

---

## heading
more interesting text
like image 158
Dan Avatar answered Sep 18 '22 04:09

Dan