adding horizontal rule to html rmarkdown doc hides

2019-07-15 05:15发布

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.

1条回答
beautiful°
2楼-- · 2019-07-15 05:56

The horizontal break needs to be surrounded by a beginning and an ending new line, like this:

## heading
much interesting text ...

---

## heading
more interesting text
查看更多
登录 后发表回答