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

Respect opt_row_striping() with pdf output #1625

Open
olivroy opened this issue Apr 18, 2024 · 0 comments
Open

Respect opt_row_striping() with pdf output #1625

olivroy opened this issue Apr 18, 2024 · 0 comments

Comments

@olivroy
Copy link
Contributor

olivroy commented Apr 18, 2024

Recently, some support was added for styling gt tables in pdf output

A great example is #1257 (comment)

However, there are some options that are ignored with pdf table processing

  • For example opt_row_striping() does nothing

Currently, this displays a table with no colors. (numbers are present though)

---
title: title
format: pdf
---

```{r}
library(gt)
my_gt_styled <- 
exibble |> 
  gt::gt() |> 
  gt::opt_row_striping(TRUE)
my_gt_styled
```

So, I currently discovered I could use a workaround for now. This table will render as expected in pdf output.

# compute manually even rows
rows_to_span <- which(seq_len(nrow(exibble)) %% 2 == 0)

my_gt_workaround <- exibble |> 
gt() |>
  gt::tab_style(
    style = gt::cell_fill("gray85"), # cell_fill() seems to have been implemented.
    locations = gt::cells_body(rows = rows_to_span)
  )

# also need to disable processing
my_gt_workaround |> tab_options(quarto.disable_processing = TRUE)

Maybe gt could build on this workaround to make opt_row_striping() work as expected in pdf output?

Also, it would be great to document the current limitations of other formats rendering.

A lot already works, but it is hard to find. It took me a while moving between LaTeX / Quarto / gt documentation. I ended up finding what I need in the issue.

So I think it would be also great to document what is currently working, what is planned, how to work around it for now.

@olivroy olivroy changed the title Respect opt_row_striping() with `as_latex() Respect opt_row_striping() with as_latex() Apr 18, 2024
@olivroy olivroy changed the title Respect opt_row_striping() with as_latex() Respect opt_row_striping() with pdf output Apr 18, 2024
@rich-iannone rich-iannone self-assigned this Apr 20, 2024
@rich-iannone rich-iannone added this to the v0.11.0 milestone Apr 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment