PgBiel / typst-tablex

More powerful and customizable tables in Typst
MIT License
370 stars 12 forks source link

Easily disable hlines and vlines at the edge of the table? #33

Open lf- opened 1 year ago

lf- commented 1 year ago

I have tried writing something like the following, but it seems clumsy. Is there a better way to turn off vlines and hlines inside a table? One issue I have is that I can't tell the dimensions of the table from inside map-hlines, so I can't automatically know the end of the table.

#tablex(
    columns: (auto, auto, auto, auto, auto),
    auto-vlines: false,
    map-hlines: h => if (h.y == 0 or h.y == 2) { hlinex(stroke: none) } else { h },
    (), vlinex(), vlinex(), vlinex(), vlinex(), (),
    [a], [$u$], [$v$], [c], [d]
)
PgBiel commented 1 year ago

Does the following work?

#tablex(
    columns: (auto, auto, auto, auto, auto),
    auto-vlines: false,
    hlinex(stroke: none),
    (), vlinex(), vlinex(), vlinex(), vlinex(), (),
    [a], [$u$], [$v$], [c], [d],
    hlinex(stroke: none)
)
PgBiel commented 1 year ago

Although I agree it'd be nice to be able to tell how far a certain line is from the end of the table when mapping it, so we can consider that a feature request.

lf- commented 1 year ago

Indeed, this works. It is kind of a bodge, but it absolutely works.