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

LaTeX tables: column spanner widths are affected by order of the input data #1922

Open
2 tasks done
bzkrouse opened this issue Nov 14, 2024 · 1 comment
Open
2 tasks done

Comments

@bzkrouse
Copy link

Prework

Description

First, thank you for all the recent efforts to improve LaTeX capabilities! This issue is somewhat related to #1656.
For tables with a stub and column spanners, the column spanner's width is influenced by the order of the input data.

Reproducible example

[correct behavior] For the table below, the order of the data columns matches the order of the table columns. Widths are correctly set when rendered to latex:

library(gt)
gtcars |> 
  dplyr::select(mfr, model, year, trim) |> 
  dplyr::slice(1:10) |> 
  gt(rowname_col = "mfr") |>
  cols_width(
    mfr ~ pct(55),
    model ~ pct(15),  
    year ~ pct(15),
    trim ~ pct(15)
  ) |>  
  tab_spanner(
    label = "a spanner",
    columns = c(year, trim)
  )

image

However, if we move mfr (row label) to the last column in the data, the spanner incorrectly inherits the width of the stub column:

gtcars |> 
  dplyr::select(model, year, trim, mfr) |>  
  dplyr::slice(1:10) |> 
  gt(rowname_col = "mfr") |>
  cols_width(
    mfr ~ pct(55),
    model ~ pct(15),  
    year ~ pct(15),
    trim ~ pct(15) 
  ) |>  
  tab_spanner(
    label = "a spanner",
    columns = c(year, trim)
  )

image

Expected result

I would expect the spanner widths to be independent of the order of the input data. Tables without spanners and/or stubs seem to work fine regardless of the order of the input data.

@olivroy
Copy link
Collaborator

olivroy commented Nov 15, 2024

Yes, there are a couple of issues with borders + stub in LaTeX, like #1864. @kbrevoort I wonder if you were able to make progress on the issue?

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

No branches or pull requests

3 participants