How to set font size of margin notes?

I am using the marginalia package and I am having problems customizing of the margin notes.

I want to change the font size. According to the documentation, note has a text-style argument. When I try to change it using a set rule, the document compiles with an error:

#set note(
    text-style: (size: 8pt)
)
error: only element functions can be used in set rules

Is there a better solution than to wrap the note function in my custom function?

#let mote(t) = note(text-style: (size: 8pt))[#t]

Since the documentation states that

Both note() and notefigure() accept a text-style and par-style parameter…

using the function note() itself for the configuration seems to be your only option. Instead redefining it you can however just change the default value of text-style with with(). You will still have access to the other parameters and you can even override the text-style.

#let note = note.with(text-style: (size: 8pt))

Edit: This was also the answer by the author of the package to the same question in a GitHub issue, see Globally setting text characteristics for margin notes · Issue #5 · nleanba/typst-marginalia · GitHub.

A note regarding the compilation error. Set rules for custom elements/functions are not (yet) available. There is an experimental package called elembic that introduces custom elements and types. This does however not help you here since marginalia does not use this.

4 Likes