How to remove white space at the end of an Rmarkdown HTML output
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
.