Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vertical misalignment of arrays #2083

Closed
kwkbtr opened this issue Nov 21, 2018 · 3 comments
Closed

Vertical misalignment of arrays #2083

kwkbtr opened this issue Nov 21, 2018 · 3 comments
Labels
Expected Behavior This is how MathJax works

Comments

@kwkbtr
Copy link

kwkbtr commented Nov 21, 2018

Minimal test case: https://jsbin.com/vedulobegu/1/edit?html,output

The top padding of (the first line of) a LaTeX array changes depending on existence of horizontal rules inside the array.
In the above test case, top edges of two arrays are misaligned with each other.
It seems that the difference comes from this code: 577b37e#diff-2f75a19c51cea069923d362e44d2deb0R154
Is this expected behavior? Is there any workaround to align them?

@dpvc
Copy link
Member

dpvc commented Nov 21, 2018

Is this expected behavior?

Yes, this is the expected behavior at the moment. In fact, the commit that you reference specifically established this behavior (as described in the commit message).

The easiest way to get the two to be the same size would be either to add padding to the one without the line to make it the same size as the other, or to add negative margin to the one with the line to remove the extra padding that it gets because of the line.

The first could be handled via:

\bbox[padding: .5ex .4em]{\begin{array}{ll}
        AB & CD\\
        EF & GH\\
        IJ & KL
        \end{array}}

to match the extra frame spacing that the line forces on the array, while the second would be

\bbox[margin: -.5ex 0]{\begin{array}{ll}
        AB & CD\\
        EF & GH\\ \hline
        IJ & KL
        \end{array}}

to remove the extra vertical spacing from the array with the line. (You could use -.4em in place of the 0, but because the lines do extend .4em beyond the array, you might not want to do that.)

@dpvc dpvc added the Expected Behavior This is how MathJax works label Nov 21, 2018
@kwkbtr
Copy link
Author

kwkbtr commented Nov 21, 2018

Thank you for the answer.

In fact, the commit that you reference specifically established this behavior (as described in the commit message).

I do not understand why this behavior is introduced.
The commit message "Make mtable row and column lines extend through frame spacing even when no frame is used" is about how far lines extend and it seems to me that it is unrelated to padding above first lines of arrays.
I hope this issue to be addressed, but I will try the workaround you suggested at the moment.

P.S. I am trying various features of MathJax currently and amazed by its quality and flexibility. Thank you for the great library!

@dpvc
Copy link
Member

dpvc commented Nov 21, 2018

I do not understand why this behavior is introduced.

It has to do with how the underlying MathML is handled (since the TeX is turned into MathML). In version 3, the lines will not extend as they do in v2. In version 2, any line causes the MathML frame spacing to be used (and the frame spacing is in both directions). The TeX conversion to MathML could have set the frame spacing to 0, but didn't in v2.

I am trying various features of MathJax currently and amazed by its quality and flexibility. Thank you for the great library!

You are welcome, and thank you for the kind words.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Expected Behavior This is how MathJax works
Projects
None yet
Development

No branches or pull requests

2 participants