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

Floating table #1588

Merged
merged 49 commits into from
Jul 15, 2024
Merged

Floating table #1588

merged 49 commits into from
Jul 15, 2024

Conversation

AaronGullickson
Copy link
Contributor

@AaronGullickson AaronGullickson commented Feb 25, 2024

Summary

This PR addresses issue #157, specifically the ability to create latex floating environment tables with the use of the table + tabular environments rather than the longtable environment. Currently, I believe this is a major limitation of gt because tables are often broken up across pages, and most people expect tables to operate in a similar manner to figures.

I added an option to tab_option called latex.use.longtable which defaults to FALSE. I then use a few ifelse clauses in utils_render_latex.R to get the proper output. Specification of the positioning of the float works well from the quarto code chunk option tbl-pos.

If I run the following code:

head(state.x77) |> 
  as.data.frame() |>
  gt() |>
  tab_options(latex.use.longtable = FALSE) |>
  as_latex()

Here is the latex output with the option set to FALSE:

"\\begin{table}\n\\begin{tabular}{rrrrrrrr}\n\\toprule\nPopulation & Income & Illiteracy & Life Exp & Murder & HS Grad & Frost & Area \\\\ \n\\midrule\\addlinespace[2.5pt]\n3615 & 3624 & 2.1 & 69.05 & 15.1 & 41.3 & 20 & 50708 \\\\ \n365 & 6315 & 1.5 & 69.31 & 11.3 & 66.7 & 152 & 566432 \\\\ \n2212 & 4530 & 1.8 & 70.55 & 7.8 & 58.1 & 15 & 113417 \\\\ \n2110 & 3378 & 1.9 & 70.66 & 10.1 & 39.9 & 65 & 51945 \\\\ \n21198 & 5114 & 1.1 & 71.71 & 10.3 & 62.6 & 20 & 156361 \\\\ \n2541 & 4884 & 0.7 & 72.06 & 6.8 & 63.9 & 166 & 103766 \\\\ \n\\bottomrule\n\\end{tabular}\n\\end{table}"

Here is the latex output with the option set to TRUE:

"\\begin{longtable}{rrrrrrrr}\n\\toprule\nPopulation & Income & Illiteracy & Life Exp & Murder & HS Grad & Frost & Area \\\\ \n\\midrule\\addlinespace[2.5pt]\n3615 & 3624 & 2.1 & 69.05 & 15.1 & 41.3 & 20 & 50708 \\\\ \n365 & 6315 & 1.5 & 69.31 & 11.3 & 66.7 & 152 & 566432 \\\\ \n2212 & 4530 & 1.8 & 70.55 & 7.8 & 58.1 & 15 & 113417 \\\\ \n2110 & 3378 & 1.9 & 70.66 & 10.1 & 39.9 & 65 & 51945 \\\\ \n21198 & 5114 & 1.1 & 71.71 & 10.3 & 62.6 & 20 & 156361 \\\\ \n2541 & 4884 & 0.7 & 72.06 & 6.8 & 63.9 & 166 & 103766 \\\\ \n\\bottomrule\n\\end{longtable}\n"

I have also supplied an example qmd document in tests/gt-examples/03-latex/latex-15-floating.qmd.

I am submitting this PR currently as a draft as I have not fully stress tested it nor have I written a proper testthat test (not very experienced with those). I am happy to proceed with doing so, if the maintainers think I am on the right path here, but wanted to get feedback before continuing.

Related GitHub Issues and PRs

Checklist

Fixes: #157

…han longtable

Currently I just have a temporary boolean in here, but I need to figure out how to add this as an option to gt somewhere and pull it.
@AaronGullickson
Copy link
Contributor Author

Correction, I did not commit the qmd file because these are apparently ignored by the project.

With the tabular* environment you need to specify a width for the table. This will default to \linewidth so tables will fill the whole page horizontally by default. However, it will also respect the use of other percentages in the table.width option.
@AaronGullickson
Copy link
Contributor Author

Commit 51da31e add tests on the latex format for the new case.

@AaronGullickson
Copy link
Contributor Author

AaronGullickson commented Feb 26, 2024

I have decided to use the tabular* environment rather than the tabular environment. This environment makes it possible to easily adjust the width of the table to conform to the expectation of the table.width argument in tab_options. By default floating environment tables will be full width (e.g. 100%) but users can adjust this expectation using either pixels or percentages. This change should not affect any other formatting issues because longtable and tabular* both use the same formatting for the interior of the table.

