Skip to content

gt() table placement in LaTeX / PDF output doesn't work as expected #2003

@mine-cetinkaya-rundel

Description

@mine-cetinkaya-rundel

Description

gt() tables in Quarto documents with format: pdf are not placed where they should be in the output.

Reproducible example

---
title: "Title"
format: pdf
keep-tex: true
execute:
  echo: fenced
---

```{r}
library(knitr)
library(gt)
```

# Section 1

The `gt()` table is at the bottom of the page but it should be immediately below this text.

```{r}
gt(mtcars[1:5,1:5])
```

This text should be below the table.

{{< pagebreak >}}

# Section 2

The `gt()` should be below this text, but it's showing up above it.

```{r}
gt(mtcars[1:10,1:5])
```

{{< pagebreak >}}

# Section 3

The `kable()` table is correctly showing up below this text.

```{r}
kable(mtcars[10:20,1:5])
```

Rendered output is below.

Untitled-1.pdf

Expected result

The reprex above includes the expected results in each case as well.

Session info

R version 4.5.0 (2025-04-11)
Platform: aarch64-apple-darwin20
Running under: macOS Sequoia 15.5

Matrix products: default
BLAS:   /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib 
LAPACK: /Library/Frameworks/R.framework/Versions/4.5-arm64/Resources/lib/libRlapack.dylib;  LAPACK version 3.12.1

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

time zone: America/New_York
tzcode source: internal

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
 [1] palmerpenguins_0.1.1 lubridate_1.9.4      forcats_1.0.0        stringr_1.5.1       
 [5] dplyr_1.1.4          purrr_1.0.4          readr_2.1.5          tidyr_1.3.1         
 [9] tibble_3.3.0.9000    ggplot2_3.5.2        tidyverse_2.0.0     

loaded via a namespace (and not attached):
 [1] gtable_0.3.6       compiler_4.5.0     tidyselect_1.2.1   xml2_1.3.8        
 [5] textshaping_1.0.1  systemfonts_1.2.3  scales_1.4.0       fastmap_1.2.0     
 [9] R6_2.6.1           labeling_0.4.3     generics_0.1.4     pillar_1.10.2     
[13] RColorBrewer_1.1-3 tzdb_0.5.0         rlang_1.1.6        stringi_1.8.7     
[17] timechange_0.3.0   cli_3.6.5          withr_3.0.2        magrittr_2.0.3    
[21] digest_0.6.37      grid_4.5.0         hms_1.1.3          lifecycle_1.0.4   
[25] vctrs_0.6.5        glue_1.8.0         farver_2.1.2       ragg_1.4.0        
[29] gt_1.0.0           tools_4.5.0        pkgconfig_2.0.3    htmltools_0.5.8.1 

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions