Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
dmurdoch opened this issue Dec 25, 2024 · 3 comments
Open

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

dmurdoch opened this issue Dec 25, 2024 · 3 comments

Comments

@dmurdoch
Copy link

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.

@dmurdoch
Copy link
Author

This issue should probably have been a comment on #1588, but I didn't see that before posting it since searching issues doesn't find PRs.

@olivroy
Copy link
Collaborator

olivroy commented Jan 2, 2025

@AaronGullickson @kbrevoort @snhansen @nielsbock What are your opinions on this?

@AaronGullickson
Copy link
Contributor

I think this makes sense as a modification to the default option and should be an easy fix. I will put together a PR for it shortly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants