Skip to content

Commit 12deaea

Browse files
committed
note markers link back to anchors (#19)
1 parent 2883f5f commit 12deaea

4 files changed

Lines changed: 659 additions & 435 deletions

File tree

‎Marginalia.pdf‎

29 KB
Binary file not shown.

‎lib.typ‎

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -551,7 +551,7 @@
551551
/// - If ```typc auto```, will use the given @note.numbering.
552552
/// -> none | auto | function | string
553553
anchor-numbering: auto,
554-
/// Whether to make have the anchor link to the note.
554+
/// Whether to have the anchor link to the note, and vice-versa.
555555
/// -> boolean
556556
link-anchor: true,
557557
/// Counter to use for this note.
@@ -629,15 +629,23 @@
629629

630630
assert(side == "left" or side == "right", message: "side must be auto, left, right, outer, or inner.")
631631
let body = if numbering != none {
632-
if flush-numbering {
633-
box({
632+
let number = {
633+
if link-anchor {
634+
show link: it => {
635+
show underline: i => i.body
636+
it
637+
}
638+
link(here(), counter.display(numbering))
639+
} else {
634640
counter.display(numbering)
635-
})
641+
}
642+
}
643+
if flush-numbering {
644+
box(number)
636645
h(0pt, weak: true)
637646
body
638647
} else {
639648
body
640-
let number = counter.display(numbering)
641649
let width = measure({
642650
set text(..text-style)
643651
set par(..par-style)

‎main.typ‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@
4242
#show: marginalia.show-frame.with(footer: false)
4343

4444

45-
#show heading.where(level: 1): set block(above: 34pt, below: 12pt)
46-
#show heading.where(level: 2): set block(above: 26pt, below: 12pt)
45+
#show heading.where(level: 1): set block(above: 30pt, below: 12pt)
46+
#show heading.where(level: 2): set block(above: 20pt, below: 10pt)
4747

4848
#let note = note.with(text-style: (size: 8.5pt))
4949
#let notefigure = notefigure.with(text-style: (size: 8.5pt))
@@ -86,6 +86,7 @@ _Write into the margins!_
8686

8787
= Setup
8888
Put something akin to the following at the start of your `.typ` file:
89+
#note[Do not #[```typ #import "...": *```], this will shadow built-in functions.]
8990
#codeblock[
9091
```typst
9192
#import "@preview/marginalia:0.2.4" as marginalia: note, notefigure, wideblock
@@ -119,8 +120,6 @@ Additionally, I recommend using Typst's partial function application feature to
119120
```
120121
]
121122

122-
Do not #strike[```typ #import "@preview/marginalia:0.2.4": *```], this will shadow built-in functions.
123-
124123
// // #context if calc.even(here().page()) {pagebreak(to: "odd", weak: true)}
125124
// #pagebreak(to: "odd", weak: true)
126125
// = Showcase

0 commit comments

Comments
 (0)