Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 6 additions & 7 deletions drafting.typ
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
/// - `rect` (function): Function to use for drawing the margin note's border. This
/// function must accept positional `content` and keyword `width` arguments.
/// - `side` (side): Which side of the page to place the margin note on. Must be `left`
/// or `right`
/// `right` or `auto`. When set to `auto`, the note will be placed on the
/// side that it is closest to
/// - `hidden` (bool): Whether to hide the margin note. This is useful for temporarily
/// disabling margin notes without removing them from the code
#let margin-note-defaults = state(
Expand Down Expand Up @@ -308,16 +309,14 @@
}

#let _update-descent(side, dy, anchor-y, note-rect, page-number) = context {
style(styles => {
let height = measure(note-rect, styles).height
let dy = measure(v(dy + height), styles).height + anchor-y
let height = measure(note-rect).height
let dy = measure(v(dy + height)).height + anchor-y
note-descent.update(old => {
let (cnt, props) = _get-current-descent(old, page-number: page-number)
props.insert(side, calc.max(dy, props.at(side)))
old.insert(cnt, props)
old
})
})
}

#let _margin-note-right(body, dy, anchor-x, anchor-y, ..props) = {
Expand Down Expand Up @@ -398,9 +397,9 @@
return
}

// If properties.side is auto, place out if this note in the margin it is closest to
if properties.side == auto {
let (r, l) = (properties.margin-right, properties.margin-left)
properties.side = if calc.max(r, l) == r { right } else { left }
properties.side = if pos.x > (properties.page-width + properties.margin-left + properties.margin-right)/2 {right} else {left}
}
for k in ("margin-right", "margin-left", "page-width") {
if k not in properties or properties.at(k) == none {
Expand Down