lvjr / tabularray

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

Excluding rows and columns #382

Open Enivex opened 1 year ago

Enivex commented 1 year ago

If I want to add a textbullet in front of every cell in a column, except say those in row 5 and 9 (maybe used for comments to items in a list) I'll have to write

cell{1-4,6-8,10-Z}{3} = {preto=\textbullet\,}

It would be great if it was possible to do this using something like

cell{1-Z_5,9}{3} = {preto=\textbullet\,}

or even

cell{-_5,9}{3} = {preto=\textbullet\,}

(I have no idea what a good separator would be, so I just choose _ at random.)

lvjr commented 1 year ago

You could define a new selector not with \NewChildSelector command so that you could write

cell{not{5,9}}{3} = {preto=\textbullet}

You can search even or odd in the source code to see how these selectors are defined.

In the future, we might provide more selectors (such as and for intersection of two sets). But we need to handle compositions of selectors such as and{odd[5]}{every{7}} (we have not yet added every selector (https://github.com/lvjr/tabularray/issues/301)).

Enivex commented 1 year ago

Thanks, I'll definitely take a look at how even and odd are defined. Though I suspect that it would take me a significant amount of time to implement myself, since I'm not really familiar with the more behind-the-scenes latex usage (meaning the kind you need to author packages like this).

Enivex commented 1 year ago

By the way:

if you plan to add more selectors it would be useful to have non-inclusive before and after selectors. Especially if the IDs get implemented.

That way I can do

row{before{Hello}} row{Hello} row{after{Hello}}

You could even have an optional argument. Let's say

before[1]{Hello} means the same as before{Hello} before[0]{Hello} would be inclusive before[2]{Hello} would include be all rows up to but not including that row and the one immediately before it. before [-1]{Hello} would include all rows up to and including the row and the one immediately after it.