With the settings
output:
github_document:
toc: true
number_sections: true
and
```{r, include=FALSE}
knitr::opts_chunk$set(collapse = TRUE)
```
compare
# Test
* foo
* bar
* boo
with output
to
# Test
* foo
```{r, echo = TRUE}
print("eg")
```
* bar
* boo
with output
and we can see that the vertical spacing has been changed without any command to do so. How can this be prevented?
Consider this quick workaround:
---
output:
github_document:
toc: true
number_sections: true
---
```{css, echo = FALSE}
li>p {
margin-top: 0; # default value: 16px
}
p, blockquote, ul, ol, dl, table, pre {
margin-bottom: 0; # default value: 16px
}
```
```{r, include = FALSE}
knitr::opts_chunk$set(collapse = TRUE)
```
By default, code chunks in R Markdown are included in the tag <div class="..." />
in the HTML output. When <div>
element is embedded in the list, item content (foo) will be wrapped in the <p>
tag. So, we need to set its CSS properties: margin-top
and margin-bottom
to the 0
.
<ul>
<li>
<p>foo</p>
<div class="sourceCode" id="...">...</div>
</li>
.
.
</ul>