0 votes

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?

PTXprint by (1.8k points)

2 Answers

0 votes

Have you received any response to this?

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

Mike

by (1.2k points)

I did not receive a reply.

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.

+1 vote

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).

These \toc1 fields should now get picked up and used in the Table of Contents.

Note that you can also generate a sorted (table of contents) from these same \toc1 markers for an index at the back of the song book. Just use \ztoc|sorta\* instead of \ztoc|main\*

by (2.6k points)

Argh, sorry about that. I was thinking this question was in reference to SAB (where this is still an open problem).

Yes, this problem was ‘easily’ solved using regex similar to what @mjpenny states above.

One point where you’ll probably want to check things carefully. When I originally used a regex like the one above, in cases where \s markers fell at the top of the page the page numbers in the ToC were off by one (they were for the previous page). You can see the bug report here, along with a solution using a more complicated regex expression.

(post deleted by author)

Related questions

0 votes
4 answers
PTXprint Jun 19, 2023 asked by anon041638 (112 points)
0 votes
2 answers
PTXprint Aug 31, 2021 asked by rickarellanes (166 points)
Welcome to Support Bible, where you can ask questions and receive answers from other members of the community.
And over all these virtues put on love, which binds them all together in perfect unity.
Colossians 3:14
2,626 questions
5,364 answers
5,041 comments
1,420 users