Dynamically generates the table of contents