I have also cleaned up all of the issues with testthat failing because it expected a longtable header and the default is now a tabular.

I have a qmd file that I have used for testing. It won't upload, so I provide it below.

---
title: "latex-15-floating"
format: 
  pdf:
    keep-tex: true
---

```{r}
#| label: setup
#| include: false

library(gt)
```

Lorem ipsum dolor sit amet, ac purus ut. Sit lectus ac, diam, turpis elementum, tempus. Diam eros eget et placerat lectus odio pulvinar ac. Et tristique phasellus feugiat et. Pretium sociosqu. Nisi, sed et dis vel lacus congue aenean turpis, nec. Convallis, et cursus non ligula at at quis diam pulvinar. Nec tempor tempus quis at tincidunt blandit vitae, eros. Neque aliquet vel non auctor posuere, mi aptent. In in dictum ad, nisl eros mollis sed.

Nullam curabitur, sapien. Tellus habitant, neque. Quis vivamus tortor nulla aliquet aliquet. Aliquet leo, tristique viverra pellentesque lectus lacus quis aliquam egestas. Nunc sed et malesuada magnis, luctus. Et, ultricies vitae ad sed. Habitant ante aliquet hendrerit nisl in ac arcu massa, et. Convallis, faucibus ipsum nisl amet aliquam elementum. Imperdiet est habitasse, diam sapien dapibus himenaeos. A erat tellus mollis, tristique in sem erat cras. Cubilia id in sed non risus neque fringilla a mollis magnis nec. Purus egestas, bibendum. At potenti sem curabitur leo elit class in, sem massa et congue.                                                                                 

Sed dapibus feugiat iaculis erat nibh lobortis sagittis eleifend convallis in. Tristique ac ipsum curabitur amet et leo interdum! Donec mus pharetra. Sed, metus non mauris phasellus semper ut pulvinar fermentum sodales. Bibendum mollis dignissim sed, in dui. Pellentesque sed in elit montes sed tincidunt euismod, eros sit ultrices! Etiam at metus ut aenean libero amet. Feugiat facilisis posuere justo quis faucibus vitae nullam nulla. Scelerisque sapien hendrerit lobortis, pulvinar non nostra amet vehicula ac sed. Ex eget eleifend luctus fusce. Tincidunt in pulvinar eget rhoncus eu eget vitae lacus ornare nunc lacinia amet lacus! Eros interdum suscipit aliquet donec tincidunt phasellus est hendrerit.

Taciti ac, nec non ornare amet litora nascetur nunc elementum. Sollicitudin ut sit conubia et habitasse, integer. Egestas egestas cubilia id facilisi. Tempor ut nec facilisi congue, varius tortor. Aliquam viverra a ipsum aptent eu eu. Id purus metus volutpat malesuada et. In nec consequat eros sed nec at mauris ligula. Ut sapien, eget, in in, potenti torquent, semper mollis ligula vel. Sem quisque varius eros lobortis ut ac mus, dui. Senectus mattis eget, himenaeos pellentesque vitae varius adipiscing, taciti justo. Mauris morbi nunc, laoreet a, non, iaculis libero varius dis tincidunt tortor a.                                                                                                        
Nibh, amet sit sociis, eros in. Ac odio eros luctus at, mauris, tincidunt. Tristique phasellus etiam vel quis, netus tincidunt, tristique eros. Scelerisque massa integer ac aliquet porta non taciti. In ante, consectetur nullam urna, nunc volutpat pellentesque libero tortor nisi! Ante amet habitasse in est dis pellentesque. Nec turpis quis, natoque sagittis ac vestibulum morbi velit mattis. Purus convallis ac luctus eu purus et egestas. 

Consectetur at at magna viverra mauris. Leo augue in nullam laoreet. Eu adipiscing suspendisse eros dis torquent integer et sed tortor ac habitasse et nec. Ullamcorper aliquam maecenas platea et ut integer bibendum justo. Gravida cum est et porttitor ut purus in. Urna magnis ad at senectus in laoreet ut tempor, varius velit. Ac varius lorem, facilisi, blandit, cum ante mauris eu dui enim pharetra. Felis sed odio faucibus netus eget sed vestibulum. Nostra non libero suscipit sed sed egestas. Proin, nulla. Felis suscipit nec pellentesque id gravida ipsum massa. Sagittis consequat quis consequat. Dictumst lectus molestie, est, ut vitae consectetur. Leo mauris eget congue. 

