+1 vote

I’d like to have a horizontal rule (line) at the end of the introduction.
Adding this to changes.txt adds a rule before chapter 1 in each book:
'(\\c 1 ?\r?\n)' > '\\zrule |width=".6"\\*\r\n\1 '

Alas, I’m publishing a collection of OT portions in which chapter 1 is frequently omitted. So, I’ve written a series of rules like this to changes.txt, one for each book:

at NUM 0 '(\\c )'	>	'\\zrule |width=".6"\\*\r\n\1 '
at JDG 0 '(\\c )'	>	'\\zrule |width=".6"\\*\r\n\1 '
at 2SA 0 '(\\c )'	>	'\\zrule |width=".6"\\*\r\n\1 '

This adds a rule before the first \c to occur in “chapter 0”. Is there a way to write a rule which would do this in all books, so I don’t need to specify the book names and I could replace my \c 1 rule above?

Wouldn’t this be a nice feature to add to the PTXprint UI?

PTXprint by (594 points)

7 Answers

0 votes

I can’t think of something that would catch all the “other first chapters” of each book. I wonder if the TeX guys could use some kind of a (only-used-once) hook to achieve the same thing.

But one shorthand for your rule is to put multiple refs on the same line:

at NUM 0 JDG 0 2SA 0 '(\\c )' > '\\zrule |width=".6"\\*\r\n\1 '

by (2.6k points)
0 votes

I think I’m missing something. Are you asking for something to fire on the first transition from introductory material to chapter? Or for any such transition?

Some kind of \sethook{first}{c}{code} (i.e. code that fires when the implicit \c 0 at the start of a book ends?)

by (737 points)
0 votes

Yes, almost… We need to insert a \zrule just before the first \c of a book (regardless if it is chapter 1 or chapter 99).

by (2.6k points)
0 votes

Seems to work (current github):

\sethook{first}{c}{\zrule|width="0.6" \*}

Mechanism:
\id sets the chapter number to 0 (zero). When \c is reached then if the chapter number is zero, the above hook code is executed, just before the new chapter number gets set.

by (737 points)
0 votes

Thanks Mark, you saying “before the first \c of a book” gave me an idea of how to do this in RegEx. This changes.txt rule seems to work for all books:

'(?s)(\\id .+?)(?=\\c)' > '\1\\zrule |width=".6"\\*\r\n '

  • (?s) causes . to match line breaks too
  • (\id .+?) finds \id followed by any other stream of characters.
  • (?=\c) is a positive lookahead which finds \c
    So, this expression captures into group \1 everything from \id up to the last character before the first occurrence of \c.

The right side of the rule “replaces” everything before \c with what was there (\1) followed by a rule and a new line.

by (594 points)
0 votes

Nice work @EricP! Just to make it clear for anyone else following this thread, the RegEx rule above would go into the changes.txt file. (BTW, is there a stray space after the final \n and if so, you might want to take it away. Or perhaps I’m missing something about why it is needed.)

But if you want to use the \sethook method instead, then that would go into the ptxprint-mods.tex file instead.

by (2.6k points)
0 votes

Is there a way to add a rule using the \ie marker?

by (140 points)

If you already have \ie markers in the text then adding this to changes.txt will print a rule (line) right after \ie.
'(\\ie)' > '\1\\zrule |width=".57"\\*'

Related questions

0 votes
1 answer
0 votes
2 answers
0 votes
2 answers
Welcome to Support Bible, where you can ask questions and receive answers from other members of the community.
And let us consider how we may spur one another on toward love and good deeds, not giving up meeting together, as some are in the habit of doing, but encouraging one another—and all the more as you see the Day approaching.
Hebrews 10:24-25
2,648 questions
5,396 answers
5,069 comments
1,443 users