How can I use different bullet list markers for items in a single a list?

When I write proofs to some theorems, I use

#set list(marker: [$subset.eq$:])
- Proof that $A subset.eq B$
#set list(marker: [$supset.eq$:])
- Proof that $A supset.eq B$

I wonder if I can do the same using one list or function .

You can try this syntax and see if you like it:

#list(marker: $subset.eq: $)[Proof of 1]
#list(marker: $supset.eq: $)[Proof of 2]

There is the term list/definition list syntax, maybe that fits, which doesn’t show a colon by default but can have one like this. It could also have its style changed.

/ $subset.eq$\:: Proof of 1
/ $supset.eq$\:: Proof of 2

Thank you for your reply. These are good ways, but I meant something like this

#let CoolFunction={ there is something }

#CoolFunction
- Proof of 1
- Proof of 2

A function cannot use “set” and have it take effect outside itself, but we can get close to the required contract like this.

#let CoolFunction(it) = {
  // This function will fail with list items other than 1 and 2..
  let symbols = ("1": $subset.eq$, "2": $supset.eq$)
  set enum(numbering: x => symbols.at(str(x)) + ":")
  it
}

#show: CoolFunction
+ Proof of 1
+ Proof of 2
// alternative calling mode which only affects one numbered list
#CoolFunction[
+ Proof of 1
+ Proof of 2
]

Note that the function must get access to the list itself to be able to change it. With a show rule, or passed as an explicit parameter.

If you want to do this with list instead of enum I think it’s possible but more complicated, you’ll have to reimplement a little bit of list layout and item placement to change the marker per item, which just seems unnecessary.

1 Like

Thanks a lot. I actually forgot about the power of numbered lists

See also How can I set the marker per item in a bullet point list? which seems cool, and they do reimplement placing markers for the default list. But it doesn’t hit your use case even if it can solve it, I think.

Assuming lists are unique, using it as a global show rule will result in undesired behavior.

Also, you don’t have to create a dictionary if you use index, just use array instead:

#let custom-list-markers(body) = {
  // This function will fail with list items other than 1 and 2.
  let symbols = ($subset.eq$, $supset.eq$)
  set enum(numbering: n => symbols.at(n - 1) + ":")
  body
}

#custom-list-markers[
  + Proof of 1
  + Proof of 2
]

There is however a quirk that Typst support negative index access for arrays, but I don’t think anyone has negative numbered list in their documents.

To make it customizable and not error on long lists:

#let custom-list-markers(body, markers: ($subset.eq:$, $supset.eq:$)) = {
  set enum(numbering: n => markers.at(calc.rem-euclid(n - 1, markers.len())))
  body
}

#custom-list-markers[
  + Proof of 1
  + Proof of 2
  + Proof of 3
  + Proof of 4
]

#custom-list-markers(markers: ([•], [‣], [–]))[
  + Proof of 1
  + Proof of 2
  + Proof of 3
  + Proof of 4
]

image

I contributed a solution or a part of a solution, and then the each person will know how to best apply it in their context.