Skip to content

Commit 3870ee9

Browse files
edemainemvrgreptile-apps[bot]
authored
fix: remove extra \jot space at bottom of align/gather/etc. (#4184)
Co-authored-by: mvr <mitchell.v.riley@gmail.com> Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
1 parent e74702f commit 3870ee9

8 files changed

Lines changed: 25 additions & 3 deletions

File tree

src/environments/array.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -366,9 +366,10 @@ const htmlBuilder: HtmlBuilder<"array"> = function(group, options) {
366366
}
367367
}
368368
// In AMS multiline environments such as aligned and gathered, rows
369-
// correspond to lines that have additional \jot added to the
370-
// \baselineskip via \openup.
371-
if (group.addJot) {
369+
// correspond to lines that have additional \jot added between lines
370+
// via \openup.
371+
// We simulate this by adding \jot depth to each row except the last.
372+
if (group.addJot && r < group.body.length - 1) {
372373
depth += jot;
373374
}
374375

test/katex-spec.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3094,6 +3094,27 @@ describe("An aligned environment", function() {
30943094
const ae = getParsed`\begin{aligned}&E_1 & (1)\\&E_2 & (2)\\&E_3 & (3)\end{aligned}`[0];
30953095
expect(ae.body).toHaveLength(3);
30963096
});
3097+
3098+
it("should not add \\jot below a single row", function() {
3099+
const aligned = getBuilt`\begin{aligned}(M)\end{aligned}`[0];
3100+
const alignedExtra = getBuilt`\begin{aligned}(M)\\\end{aligned}`[0];
3101+
const matrix = getBuilt`\begin{matrix*}[r]\displaystyle(M)\end{matrix*}`[0];
3102+
3103+
expect(aligned.height).toBeCloseTo(matrix.height, 5);
3104+
expect(aligned.depth).toBeCloseTo(matrix.depth, 5);
3105+
expect(alignedExtra.height).toBeCloseTo(matrix.height, 5);
3106+
expect(alignedExtra.depth).toBeCloseTo(matrix.depth, 5);
3107+
});
3108+
3109+
it("should not add \\jot below the final row", function() {
3110+
const aligned = getBuilt`\begin{aligned}a&=b\\c&=d\end{aligned}`[0];
3111+
const matrix = getBuilt`\begin{matrix*}[r]\displaystyle a&\displaystyle =b\\[3pt]\displaystyle c&\displaystyle =d\end{matrix*}`[0];
3112+
// [3pt] equals \jot, and for simple content depth == arstrutDepth,
3113+
// so the two gap computations coincide.
3114+
3115+
expect(aligned.height).toBeCloseTo(matrix.height, 5);
3116+
expect(aligned.depth).toBeCloseTo(matrix.depth, 5);
3117+
});
30973118
});
30983119

30993120
describe("AMS environments", function() {
-10 Bytes
Loading
-5 Bytes
Loading
0 Bytes
Loading
-3 Bytes
Loading
45 Bytes
Loading
706 Bytes
Loading

0 commit comments

Comments
 (0)