在数字/代码块上方和下方添加垂直空间(HTML)

时间:2017-05-31 14:45:11

标签: css r rstudio r-markdown

我正在将RStudio中的Rmd文件编织为HTML,我想增加正文和表格/数字之间的空间。 Here's a nice solution用于PDF输出。 CSS的哪一部分在HTML输出中指定了这个间距?我正在寻找模板范围的解决方案,而非手动<br>

---
title: "Example"
output: 
  bookdown::html_document2:
    fig_captions: yes
    number_sections: false
    theme: cerulean
    highlight: tango
    toc: true
    code_download: true
    code_folding: "show"
    toc_float: true
---

<style type="text/css">

body{ /* Normal  */
      font-size: 18px;
      font-family: Helvetica;
  }

div#TOC li {
    list-style:none;
    background-image:none;
    background-repeat:none;
    background-position:0;
}
</style>

```{r setup, include=FALSE}
library(ggplot2)
library(knitr)
```

## Section

Here is some text before a table.

```{r cars}
kable(head(cars))
```

Here is some text after the table. Here comes a plot. Could use more space after the table and before the plot.

```{r pressure, echo=FALSE, fig.align="center", fig.cap="My caption", message=FALSE, warning=FALSE}
ggplot(cars, aes(speed)) +
  geom_histogram()
```

Here is some text after the plot. Need some space between the figure caption and the body text.

enter image description here

1 个答案:

答案 0 :(得分:2)

添加

.figure {
   margin-top: 100px;
   margin-bottom: 100px;
}

table {
    margin-top: 100px;
    margin-bottom: 100px !important;
}

<style>标记内。显然需要调整到所需的数量。