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
LaTeX not compiling when "Intercept" is surrounded by () #50
Comments
OH WAIT. You've already opened this issue at gt: rstudio/gt#145 |
Yep, you found the problem @andrewheiss ! Howeeeever, I did put together a hack that should work until this is resolved upstream. If you look at the following portion of the README, you'll find example markdown documents that compile to pdf or tex, even with https://github.com/vincentarelbundock/modelsummary#latex-output-and-dynamic-documents-with-knitr Please let me know if that doesn't work for you. |
That works great! |
This problem seems to have returned. Here's a simple test document: ---
title: Test Document
format: pdf
---
```{r}
library(modelsummary)
lm(disp ~ hp, data = mtcars) |>
modelsummary()
``` I get the same LaTeX error when asking Quarto to render to PDF:
I think this changed some time in the past 6 months, since last fall I worked on a set of lecture notes that used modelsummary extensively, and I believe I rendered them to PDF successfully after the time I started using modelsummary. But I may be mistaken. Was the workaround removed at some point? |
@capnrefsmmat can you make sure you are running a very recent version of LaTeX (and especially the I tried your example on my local computer and it worked in both Quarto and Rmarkdown. A similar example is also included in the test suite, which passes on continuous integration machines. |
I was on MacTeX 2022, so I upgraded to 2023, then used the TeX Live Utility to upgrade all the packages to their latest version. That puts me on siunitx version 3.2.6. I also used Nonetheless, I get the same error with an updated version:
That was by running I'm not sure what else to try. If it tells you anything, here's how the table appears in my TeX file: \begin{longtable*}{lc}
\toprule
& (1) \\
\midrule
(Intercept) & 20.992 \\
& (32.607) \\
hp & 1.430 \\
& (0.202) \\
Num.Obs. & 32 \\
R2 & 0.626 \\
R2 Adj. & 0.613 \\
AIC & 372.8 \\
BIC & 377.2 \\
Log.Lik. & -183.412 \\
F & 50.128 \\
RMSE & 74.64 \\
\bottomrule
\end{longtable*} |
Are you doing something weird to get a |
Not as far as I know -- I've always been getting longtable environments in my Quarto files. Is the TeX for the table being generated by modelsummary, or does it generate a form that Quarto is converting (via Pandoc) to TeX? Because Pandoc automatically generates longtable by default. |
@capnrefsmmat Maybe you don't have the This is what I get. Notice the environment, and notice the \begin{table}
\centering
\begin{tabular}[t]{lc}
\toprule
& (1)\\
\midrule
(Intercept) & \num{30.099}\\
& (\num{1.634})\\
hp & \num{-0.068}\\
& (\num{0.010})\\
\midrule
Num.Obs. & \num{32}\\
R2 & \num{0.602}\\
R2 Adj. & \num{0.589}\\
AIC & \num{181.2}\\
BIC & \num{185.6}\\
Log.Lik. & \num{-87.619}\\
F & \num{45.460}\\
RMSE & \num{3.74}\\
\bottomrule
\end{tabular}
\end{table} |
Aha. I don't have kableExtra. That solves the problem. Thanks! I see the documentation says we can use kableExtra to customize tables, but I don't see anywhere saying it's necessary for LaTeX tables to work reliably. Maybe that can be stated prominently somewhere? (Or it is and I don't know where to look...) |
I'm seeing some strange behavior with current versions of modelsummary and gt. When knitting a document like this with LaTeX…
…I get this error about something with the (Intercept) line in the table:
If I edit the generated .tex file and remove the parentheses around
(Intercept)
, though, it compiles just fine:The text was updated successfully, but these errors were encountered: