How to setup table of content indent with hanging-indent analogue from heading

Hello everyone. I need to adjust the margins in the table of contents. They should look the same as they currently look in simple headlines. As far as I understand, I need to add the hanging-indent from the header parameters to the table of contents.
Also, please indicate the place in the documentation (or other source) where you got this information from.
Here is my code. The headings look correct, but the table of contents doesn’t:

#set heading(
  numbering: "1.1.1.",
  hanging-indent: 0mm
)


#outline(
  indent: 0mm
)

= #lorem(20)
== #lorem(20)
=== #lorem(20)
=== #lorem(20)
= #lorem(20)
== #lorem(20)
=== #lorem(20)

This code will generate the headings I need (for long headings, the correct indentation. Highlighted in green). How can I repeat this formatting in the table of contents? (highlighted in red).

Do you have a picture of what you want? I’m not quite sure what you’re hoping to achieve.

You mention margins so I’ll start there. Each page can only have one set of margins (changing them will create a new page). But you add some padding on the left and right side of the table of contents by placing it in a block with an inset:

#block(
  inset: (x: 1em),
  
  outline(
    indent: 0mm
  )  
)

Blocks are very useful and are used by many built in elements of Typst.

In the table of contents, the text margins should look the same as in the headings (highlighted in red and green. Red should be the same as green).

Hi there @jintaxi,

The title of your post being vague, it is unlikely it will attract many responses as setting up an outline is a very basic task. I suggest you rephrase it by editing your post. Perhaps something line How to style an outline to ensure entries are similar to the headings or similar.

The issue here is not about the margins, but the hanging-indent: 0mm that you have applied to the heading.

From what it looks, you would probably have to customize the outline.entry such as in How to customize the body of an outline entry? - #2 by flokl

I have not looked into it but perhaps a package like outrageous – Typst Universe will solve your case.

Thank you. I tried to formulate my request more precisely.

(post deleted by author)

For some reason, here on the Typst forum at least, the term hanging indent seems to have ended up back-to-front. In the OPs example, it is the Outline that has the hanging indents, not the headings.

For hanging indentation all but the first line of a paragraph is indented. (Wikipedia)

That would be because OP has set it to 0mm for the headings (so it is visually non-existent) and would like it the same for the outline.

I believe this is what you are looking for:

#set heading(
  numbering: "1.1.1.",
  hanging-indent: 0mm,
)

#show outline.entry: it => {
  it.indented(
    none, // set prefix to none
    it.prefix() + [ ] + it.inner(), // concatenate prefix and inner
  )
}

#outline(indent: 0mm) //try with and without

= #lorem(20)
== #lorem(20)
=== #lorem(20)
=== #lorem(20)
= #lorem(20)
== #lorem(20)
=== #lorem(20)