
Use the following command in the document body of the main file to generate TOC:

\UserCommand{Generate Table of Contents}<\cs{TableofContents}>{
    \cs{TableofContents}
}

The table of contents generated by \cs{TableofContents} will automatically include all section files imported via \cs{ImportSection}. The table of contents itself will not be listed as an entry within it. After the first compilation following any document modifications, all section entries and part titles will update automatically. However, due to the multi-pass nature of \TeX's cross-reference mechanism, you will need to compile a second time to ensure page numbers and hyperlinks are displayed correctly.

If you need to execute typesetting commands between two section entries within the table of contents, please place them between the corresponding \cs{ImportSection} commands and wrap them in the following command:

\UserCommand{TOC Typesetting Command}<\cs{TableCommand}>{
    \cs{TableCommand}
    \{\meta{LaTeX Command}\longarg\}
}[
    - \meta{LaTeX Command}\longarg\ : The \LaTeX\ code to be executed during TOC typesetting.
]

\Example{TOC Typesetting-Example}{
    \par\noindent\ \cs{TableofContents}
    \par\noindent\ \cs{AddPart} \{Part A\}
    \par\noindent\ \cs{ImportSection} \{Group/Section A1\}
    \par\noindent\ \cs{ImportSection} \{Group/Section A2\}
    \par\noindent\ \cs{AddPart} \{Part B\}
    \par\noindent\ \cs{ImportSection} \{Group/Section B1\}
    \par\noindent\ \cs{TableCommand} \{\cs{bigskip}\cs{bigskip}\}
    \par\noindent\ \cs{TextCommand} \{\cs{newpage}\}
    \par\noindent\ \cs{AddPart} \{Appendix\}
    \par\noindent\ \cs{ImportSection} \{Appendix 1\}
    \par\noindent\ \cs{ImportSection} \{Appendix 2\}
}

\newpage
