Thank you @vmartel08 for the nudge in the right direction, I knew of sink arguments but couldn’t get it right the first time, so I did give it a second more careful try and ended up with a better result!
I replaced the suffix: (text:auto,fill: blue)
with ...suffix
I knew that from previous attempts,
yet I didn’t know how to set the defaults for the keys so I assumed I needed a lower level approach. But thanks to your insight, I realized that I missed the option default
in definitions/methods like at()
which allowed me to set keys with defaults, and now works as expected.
my latest attempt:
#let (mytheo-counter, mytheo-box, mytheo, show-mytheo) = make-frame(
"theorem",
"Theorem",
counter: theorem-counter,
inherited-levels: 2,
inherited-from: heading,
render: (
prefix: auto,
title: "",
full-title: auto,
..suffix,
body) => [
#block(
fill:blue.lighten(85%),
inset: 0.5em,
radius: 0.4em,
)[
*#full-title*
#h(1fr)
#{
if suffix.at("suffix", default: "") != "" {
tag(fill: suffix.at("suffill", default: blue))[#suffix.at("suffix", default: "")]
}
}
#linebreak()
#body
]
]
)
#show: show-mytheo
#mytheo(
suffix:"important",
suffill:red, //works as expected
)[
#lorem(5)
]
This for is more than acceptable, both the text are independent and fall back to defaults. But If you don’t mind me asking, what else do I need to utilize to approach the form suffix:(text:"important",)
without triggering errors for not specifying the other key?