Skip to content

Commit

Permalink
changed from snake_case to kebab-case
Browse files Browse the repository at this point in the history
  • Loading branch information
nleanba committed Nov 19, 2024
1 parent 939eb0d commit 005cf00
Show file tree
Hide file tree
Showing 5 changed files with 1,197 additions and 1,067 deletions.
Binary file modified Marginalia.pdf
Binary file not shown.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ Put something akin to the following at the start of your `.typ` file:
// top: 2.5cm,
// bottom: 2.5cm,
// book: false,
// flush_numbers: false,
// flush-numbers: false,
// numbering: /* numbering-function */,
)
#marginalia.configure(..config)
#set page(
// setup margins:
..marginalia.page_setup(..config),
..marginalia.page-setup(..config),
/* other page setup */
)
```
Expand Down
32 changes: 16 additions & 16 deletions lib.typ
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
top: config.at("top", default: 2.5cm),
bottom: config.at("bottom", default: 2.5cm),
book: config.at("book", default: false),
flush_numbers: config.at("flush_numbers", default: false),
flush-numbers: config.at("flush-numbers", default: false),
numbering: config.at("numbering", default: as-note),
)
}
Expand All @@ -76,17 +76,17 @@
/// - top (length): Top margin.
/// - bottom (length): Bottom margin.
///
/// These are not used for any of the Marginalia-functionality, they are only used when passed to @@page_setup().
/// These are not used for any of the Marginalia-functionality, they are only used when passed to @@page-setup().
/// - book (boolean): If ```typc true```, will use inside/outside margins, alternating on each page. If ```typc false```, will use left/right margins with all pages the same.
/// - flush_numbers (boolean): Disallow note icons hanging into the whitespace.
/// - flush-numbers (boolean): Disallow note icons hanging into the whitespace.
/// - numbering (str, function): Function or `numbering`-string to generate the note markers from the `notecounter`.
#let configure(
inner: (far: 5mm, width: 15mm, sep: 5mm),
outer: (far: 5mm, width: 15mm, sep: 5mm),
top: 2.5cm,
bottom: 2.5cm,
book: false,
flush_numbers: false,
flush-numbers: false,
numbering: as-note,
) = { }
#let configure(..config) = (
Expand All @@ -105,12 +105,12 @@
/// This will generate a dictionary ```typc ( margin: .. )``` compatible with the passed config.
/// This can then be spread into the page setup like so:
///```typ
/// #set page( ..page_setup(..config) )```
/// #set page( ..page-setup(..config) )```
///
/// Takes the same options as @@configure().
/// - ..config (dictionary): Missing entries are filled with package defaults. Note: missing entries are _not_ taken from the current marginalia config, as this would require context.
/// -> dictionary
#let page_setup(..config) = {
#let page-setup(..config) = {
let config = _fill_config(..config)
if config.book {
return (
Expand Down Expand Up @@ -139,7 +139,7 @@
///
/// Requires context.
/// -> dictionary
#let get_left() = {
#let get-left() = {
let config = _config.get()
if not (config.book) or calc.odd(here().page()) {
return config.inner
Expand All @@ -154,7 +154,7 @@
///
/// Requires context.
/// -> dictionary
#let get_right() = {
#let get-right() = {
let config = _config.get()
if not (config.book) or calc.odd(here().page()) {
return config.outer
Expand Down Expand Up @@ -198,9 +198,9 @@
} else {
-lineheight
}
let offset = get_left().far - anchor.x
let width = get_left().width
let notebox = box(width: get_left().width, body)
let offset = get-left().far - anchor.x
let width = get-left().width
let notebox = box(width: get-left().width, body)
box(
place(
dx: offset,
Expand Down Expand Up @@ -228,9 +228,9 @@
} else {
-lineheight
}
let offset = pagewidth - anchor.x - get_right().far - get_right().width
let width = get_right().width
let notebox = box(width: get_right().width, body)
let offset = pagewidth - anchor.x - get-right().far - get-right().width
let width = get-right().width
let notebox = box(width: get-right().width, body)
box(
width: 0pt,
place(
Expand All @@ -257,7 +257,7 @@
set text(size: 9pt, style: "italic", weight: "regular")
if numbered {
notecounter.step()
let body = context if _config.get().flush_numbers {
let body = context if _config.get().flush-numbers {
notecounter.display(_config.get().numbering)
h(1.5pt)
body
Expand Down Expand Up @@ -310,7 +310,7 @@
/// To be able to set this appendix in a many-page wideblock, this code was used:
///```typst
///#configure(..config, book: false)
///#set page(..page_setup(..config, book: false))
///#set page(..page-setup(..config, book: false))
///#wideblock(reverse: true)[...]
///```
///
Expand Down
52 changes: 23 additions & 29 deletions main.typ
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
#import "lib.typ" as marginalia: page_setup, note, wideblock
#import "lib.typ" as marginalia: page-setup, note, wideblock

#let config = (
inner: ( far: 16mm, width: 20mm, sep: 8mm ),
inner: ( far: 16mm, width: 18mm, sep: 8mm ),
outer: ( far: 16mm, width: 40mm, sep: 8mm ),
top: 32mm + 1em, bottom: 16mm,
book: true,
// flush_numbers: false,
// flush-numbers: false,
// numbering: "a",
)

#marginalia.configure(..config)
#set page(
..marginalia.page_setup(..config),
..marginalia.page-setup(..config),
header-ascent: 16mm,
header: context {
marginalia.notecounter.update(0)
let book = marginalia._config.get().book
let leftm = marginalia.get_left()
let rightm = marginalia.get_right()
let leftm = marginalia.get-left()
let rightm = marginalia.get-right()
if here().page() > 1 {
wideblock(
double: true,
Expand Down Expand Up @@ -52,8 +52,8 @@
}
},
background: context {
let leftm = marginalia.get_left()
let rightm = marginalia.get_right()
let leftm = marginalia.get-left()
let rightm = marginalia.get-right()
place(
dx: leftm.far,
rect(width: leftm.width, height: 100%, stroke: (x: luma(90%))),
Expand Down Expand Up @@ -104,20 +104,20 @@ Put something akin to the following at the start of your `.typ` file:
#block[
#set text(size: 0.9em)
```typst
#import "@preview/marginalia:version": note, wideblock
#import "@preview/marginalia:0.1.0": note, wideblock
#let config = (
// inner: ( far: 5mm, width: 15mm, sep: 5mm ),
// outer: ( far: 5mm, width: 15mm, sep: 5mm ),
// top: 2.5cm,
// bottom: 2.5cm,
// book: false,
// flush_numbers: false,
// flush-numbers: false,
// numbering: /* numbering-function */,
)
#marginalia.configure(..config)
#set page(
// setup margins:
..marginalia.page_setup(..config),
..marginalia.page-setup(..config),
/* other page setup */
)
```
Expand All @@ -126,7 +126,7 @@ Put something akin to the following at the start of your `.typ` file:
Where you can then customize `config` to your preferences. Shown here (as comments) are the default values taken if the corresponding keys are unset.
See the appendix for a more detailed explanation of the #link(label("marginaliaconfigure()"), [```typc configure()```])
and #link(label("marginaliapage_setup()"), [```typc page_setup()```])
and #link(label("marginaliapage-setup()"), [```typc page-setup()```])
functions.
Expand All @@ -148,29 +148,23 @@ If~#note[Note 1] we~#note[Note 2] place/*~#note[Note 3]*/ multiple/*~#note[Note
However, a ```typc dy``` argument can be passed to shift them by that length vertically.
== Markers
The margin notes are decorated with little symbols, which by default hang into the gap. If this is not desired, set the configuration option ```typc flush_numbers: true```.
The margin notes are decorated with little symbols, which by default hang into the gap. If this is not desired, set the configuration option ```typc flush-numbers: true```.
Setting the argument ```typc numbered: false```, we obtain notes without icon/number.#note(numbered: false)[Like this.]
To change the markers, you can override ```typc config.numbering```-function which is used to generate the markers.
It is recommended to reset the `notecounter` regularly, either per page:
#block[
#set text(size: 0.9em)
```typ
#set page(
header: {
marginalia.notecounter.update(0)
}
)
#set page(header: { marginalia.notecounter.update(0) })
```
]
or per heading:
#block[
#set text(size: 0.9em)
```typ
#show heading.where(level: 1): it => {
marginalia.notecounter.update(0)
it
}
#show heading.where(level: 1): it =>
{ marginalia.notecounter.update(0); it }
```
]
Expand All @@ -192,10 +186,10 @@ or per heading:
Note that setting both `reverse: true` and `double: true` will panic.
]
= Headers and Page Background
= Headers and Background
This is not (yet) a polished feature and requires to access ```typc marginalia._config.get().book``` to read the respective config option.
In your documents, consider removing this check and simplifying the ```typc if``` a bit.
Also, please don't ever try to ```typc .update``` the `marginalia._config` directly, this might easily break the code.
#note[Also, please don't ```typc .update()``` the `marginalia._config` directly, this can easily break the notes.]
Here's how the headers in this document were made:
Expand All @@ -205,8 +199,8 @@ Here's how the headers in this document were made:
#set page(header: context {
marginalia.notecounter.update(0)
let book = marginalia._config.get().book
let leftm = marginalia.get_left()
let rightm = marginalia.get_right()
let leftm = marginalia.get-left()
let rightm = marginalia.get-right()
if here().page() > 1 {
wideblock(double: true, {
box(width: leftm.width, {
Expand Down Expand Up @@ -241,8 +235,8 @@ And here's the code for the lines in the background:#note[
#set text(size: 0.9em)
```typst
#set page(background: context {
let leftm = marginalia.get_left()
let rightm = marginalia.get_right()
let leftm = marginalia.get-left()
let rightm = marginalia.get-right()
place(
dx: leftm.far,
rect(width: leftm.width, height: 100%,
Expand Down Expand Up @@ -298,7 +292,7 @@ Also shout-out to #link("https://typst.app/universe/package/tidy")[tidy], which
// no more book-style to allow for multipage wideblock
#marginalia.configure(..config, book: false)
#set page(
..marginalia.page_setup(..config, book: false),
..marginalia.page-setup(..config, book: false),
)
#context counter(heading).update(0)
#show heading.where(level: 1): set heading(numbering: "A.1", supplement: "Appendix")
Expand Down
Loading

0 comments on commit 005cf00

Please sign in to comment.