Sed dapibus feugiat iaculis erat nibh lobortis sagittis eleifend convallis in. Tristique ac ipsum curabitur amet et leo interdum! Donec mus pharetra. Sed, metus non mauris phasellus semper ut pulvinar fermentum sodales. Bibendum mollis dignissim sed, in dui. Pellentesque sed in elit montes sed tincidunt euismod, eros sit ultrices! Etiam at metus ut aenean libero amet. Feugiat facilisis posuere justo quis faucibus vitae nullam nulla. Scelerisque sapien hendrerit lobortis, pulvinar non nostra amet vehicula ac sed. Ex eget eleifend luctus fusce. Tincidunt in pulvinar eget rhoncus eu eget vitae lacus ornare nunc lacinia amet lacus! Eros interdum suscipit aliquet donec tincidunt phasellus est hendrerit.

```{r}
#| label: tbl-state
#| tbl-cap: Some State Information
#| tbl-pos: "!t"
#| echo: false

temp <- head(state.x77) |> 
  as.data.frame()

temp <- cbind(State=row.names(head(state.x77)), temp)

temp |>
  subset(select=c("State","Population","Income","Frost","Murder")) |>
  gt(rowname_col = "State") |>
  tab_spanner(label = "Bad Things", columns = c("Frost", "Murder")) |>
  fmt_number(decimals = 0, columns = c("Population", "Income")) |>
  cols_width(State ~ pct(30))  |>
  tab_source_note(md("*Source:* This is a test.")) |>
  tab_options(latex.use.longtable = FALSE)
```

See @tbl-state.

aciti ac, nec non ornare amet litora nascetur nunc elementum. Sollicitudin ut sit conubia et habitasse, integer. Egestas egestas cubilia id facilisi. Tempor ut nec facilisi congue, varius tortor. Aliquam viverra a ipsum aptent eu eu. Id purus metus volutpat malesuada et. In nec consequat eros sed nec at mauris ligula. Ut sapien, eget, in in, potenti torquent, semper mollis ligula vel. Sem quisque varius eros lobortis ut ac mus, dui. Senectus mattis eget, himenaeos pellentesque vitae varius adipiscing, taciti justo. Mauris morbi nunc, laoreet a, non, iaculis libero varius dis tincidunt tortor a.                                                                                                        
Nibh, amet sit sociis, eros in. Ac odio eros luctus at, mauris, tincidunt. Tristique phasellus etiam vel quis, netus tincidunt, tristique eros. Scelerisque massa integer ac aliquet porta non taciti. In ante, consectetur nullam urna, nunc volutpat pellentesque libero tortor nisi! Ante amet habitasse in est dis pellentesque. Nec turpis quis, natoque sagittis ac vestibulum morbi velit mattis. Purus convallis ac luctus eu purus et egestas. 

Consectetur at at magna viverra mauris. Leo augue in nullam laoreet. Eu adipiscing suspendisse eros dis torquent integer et sed tortor ac habitasse et nec. Ullamcorper aliquam maecenas platea et ut integer bibendum justo. Gravida cum est et porttitor ut purus in. Urna magnis ad at senectus in laoreet ut tempor, varius velit. Ac varius lorem, facilisi, blandit, cum ante mauris eu dui enim pharetra. Felis sed odio faucibus netus eget sed vestibulum. Nostra non libero suscipit sed sed egestas. Proin, nulla. Felis suscipit nec pellentesque id gravida ipsum massa. Sagittis consequat quis consequat. Dictumst lectus molestie, est, ut vitae consectetur. Leo mauris eget congue.   

Sed dapibus feugiat iaculis erat nibh lobortis sagittis eleifend convallis in. Tristique ac ipsum curabitur amet et leo interdum! Donec mus pharetra. Sed, metus non mauris phasellus semper ut pulvinar fermentum sodales. Bibendum mollis dignissim sed, in dui. Pellentesque sed in elit montes sed tincidunt euismod, eros sit ultrices! Etiam at metus ut aenean libero amet. Feugiat facilisis posuere justo quis faucibus vitae nullam nulla. Scelerisque sapien hendrerit lobortis, pulvinar non nostra amet vehicula ac sed. Ex eget eleifend luctus fusce. Tincidunt in pulvinar eget rhoncus eu eget vitae lacus ornare nunc lacinia amet lacus! Eros interdum suscipit aliquet donec tincidunt phasellus est hendrerit.

