rr-markdownquartogt

Why do gt tables render differently in Quarto compared to R Markdown, despite consistent settings?


I am planning to move from R Markdown to Quarto for parameterised reporting, but one appearance issue has prevented me from progressing further.

In R Markdown, the preview of a gt table looks identical to the knitted HTML file:

enter image description here

However, in Quarto, while the preview of a gt table appears the same as above, the rendered HTML file looks different:

enter image description here

The table includes stripes, which should be FALSE by default based on the gt documentation. Even if I explicitly turn it off using opt_row_striping(row_striping = FALSE), the issue persists:

enter image description here

How can I resolve this so that the output matches the preview?

The full quarto code example can be found below:

---
title: "GT tables"
format: 
   html:
     embed-resources: true
---
#| message: false
library(gt)
library(dplyr)
  1. Default gt table:
iris |> 
  slice_head(n = 5) |> 
  gt()
  1. Explicitly tell gt to turn strips off:
iris |> 
  slice_head(n = 5) |> 
  gt() |> 
  opt_row_striping(row_striping = FALSE)

Solution

  • By default Quarto modifies some table properties when rendering gt (and other computational) tables, most noticeably adding a bootstrap class that includes row striping. In gt's case you can disable this by using tab_options(quarto.disable_processing = TRUE):

    ---
    title: "GT tables"
    format: 
       html:
         embed-resources: true
    ---
    
    ```{r}
    #| message: false
    library(gt)
    library(dplyr)
    
    
    iris |> 
      slice_head(n = 5) |> 
      gt() |> 
      tab_options(quarto.disable_processing = TRUE)
    
    ```
    

    enter image description here