How to stop bookdown tables from floating to bottom of the page in pdf?
I had to use
kable_styling(latex_options = "HOLD_position")
Note the uppercase HOLD_position, different from hold_position. See also here.
To be able to use that, I also had to add to the top section of the doc (from How to build a latex kable through bookdown::render_book?):
output:
pdf_document:
extra_dependencies: ["float"]
You can solve this problem with kableExtra
by
data_frame(col_a = seq_len(5), col_b = rnorm(5), col_c = runif(5)) %>%
knitr::kable(caption = "This is a test") %>%
kableExtra::kable_styling(latex_options = "hold_position")
It basically insert a [!h]
to the LaTeX table
environment which will prevent the floating behavior and pin the table at current location.