Markdown 结束时是否存在空白的常见罪魁祸首?这是我的 HTML 输出的结尾。我的选择:
```
{r }
knitr::opts_chunk$set(fig.width=6, fig.asp=.618, fig.align="center",
fig.path='Figs/', warning=FALSE, message=FALSE, cache=TRUE)
```
虽然我手边没有 reprex,但我确实尝试了几次重新运行,发现 YAML 导致了空白,特别是 toc_float: true
。
date: "`r format(Sys.time(), '%B, %d %Y')`"
output:
html_document:
theme: united
highlight: textmate
code_folding: show
toc: true
toc_float: true
editor_options:
chunk_output_type: inline
always_allow_html: yes
编辑:这是一个可重现的例子:
---
date: "`r format(Sys.time(), '%B, %d %Y')`"
output:
html_document:
theme: united
highlight: textmate
code_folding: show
toc: true
toc_float: true
editor_options:
chunk_output_type: inline
always_allow_html: yes
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
## R Markdown
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>.
When 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:
```{r cars}
summary(cars)
```
## Including Plots
You can also embed plots, for example:
```{r pressure, echo=FALSE}
plot(pressure)
```
最佳答案
根据 https://community.rstudio.com/t/floating-table-of-contents-and-plots-produce-extra-whitespace-at-bottom/12606/8您可以通过在 .Rmd 文件底部插入以下 html 代码来保留 toc_float
并删除多余的空格:
<div class="tocify-extend-page" data-unique="tocify-extend-page" style="height: 0;"></div>
对我有用!
关于html - 如何删除 Rmarkdown HTML 输出末尾的空格,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52933437/