Taciti ac, nec non ornare amet litora nascetur nunc elementum. Sollicitudin ut sit conubia et habitasse, integer. Egestas egestas cubilia id facilisi. Tempor ut nec facilisi congue, varius tortor. Aliquam viverra a ipsum aptent eu eu. Id purus metus volutpat malesuada et. In nec consequat eros sed nec at mauris ligula. Ut sapien, eget, in in, potenti torquent, semper mollis ligula vel. Sem quisque varius eros lobortis ut ac mus, dui. Senectus mattis eget, himenaeos pellentesque vitae varius adipiscing, taciti justo. Mauris morbi nunc, laoreet a, non, iaculis libero varius dis tincidunt tortor a.                                                                                                        
Nibh, amet sit sociis, eros in. Ac odio eros luctus at, mauris, tincidunt. Tristique phasellus etiam vel quis, netus tincidunt, tristique eros. Scelerisque massa integer ac aliquet porta non taciti. In ante, consectetur nullam urna, nunc volutpat pellentesque libero tortor nisi! Ante amet habitasse in est dis pellentesque. Nec turpis quis, natoque sagittis ac vestibulum morbi velit mattis. Purus convallis ac luctus eu purus et egestas. 

Consectetur at at magna viverra mauris. Leo augue in nullam laoreet. Eu adipiscing suspendisse eros dis torquent integer et sed tortor ac habitasse et nec. Ullamcorper aliquam maecenas platea et ut integer bibendum justo. Gravida cum est et porttitor ut purus in. Urna magnis ad at senectus in laoreet ut tempor, varius velit. Ac varius lorem, facilisi, blandit, cum ante mauris eu dui enim pharetra. Felis sed odio faucibus netus eget sed vestibulum. Nostra non libero suscipit sed sed egestas. Proin, nulla. Felis suscipit nec pellentesque id gravida ipsum massa. Sagittis consequat quis consequat. Dictumst lectus molestie, est, ut vitae consectetur. Leo mauris eget congue.   

The file that is produced is attached:

latex-15-floating.pdf

@AaronGullickson AaronGullickson marked this pull request as ready for review February 26, 2024 20:36
@rich-iannone
Copy link
Member

