summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMax <me@mkor.je>2024-10-01 08:01:28 +0000
committerGitHub <noreply@github.com>2024-10-01 08:01:28 +0000
commit8eee3ec8d1b4d960017cb558887bd6180cc99cea (patch)
tree316835fb26b0302551a291699cc51c0a0025eecd
parent4ef1096ad99059fd86526ed819bf8a7abd3aef2b (diff)
Fix breakable block equation overflow (#5078)
-rw-r--r--crates/typst/src/math/equation.rs4
-rw-r--r--tests/ref/math-pagebreaking-single-line-numbered.pngbin0 -> 760 bytes
-rw-r--r--tests/ref/math-pagebreaking-single-line.pngbin0 -> 674 bytes
-rw-r--r--tests/suite/math/multiline.typ17
4 files changed, 18 insertions, 3 deletions
diff --git a/crates/typst/src/math/equation.rs b/crates/typst/src/math/equation.rs
index bf5ef9dd..dfcb0f7b 100644
--- a/crates/typst/src/math/equation.rs
+++ b/crates/typst/src/math/equation.rs
@@ -322,10 +322,8 @@ fn layout_equation_block(
.layout_into_run(&elem.body, styles)?
.multiline_frame_builder(&ctx, styles);
let width = full_equation_builder.size.x;
- let can_break =
- BlockElem::breakable_in(styles) && full_equation_builder.frames.len() > 1;
- let equation_builders = if can_break {
+ let equation_builders = if BlockElem::breakable_in(styles) {
let mut rows = full_equation_builder.frames.into_iter().peekable();
let mut equation_builders = vec![];
let mut last_first_pos = Point::zero();
diff --git a/tests/ref/math-pagebreaking-single-line-numbered.png b/tests/ref/math-pagebreaking-single-line-numbered.png
new file mode 100644
index 00000000..4e5b93eb
--- /dev/null
+++ b/tests/ref/math-pagebreaking-single-line-numbered.png
Binary files differ
diff --git a/tests/ref/math-pagebreaking-single-line.png b/tests/ref/math-pagebreaking-single-line.png
new file mode 100644
index 00000000..877d9c8b
--- /dev/null
+++ b/tests/ref/math-pagebreaking-single-line.png
Binary files differ
diff --git a/tests/suite/math/multiline.typ b/tests/suite/math/multiline.typ
index 8377b93e..3c0ed2f4 100644
--- a/tests/suite/math/multiline.typ
+++ b/tests/suite/math/multiline.typ
@@ -130,6 +130,23 @@ $ a &+ b + & c \
& & c && + d \
&= 0 $
+--- math-pagebreaking-single-line ---
+// Test breaking of single line equations.
+#set page(height: 4em)
+#show math.equation: set block(breakable: true)
+
+Shouldn't overflow:
+$ a + b $
+
+--- math-pagebreaking-single-line-numbered ---
+// Test breaking of single line equations with numbering.
+#set page(height: 4em)
+#show math.equation: set block(breakable: true)
+#set math.equation(numbering: "(1)")
+
+Shouldn't overflow:
+$ a + b $
+
--- issue-1948-math-text-break ---
// Test text with linebreaks in math.
$ x := "a\nb\nc\nd\ne" $