rstudio / gt

Easily generate information-rich, publication-quality tables from R
https://gt.rstudio.com
Other
2.04k stars 209 forks source link

Restrict width of notes to table width in LaTeX output #881

Open rich-iannone opened 2 years ago

rich-iannone commented 2 years ago

Discussed in https://github.com/rstudio/gt/discussions/860

Originally posted by **turbanisch** December 28, 2021 Dear community - I'm relatively new to `gt` but already in love with its design philosophy. I understand that html output is the focus of this package yet some functionality to create LaTeX output is provided. It seems that the current implementation simply creates a minipage environment of line width for table notes. In many academic publications, however, table notes extend no further than the width of the table itself. Should this option be added (or even set as the default)? Although not perfect by themselves, the LaTeX packages `threeparttable` and `threeparttablex` could be used for this. Below I include a sample R Markdown document illustrating my case: ```` --- title: "GT LaTeX" output: pdf_document: keep_tex: true editor_options: chunk_output_type: console --- ```{r, include=FALSE} library(tidyverse) library(gt) ``` ```{r} df <- mtcars %>% head(5) %>% select(1:5) df %>% gt() %>% tab_source_note(md("*Note:* This is a very long note that needs to be wrapped. This is a very long note that needs to be wrapped. This is a very long note that needs to be wrapped.")) %>% tab_source_note("Here is another one.") %>% tab_footnote( footnote = md("medium-sized **cylinders**"), locations = cells_body(columns = cyl, rows = (cyl == 6)) ) ``` ```` yielding grafik And the version using `threeparttablex`: grafik
MarcoPortmann commented 11 months ago

Is there a timetable for this issue? I ask because currently no alternative package for creating LaTeX tables is free of errors when dealing with extra-wide footnotes, which suggests the use of threeparttable. gt's philosophy is great and I would like to use the package more often. A threeparttable implementation for quarto-pdf/LaTeX would make the package even more useful for me.