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
longtable + booktabs breaks on row starting with ( or [ #145
Comments
I've tried out the code and indeed ran into the LaTeX error because the compiler thinks that |
I'm curious to know what other issues you encountered. No pressure though, i know time is scarce. In library(gt)
library(gtsummary)
data.frame('a' = c('(BAD)', 'OK'), 'b' = 1:2) %>% gt() %>% as_latex() %>% cat
#> \captionsetup[table]{labelformat=empty,skip=1pt}
#> \begin{longtable}{cr}
#> \toprule
#> a & b \\
#> \midrule
#> (BAD) & 1 \\
#> OK & 2 \\
#> \bottomrule
#> \end{longtable}
data.frame('a' = c('(BAD)', 'OK'), 'b' = 1:2) %>% gt() %>% gtsummary::knit_latex() %>% cat
#> \captionsetup[table]{labelformat=empty,skip=1pt}
#> \begin{longtable}{cr}
#> \toprule
#> a & b \\
#> \midrule\relax
#> (BAD) & 1 \\
#> OK & 2 \\
#> \bottomrule
#> \end{longtable} Created on 2019-01-31 by the reprex package (v0.2.1) |
Let me know if this belongs in a separate issue, but I wonder if this bug is related (which is also not limited to library(tidyverse)
library(gt)
tribble(
~groupname, ~Subtype, ~Units,
"Group1", "A", 100,
"Group2", "B", 200) %>%
gt() %>%
as_latex() %>%
cat
#> \captionsetup[table]{labelformat=empty,skip=1pt}
#> \begin{longtable}{lr}
#> \toprule
#> Subtype & Units \\
#> \midrule
#> \multicolumn{1}{l}{Group1} \\
#> \midrule
#> A & 100 \\
#> \midrule
#> \multicolumn{1}{l}{Group2} \\
#> B & 200 \\
#> \bottomrule
#> \end{longtable} Created on 2019-02-05 by the reprex package (v0.2.1) |
Just encountered this when using gtsummary with a quarto pdf. Any regression table including an intercept "(Intercept)" will fail because the top leftmost cell starts with a parenthesis. I've been testing what works and what fails, and wanted to leave it here in case is useful
|
Apparently, when using both booktabs and longtable, if a row starts with the characters ( or [, latex compilation doesn't work. This happened to me when attempting to compile a notebook where a table had "(Intercept)" as a cell in the left-column.
This weird behavior is not caused by
gt
per se. One solution is documented here: https://tex.stackexchange.com/questions/228755/undefined-control-sequence-on-left-parenthesis-after-midrule-in-longtable/228756#228756That is to use
\midrule\relax
instead of just\midrule
.I could probably hack around this in
gtsummary
, but this problem may arise for othergt
users as well.What do you think?
The text was updated successfully, but these errors were encountered: