I made this function which can create a list of words:
#let bullet(list_bullet)={
let number=0
for content in list_bullet {
number=number+1
if number == list_bullet.len() {
[[#content .]]
break
}
[[#content ;], ]
}
}
#let example = ("Hello","Word")
#bullet(example)
==> [Hello;],[Word.]
I would like to insert this result in #list function but its not working …
#list(marker: [#text(rgb(0,158,161))[#sym.circle.filled]], spacing : 8pt, indent : 12pt, bullet(example))
I have this result:
- [Hello ;], [Word .]
And I would like :
- Hello;
- Word.
I would like to know which differences Typste made between:
#list(marker: [#text(rgb(0,158,161))[#sym.circle.filled]], spacing : 8pt, indent : 12pt, bullet(example))
And:
#list(marker: [#text(rgb(0,158,161))[#sym.circle.filled]], spacing : 8pt, indent : 12pt,[Hello;],
[Word.])
Is working.
In your code, bullet
doesn’t return an array of content:
#let example = ("Hello", "Word")
#repr(bullet(example))
#repr(([Hello;], [Word.]))
The list
needs an array of content (or string) to render, and I would use code like this:
#let bullet_next(list_bullet) = {
list_bullet
.enumerate()
.map(item => {
if item.first() != list_bullet.len() - 1 {
item.last() + ";"
} else {
item.last() + "."
}
})
}
#bullet_next(example)
#repr(bullet_next(example))
#list(
marker: [#text(rgb(0, 158, 161))[#sym.circle.filled]],
spacing: 8pt,
indent: 12pt,
..bullet_next(example),
)
And the result is:
The code maps items to (index, item)
, then transforms the tuple into a string. You can also use text
, block
, and so on as the return content:
#let bullet_next(list_bullet) = {
list_bullet
.enumerate()
.map(item => {
if item.first() != list_bullet.len() - 1 {
block(stroke: 1pt, inset: 2pt, item.last() + ";")
} else {
item.last() + "."
}
})
}
#bullet_next(example)
#repr(bullet_next(example))
#list(
marker: [#text(rgb(0, 158, 161))[#sym.circle.filled]],
spacing: 8pt,
indent: 12pt,
..bullet_next(example),
)