How to create a TOC from multiple files


I have multiple exercise topics and each exercise is documented in its own file.

I want to create a Table of Contents (TOC) that can read the H1, H2 and H3 from each file.

I want to the Table of Contents to be in its own file and read the information from the other files.
How do I make this work?
Can I store the files in their own folders or do they have to be in the same folder as the TOC file?


I use Atom … but also other useful editors which might better suit your purposes. Here is a link to cherrytree where you can hold your exercises in hierarchical nodes and create a TOC.

But staying within the Atom framework with a more complicated configuration I would look at installing Pandoc and then some packages such as markdown-preview-enhanced and pandoc-convert then first read here and then read here how to create TOC from multiple documents. In my Atom setup I write in markdown and create output through markdown-preview-enhanced options > Preview.