This is a show rule for building tree-like documents in Typst. The initial version was developed by @hongjr03, and I have refined the code, adding #end-sect and numbering-related features.
Although I've made efforts to extract customizable options from the huge build-tree function, I still think the code is too tightly coupled to be suitable for release as a public package.
- Tree-like Document Structure
The original structure of Typst documents is linear, meaning headings and other content are arranged sequentially. This makes it challenging to customize styles (like section indentation) and add summaries after subsections. With
#show: build-tree(func: xxx), you can easily construct a tree-like document structure and use#end-sectto return to the parent "node".