-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Add \jot lineskip to aligned environment, switch contents to displaystyle, and add gathered #725
Conversation
While I'm here, I tweaked the definition of the I'm going to add the |
0ef1ded
to
0c9a561
Compare
I added the Let me know if you can see where the extra vertical space is coming from in LaTeX... The difference is the |
@@ -592,6 +592,9 @@ groupTypes.array = function(group, options) { | |||
|
|||
// Vertical spacing | |||
const baselineskip = 12 * pt; // see size10.clo | |||
// Default \jot from ltmath.dtx | |||
// TODO(edemaine): allow overriding \jot via \setlength (#687) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice TODO
whoops... I only meant to "comment" not "close and comment". |
src/environments.js
Outdated
}; | ||
res = parseArray(context.parser, res); | ||
res = parseArray(context.parser, res, "display"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the aligned
environment also supposed to be in \displaystyle only?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I checked in LaTeX, and $\begin{aligned} \frac{x}{y} \end{aligned}$
renders a display fraction.
src/environments.js
Outdated
// Count number of columns = maximum number of cells in each row. | ||
// At the same time, prepend empty group {} at beginning of every second | ||
// cell in each row (starting with second cell) so that operators become | ||
// binary. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is so that operators at the start of cell will have the proper spacing around them. What about operators at the end of a cell, or does that not happen in practice?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just added documentation here, because it took me a long time to figure out why the existing code was adding empty groups. I checked and this is indeed how it's implemented in amsmath, specifically in \start@aligned
. I'll add a note this effect.
src/buildHTML.js
Outdated
// In AMS multiline environments such as aligned and gathered, rows | ||
// correspond to lines that have additional \jot added to the | ||
// \baselineskip via \openup. | ||
if (group.value.rowsAreLines) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The naming of this variable is confusing to me. Aren't rows already lines? This just adds more space between the rows/lines. Maybe change this to addJotBetweenRows
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed, that is confusing. Renamed to addJot
, which seems clear enough (as \jot
is an interline spacing).
Comments addressed in 3c00b27 . Thanks for the review! |
@edemaine did you rebase and run |
@kevinbarabash Yes, I rebased. Almost no screenshot tests involve |
Thanks for the PR. Awesome to see how quickly new environments can be added. |
AMS environments
aligned
andgathered
(not yet implemented in KaTeX, see #682) use\openup\jot
to increase\baselineskip
by\jot
(which defaults to 3pt, see #687 for overriding). This lineskip in turns defines\strutbox
in thearray
environment, which then gets scaled by\arraystretch
. (As reported in #686, which this PR fixes.)I've added a
rowsAreLines
option toarray
objects in the parse tree that encourages the outputter (here, buildHTML) to add\jot
(currently hard-coded to 3pt, see #687) to each line. This seemed simpler than e.g. manually putting the equivalent of 3pt in the environment definition, and will be useful when we implementgathered
in #682.texcmp Aligned
before this change:texcmp Aligned
after this change:Note that other environments like
array
remain unaffected, as they were already correct (vertically anyway):