Column width not working with gt table and Quarto Typst

I have a Quarto document rendering to a PDF using Typst. When I insert a gt table I can't control the width. Other formatting works (i.e. conditional text color) but the cols_width arguments gets ignored. Below are screens shots of when it's run in the console vs rendered document:

Console:

Document:

Here is my code:

---
title: "Untitled"
format: typst
---

```{r}
#| include: false 

library(tidyverse)
library(gt)

#| results: asis
#| tbl-cap: "Caption"

gtcars |> 
  select(1:5) |> 
  head() |> 
  gt() |> 
  cols_width(
    mfr ~ px(150), 
    model ~ px(150)
    ) |> 
  data_color(
    columns = year,
    rows = year >= 2016,
    palette = c("red"),
    apply_to = "text"
  )


1 Like

Solution provided here: `gt::cols_width` does not work with `format: typst` · Issue #226 · quarto-dev/quarto-r · GitHub

Column widths must be in percentages.


gtcars |>
  select(1:3) |>
  head() |>
  gt() |>
  cols_width(
    mfr ~ "50%",
    model ~ "25%",
    year ~ "25%"
    ) |>
  data_color(
    columns = year,
    rows = year >= 2016,
    palette = c("red"),
    apply_to = "text"
  )
1 Like

This topic was automatically closed 7 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.