From bc802bd8fb1656e5004b7c1b8a4e02ec7fc31aa8 Mon Sep 17 00:00:00 2001 From: Alex Saveau Date: Mon, 24 Apr 2023 02:16:13 -0700 Subject: Fix broken matrices with alignment and optimize code while we're at it (#935) --- tests/typ/math/alignment.typ | 60 ------------------------------------- tests/typ/math/matrix-alignment.typ | 55 ++++++++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+), 60 deletions(-) create mode 100644 tests/typ/math/matrix-alignment.typ (limited to 'tests/typ/math') diff --git a/tests/typ/math/alignment.typ b/tests/typ/math/alignment.typ index 70c52d37..8f12971f 100644 --- a/tests/typ/math/alignment.typ +++ b/tests/typ/math/alignment.typ @@ -25,69 +25,9 @@ $ "left" \ $ ---- -// Test alternating alignment. -$ -"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) $ diff --git a/tests/typ/math/matrix-alignment.typ b/tests/typ/math/matrix-alignment.typ new file mode 100644 index 00000000..fd149dd8 --- /dev/null +++ b/tests/typ/math/matrix-alignment.typ @@ -0,0 +1,55 @@ +// Test matrix alignment math. + +--- +// 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. +$ 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) $ -- cgit v1.2.3