# ToC for Bible Modules

I would like to create a ToC for a Bible Modules. Ideally I’d like the ToC to be automatically generated for each \s marker, so that each section title is a line in the ToC and the corresponding page number shows up.

If PTXprint can’t create that automatically based on \s, then I’d like to be able to add extra tags throughout the modules with information in each to state “add a ToC entry here”. I tried something like `\toc1 entry_name` but that didn’t work (which isn’t entirely unexpected, since generally you don’t want more than one \toc1 entry in a given book).

The thing is, I could swear I had this working a couple of weeks ago but I can’t recreate my work. Does anyone know how to create such a ToC which isn’t simply based on \toc1/2/3 entries from different books?

Have you received any response to this?

A TOC based on \s would work very well for Song books as well.

Mike

At that time I was working with a few different modules each of which had around 100 section titles. So the amount of manual labor which would have been necessary to create the contents by hand was massive, and subsequent revisions would have been difficult.

I ended up writing a few Python scripts which allowed me to create or populate the underlying `context.xml` file manually. It was confusing to work with and required remember when things needed to be updated externally, but at least it was quick.

The easiest way to add an index of songs is to duplicate the contents of the \s Song Titles using a Changes.txt rule like this:

``````'(\\s )([^\\]+)( ?\r?\n)' > '\\toc1 \2\3\1\2\3'
``````

This says, look for a \s section heading and call that match-group 1.
Then grab the content/text of that heading, calling that match-group 2.
Grab the end of line (which needs at least an \n but might have a space and/or \r before the final \n) and call that match-group 3.

Then, on the replace-with side, put in the new marker \toc1 followed by the contents of 2 and the end of line piece. Then put everything else back as you found it (1,2,3).