Description
Prework
- [ x] Read and agree to the code of conduct and contributing guidelines.
- [ x] If there is already a relevant issue, whether open or closed, comment on the existing thread instead of posting a new issue.
Description
In R Markdown, if the latex_tbl_pos
option is not modified, the table position defaults to "!t"
. This is not a good default, as it forces the table to the top of the page even when that doesn't make sense. A better default would be "t"
, which usually puts the table at the top of the page, but might push it to the top of the next page in some circumstances, e.g. on the first page of an article where the article title should be at the top of the first page.
Reproducible example
Run this in R Markdown:
---
title: "Mtcars example"
output: pdf_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
library(gt)
```
## Example
Here is some text before the table.
```{r table}
head(mtcars) |> gt()
sessionInfo()
```
This puts the table above the article title:
Expected result
The table should appear on the next page. This is what happens If |> tab_options(latex.tbl.pos = "t")
is added to the line generating the table, because LaTeX knows not to put a table before the title. That would be a better default than the current one.