Closed Proliecan closed 1 year ago
The reason this fails is because body
has no default value in algo
, and thus it must be passed as a positional argument:
#let pseudocode(content:[], title: "", parameters: (), additionalKeywords: none, caption: none, _label: "") = {
[
#figure(
align(left,
algo(
content, // <-- HERE
title: title,
parameters: parameters,
keywords: _algo-default-keywords + ("assert", "clone") + additionalKeywords,
comment-prefix: [#sym.triangle.stroked.r ],
comment-styles: (fill: rgb(100%, 0%, 0%)),
)
),
caption: caption,
supplement: [Pseudocode],
kind: "pseudocode",
) #label(_label)
]
v(0.2cm)
}
This is just an oddity with the way Typst handles parameters in comparison to other scripting languages like Python. The Typst developers are considering alternative schemes that would allow function calls to be more flexible, but for now this is just how it is.
Side note: I also changed pseudocode
's default value for parameters
to ()
because algo
always expects it to be an array.
Thanks a lot!
fails to build when used as function.