bartp5 / libtexprintf

Library providing printf-style formatted output routines with tex-like syntax support.
GNU General Public License v3.0
28 stars 2 forks source link

Sum not vertically centered #10

Closed larseggert closed 1 year ago

larseggert commented 1 year ago

utftex '\\sum_{i=6}^{10}\\left[\\binom{A}{i} \\binom{L}{10-i}\\right] produces

10
⎯⎯
╲  ⎡⎛A⎞ ⎛ L  ⎞⎤
╱  ⎢⎜ ⎟ ⎜    ⎟⎥
⎺⎺ ⎣⎝i⎠ ⎝10-i⎠⎦
i=6

Also, the bottom of the sum (⎺⎺) is using a different dash than the top (⎯⎯)?

bartp5 commented 1 year ago

That would be tweaking a bit. I use center aligning for the "drawn" symbols. The sum symbol here is 4 characters high, so it is aligned at the second character. As you noted correctly, I use different characters for the bottom and top line. This way the bottom line is a bit higher and the top line a bit lower, so these lines stay close to the rest of the symbol. However, as the bottom line is high, the alignment seems off.

The best way to fix that would be to draw the sum character differently. This is not so hard to do, I already have different "styles" for such drawn symbols. If you run ufftex with the -A option utftex will draw (often ugly) ASCII symbols. In the ASCII style you will see that at least the alignment is better:

utftex -A '\sum_{i=6}^{10}\binom{A}{i}'

10
__ /A\
\  | |
/_ \i/
i=6

vs

utftex '\sum_{i=6}^{10}\binom{A}{i}'

10
⎯⎯
╲  ⎛A⎞
╱  ⎜ ⎟
⎺⎺ ⎝i⎠

i=6

I could go for the ASCII version, or come up with some other way to draw a sum symbol. I once started with using the unicode Summation Top and Bottom symbols, which appear to be made for this. However, In many fonts these look awful, so it depends also on that.

utftex '⎲\\⎳'
⎲
⎳
bartp5 commented 1 year ago

I figured I cannot really take into account that there are fonts for which the unicode Summation Top and Bottom symbols look terrible. I added suggestions in the README for a good font to use. I close this issue.