Add \jot lineskip to aligned environment, switch contents to displaystyle, and add gathered#725
Add \jot lineskip to aligned environment, switch contents to displaystyle, and add gathered#725k4b7 merged 4 commits intoKaTeX:masterfrom
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 |
| // Vertical spacing | ||
| const baselineskip = 12 * pt; // see size10.clo | ||
| // Default \jot from ltmath.dtx | ||
| // TODO(edemaine): allow overriding \jot via \setlength (#687) |
|
whoops... I only meant to "comment" not "close and comment". |
| rowsAreLines: true, | ||
| }; | ||
| res = parseArray(context.parser, res); | ||
| res = parseArray(context.parser, res, "display"); |
There was a problem hiding this comment.
Is the aligned environment also supposed to be in \displaystyle only?
There was a problem hiding this comment.
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.
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.
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.
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.
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
alignedandgathered(not yet implemented in KaTeX, see #682) use\openup\jotto increase\baselineskipby\jot(which defaults to 3pt, see #687 for overriding). This lineskip in turns defines\strutboxin thearrayenvironment, which then gets scaled by\arraystretch. (As reported in #686, which this PR fixes.)I've added a
rowsAreLinesoption toarrayobjects 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 implementgatheredin #682.texcmp Alignedbefore this change:texcmp Alignedafter this change:Note that other environments like
arrayremain unaffected, as they were already correct (vertically anyway):