Skip to content

Commit 5ea0fdf

Browse files
committed
bugfix: margin notes at end-of-line.
Addresses one of the issues from #8
1 parent 1e27b86 commit 5ea0fdf

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

drafting.typ

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -349,14 +349,14 @@
349349
let (cur-page, descents) = _get-descent-at-page(loc)
350350
let cur-descent = descents.at(repr(properties.side))
351351
dy = calc.max(0pt, cur-descent - loc.position().y)
352-
// Notes at the beginning of a line misreport their y position, since immediately
353-
// after they are placed, a new line is created which moves the note down.
354-
// A hacky fix is to subtract a line's worth of space from the y position when
355-
// detecting a note at the beginning of a line.
356-
// TODO: When https://github.com/typst/typst/issues/763 is resolved,
357-
// `get` this value from `par.leading` instead of hardcoding`
358-
if anchor-x == properties.margin-left {
359-
dy -= 0.65em
352+
// Notes at the end of a line misreport their x position, the placed box will wrap
353+
// onto the next line and invalidate the calculated distance.
354+
// A hacky fix is to manually replace the x position to an offset of 0.
355+
let is-end-of-line = calc.abs(
356+
anchor-x - properties.margin-left - properties.page-width - properties.page-offset-x
357+
) < 0.1pt
358+
if is-end-of-line {
359+
anchor-x -= properties.page-width
360360
}
361361
}
362362

0 commit comments

Comments
 (0)