Obey alignment in matrices (#892)
This commit is contained in:
parent
e5ea3ecbbb
commit
5ccc687619
@ -272,8 +272,10 @@ fn layout_mat_body(ctx: &mut MathContext, rows: &[Vec<Content>]) -> SourceResult
|
||||
let mut y = Abs::zero();
|
||||
for ((cell, &ascent), &descent) in col.into_iter().zip(&ascents).zip(&descents) {
|
||||
let cell = cell.into_aligned_frame(ctx, &points, Align::Center);
|
||||
let pos =
|
||||
Point::new(x + (rcol - cell.width()) / 2.0, y + ascent - cell.ascent());
|
||||
let pos = Point::new(
|
||||
if points.is_empty() { x + (rcol - cell.width()) / 2.0 } else { x },
|
||||
y + ascent - cell.ascent(),
|
||||
);
|
||||
frame.push_frame(pos, cell);
|
||||
y += ascent + descent + row_gap;
|
||||
}
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 9.5 KiB After Width: | Height: | Size: 23 KiB |
@ -2,9 +2,8 @@
|
||||
|
||||
---
|
||||
// Test alignment step functions.
|
||||
#set page(width: 300pt)
|
||||
$
|
||||
"abc" &= c \
|
||||
"a" &= c \
|
||||
&= c + 1 & "By definition" \
|
||||
&= d + 100 + 1000 \
|
||||
&= x && "Even longer" \
|
||||
@ -12,17 +11,83 @@ $
|
||||
|
||||
---
|
||||
// Test post-fix alignment.
|
||||
#set page(width: 300pt)
|
||||
$
|
||||
& "right" \
|
||||
"a very long line" \
|
||||
"left" \
|
||||
$
|
||||
|
||||
---
|
||||
// Test no alignment.
|
||||
$
|
||||
"right" \
|
||||
"a very long line" \
|
||||
"left" \
|
||||
$
|
||||
|
||||
---
|
||||
// Test alternating alignment.
|
||||
#set page(width: 300pt)
|
||||
$
|
||||
"abc" & "abc abc abc" & "abc abc" \
|
||||
"abc abc" & "abc abc" & "abc" \
|
||||
"abc abc abc" & "abc" & "abc abc abc" \
|
||||
"a" & "a a a" & "a a" \
|
||||
"a a" & "a a" & "a" \
|
||||
"a a a" & "a" & "a a a" \
|
||||
$
|
||||
|
||||
---
|
||||
// Test alternating alignment in a vector.
|
||||
$ vec(
|
||||
"a" & "a a a" & "a a",
|
||||
"a a" & "a a" & "a",
|
||||
"a a a" & "a" & "a a a",
|
||||
) $
|
||||
|
||||
---
|
||||
// Test alternating explicit alignment in a matrix.
|
||||
$ mat(
|
||||
"a" & "a a a" & "a a";
|
||||
"a a" & "a a" & "a";
|
||||
"a a a" & "a" & "a a a";
|
||||
) $
|
||||
|
||||
---
|
||||
// Test alignment in a matrix.
|
||||
$ mat(
|
||||
"a", "a a a", "a a";
|
||||
"a a", "a a", "a";
|
||||
"a a a", "a", "a a a";
|
||||
) $
|
||||
|
||||
---
|
||||
// Test explicit left alignment in a matrix.
|
||||
$ mat(
|
||||
&"a", &"a a a", &"a a";
|
||||
&"a a", &"a a", &"a";
|
||||
&"a a a", &"a", &"a a a";
|
||||
) $
|
||||
|
||||
---
|
||||
// Test explicit right alignment in a matrix.
|
||||
$ mat(
|
||||
"a"&, "a a a"&, "a a"&;
|
||||
"a a"&, "a a"&, "a"&;
|
||||
"a a a"&, "a"&, "a a a"&;
|
||||
) $
|
||||
|
||||
---
|
||||
// Test #460 equations.
|
||||
$
|
||||
a &=b & quad c&=d \
|
||||
e &=f & g&=h
|
||||
$
|
||||
|
||||
$ mat(&a+b,c;&d, e) $
|
||||
$ mat(&a+b&,c;&d&, e) $
|
||||
$ mat(&&&a+b,c;&&&d, e) $
|
||||
$ mat(.&a+b&.,c;.....&d&....., e) $
|
||||
|
||||
---
|
||||
// Test #454 equations.
|
||||
$ mat(-1, 1, 1; 1, -1, 1; 1, 1, -1) $
|
||||
$ mat(-1&, 1&, 1&; 1&, -1&, 1&; 1&, 1&, -1&) $
|
||||
$ mat(-1&, 1&, 1&; 1, -1, 1; 1, 1, -1) $
|
||||
$ mat(&-1, &1, &1; 1, -1, 1; 1, 1, -1) $
|
||||
|
Loading…
x
Reference in New Issue
Block a user