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

Cannot use multiple tab_source_note in a LaTeX table (works in HTML) #593

Closed
vincentarelbundock opened this issue May 22, 2020 · 0 comments · Fixed by #864
Closed

Cannot use multiple tab_source_note in a LaTeX table (works in HTML) #593

vincentarelbundock opened this issue May 22, 2020 · 0 comments · Fixed by #864

Comments

@vincentarelbundock
Copy link

We can use multiple calls to tab_source_note to insert multiple notes at the bottom of a table. These notes appear correctly in HTML, but only the first note appears in LaTeX output.

Example:

library(gt)

tab <- data.frame(x = 1:2, y = 2:3) %>%
       gt %>%
       tab_source_note('note 1') %>%
       tab_source_note('note 2')

tab %>% as_latex %>% cat
#> \captionsetup[table]{labelformat=empty,skip=1pt}
#> \begin{longtable}{cc}
#> \toprule
#> x & y \\ 
#> \midrule
#> 1 & 2 \\ 
#> 2 & 3 \\ 
#> \bottomrule
#> \end{longtable}
#> \begin{minipage}{\linewidth}
#> note 1\\ 
#> \end{minipage}

Created on 2020-05-22 by the reprex package (v0.3.0)

The result is correct in HTML:

tab

The problem is related to Line 326 of the utils_render_latex.R file, which only selects the first element of the list of notes. In my gt fork, I removed that line and it fixed the problem:

https://github.com/rstudio/gt/blob/master/R/utils_render_latex.R#L326

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