$#(1, 2, 3, $alpha$, $beta$).intersperse(",").map(x => [#x]).join()$
One of the key problems you are having is that you get an array
and not a content
. Currently, content
can be represented by a few (hidden) types: context
, sequence
, styled
. context
is something you can look up, but the other two normally only can be discovered when tinkering/hacking. sequence
is a sequence of elements (something that can be implicitly converted to content
), while styled
is when you add some set/show rules to your document.
You can use repr()
(and .func()
/type()
) to look deeper at how things work:
#let list = (1, 2, 3, $alpha$, $beta$)
#repr(list) // `array`
#let list = (1, 2, 3, $alpha$, $beta$)
// `array` (commas inserted between all elements)
#repr(list.intersperse(","))
#let list = (1, 2, 3, $alpha$, $beta$)
// `array` where all elements of type `content`
// You can't join `content`/`str` with `int`.
#repr(list.intersperse(",").map(x => [#x]))
#let list = (1, 2, 3, $alpha$, $beta$)
#repr(list.intersperse(",").map(x => [#x]).join()) // `sequence`
I want to make an explicit note that in the future the way content
is internally defined can be changed and these sequence
and styled
can become inaccessible or disappear altogether. But for now a few packages and solutions do depend on them, but these are all considered hacks, since there were no intention that users will use the functions directly.
Edit:
As was correctly pointed out by @Eric the intersperse()
here is exessive as array.join()
has an optional positional separator
argument (that can have any type). This brings the MRE down to:
$#(1, 2, 3, $alpha$, $beta$).map(x => [#x]).join[,]$