[texhax] [Q] Tricky customisation of headers in memoir
Ozan Öktem
ozan.oktem at sidec.com
Fri Feb 3 15:22:20 CET 2006
Hi,
I want to customise the headers in a memoir document by redefining the
\leftmark and \rightmark commands. This is well-described in the memoir
manual, but I don't now how the achieve the following rather tricky
customisation. Any suggestions are most welcome.
I begin by introducing some terminology. Define "main-mark" as the mark
for the highest document division (except for part) that exists in the
document. As an example, assume you have a document using the memoir
class where you make use of \chapter command. Then, main-mark would be
chapter. If \section is the highest document division (which is the case
when one writes shorter article-type documents) used in the document,
then main-mark would be section. Also, define "sub-mark" as the document
division that precedes main-mark. Hence, if main-mark is chapter or
section, then sub-mark would be section and subsection, respectively.
We also define three different types of pages in the mainmatter of a
document.
Pages of type 1: These are pages in the main matter where all contents
does not belong to the main-mark (we use the convention where contents
be longing to the sub-mark also belongs to the main-mark). As an
example, if our main-mark is chapter, then the pages that we are dealing
with here could be pages between the frontmatter and the first \chapter
command, or alternatively, pages between a \part command and the first
\chapter command in that part.
Pages of type 2: These are pages in the main matter where all contents
only belongs to the main-mark. As an example, if our main-mark is
chapter, then the pages that we are dealing with here could be pages
between the \chapter command and the first \section command in that
chapter.
Pages of type 3: These are pages in the main matter where some of the
contents belongs to the sub-mark. As an example, if our main-mark is
chapter, then the pages that we are dealing with here could pages that
follow a \subsection command within the chapter or pages that contain a
\subsection command.
Now, I would like to now how one can define \leftmark and \rightmark in
the memoir class in order to achieve the following behaviour:
Page of type 1: For pages in the main matter of type 1, both \leftmark
and \rightmark should both be empty.
Page of type 2: For pages in the main matter of type 2, both \leftmark
and \rightmark should contain information about the main-mark only (see
(a) below). However, this is only if the main-mark is at least a
section. In other cases, i.e. when main-mark (for some strange reason)
is a subsection (or a lower document division), then \leftmark and
\rightmark should be empty.
Page of type 3: For pages in the main matter of type 3, \leftmark should
contain information about the main-mark and \rightmark should contain
information about the sub-mark (see (b) below). However, this is only if
the main-mark is at least a section. In other cases, i.e. when main-mark
(for some strange reason) is a subsection (or a lower document
division), then \leftmark and \rightmark should be empty.
a) Information about the main-mark is defined as follows: If main-mark
is chapter, then it should be the chapter tag (specified by \@chapapp,
could e.g. be the word "Chapter"), the chapter number, and finally the
name of the chapter itself. If the main-mark is a section, then the
information is the section number and the name of the section itself.
b) Information about the sub-mark is defined as follows: If sub-mark is
section or subsection, then it should contain the number and name.
Preferably, the \leftmark and \rightmark should be defined through the
\markboth and \markright commands, or even better, through the
\chaptermark and \sectionmark commands.
/Ozan
More information about the texhax
mailing list