lvjr / tabularray

Typeset tabulars and arrays with LaTeX3
https://ctan.org/pkg/tabularray
247 stars 22 forks source link

Automatic colspec #319

Closed london111 closed 1 year ago

london111 commented 1 year ago

I think a nice feature for the future would be that you don't need to specify the number of columns, i.e. that something like

\begin{tblr}
a & b & c \\
\end{tblr}

should work (with a default col spec), so in particular you don't need to know or count the number of columns.

Then it should be possible to specify the colspec for specific columns directly, for example:

\begin{tblr}{colspec{3}={l}}
a & b & c \\
\end{tblr}

This should just set the column type of the third row (if existent, if not just throw a warning, but no error).

Moreover something like this

\begin{tblr}{colspec{2,4}={c},colspec{3}={l}}
a & b & c  & d & e & f \\
\end{tblr}

should also work (i.e. setting the column type of columns 2 and 4 to c and that of 3 to l). Maybe allowing also ranges like colspec{2...5} = ...

In this context it would also be great to implement named columns (by the context of the first row), i.e. something like

\begin{tblr}{colspec{b,d}={c},colspec{c}={l}}
a & b & c  & d & e & f \\
A & B & C & D & E & F\\
\end{tblr}

I.e. referencing the columns by name not by number.

lvjr commented 1 year ago

This feature is already there since the first public release. Please see the manual.

\SetTblrInner{hlines,vlines,columns={r}}

\begin{tblr}{}
a  & b  & c  & d  & e  & f  \\
AA & BB & CC & DD & EE & FF \\
\end{tblr}

\begin{tblr}{column{1,Z}={c},column{2-Y}={l}}
a  & b  & c  & d  & e  & f  \\
AA & BB & CC & DD & EE & FF \\
\end{tblr}
london111 commented 1 year ago

Thanks, great. I overlooked this in the manual. If I am not mistaken, the first occurrence of such an example is in manual is in section 2.2.1. Maybe one could mention it already in 1.1 that the number of columns could be detected automatically. However the "named" reference doesn't seem to be implemented yet? May I ask for this in a new post?

lvjr commented 1 year ago

However the "named" reference doesn't seem to be implemented yet? May I ask for this in a new post?

Sorry, it is unlikely that I will implement named columns by the context of the first row.

london111 commented 1 year ago

Ok thanks. The idea was to be able to reference the columns similar as in python pandas. Maybe for the remote future...