@AaronGullickson Apologies for not commenting earlier but thank you for the work done here! We have another PR underway that focuses on LaTeX output (#1595). It would be good to have that merged first before reviewing this one. (After that one is merged, the merge conflict here could be also addressed.)

@AaronGullickson
Copy link
Contributor Author

@rich-iannone Sounds good. One important thing to consider when reviewing is which case (floating table or longtable) should be the default. I set it up here with floating table as the default, because I think that will be a more common case - i.e. if a table is not too long for a page, it should float by default. However, this will be a breaking change for existing documents in the sense that someone with a multipage table will now have it running off the page. I think its worth it for the long term benefit, but wanted to raise the issue here.

Merge branch 'master' into floating-table

# Conflicts:
#	tests/testthat/test-as_latex.R
Instead of trying to add \begin{table} and \end{table} within various functions, I moved this step to the export.R as_latex function to create a wrapping environment that is either \begingroup-\endgroup for longtables or \begin{table}-\end{table} for floating tables. This will allow floating tables to be able to use fontsize changes and any other future changes that are meant to be added below the enclosing environment.
@AaronGullickson
Copy link
Contributor Author

I made some changes to how the wrapping table environment is injected as described in the comments on commit 0e4503d. Basically, longtable should be surrounded with \begingroup and \endgroup but tabular should be surrounded by \begin{table} and \end{table}. This approach is much saner and makes it easier for both approaches to use things like the font size changes.

I have also updated tests and I think its ready to go. Its failing something with word, but I think that is unrelated to anything I am doing.

@AaronGullickson
Copy link
Contributor Author

I am actually going to make one more change - I want to see if I can give the user the ability to specify the float position with a table option, rather than depend on Quarto.

@AaronGullickson
Copy link
Contributor Author

Ok, never mind about the floating position. When using captions from a code chunk, pandoc injects caption information into the table immediately after the curly closing bracket of \begin{table} which breaks the pre-existing floating position and you just end up with unintentional text in the table. So its better to specify floating position with the code chunk option tbl-pos which works correctly.

I added a news item and all checks are passing. It should be ready for review.

@kbrevoort
Copy link
Collaborator

@AaronGullickson May I ask a question about this PR as an interested user who would love for {gt} to include a float option?

I believe that the tbl-pos chunk option only works in Quarto. That won't be available to users who want to keep working with RMarkdown or people who want to use {gt} to generate tables that they can upload to Overleaf or use with a local install of TeX Live. Is it possible for those users to specify a floating position without editing the code by hand each time they generate a table?

@AaronGullickson
Copy link
Contributor Author

@kbrevoort Thats a good point. I did try to add that as another tab_option but found that it will not work correctly in Quarto. Let my try it again and see if it works in R Markdown. I can just add some documentation to the option to tell Quarto users not to do it this way, I suppose.

@rich-iannone
Copy link
Member

Just wanted to chime in here and offer that the check_quarto() function could be used at render time to determine whether the rendering is occurring in a Quarto environment. This could be used in a conditional to enable options that are specific to Quarto.

Adds a latex.tbl.pos option to tab_options. The value here will be applied to latex output when a floating table is used to specify the floating position. It checks whether we are in a quarto environment to avoid messing up quarto output since floating position should be specified in tbl-pos chunk option in quarto docs.
Copy link
Collaborator

@olivroy olivroy left a comment

Choose a reason for hiding this comment

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

Thanks for working on this! A few comments.

Also, I tested this locally with usethis::pr_fetch(1588).

There is something I don't understand.

Given the following code (Rmd):

---
title: "latex-03-pressure"
output: 
  - pdf_document
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
devtools::load_all(".")
```

Create a display table based on `pressure`.

```{r}
pressure %>% dplyr::bind_rows(pressure) %>% dplyr::bind_rows(pressure) %>% 
gt() %>%
  fmt_scientific(
    columns = pressure,
    decimals = 2
  ) %>% 
  tab_options(latex.use.longtable = TRUE)
```

I notice that the table headings aren't repeated as the table crosses 2 pages. 
![image](https://github.com/rstudio/gt/assets/52606734/7d294501-a5a3-4ce0-8bc5-5b5f9c306396)

I haven't followed the full conversation, so please enlighten me. In the longtable manual, this seems like a supported feature. It could be supported via page.header.use_tbl_headings

R/utils_render_latex.R Outdated Show resolved Hide resolved
@@ -35,7 +35,7 @@ gt(
data = tbl,
groupname_col = "date"
) %>%
tab_header(title = "The Table Title", subtitle = "The subtitle.") %>%
#tab_header(title = "The Table Title", subtitle = "The subtitle.") %>%
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why did you comment that out?

Copy link
Member

Choose a reason for hiding this comment

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

I looked into this and if the line is uncommented and tab_options(latex.use.longtable = TRUE) is removed, we get a LaTeX error when rendering the .Rmd file:

! You can't use `\hrule' here except with leaders.
\caption@hrule ->\hrule 
                        \@height \z@ 
l.199 }
        \\ 

Error: LaTeX failed to compile latex-13-adding_footnotes.tex. See https://yihui.org/tinytex/r/#debugging for debugging tips. See latex-13-adding_footnotes.log for more info.
Execution halted

Copy link
Collaborator

Choose a reason for hiding this comment

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

@AaronGullickson Are you able to fix this? It is important that LaTeX tables don't get compilation issues if they have a header

Copy link
Contributor

@nielsbock nielsbock Jul 11, 2024

Choose a reason for hiding this comment

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

The error is due to the unnumbered caption being placed within the tabular environment when tab_options(latex.use.longtable = FALSE). I'm not exactly sure how why the error occurs in the test because this specific problem is solved with the code in lines 727-762 in R/export.R.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I must have commented that out early on and forgot about it. However, when I uncomment the line, the Rmd file renders fine for me with the latest changes from the PR. @rich-iannone Can you please confirm it gives you that error with the latest?

Copy link
Member

Choose a reason for hiding this comment

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

@AaronGullickson everything is good here now!

