How to apply set rules to custom functions?

Hey guys I am frequently using function in my documents. For example

#let formatXY(msg, color: blue) = {
text(msg, color)
}

Now having declared a function we can simply use it and provide arguments to it. Like:

Some paragraph #formatXY("test")

My question now is how to for instance set the color of all future formatXY calls to be red instead. When trying to use a set / show rule, I get the hint / error that: “only element functions can be used in set rules”.

For example: #set formatXY(color:red)

Has anyone of you figured this one out or is it impossible to use show / set rules for custom functions?

1 Like

Hi,

you can overwrite your function like this.

#let formatXY = formatXY.with(color: red)

It will be possible to use show / set on custom functions in the future with custom elements, but for now you can use the above.

1 Like