Closed vincentarelbundock closed 4 months ago
@mjdcurtis, that sounds like a good idea.
One option that could be good is to add a tabularray=TRUE
(default) argument to this function:
https://github.com/vincentarelbundock/tinytable/blob/main/R/theme_tt.R#L17
It would be easy to use the utilities here to drop appropriate lines from the template and replace tblr
by tabular
.
I'm marking this as "Good First Issue" because most people should be able to implement this without deep knowledge of the code base.
In version 0.3.0.18 from Github, theme_tt("tabular")
returns a pure tabular
environment, without requiring booktabs
or tabularray
.
The tabular theme is fantastic if you follow the steps on the website.
If you use modelsummary, it doesn't work without some manual editing of the .tex output:
library(modelsummary)
library(tinytable)
reg<-lm(data=mtcars,mpg~cyl)
# still has talltblr syntax after begin
modelsummary(reg)|> theme_tt('tabular') |> print('latex')
# still has talltblr syntax after begin
# ends with talltblr
modelsummary(reg, stars = c('*' = .1, '**' = .05, '***' = 0.01))|>
theme_tt('tabular') |> print('latex')
If it helps, I was running something like:
simplify_table<-function(x){
ncol<-gregexpr('\\&', raw[which(raw=='\\toprule')+1])[[1]] |> length()
c(paste0('\\begin{tabular}{l',paste0(rep('r',ncol),collapse=''),'}'),
x[which(x=='\\toprule'):which(x=='\\bottomrule')],
'\\end{tabular}')
}
modelsummary(reg) |> print('latex')|> capture.output() |>simplify_table()
But it would not work in all cases, e.g. I removed group_tt commands etc. before running this.
(Please disregard if not helpful / annoying!)
This is fixed upstream in tinytable
Originally posted by @mjdcurtis in https://github.com/vincentarelbundock/tinytable/issues/30#issuecomment-2158178124