Closed pkvil closed 2 years ago
You are right, my example was full of mistakes. Thank you for notification. I will correct it.
Your solution is OK, if there is no \nonum\chap
used in the document. I think that \nonum\chap
is very rare case so it is OK. But I corrected my example by adding \vfil\break
to \_chapx
because \_chapx
is called only if no \nonum
is used. There is new complication with it here: \_chapx
is called when \globaldefs=1
and it is undesirable to call output routine in this state: following macros are broken. So, there is \globaldefs=0
before \vfil\break
:
\addto\_chapx {\globaldefs=0 \vfil\break % headline of previous chapter is printed
\xdef\_runningchap {\_thechapnum: \_unexpanded\_ea{\_savedtitle}}}
\def \formathead #1#2{\isempty{#1}\iffalse #1: #2\fi}
\headline = {%
%\ifodd \pageno % Commented because the chapters are short, to make \_runningchap show on all pages..
%\hfil \ea\formathead\firstmark{}{}%
%\else
\ifx\_runningchap\undefined \else Chapter \_runningchap \fi \hfil
%\fi
}
I discovered new issue when testing your example: the chapter titles aren't at the same vertical position on various pages because the \prevdepth
from previous line (at the previous page) is taken into account. I'll correct it by adding \prevdepth=0pt
after \_vfill\_supereject
in \_printchap
macro.
It seems to work fine now! Thank you.
On page 127 of the manual the following code is given as an example of how to implement running heads:
I should first say that I am testing this with version 1.03, but I can't see changes that would make a difference in version 1.07. The first issue is that
\_runningchap
is defined, but\runningchap
(without "_") is called. This is easily fixed though. The second issue is that the output shows the wrong chapter number in the header. This code:produces these headlines: Page 1: "Chapter 2: Second chapter" Page 2: "Chapter 3: Third chapter" Page 3: "Chapter 3: Third chapter"
If the text in each chapter is made longer so that it covers more than one page, the page before the next chapter gets the header incremented and shown like the following chapter.
I suspect that the issue is that
\_runninghead
is defined before the page break from\_printchap
. Moving the definition to\_inchap
after\_printchap
seems to solve the issue.The following code:
Seems to fix the issue for me, producing the headlines: Page 1: "Chapter 1: First chapter" Page 2: "Chapter 2: Second chapter" Page 3: "Chapter 3: Third chapter"
Since I'm a beginner it's entirely possible that I'm just doing things wrong though, in which case I apologize for wrongfully submitting this.