ForNeVeR / xaml-math

A collection of .NET libraries for rendering mathematical formulae using the LaTeX typesetting style, for the WPF and Avalonia XAML-based frameworks
MIT License
637 stars 100 forks source link

Alignment issue in matrix with an empty cell. #387

Closed Orace closed 1 year ago

Orace commented 1 year ago

There is an alignment problem in the matrix rendering when there is an empty cell.

Ex: \matrix{A & B \\ A & B \\ & B} image

It seems that the issue is located in GetTopBottomPadding: https://github.com/ForNeVeR/xaml-math/blob/77d0bceeab5e6790cfb0b9a193b65f22b4217385/src/XamlMath.Shared/Atoms/MatrixAtom.cs#L139-L145

If one replace the shift argument by 0:

Tuple<Box, Box> GetTopBottomPadding(int i, int j)
{
    var value = matrixCellGaps[i][j].Vertical;
    var topBox = new StrutBox(0.0, VerticalPadding / 2 + value, 0.0, 0.0);
    var bottomBox = new StrutBox(0.0, VerticalPadding / 2 + value, 0.0, 0.0);
    return new Tuple<Box, Box>(topBox, bottomBox);
}

The issue disappears: image

I don't have enough hindsight to know if there are side effects.

ForNeVeR commented 1 year ago

I believe that your fix is correct. I can't remember the purpose of non-zero Shift in this place either.