Skip to content

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

Closed

Description

@bzkrouse

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.

Activity

  1. olivroy commented on Nov 15, 2024

    @olivroy
    Collaborator

    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

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions