arguments自始可用
捕获的函数参数。 [⚠️💀]
参数收集器[⚠️]
与内置函数一样,自定义函数也可以接受可变数量的参数。您可以指定一个参数收集器,将所有多余参数收集为..sink。生成的sink值的类型为arguments。它暴露了访问位置参数和「通过名称传入的」(named)参数的方法。 [⚠️]
#let format(title, ..authors) = {
let by = authors
.pos()
.join(", ", last: " and ")
[*#title* \ _Written by #by;_]
}
#format("ArtosFlow", "Jane", "Joe")

展开[⚠️]
与参数收集器相反,您可以展开参数、数组和字典,使用..spread运算符: [⚠️]
#let array = (2, 3, 5)
#calc.min(..array)
#let dict = (fill: blue)
#text(..dict)[Hello]

构造函数0.10.0起可用
在原地构造「可展开」(spreadable)的「参数」(argument)。
此函数的行为类似于let args(..sink) = sink。 [⚠️]
展开示例
#let args = arguments(stroke: red, inset: 1em, [Body])
#box(..args)

argumentsany必需参数位置参数变长参数
构造的参数。 [⚠️]
定义
len0.15.0起可用
The number of arguments, positional or named.
at0.12.0起可用
返回指定索引处的「位置参数」,或具有指定名称的「命名参数」。
如果键是整数,这相当于先调用pos,然后调用array.at。如果是字符串,这相当于先调用named,然后调用dictionary.at。 [⚠️]
key
要获取的参数的索引或名称。 [⚠️]
defaultany
A default value to return if the key is invalid.
pos自始可用
将捕获的「位置参数」作为数组返回。 [⚠️]
named自始可用
将捕获的「命名参数」作为「字典」返回。 [⚠️]
filter0.15.0起可用
Produces a new arguments with only the arguments for which the value passes the test.
展开示例
#{
arguments(-1, a: 0, b: 1, 2)
.filter(v => v > 0)
}

test
The function to apply to each value. Must return a boolean.
map0.15.0起可用
Produces a new arguments by transforming each argument value with the passed function.
展开示例
#{
arguments(0, a: 1, 2)
.map(v => v + 1)
}

mapper
The function to apply to each value.