lvjr / tabularray

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

Naming cells, rows and columns #381

Open Enivex opened 1 year ago

Enivex commented 1 year ago

I like to use the new interface, where cell properties are handled outside the table itself. Currently (unless I'm missing something), it is only possible to do so using explicit numbers, the letters U-Z for the final rows, and odd/even. This is extremely tedious if you want to change specific cells or rows and make changes that shift the numbering around (you have to update everything).

What I'm looking for is something like \TblrLabel{clever_cell_name} that I can put inside the cell and then be able to write

column{clever_cell_name} = {preto=\textbullet\,} or row{clever_cell_name} = {font = \bfseries} or cell{clever_cell_name} = {r=2,c=1}{}

lvjr commented 1 year ago

It is possible to provide \SetId and \SetClass commands (similar to those in html/css). With \SetId{Hello} at the beginning of one cell, its rownum and colnum are saved and you could write

row{Hello} = {...}
column{Hello} = {...}

or

row{2-Hello} = {...}
column{Hello-Z} = {...}

With \SetClass{World} at the beginning of some cells, their rownums and colnums are saved and you could write

row{class{World}} = {...}
column{class{World}} = {...}

where class is a new child selector (see also https://github.com/lvjr/tabularray/issues/382).

The names of ids and classes must start with capital letters and the names of selectors must start with lowercase letters, so that we can easily distinguish them.

Enivex commented 1 year ago

That would be great! Although I have some questions:

Would you need to write cell{Hello}{Hello} to refer to the specific cell, or would it be possible to have the less verbose cell{Hello}?

This distinction becomes more important for the class, because if I add cells (1,2) and (2,1) to World then presumably cell{class{World}}{class{World}} would affect cells (1,2), (2,1), (1,1) and (2,2), while you'd really like cell{class{World}} to affect only (1,2) and (2,1).

Hopefully I explained myself clearly.

lvjr commented 1 year ago

Yes, it seems we need to first make tabularray accept syntax like this (I'm not sure which one is the best)

cell{{1}{2},{2}{1},{3}{4},{4}{3}}

or

cell{{1,2},{2,1},{3,4},{4,3}}

or

cell{{1,2}{2,1}{3,4}{4,3}}

or

cell{1:2,2:1,3:4,4:3}

so that we can write

cell{class{World}}
Enivex commented 1 year ago

cell{{1,2},{2,1},{3,4},{4,3}}

Looks nicest to my eyes, and aligns the closest with usual notation for sets of tuples.