[texhax] Insert chapter and section heading into document header

Jerry jerry at seibercom.net
Tue Dec 18 00:03:14 CET 2012


On Mon, 17 Dec 2012 10:03:08 -0600
David Gatwood articulated:

> On Dec 16, 2012, at 5:00 AM, texhax-request at tug.org wrote:
> 
> >> 
> >> "The \leftmark contains the Left argument of the Last \markboth on
> >> the page, the \rightmark contains the Right argument of the ?Rst
> >> \markboth or the only argument of the ?Rst \markright on the page."
> >> 
> >> This is designed to be clever in twosided printing, for example,
> >> and to show on a spread the information corresponding to the
> >> beginning on the left page and the end on the right page (I
> >> think). The rest of that section of the documentation shows how to
> >> re-define, e.g., \sectionmark (which is called when you issue a
> >> \section command) to put the information you want, and format it
> >> as you want, into \markboth or \markright. I'll stop here as I've
> >> hit the limit of my ignorance, but suggest you play with these and
> >> replace your 
> >> 
> >> \fancyhead{r}{\chaptertitlename\ \thechapter\ \thesection
> >> \thesubsection}
> >> 
> >> with something like
> >> 
> >> \fancyhead{r}{\rightmark}
> >> 
> >> In essence, your problem stems from the fact that the output from
> >> things like \thechapter depends on WHEN in your latex run that
> >> command is executed and the header put together by latex. 
> > 
> > I am beginning to think it either cannot be done; or at the very
> > least, it is beyond my skill level. Since I used code that forces
> > all of the "chapters" to run together rather than each starting on
> > a new page, it appears that I cannot accomplish my task. I just
> > spend over two hours trying every thing I know without success.
> > 
> > What pisses me off is that I can do this in MS Word.

> I'm pretty sure it is doable, but it might not be straightforward.
> If nothing else, you could save a reference to each chapter as you
> create the chapter mark, then in your heading, compare the current
> page number to each chapter start page in the list and then decide
> which chapter number(s) to show.
> 
> That said, since your change won't ever affect the number of lines,
> you might also be able to do something clever like overwriting the
> existing line when you hit a chapter mark, or moving the chapter mark
> drawing code into AddToShipoutPicture so that it gets processed at
> the end of the page (after you have changed the chapter number).
> 
> Incidentally, if you're starting chapters in the middle of a page,
> I'd be tempted to show both chapter numbers on the first page of the
> chapter unless the heading falls at the start of a page.  The code
> for doing so is left as an exercise for the reader, but probably
> involves comparing the current drawing position to the top of the
> page....

I am (1) sure it is possible and (2) beyond my skill level. I have
written about this question on several other forums and been informed
several times that it is probably possible; however, no one knows how
to do it.

I was lucky that I was able to get MS Word to create the document in
the form specified. I will continue to investigate this further on
though and if I ever do learn how to accomplish it, I will write it up.


-- 
Jerry ♔

Disclaimer: off-list followups get on-list replies or get ignored.
Please do not ignore the Reply-To header.
__________________________________________________________________



More information about the texhax mailing list