summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2024-10-14 17:36:29 +0200
committerLaurenz <laurmaedje@gmail.com>2024-10-15 15:06:36 +0200
commitfe43e27750971318e8dbbbb549e54c6a00120147 (patch)
treec46ff2dd950d41c1ed3e06b315c37142586de3f5
parent92d6c2fc88666cb331bdffc3d29c8804def5bb15 (diff)
Put floats back above footnotes instead of below (#5204)
-rw-r--r--crates/typst/src/layout/flow/compose.rs26
-rw-r--r--tests/ref/footnote-break-across-pages-float.pngbin1414 -> 1428 bytes
-rw-r--r--tests/ref/footnote-in-place.pngbin1103 -> 1110 bytes
3 files changed, 17 insertions, 9 deletions
diff --git a/crates/typst/src/layout/flow/compose.rs b/crates/typst/src/layout/flow/compose.rs
index 4b991f2b..a262d5c1 100644
--- a/crates/typst/src/layout/flow/compose.rs
+++ b/crates/typst/src/layout/flow/compose.rs
@@ -634,6 +634,23 @@ impl<'a, 'b> Insertions<'a, 'b> {
output.push_frame(Point::with_y(self.top_size), inner);
+ // We put floats first and then footnotes. This differs from what LaTeX
+ // does and is a little inconsistent w.r.t column vs page floats (page
+ // floats are below footnotes because footnotes are per column), but
+ // it's what most people (including myself) seem to intuitively expect.
+ // We experimented with the LaTeX ordering in 0.12.0-rc1, but folks were
+ // surprised and considered this strange. In LaTeX, it can be changed
+ // with `\usepackage[bottom]{footmisc}`. We could also consider adding
+ // configuration in the future.
+ for (placed, frame) in self.bottom_floats {
+ offset_bottom += placed.clearance;
+ let x = placed.align_x.position(size.x - frame.width());
+ let y = offset_bottom;
+ let delta = placed.delta.zip_map(size, Rel::relative_to).to_point();
+ offset_bottom += frame.height();
+ output.push_frame(Point::new(x, y) + delta, frame);
+ }
+
if let Some(frame) = self.footnote_separator {
offset_bottom += config.footnote.clearance;
let y = offset_bottom;
@@ -648,15 +665,6 @@ impl<'a, 'b> Insertions<'a, 'b> {
output.push_frame(Point::with_y(y), frame);
}
- for (placed, frame) in self.bottom_floats {
- offset_bottom += placed.clearance;
- let x = placed.align_x.position(size.x - frame.width());
- let y = offset_bottom;
- let delta = placed.delta.zip_map(size, Rel::relative_to).to_point();
- offset_bottom += frame.height();
- output.push_frame(Point::new(x, y) + delta, frame);
- }
-
output
}
}
diff --git a/tests/ref/footnote-break-across-pages-float.png b/tests/ref/footnote-break-across-pages-float.png
index 94f8a587..5d3ea107 100644
--- a/tests/ref/footnote-break-across-pages-float.png
+++ b/tests/ref/footnote-break-across-pages-float.png
Binary files differ
diff --git a/tests/ref/footnote-in-place.png b/tests/ref/footnote-in-place.png
index fa5e1bd1..b500ac80 100644
--- a/tests/ref/footnote-in-place.png
+++ b/tests/ref/footnote-in-place.png
Binary files differ