Skip to content

Default latex table position is poor choice in R Markdown #1935

Closed
@dmurdoch

Description

@dmurdoch

Prework

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:
Image

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.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions