lvjr / tabularray

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

Inconsistent behavior of abovepos and belowpos #272

Closed Felipe-Math closed 1 year ago

Felipe-Math commented 2 years ago

There is an inconsistency when setting belowpos=0.

If I set leftpos=0, rightpos=0 or abovepos=0 the behavior is the same: the line that is being setted doesn't cross any line, only touches the first line.

But, If I set belowpos=0, the vertical line covers the first horizontal line below.

The wiredest is that, if i set belowpos=0.0000000001, then the vertical line behaves just like the others, so it doesn't cover the first line below, only touches it.

MWE:

\documentclass{article}
\usepackage{tabularray}
\begin{document}
\begin{tblr}{
        hlines={ leftpos=0,rightpos=0,10pt},
        hlines={2}{-}{ leftpos=0,rightpos=0,10pt},
        vlines={10pt},
        vline1={abovepos=0,belowpos=0},
        vline2={abovepos=0,belowpos=0.00000001},
        vline3={abovepos=0,belowpos=1},
    }
    AAAAAA & BBBBB\\
    AAAAA & BBBBBB
\end{tblr}
\end{document}

That results: Print

Thanks

image

lvjr commented 2 years ago

If I set leftpos=0, rightpos=0 or abovepos=0 the behavior is the same: the line that is being setted doesn't cross any line, only touches the first line. But, If I set belowpos=0, the vertical line covers the first horizontal line below.

Either the above end or the below end of a vline segment has to cover a hline by default, otherwise you will get a hole in a vline of multirow cells, which is unacceptable.

The wiredest is that, if i set belowpos=0.0000000001, then the vertical line behaves just like the others, so it doesn't cover the first line below, only touches it.

I can treat all positve values as zeros for belowpos when there is only one hline below.

PS: you can copy and paste images directly in writing a github issue.

Felipe-Math commented 2 years ago

Thanks for answer me.

I've tried to drag the image directly in the github issue, but for some reason it doesn't worked.

This way of controling has some advantages, like setting 1 will garrantee that all lines are covered. But it has some disvantages, for instance, if you have 4 vertical lines and wants a horizontal line to exactly covers the second vertical line, then you need to make an account, like this: rightpos = (wd[1] + rulesep + wd[2])/(wd[1] + rulesep + wd[2] + rulesep + wd[3] + rulesep + wd[4]), where wd[i] denotes the width of the i-th line.

Perhaps some feature could be thinked to make some of this settings easier, perhaps someting like: rightpos = { to = 2, cover }, where to could be used to define until wich vline the hline "stretches", and keywords like cover, touch and middle to contol the intersecction behavior.

lvjr commented 2 years ago

This way of controling has some advantages, like setting 1 will garrantee that all lines are covered. But it has some disvantages, for instance, if you have 4 vertical lines and wants a horizontal line to exactly covers the second vertical line, then you need to make an account, like this: rightpos = (wd[1] + rulesep + wd[2])/(wd[1] + rulesep + wd[2] + rulesep + wd[3] + rulesep + wd[4]), where wd[i] denotes the width of the i-th line.

Not time for tests, but I think rightpos=0.3333 is more or less enough in most of the time.

Perhaps some feature could be thinked to make some of this settings easier, perhaps someting like: rightpos = { to = 2, cover }, where to could be used to define until wich vline the hline "stretches", and keywords like cover, touch and middle to contol the intersecction behavior.

We have to make a compromise between functionality and performance. Many people agree with the opinion of booktabs package that vertical lines are evil. And I have never seen a real document which uses more than two hlines or vlines. Therefore I think it is acceptable to provide a simplified solution for better performance (actually some users have complained about the speed of tabularray package).

lvjr commented 2 years ago

I decide to make the behavior of abovepos and belowpos the same as leftpos and rightpos: with value 0 a vline segment touches the first hline. And it has default position that covers the first hline. This will also fix issue #216.