ntjess / typst-drafting

Some common drafting utilities for the `typst` document typesetter
The Unlicense
59 stars 3 forks source link

Use general 'note' command & extend documentation #10

Open th1j5 opened 6 months ago

th1j5 commented 6 months ago

I use typst drafting as the typst equivalent of todonotes. I'm new to typst, which is why I struggled to get some equivalent functionality, but I think I managed: I'd like to propose to

  1. add some extra examples in the documentation which show the usage of different variants of notes
  2. add a general #note command, which can switch between the inline & margin variant, with a default to margin. (or if not, also add this to the documentation as an example of working with it...)

If you are ok with this, I can send a PR (when I find some time)

A note, defaulting to a margin note:

#let note(inline: false, ..kwargs) = {
    if inline {
        inline-note(..kwargs)
    } else {
        margin-note(..kwargs)
    }
}

An example of defining custom todo-commands:

#let todo-ballon = rect.with(inset: 0.3em, radius: 0.5em)
#let todo-unsure = note.with(
        stroke: maroon,
        rect  : todo-ballon.with(fill: maroon.lighten(70%)))
#let todo-add = note.with(
        stroke: blue,
        rect  : todo-ballon.with(fill: blue.lighten(60%)))
#let todo-change = note.with(...)

Usage:

#todo-add(inline: true)[Inline todo note, showing that I should add something...]
#todo-add[Todo note in the margin, showing that I should add something here...]
ntjess commented 5 months ago

Extra examples are welcome! Thank you for the consideration.

I am more hesitant to provide uniform access both to inline and margin notes, since each needs slightly different parameters (i.e. inline notes have a par-break option, and I am hoping in the future to have more margin-aware options for margin notes).

Since the code to provide this is so short, I'm also happy to merge an example that shows you can use a function like this if you need the unified API.