Skip to content

Replace gt dependency with lt#629

Open
yihui wants to merge 25 commits into
mainfrom
replace-gt-with-lt
Open

Replace gt dependency with lt#629
yihui wants to merge 25 commits into
mainfrom
replace-gt-with-lt

Conversation

@yihui

@yihui yihui commented May 21, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Remove the gt package from Imports and replace with the lightweight lt package
  • New as_lt() generic + S3 methods for fixed_design_summary and gs_design_summary, fully replacing as_gt()
  • All 14 vignettes updated to use lt functions (lt(), lt_header(), lt_spanner(), lt_format(), lt_footnote(), lt_note(), lt_label())
  • Tests updated for lt_tbl assertions

Migration mapping

gt lt
gt::gt(x) lt(x)
group_by(col) |> gt() lt(x, row_group = "col")
tab_header(title, subtitle) lt_header(title, subtitle)
tab_spanner(label, columns) lt_spanner(label, columns)
fmt_number(columns, decimals) lt_format(columns, decimals)
tab_footnote(fn, cells_column_labels(col)) lt_footnote(text, "column", columns)
tab_footnote(fn) (no location) lt_note(text)
cols_label(a = "A") lt_label(a = "A")

Test plan

  • as_lt() unit tests pass for fixed and GS designs
  • All design types render correctly (fixed_ahr, gs_ahr, gs_wlr, gs_rd)
  • Visual comparison with gt output confirms structural equivalence
  • Non-binding design body footnote renders correctly
  • Custom footnotes (colname, title, analysis, spanner) all work
  • R CMD check passes
  • All vignettes build without error

Vignette comparison

This zip archive contains all vignettes and articles built with gt and lt, respectively. You can compare the rendered HTML pages side by side: vignette-compare.zip

Question

Why did we test the LaTeX output of gt::as_latex()?

gt_to_latex <- function(data) cat(as.character(gt::as_latex(data)))

yihui and others added 4 commits May 21, 2026 14:05
Remove the gt package dependency entirely and use the lightweight lt
package for table rendering. This reduces install weight and aligns
with the project's move toward minimal dependencies.

Changes:
- New as_lt() generic + methods replacing as_gt()
- All vignettes updated: gt() → lt(), tab_header() → lt_header(),
  fmt_number() → lt_format(), tab_spanner() → lt_spanner(),
  tab_footnote() → lt_footnote()/lt_note(), cols_label() → lt_cols_label()
- README.Rmd: use knitr::kable() for GitHub rendering
- DESCRIPTION: gt removed from Imports, lt added
- Tests updated for lt_tbl assertions

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
lt requires character strings for column names (unlike gt's tidy-select).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@yihui yihui marked this pull request as draft May 21, 2026 19:07
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

@jdblischak jdblischak left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When I run the tests locally, I get two failures:

library("testit")
test_pkg()
## Error: -- Assertion failed: as_lt: footnote=FALSE removes footnote --
##    1. count_footnotes(z1) (LHS) ==>
##        int 0
##       ----------
##        int 1
##       <== (RHS) 1L
##       count_footnotes(z1) %==% 1L is not TRUE but FALSE at tests/testit/test-developer-as_lt.R#14
##    2. count_footnotes(z1) (LHS) ==>
##        int 0
##       ----------
##        int 2
##       <== (RHS) 2L
##       count_footnotes(z1) %==% 2L is not TRUE but FALSE at tests/testit/test-developer-as_lt.R#22

sessioninfo::package_info(c("gsDesign2", "lt"), dependencies = FALSE)
##  package   * version date (UTC) lib source
##  gsDesign2 * 1.1.8   2026-05-28 [1] local
##  lt          0.0.7   2026-05-28 [1] Github (yihui/lt@e485eb6)
##
##  [1] C:/Users/john/AppData/Local/R/win-library/4.4
##  [2] C:/Program Files/R/R-4.4.3/library
##  * ── Packages attached to the search path.

Comment thread R/as_gt.R
@jdblischak

This comment was marked as outdated.

@yihui

This comment was marked as outdated.

yihui and others added 14 commits June 2, 2026 14:26
- Restore as_gt() as a thin, deprecated wrapper that warns and delegates
  to as_lt(), so existing users get a migration path instead of a hard
  break.
- Bundle inst/css/gt-style.css and apply it from both as_lt() methods via
  lt::lt_css(), making lt output nearly indistinguishable from the old gt
  tables (top caption, light-grey rules, system-ui font, bare footnote
  superscripts). lt dedups the stylesheet across a knitted document.
- Fix count_footnotes() test helper to read $footnotes (where lt_footnote
  stores them) instead of $ops.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
as_gt() is exported again (as a deprecated wrapper), so pkgdown requires
it in the reference index.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Drop properties already set by lt's default stylesheet or by browser
defaults (caption-side, empty-spanner border, normal-weight subtitle/th),
keeping only the rules that actually change the appearance toward gt.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Drop the gt-era prose; the help page now just states as_gt() is
superseded by as_lt() and points there.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
lt now ships the gt-like theme as lt-gt.css and lt_css() resolves bare
filenames against the package, so gsDesign2 no longer needs its own copy.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
lt's default stylesheet is now gt-like, so as_lt() no longer needs to
attach a separate theme via lt_css().

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Define lt.fixed_design_summary() and lt.gs_design_summary() that
dispatch when users call lt::lt() on gsDesign2 summary objects.
as_lt() is removed (never released). as_gt() remains as a deprecated
wrapper pointing to lt::lt().

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…ests

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
lt_cols_label doesn't exist in lt; the correct function is lt_label.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@yihui

yihui commented Jun 25, 2026

Copy link
Copy Markdown
Collaborator Author

Just a quick update: I've submitted lt v0.1 to CRAN. Currently there are 132 newbies in the queue. I guess the initial review may take place a week later. Fingers crossed.

LittleBeannie and others added 5 commits July 1, 2026 18:16
* Update DESCRIPTION and NEWS.md for v1.1.9

* Fix grammar

* I guess 2x is not that substantial [ci skip]

---------

Co-authored-by: Yihui Xie <xie@yihui.name>
- Remove `Remotes: yihui/lt` since lt is now on CRAN
- Remove redundant `lt::` prefix in vignettes where library(lt) is loaded
- Add library(lt) to story-seven-test-types.Rmd
- Delete gt_to_latex snapshot tests (gt no longer available)
- Bump version to 1.2.0; update NEWS

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Replace dual-block pattern (eval=FALSE lt() + hidden knitr::kable())
with single lt() calls rendered via lt_html(fragment=TRUE, css=FALSE).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@yihui yihui force-pushed the replace-gt-with-lt branch from b79e349 to 961c996 Compare July 4, 2026 04:48
@yihui yihui marked this pull request as ready for review July 4, 2026 15:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants