Is there a common culprit for white space at the end of a markdown? Here's what the end of my HTML output looks like. And my options:
```
{r }
knitr::opts_chunk$set(fig.width=6, fig.asp=.618, fig.align="center",
fig.path='Figs/', warning=FALSE, message=FALSE, cache=TRUE)
```
While I do not have a reprex handy, I did try several reruns, and found that the YAML is causing the white space, specifically the 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
Edit: Here's a reproducible example:
---
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)
```
According to https://community.rstudio.com/t/floating-table-of-contents-and-plots-produce-extra-whitespace-at-bottom/12606/8 you can keep toc_float
and remove the extra white space by inserting the following html code at the bottom of the .Rmd file:
<div class="tocify-extend-page" data-unique="tocify-extend-page" style="height: 0;"></div>
Worked for me!
This seems to be caused by the tocify script included in HTML output. The script is included if toc_float
is set to true
(or if it contains more options).
The option to add the white space is configurable in principle through the tocify extendOffset
option. However, it appears that R Markdown does not expose a way to set the option through YAML. Currently, the only way to get rid of it is to unset toc_float
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With