0 votes
How do you make sure that all \q2 lines are always on the same page as the prior \q1 line?
PTXprint by (1.3k points)

3 Answers

0 votes
Best answer

I actually know one way to do this, but I wanted to post it here so that I can find it next time I need it!

In the ptxprint-mods.tex file (check the box for that file on the Advanced tab and click Edit...) add this line:

\sethook{before}{q2}{\nobreak}
by (1.3k points)
0 votes
Of course if you want to take your question very precisely and only avoid breaking between q1 and q2 (and say allow a break between q2 and q2) then the problem gets a little more interesting:

\catcode`\@=11
\addtoparstylehooks{\xdef\lastmarker{\m@rker}}
\m@kedigitsletters
\def\@qone{q1}
\m@kedigitsother
\sethook{before}{q2}{\ifx\lastmarker\@qone\relax\nobreak\fi}

Here we grab the marker of the previous paragraph at the end of each paragraph, then before a q2 we  test that the last paragraph marker was a q1 and if so insert the nobreak. Notice that to compare the marker against q1, we store q1 as something to compare, but the 1 in q1 is a letter not a digit so we have to recategorise digits as letters while we do that def and then put them back. sethook is clever in that it does the recategorising for us without having to do that kind of thing.
by (358 points)
0 votes

I know there have been other answers, but Martin's is overkill when this exists...
 

\setbetweenhook{q1}{q2}{\nobreak}


by (704 points)
I assume if you used this that you would also want:

\setbetweenhook{q2}{q2}{\nobreak}

So that if you had multiple \q2's in a row, that they would also be kept together.
Welcome to Support Bible, where you can ask questions and receive answers from other members of the community.
Give proper recognition to those widows who are really in need.
1 Timothy 5:3
2,588 questions
5,328 answers
5,026 comments
1,400 users