From 34e3bd52aa4ca0ba0586736dde299070848c5a42 Mon Sep 17 00:00:00 2001 From: Myriad-Dreamin <35292584+Myriad-Dreamin@users.noreply.github.com> Date: Wed, 3 Jan 2024 20:04:36 +0800 Subject: Inline equations linebreak at appropriate places (#2938) Co-authored-by: David Maxwell Co-authored-by: Laurenz --- tests/ref/math/delimited.png | Bin 29020 -> 29090 bytes tests/ref/math/linebreak.png | Bin 0 -> 7385 bytes tests/ref/text/linebreak-obj.png | Bin 45919 -> 46208 bytes tests/typ/math/delimited.typ | 1 + tests/typ/math/linebreak.typ | 50 +++++++++++++++++++++++++++++++++++++++ tests/typ/math/spacing.typ | 2 +- 6 files changed, 52 insertions(+), 1 deletion(-) create mode 100644 tests/ref/math/linebreak.png create mode 100644 tests/typ/math/linebreak.typ (limited to 'tests') diff --git a/tests/ref/math/delimited.png b/tests/ref/math/delimited.png index 727f2d13..5c827c48 100644 Binary files a/tests/ref/math/delimited.png and b/tests/ref/math/delimited.png differ diff --git a/tests/ref/math/linebreak.png b/tests/ref/math/linebreak.png new file mode 100644 index 00000000..f3212a4a Binary files /dev/null and b/tests/ref/math/linebreak.png differ diff --git a/tests/ref/text/linebreak-obj.png b/tests/ref/text/linebreak-obj.png index 3c21377c..b13ced1a 100644 Binary files a/tests/ref/text/linebreak-obj.png and b/tests/ref/text/linebreak-obj.png differ diff --git a/tests/typ/math/delimited.typ b/tests/typ/math/delimited.typ index 6607c302..ba623b34 100644 --- a/tests/typ/math/delimited.typ +++ b/tests/typ/math/delimited.typ @@ -2,6 +2,7 @@ --- // Test automatic matching. +#set page(width:122pt) $ (a) + {b/2} + abs(a)/2 + (b) $ $f(x/2) < zeta(c^2 + abs(a + b/2))$ diff --git a/tests/typ/math/linebreak.typ b/tests/typ/math/linebreak.typ new file mode 100644 index 00000000..88ce69d2 --- /dev/null +++ b/tests/typ/math/linebreak.typ @@ -0,0 +1,50 @@ +// Test inline equation line breaking. + +--- +// Basic breaking after binop, rel +#let hrule(x) = box(line(length: x)) +#hrule(45pt)$e^(pi i)+1 = 0$\ +#hrule(55pt)$e^(pi i)+1 = 0$\ +#hrule(70pt)$e^(pi i)+1 = 0$ + +--- +// LR groups prevent linbreaking. +#let hrule(x) = box(line(length: x)) +#hrule(76pt)$a+b$\ +#hrule(74pt)$(a+b)$\ +#hrule(74pt)$paren.l a+b paren.r$ + +--- +// Multiline yet inline does not linebreak +#let hrule(x) = box(line(length: x)) +#hrule(80pt)$a + b \ c + d$\ + +--- +// A single linebreak at the end still counts as one line. +#let hrule(x) = box(line(length: x)) +#hrule(60pt)$e^(pi i)+1 = 0\ $ + +--- +// Inline, in a box, doesn't linebreak. +#let hrule(x) = box(line(length: x)) +#hrule(80pt)#box($a+b$) + +--- +// A relation followed by a relation doesn't linebreak +#let hrule(x) = box(line(length: x)) +#hrule(70pt)$a < = b$\ +#hrule(74pt)$a < = b$ + +--- +// Page breaks can happen after a relation even if there is no +// explicit space. +#let hrule(x) = box(line(length: x)) +#hrule(90pt)$<;$\ +#hrule(95pt)$<;$\ +#hrule(90pt)$<)$\ +#hrule(95pt)$<)$ + +--- +// Verify empty rows are handled ok. +$ $\ +Nothing: $ $, just empty. diff --git a/tests/typ/math/spacing.typ b/tests/typ/math/spacing.typ index e62d2eb3..63a60ae1 100644 --- a/tests/typ/math/spacing.typ +++ b/tests/typ/math/spacing.typ @@ -3,7 +3,7 @@ --- // Test spacing cases. $ä, +, c, (, )$ \ -$=), (+), {times}$ +$=), (+), {times}$ \ $⟧<⟦, abs(-), [=$ \ $a=b, a==b$ \ $-a, +a$ \ -- cgit v1.2.3