gt
gt copied to clipboard
Characters generated using `fmt_number()` with the `pattern` argument are not escaped when rendered with `as_latex()`
If I try to add a % after a number, with fmt_number(pattern = "{x} %"), the % is not escaped when the table is converted to latex.
(I know I should use fmt_percent() but my actual pattern is a bit more complicated).
library(gt)
test_table <- gt(exibble[1:2,1:2]) %>%
fmt_number(columns = "num", rows = 1, pattern = "{x} %")
test_table

test_table %>%
as_latex() %>%
as.character() %>%
cat()
#> \captionsetup[table]{labelformat=empty,skip=1pt}
#> \begin{longtable}{rl}
#> \toprule
#> num & char \\
#> \midrule
#> $0.11$ % & apricot \\
#> 2.222 & banana \\
#> \bottomrule
#> \end{longtable}
Created on 2021-10-27 by the reprex package (v2.0.0)
Thanks for filing this issue. This is a pretty bad bug so I’m hoping to get a fix for it sooner than later!