How can I "set" a default value for an exist custom function parameter?

Hi,
specifically I have this:

#import "@preview/physica:0.9.5": *
$ dd(x,y,p:and) $

I want to “set” (?) the “p:and” as the default so that I can write:

$ dd(x,y) $

Would someone be so kind as to tell me how to do this?

Hi! I’ve changed your post’s title to hopefully make it more easy to understand from the topic list.


The tool for doing this would be with:

#import "@preview/physica:0.9.5": *
#let dd = dd.with(p: $and$)
$ dd(x, y) $
$ dd(x, y, p: or) $

With built-in function you’d use a set rule, but those don’t work for custom ones like the ones from physica.

Note that if you have multiple files, you have to do this in every file. A way around this could be making your own wrapper module, like this:

// physica.typ
#import "@preview/physica:0.9.5": *
#let dd = dd.with(p: $and$)

// main.typ
#import "physica.typ": *
$ dd(x, y) $
$ dd(x, y, p: or) $

(this can be useful anyway, because you can’t accidentally import two different versions of physica when you only import it once anyway)

2 Likes