Closed muzimuzhi closed 7 months ago
Thank you for this proposal. It looks good, but I have to test it later with more time.
I like the new \csvautotabularray
very much and I think this is a very valuable addition to the package.
Many people ask for customization of the \csvauto...
macros which are quite limited. The tabularray
variant opens much more possibilties for customization due to the power of the tabularray
package.
I will add some modified version of your proposal to the next version. Thank you!
Reviewing the change in 3cb41f7 (2.5.0, 2023-10-16), I found the updated tabularray
example can be a little bit better.
\begin{filecontents}[noheader]{data.csv}
land,group,amount
Bayern,A,1700
Baden-Württemberg,A,2300
Sachsen,B,1520
Thüringen,A,1900
Hessen,B,2100
\end{filecontents}
\documentclass{article}
\usepackage{csvsimple-l3}
\usepackage{tabularray}
\usepackage{xcolor}
\begin{document}
In v2.5.0
\csvautotabularray[table centered]{data.csv}
[
row{odd} = {blue!85!gray!7},
row{1} = {blue!50!gray!25, font=\bfseries},
hline{1,Z} = {0.1em, blue!50!black},
hline{2} = {blue!50!black}
]
Proposed, cells in first row prepended by \verb|\MakeUppercase|
\csvautotabularray[table centered]{data.csv}
[
row{odd} = {blue!85!gray!7},
row{1} = {blue!50!gray!25, font=\bfseries, preto=\MakeUppercase},
hline{1,Z} = {0.1em, blue!50!black},
hline{2} = {blue!50!black}
]
\end{document}
According to texdoc usrguide
, sec. 6 "Case changing",
Upper- and lower-casing are well-understood in general conversation. [...] The full range of Unicode UTF-8 input can be supported, with the proviso that at present the characters set up with 8-bit engines match those available in standard input encodings (
T1
,T2
,LGR
).
Hence maybe preto=\MakeUppercase
can also be safely added to autotabularray
and autolongtabularray
meta keys, like generic table options={ row{1} = {..., preto=\MakeUppercase}, ... }
.
PS: Since in tabularray
package \begin{longtblr}{...} ... \end{longtblr}
is the same as \begin{tblr}[long]{...} ... \end{tblr}
(see its doc for v2023A (2023-03-01), sec. 3.2.2 "Long and Tall Tables"), theoretically autolongtabularray
can be declared on top of autotabularray
, and \csvautolongtabularray{<file name>}
can be just \csvautotabularray{<file name>}[long][]
. The first way requires the outer and inner specifications of a tblr
table to be independently set, and the second way requires the outer and inner specifications to be additive. (\begin{tblr}[<outer spec>]{<inner spec>}
)
Current design is not flexible enough. I definitely forgot the outer spec part when opening this issue.
PS2: If the intention is to mimic the default rule widths of \toprule
(.08em), \midrule
(.05em), and \bottomrule
(.08em) in booktabs
package (just a guess), then hline{1,Z} = {0.08em}, hline{2} = {0.05em}
would be the goal (I have no preference).
Hence maybe
preto=\MakeUppercase
can also be safely added toautotabularray
andautolongtabularray
meta keys, likegeneric table options={ row{1} = {..., preto=\MakeUppercase}, ... }
.
Yes, I will add this.
PS: Since in
tabularray
package\begin{longtblr}{...} ... \end{longtblr}
is the same as\begin{tblr}[long]{...} ... \end{tblr}
(see its doc for v2023A (2023-03-01), sec. 3.2.2 "Long and Tall Tables"), theoreticallyautolongtabularray
can be declared on top ofautotabularray
, and\csvautolongtabularray{<file name>}
can be just\csvautotabularray{<file name>}[long][]
. The first way requires the outer and inner specifications of atblr
table to be independently set, and the second way requires the outer and inner specifications to be additive. (\begin{tblr}[<outer spec>]{<inner spec>}
)
I thought about this when creating the code and I also took a very quick look into the source code of tabularray
. Despite the statement in the documentation, tblr
and longtbl
are defined independendly, i.e. longtbl
is not build upon tblr
using the outer spec. I decided to follow the same approach and also define \csvautotabularray
and \csvautotabularray
by itself.
PS2: If the intention is to mimic the default rule widths of
\toprule
(.08em),\midrule
(.05em), and\bottomrule
(.08em) inbooktabs
package (just a guess), thenhline{1,Z} = {0.08em}, hline{2} = {0.05em}
would be the goal (I have no preference).
Indeed, I wanted that it looks booktabish. I will adapt the line width for the next version.
Despite the statement in the documentation,
tblr
andlongtbl
are defined independendly, i.e.longtbl
is not build upontblr
using the outer spec.
From related source lines in tabularray.sty
tblr
is defined by \NewTblrEnviron { tblr }
longtblr
is defined and configured by \NewTblrEnviron { longtblr } \SetTblrOuter [ longtblr ] { long }
talltblr
is defined and configured by \NewTblrEnviron { talltblr } \SetTblrOuter [ talltblr ] { tall }
in which \SetTblrOuter { <outer specs> }
without opt-arg is equivalent to \SetTblrOuter [ tblr ] { <outer specs> }
.
Hence defined by the same factory command \NewTblrEnviron
, these three envs (and most other similarly-defined envs) only differ in their initial outer (\SetTblrOuter
) and inner (\SetTblrInner
) specs.
I think is was done (?).
At first, I found the example displaying "a
tabularray
variant of the\csvautotabular
command" on page 59 (csvsimple-l3.pdf
, v2.4.0 (2023/05/09)) could be improved to using onlytabularray
inner options.Then I realized that there're no auto-tabular command for
tabularray
tables yet, hence tried to implement one.https://github.com/T-F-S/csvsimple/blob/e32ef0539140d6cfa79caf633fe50f9db1d9842d/doc/latex/csvsimple/csvsimple-l3.tex#L2844-L2864