How to add indent to a list only if it's not a sublist?

I need to add an indent to lists (ordered and unordered). This is easy, of course. The problem is: when I add it with below code, sublists are indented too, rendering them not aligned with the text of the parent item.

The code to add indent to all lists:

#set enum(
  indent: 0.4cm,
)
#set list(
  indent: 0.4cm,
)

Is there a way to know, inside a list’s show rule, whether that list is a sublist?

I think the following does what you want:

#set list(indent: 0.4cm)
#show list: it => {
  set list(indent: 0pt)
  it
}
3 Likes

Thank you, your solution is very simple and works, but only to unordered lists inside unordered lists. I’ve changed it a little bit, to work in lists that mix order and unordered [sub]lists:

#set enum(indent: 0.4cm)
#show enum: it => {
  set enum(indent: 0pt)
  set list(indent: 0pt)
  it
}
#set list(indent: 0.4cm)
#show list: it => {
  set enum(indent: 0pt)
  set list(indent: 0pt)
  it
}
1 Like

Here is my version:

#let custom-indent = 0.4cm
#set enum(indent: custom-indent)
#set list(indent: custom-indent)
#let remove-indent(doc) = {
  set enum(indent: 0pt)
  set list(indent: 0pt)
  doc
}
#show enum: it => { show: remove-indent; it }
#show list: it => { show: remove-indent; it }
3 Likes