summaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2024-10-14 17:36:29 +0200
committerGitHub <noreply@github.com>2024-10-14 15:36:29 +0000
commit03a766444a2770246a847f71980aebe71964e3af (patch)
tree8c07451609fc5283a936644af547b7b23010705e /crates
parent6a8e29b2e5ad5f0b7d469ad6a307f9cf1c5ad07d (diff)
Put floats back above footnotes instead of below (#5204)
Diffstat (limited to 'crates')
-rw-r--r--crates/typst/src/layout/flow/compose.rs26
1 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
}
}