vincentarelbundock / tinytable

Simple and Customizable Tables in `R`
https://vincentarelbundock.github.io/tinytable
GNU General Public License v3.0
204 stars 18 forks source link

`align="d"` is not supported for rows: `style_tt(i = 1, align = "d")` #361

Open simonheb opened 1 week ago

simonheb commented 1 week ago

The following code produces uncompilable LaTeX:

z <- data.frame(pi = c(pi * 100, pi * 1000, pi * 10000, pi * 100000))
tt(z) |>
    format_tt(j = 1, digits = 8, num_fmt = "significant_cell") |>
    style_tt(i = 1, align = "d") |> print("latex")

LaTeX:

\begin{table}
\centering
\begin{tblr}[         %% tabularray outer open
]                     %% tabularray outer close
{                     %% tabularray inner open
colspec={Q[]},
row{2}={si={table-format=-6.5,table-align-text-before=false,table-align-text-after=false,input-symbols={-,\*+()}},},
row{1}={guard},
}                     %% tabularray inner close
\toprule
pi \\ \midrule %% TinyTableHeader
314.15927 \\
3141.5927 \\
31415.927 \\
314159.27 \\
\bottomrule
\end{tblr}
\end{table} 

TeX Error message: "Undefined color `si'. \end".

I'm not sure what the ideal solution would be, since the user requests a rather unusual table configuration, but I guess it should be a t least some kind of error/warning.

vincentarelbundock commented 1 week ago

What did you insert in the LaTeX document preamble?

https://vincentarelbundock.github.io/tinytable/man/tt.html#latex-preamble

simonheb commented 1 week ago

This is the whole doc:

\documentclass{article}
\usepackage{tabularray}
\usepackage{booktabs}
\usepackage{siunitx}
\usepackage{amssymb}
\UseTblrLibrary{booktabs}
\UseTblrLibrary{siunitx}
\begin{document}
\begin{table}
    \centering
    \begin{tblr}[         %% tabularray outer open
        ]                     %% tabularray outer close
        {                     %% tabularray inner open
            colspec={Q[]},
            row{2}={si={table-format=-6.5,table-align-text-before=false,table-align-text-after=false,input-symbols={-,\*+()}},},
            row{1}={guard},
        }                     %% tabularray inner close
        \toprule
        pi \\ \midrule %% TinyTableHeader
        314.15927 \\
        3141.5927 \\
        31415.927 \\
        314159.27 \\
        \bottomrule
    \end{tblr}
\end{table}
\end{document}
vincentarelbundock commented 1 week ago

aah, sorry, I misread your original post.

align="d" is only supported as a column format, not as a row format.

I will add an informative error.