PgBiel / typst-tablex

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

H/vlines ending in the middle of col/rowspan not drawn #27

Open PgBiel opened 1 year ago

PgBiel commented 1 year ago

When lines are drawn with arbitrary length and they end at the middle of a col/rowspan, they are not drawn around that cell. This affects one of the examples in the README:

image

I've tracked this down to commit 875ebaf220a62d1cebe8db4d97636a69f8f53108, which was released in v0.0.2.

The third line in the snippet below was changed from + 1 to + cell.colspan, which considers hlines ending at the middle of cells as "having already ended" before the cell began (as it doesn't go all the way to the end of the span), and thus they are filtered out. (An equivalent change was done for vlines in that commit.)

https://github.com/PgBiel/typst-tablex/blob/875ebaf220a62d1cebe8db4d97636a69f8f53108/tablex.typ#L1383-L1385

Interestingly, however, they are drawn after a page turn.

Additionally, simply reversing the change to that particular line isn't enough, as it forces the line to be drawn all the way to the end of the cell.

See examples below.

#stack(dir: ltr, spacing: 2em,
    tablex(
        columns: 4,
        [a], [b], [c], [c],
        auto-lines: false,
        hlinex(start: 0, end: 1),
        [c], colspanx(3)[d],
        hlinex(start: 0, end: 2),
        [f], colspanx(2)[d], [e]
    ),
    tablex(
        columns: 4,
        [a], [b], [c], [c],
        auto-lines: false,
        hlinex(start: 0, end: 1),
        [c], colspanx(3)[d],
        hlinex(start: 0, end: 4),
        [f], colspanx(2)[d], [e]
    ),
)

#stack(dir: ltr, spacing: 2em,
    tablex(
        columns: 4,
        vlinex(start: 0, end: 1),
        rowspanx(2)[e], [b], [c], [c],
        auto-lines: false,
        (), [d], [e], [f]
    ),
    tablex(
        columns: 4,
        vlinex(start: 0, end: 2),
        rowspanx(2)[e], [b], [c], [c],
        auto-lines: false,
        (), [d], [e], [f]
    )
)

image