When rendering an HTML document using Quarto, light grey shading is added to alternate/odd-number rows for both {gt} and {DT} tabular output. The shading persists even when opt_row_striping(row_striping = FALSE)
is included.
library(tidyverse)
library(gt)
set.seed(10)
x <- sample(1:nrow(iris), 10)
df <- iris[x, ]
df |>
gt() |>
opt_row_striping(row_striping = FALSE)
(Note: shading does not appear when generating and viewing the table in RStudio)
This shading does not appear in when knitting this same code as an HTML document using RMarkdown.
How can this either be turned off or set to a different color?
Thanks.
cderv
March 21, 2024, 1:19pm
2
yes the shading is added by default on computational table output in Quarto
This can't be easily removed for now
opened 05:36AM - 22 Sep 23 UTC
enhancement
needs-discussion
tables
### Bug description
In this issue, https://github.com/quarto-dev/quarto-cli/iss… ues/922#issuecomment-1640093837, there's a difference in how tables are rendered by default: non-computational tables made with Markdown don't have the `.striped` class included, while tables generated with chunks (like with `knitr::kable()` or with `gt::gt()` do.
The rational for including stripes and condensed spacing by default makes sense, since tables full of numbers often need to be more information-dense. Sometimes, though, {kable} and {gt} can be used to create less number-heavy tables and just present text. As of Quarto 1.4.376, the `.striped` class seems hard-baked-in and can't be removed, though (though I might be missing some option to disable it)
### Steps to reproduce
This example uses {gt} to generate a text-based table. Row striping appears (`<table class="gt_table table table-sm table-striped small" ...>`) regardless of the `row_striping` option in `gt::opt_row_striping()` (which is a gt thing, not a quarto thing, but quarto's table rendering is inserting its own table class here)
````qmd
---
title: "Testing"
---
```{r}
dplyr::tibble(Animal = c("Bat", "Cat", "Dog"), `Has wings` = c("Yes", "No", "No")) |>
gt::gt() |>
gt::opt_row_striping(row_striping = FALSE)
```
````
<img width="191" alt="image" src="https://github.com/quarto-dev/quarto-cli/assets/73663/f3173987-8b88-47c3-b642-e5bfa8d61a39">
### Expected behavior
It would be nice to have a table without stripes. [In the documentation](https://quarto.org/docs/prerelease/1.3/tables.html#bootstrap-classes-can-be-added-to-tables) it shows that it's possible to add a bunch of different bootstrap classes to non-computational tables:
```
| fruit | price |
|--------|--------|
| apple | 2.05 |
| pear | 1.37 |
| orange | 3.09 |
: Fruit prices {.striped .hover}
```
### Actual behavior
However, that `.striped` class is hard-coded for computational output and there's no way I can find to disable it, so all kable and gt tables have stripes regardless of controlling stripes with kable- and gt-specific settings.
### Your environment
- Quarto: 1.4.376
- IDE: 2023.06.2+561
- R: 4.3.1
- OS: macOS Ventura 13.5.2
### Quarto check output
```bash
Quarto 1.4.376
[✓] Checking versions of quarto binary dependencies...
Pandoc version 3.1.8: OK
Dart Sass version 1.55.0: OK
Deno version 1.33.4: OK
[✓] Checking versions of quarto dependencies......OK
[✓] Checking Quarto installation......OK
Version: 1.4.376
Path: /Applications/quarto/bin
[✓] Checking tools....................OK
TinyTeX: v2022.08
Chromium: (not installed)
[✓] Checking LaTeX....................OK
Using: TinyTex
Path: /Users/andrew/Library/TinyTeX/bin/universal-darwin
Version: 2022
[✓] Checking basic markdown render....OK
[✓] Checking Python 3 installation....OK
Version: 3.11.3
Path: /opt/homebrew/opt/python@3.11/bin/python3.11
Jupyter: 5.3.0
Kernels: python3
(|) Checking Jupyter engine render....0.00s - Debugger warning: It seems that frozen modules are being used, which may
0.00s - make the debugger miss breakpoints. Please pass -Xfrozen_modules=off
0.00s - to python to disable frozen modules.
0.00s - Note: Debugging will proceed. Set PYDEVD_DISABLE_FILE_VALIDATION=1 to disable this validation.
(|) Checking Jupyter engine render....0.00s - Debugger warning: It seems that frozen modules are being used, which may
0.00s - make the debugger miss breakpoints. Please pass -Xfrozen_modules=off
0.00s - to python to disable frozen modules.
0.00s - Note: Debugging will proceed. Set PYDEVD_DISABLE_FILE_VALIDATION=1 to disable this validation.
[✓] Checking Jupyter engine render....OK
[✓] Checking R installation...........OK
Version: 4.3.1
Path: /Library/Frameworks/R.framework/Resources
LibPaths:
- /Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/library
knitr: 1.43
rmarkdown: 2.21
[✓] Checking Knitr engine render......OK
```
You'll find information in the discussion, including how to opt-out processing of HTML table produced by GT so that you can keep the gt layout
system
Closed
May 2, 2024, 1:20pm
3
This topic was automatically closed 42 days after the last reply. New replies are no longer allowed. If you have a query related to it or one of the replies, start a new topic and refer back with a link.