Skip to content

Table styling is incorrect when using print() statement in Rmd HTML output #2148

Description

@qdread

Description

After recent updates to gt and other packages, I am not getting expected appearance of gt tables when using print() statements and results = 'asis' when rendering Rmd to HTML. This is problematic because print() statements are needed to display tables within for loops and apply statements. I'm not sure which version update caused this breaking change. The problem occurs in Rmd but not qmd rendering to HTML.

Reproducible example

I would expect the two tables in this example Rmd document to look the same.

---
title: "GT Reprex"
author: "Quentin Read"
date: "2026-06-16"
output: html_document
---

Table displayed without explicit `print()` statement.

```{r}
library(gt)

gt_exibble <- gt(exibble)

gt_exibble
```

Table displayed with `print()` statement and `results = 'asis'`

```{r, results = 'asis'}
print(gt_exibble)
```

Here is how the output looks in my browser.

Image

Session info

Here is the sessionInfo() from the rendered document.

## R version 4.6.0 (2026-04-24 ucrt)
## Platform: x86_64-w64-mingw32/x64
## Running under: Windows 11 x64 (build 26100)
## 
## Matrix products: default
##   LAPACK version 3.12.1
## 
## locale:
## [1] LC_COLLATE=English_United States.utf8 
## [2] LC_CTYPE=English_United States.utf8   
## [3] LC_MONETARY=English_United States.utf8
## [4] LC_NUMERIC=C                          
## [5] LC_TIME=English_United States.utf8    
## 
## time zone: America/New_York
## tzcode source: internal
## 
## attached base packages:
## [1] stats     graphics  grDevices utils     datasets  methods   base     
## 
## other attached packages:
## [1] gt_1.3.0
## 
## loaded via a namespace (and not attached):
##  [1] vctrs_0.7.3       cli_3.6.6         knitr_1.51        rlang_1.2.0      
##  [5] xfun_0.57         otel_0.2.0        generics_0.1.4    jsonlite_2.0.0   
##  [9] glue_1.8.1        htmltools_0.5.9   sass_0.4.10       rmarkdown_2.31   
## [13] evaluate_1.0.5    jquerylib_0.1.4   tibble_3.3.1      fastmap_1.2.0    
## [17] yaml_2.3.12       lifecycle_1.0.5   compiler_4.6.0    dplyr_1.2.1      
## [21] fs_2.1.0          pkgconfig_2.0.3   rstudioapi_0.18.0 digest_0.6.39    
## [25] R6_2.6.1          tidyselect_1.2.1  pillar_1.11.1     magrittr_2.0.5   
## [29] bslib_0.11.0      withr_3.0.2       tools_4.6.0       xml2_1.5.2       
## [33] cachem_1.1.0

Activity

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

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions