Gt: `escape_latex` should be applied to stub

Created on 24 Jan 2019  路  1Comment  路  Source: rstudio/gt

escape_latex is not applied to the stub, which breaks latex compilation when the stub includes invalid characters. Below, the first example produces valid LaTeX, since test_this in cells is properly escaped. The second example does not compile because test_this is in the stub column and escape_latex function is not applied there.

library(gt)
library(magrittr)

# "test_this" is properly escaped
data.frame('first' = c('test_this', 'test'),
           'second' = 1:2) %>% 
  gt() %>% 
  as_latex %>% 
  cat()
#> \captionsetup[table]{labelformat=empty,skip=1pt}
#> \begin{longtable}{cr}
#> \toprule
#> first & second \\ 
#> \midrule
#> test\_this & 1 \\ 
#> test & 2 \\ 
#> \bottomrule
#> \end{longtable}

# "test_this" is NOT properly escaped
data.frame('first' = c('test_this', 'test'),
           'second' = 1:2) %>% 
  gt(rowname_col = 'first') %>% 
  as_latex %>% 
  cat()
#> \captionsetup[table]{labelformat=empty,skip=1pt}
#> \begin{longtable}{lr}
#> \toprule
#>  & second \\ 
#> \midrule
#> test_this & 1 \\ 
#> test & 2 \\ 
#> \bottomrule
#> \end{longtable}

Created on 2019-01-23 by the reprex package (v0.2.1)

[1] Novice [1] Low [3] High 鈽癸笌 Bug

Most helpful comment

Thanks for letting me know about this. I will make sure that escape_latex() is applied to the stub content when rendering to LaTeX.

>All comments

Thanks for letting me know about this. I will make sure that escape_latex() is applied to the stub content when rendering to LaTeX.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jestarr picture jestarr  路  3Comments

higgi13425 picture higgi13425  路  4Comments

steveputman picture steveputman  路  3Comments

jthomasmock picture jthomasmock  路  3Comments

courtiol picture courtiol  路  3Comments