tests/testthat/test-as_latex.R Outdated Show resolved Hide resolved
groups = 'grp_a',
fmt = ~ fmt_number(., use_seps = TRUE)) %>%
grand_summary_rows(fns =list(list(label = 'grand total', fn = 'sum')),
columns = c('num', 'currency'),
Copy link
Collaborator

Choose a reason for hiding this comment

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

Idem here! You can use styler to restyle the selection in RStudio. https://styler.r-lib.org/

@olivroy
Copy link
Collaborator

olivroy commented Jul 11, 2024

Maybe some \endhead \endfirsthead \endfoot \endlastfoot could be placed strategically From Ch 3 https://mirrors.ibiblio.org/CTAN/macros/latex/required/tools/longtable.pdf

I don't know LaTeX that much, and this feels a bit like trial and error to me.

@kbrevoort
Copy link
Collaborator

@olivroy There are a couple of open issues about headers & captions not repeating on tables that span multiple pages (#1630, #1061). The reason I haven't submitted a PR on that myself is my sense is that, while having the column headers repeat on each page would be very easy, repeating the captions (i.e., "Table 1: My Table Title (continued)" on subsequent pages) would be trickier. I'm confident it's doable (and if someone wants to get to it before I do, great!) but it's probably worthy of its own PR.

It's also a very different issue than what @AaronGullickson is addressing. This PR provides an alternative environment to longtable with many benefits for users (myself included). But one thing the new floating environment can't do is span multiple pages. It's not my call, but I recommend not holding up this PR because it doesn't fix an unrelated issue. (We can work on #1630 and #1061, and hopefully, the change that @kuriwaki was asking for while people kick the tires of the new environment.)

I hope that helps. @AaronGullickson, thanks for implementing a floating environment. I'm looking forward to trying it out once it's merged!

rich-iannone and others added 3 commits July 10, 2024 21:30
Co-authored-by: olivroy <52606734+olivroy@users.noreply.github.com>
Co-authored-by: olivroy <52606734+olivroy@users.noreply.github.com>
@olivroy
Copy link
Collaborator

olivroy commented Jul 11, 2024

@kbrevoort thanks for the explanations!

@AaronGullickson thanks for sticking with it

@rich-iannone I recommend merging this and possibly have longtable be the default at some point. The fact that long tables can now be broken up across pages instead of overflowing is a nice improvement! (EDIT: given the resolution of #1588 (comment) if possible)

@rich-iannone
Copy link
Member

@AaronGullickson if you could make that tab_header() fix, then I think we could proceed with merging this PR.

@AaronGullickson
Copy link
Contributor Author

Thanks for all of this helpful feedback. I am away for a few days built will make the corrections first thing Monday.

Comment on lines 783 to 784
tab_footnote(footnote = "A footnote.") %>%
tab_options(latex.use.longtable = TRUE)
Copy link
Collaborator

@olivroy olivroy Jul 12, 2024

Choose a reason for hiding this comment

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

Please disregard.

Copy link
Member

Choose a reason for hiding this comment

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

Regarding the option latex.use.longtable, could we rename this slightly to latex.use_longtable? This is just for consistency with the idea that dots separate either locations, contexts, or actions. It seems to me that use_longtable is a single concrete action here.

olivroy added 2 commits July 12, 2024 15:45
Merge commit '294c09c434b492f4346f9339e3632476b052714f'

#Conflicts:
#	NEWS.md
#	tests/testthat/helper-gt_attr_expectations.R
#	tests/testthat/test-summary_rows_latex.R
@olivroy
Copy link
Collaborator

olivroy commented Jul 12, 2024

@AaronGullickson when you take this on, please merge my PR first AaronGullickson#4. I took care of resolving some merge conflicts.

@AaronGullickson
Copy link
Contributor Author

I think I have made all the requested changes. I changed the option name from latex.use.longtable to latex.use_longtable . I also uncommented the line I commented out in one of the Rmd files. It renders fine for me locally using either the table or longtable environment.

One last issue to consider is the default environment. Currently, this PR uses a floating table environment as the default. I would argue that this is the best approach because tables that are not longer than a page should be floated for the best results. Thus, longtable is only really needed for long tables, as the name implies. This does however change the environment from its previous default (and only environment) which was longtable, which could cause some confusion when users re-render existing documents (for example).

@rich-iannone rich-iannone self-requested a review July 15, 2024 20:30
@rich-iannone
Copy link
Member

Thanks again @AaronGullickson for all your time and patience with this. We're finally going to merge this PR; will do so after all CI runs pass!

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

Successfully merging this pull request may close these issues.

Add options for specialized environments before and after LaTeX table code
7 participants