mirror of
https://github.com/typst/typst
synced 2025-05-13 20:46:23 +08:00
Don't number empty regions of broken block equations (#4836)
This commit is contained in:
parent
d926e8c17d
commit
326fd33801
@ -332,8 +332,10 @@ fn layout_equation_block(
|
||||
.layout_into_run(elem, 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 BlockElem::breakable_in(styles) {
|
||||
let equation_builders = if can_break {
|
||||
let mut rows = full_equation_builder.frames.into_iter().peekable();
|
||||
let mut equation_builders = vec![];
|
||||
let mut last_first_pos = Point::zero();
|
||||
@ -415,9 +417,14 @@ fn layout_equation_block(
|
||||
};
|
||||
|
||||
// Add equation numbers to each equation region.
|
||||
let region_count = equation_builders.len();
|
||||
let frames = equation_builders
|
||||
.into_iter()
|
||||
.map(|builder| {
|
||||
if builder.frames.is_empty() && region_count > 1 {
|
||||
// Don't number empty regions, but do number empty equations.
|
||||
return builder.build();
|
||||
}
|
||||
add_equation_number(
|
||||
builder,
|
||||
number.clone(),
|
||||
|
BIN
tests/ref/issue-4829-math-pagebreaking-wrong-number.png
Normal file
BIN
tests/ref/issue-4829-math-pagebreaking-wrong-number.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 394 B |
BIN
tests/ref/math-equation-number-empty.png
Normal file
BIN
tests/ref/math-equation-number-empty.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 116 B |
@ -256,6 +256,10 @@ $ q &= sum_k ln A \
|
||||
],
|
||||
)
|
||||
|
||||
--- math-equation-number-empty ---
|
||||
// Test numbering on empty equations.
|
||||
#math.equation(numbering: "1", block: true, [])
|
||||
|
||||
--- issue-4187-alignment-point-affects-row-height ---
|
||||
// In this bug, a row of "-" only should have a very small height; but
|
||||
// after adding an alignment point "&", the row gains a larger height.
|
||||
|
@ -133,3 +133,15 @@ $ a &+ b + & c \
|
||||
--- issue-1948-math-text-break ---
|
||||
// Test text with linebreaks in math.
|
||||
$ x := "a\nb\nc\nd\ne" $
|
||||
|
||||
|
||||
--- issue-4829-math-pagebreaking-wrong-number ---
|
||||
// Test numbering of empty regions of broken equations.
|
||||
#set page(height: 5em)
|
||||
#set math.equation(numbering: "1")
|
||||
#show math.equation: set block(breakable: true)
|
||||
|
||||
#rect(height: 1.5em)
|
||||
|
||||
$ a + b \
|
||||
a + b $
|
||||
|
Loading…
x
Reference in New Issue
Block a user