Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Overcoming the limits of fancyhdr / Latex

263 views
Skip to first unread message

chri_s...@yahoo.com

unread,
Sep 3, 2005, 2:51:54 AM9/3/05
to

My book designer wants page headers that seem quite difficult to get:

leftpage: chaptertitle and sectiontitle

rightpage: subsectiontitle

Is this possible at all? The manual of fancyhdr and of latex
are a bit unclear, but they seem to indicate that this is NOT
possible (only *two* titles can be in the headers, it seems,
not three). Is this correct?

Is there a trick around the limitation? (Without changing the output
routine ,,,)

Christoph

P.S. In fact, I have a smaller problem with fancyhdr. Where should
one specify the size of the font used: in leftmark, in chaptermark,
or in fancyhead ?

Piet van Oostrum

unread,
Sep 3, 2005, 4:07:42 AM9/3/05
to
>>>>> chri_s...@yahoo.com (CS) wrote:

>CS> My book designer wants page headers that seem quite difficult to get:

>CS> leftpage: chaptertitle and sectiontitle

>CS> rightpage: subsectiontitle

>CS> Is this possible at all? The manual of fancyhdr and of latex
>CS> are a bit unclear, but they seem to indicate that this is NOT
>CS> possible (only *two* titles can be in the headers, it seems,
>CS> not three). Is this correct?

You should get section and subsection information from marks, otherwise
they may be out of sync with the pagebreaks. However there is only
\leftmark and \rightmark, so 2 instead of 3. Fortunately the chapter
information can be done without marks in the standard classes as a chapter
always starts at a new page.

>CS> Is there a trick around the limitation? (Without changing the output
>CS> routine ,,,)

Yes. I'll give you the idea, you will have to write the code yopurself. Use
\sectionmark and \subsectionmark to establish these parts, and make
\chaptermark a noop (\renewcommand{\chaptermark}[1]{})

Now you must put the chapter title in a macro at the beginning of each
chapter (after the \chapter command, or define your own chapter command),
and use that macro in the header.

>CS> P.S. In fact, I have a smaller problem with fancyhdr. Where should
>CS> one specify the size of the font used: in leftmark, in chaptermark,
>CS> or in fancyhead ?

I recommend to put only information in the marks, and do the layout things
in fancyhead.
--
Piet van Oostrum <pi...@cs.uu.nl>
URL: http://www.cs.uu.nl/~piet [PGP 8DAE142BE17999C4]
Private email: pi...@vanoostrum.org

chri_s...@yahoo.com

unread,
Sep 3, 2005, 5:22:33 PM9/3/05
to
Thanky you very much. This worked perfectly.

I am left with a last issue. My fancyheaders
use \small\scshape\rightmark .
How do I get the equivalent of
\MakeLowercase{ \small\scshape\rightmark } ?
This does not work, of course.
One needs the strange \protected@edef
and the \expandafter, but somehow I do not get
it.

Cheers
Christoph

David Lloyd Geering

unread,
Sep 3, 2005, 9:04:42 PM9/3/05
to

\small\scshape\expandafter\lowercase{\rightmark}

should do the trick.

Brooks Moses

unread,
Sep 4, 2005, 4:42:27 AM9/4/05
to
David Lloyd Geering wrote:

> chri_s...@yahoo.com wrote:
>>I am left with a last issue. My fancyheaders
>>use \small\scshape\rightmark .
>>How do I get the equivalent of
>>\MakeLowercase{ \small\scshape\rightmark } ?
>>This does not work, of course.
>>One needs the strange \protected@edef
>>and the \expandafter, but somehow I do not get
>>it.
>
> \small\scshape\expandafter\lowercase{\rightmark}
>
> should do the trick.

I think that needs to be

\small\scshape\expandafter\lowercase\expandafter{\rightmark}

so that one isn't just expanding the { after the \lowercase (and thereby
accomplishing nothing useful).

- Brooks


--
The "bmoses-nospam" address is valid; no unmunging needed.

chri_s...@yahoo.com

unread,
Sep 4, 2005, 12:33:37 PM9/4/05
to

Unfortunately, both proposals do not work: The Uppercases sail through
unharmed...

Christoph

Danie

unread,
Sep 5, 2005, 3:50:15 AM9/5/05
to
define:

\newcommand\nouppercase[1]{{%
\let\uppercase\relax
\let\MakeUppercase\relax
\expandafter\let\csname MakeUppercase \endcsname\relax
#1}}%

then try

{\small\scshape\nouppercase{\rightmark} }

Danie Els (dnjels at sun dot ac dot za)

Christian Ebert

unread,
Sep 5, 2005, 4:23:21 AM9/5/05
to
* Danie on Mon, Sep 05, 2005:

> define:
>
> \newcommand\nouppercase[1]{{%
> \let\uppercase\relax
> \let\MakeUppercase\relax
> \expandafter\let\csname MakeUppercase \endcsname\relax
> #1}}%

Is already defined in exactly the same way fancyhdr.sty. So a) it
will bark at the \newcommand and b) no need to redo it ;-) See
also fancyhdr.dvi p.9 for the caveats.

But I still don't get how one could get something like

\fancyhead[LE]{<chaptertitle>}
\fancyhead[RE]{<sectiontitle>}
\fancyhead[RO]{<subsectiontitle>}

which was what the OP wanted IIRC, without redifining \@chapter
\@schapter etc.

c
--
_B A U S T E L L E N_ lesen! --->> <http://www.blacktrash.org/baustellen.html>

Ulrike Fischer

unread,
Sep 5, 2005, 4:37:21 AM9/5/05
to
chri_s...@yahoo.com schrieb:

>
> My book designer wants page headers that seem quite difficult to get:
>
> leftpage: chaptertitle and sectiontitle
>
> rightpage: subsectiontitle
>
> Is this possible at all? The manual of fancyhdr and of latex
> are a bit unclear, but they seem to indicate that this is NOT
> possible (only *two* titles can be in the headers, it seems,
> not three). Is this correct?
>
> Is there a trick around the limitation? (Without changing the output
> routine ,,,)

Yes. You can use either the package extramarks or (if you have a new
TeX- installation) you can define a new independant mark (search for
newmarks in google groups). You will have to make sure that chapter and
section clears the marks for subsection (like chapter clears always the
marks of section).

> P.S. In fact, I have a smaller problem with fancyhdr. Where should
> one specify the size of the font used: in leftmark, in chaptermark,
> or in fancyhead ?

I would use fancyhead. chaptermark is also possible (e.g. if you use
different fontsize for the number and the text). \leftmark is not set
by you.

--
Ulrike Fischer
e-mail: zusätzlich meinen Vornamen vor dem @ einfügen.
e-mail: add my first name between the news and the @.

Donald Arseneau

unread,
Sep 5, 2005, 5:56:09 AM9/5/05
to
Ulrike Fischer <ne...@nililand.de> writes:

> > leftpage: chaptertitle and sectiontitle

Is there room?

> > rightpage: subsectiontitle
> >
> > Is this possible at all?

Yes, especially since chapters start new pages.

Define something like....

\def\chaptermark#1{%
\gdef\CurrentChapter{#1}%
\sectionmark{}%
}
\def\sectionmark#1{%
\markboth {\CurrentChapter \hfill #1}{}%
}
\def\subsectionmark#1{%
\markright {#1}%
}

Define a page style (\@oddhead etc) that puts the marked text
in the header, and, I presume, the page number in the footer.


--
Donald Arseneau as...@triumf.ca

Danie

unread,
Sep 5, 2005, 6:07:25 AM9/5/05
to
> Is already defined in exactly the same way fancyhdr.sty. So a) it
> will bark at the \newcommand and b) no need to redo it ;-)

No barking here. It is only defined inside the fancyhdr commands and
not available outside. If you try to use it in normal text it will bite
;-)

Danie

Christian Ebert

unread,
Sep 5, 2005, 1:41:09 PM9/5/05
to
* Donald Arseneau on Mon, Sep 05, 2005:

kewl ;)

Ah, I might start to understand almost half of this mark stuff,
oh boy.

So the following seems to fit the OP's requirements and uses
fancyhdr (certainly the tweaking of \tableofcontents can be done
more elegant):

\documentclass[12pt]{book}
\usepackage[english]{babel}
\usepackage{fancyhdr}
\usepackage{blindtext}

\newcommand*\headerformat[1]{\small\scshape\MakeLowercase{#1}}
\fancyhead{}
\pagestyle{fancy}
\fancyhead[LE]{\headerformat{\leftmark}}
\fancyhead[RO]{\headerformat{\rightmark}}

\newcommand*\CurrentChapter{}
\renewcommand*\chaptermark[1]{%


\gdef\CurrentChapter{#1}%
\sectionmark{}%
}

\renewcommand*\sectionmark[1]{%


\markboth{\CurrentChapter\hfill #1}{}%
}

\renewcommand*\subsectionmark[1]{%
\markright{#1}%
}
\makeatletter
\renewcommand\tableofcontents{%
\chapter*{\contentsname}%
\markboth{\contentsname}{\contentsname}%
\@starttoc{toc}%
}
\makeatother

\begin{document}
\tableofcontents
\Blinddocument
\end{document}

Javier Bezos

unread,
Sep 6, 2005, 4:27:33 AM9/6/05
to

Christian Ebert wrote:

> Ah, I might start to understand almost half of this mark stuff,
> oh boy.

I would suggest giving a try to my titlesec package. With it
you won't need to understand that mark stuff, as it's hidden
to the user and you can write directly \sectiontitle or \thesection in
the running heads, with the right values.

Javier
-----------------------------
http://www.texytipografia.com

Christian Ebert

unread,
Sep 6, 2005, 2:20:55 PM9/6/05
to
* Javier Bezos on Tue, Sep 06, 2005:

> I would suggest giving a try to my titlesec package. With it
> you won't need to understand that mark stuff,

But I /want/ to understand, only I am to stupid -- and that can't
be cured by titlesec even.

But seriously, I will look into it if only

> as it's hidden to the user

to try to understand what's hidden ;-)

chri_s...@yahoo.com

unread,
Sep 7, 2005, 2:25:13 PM9/7/05
to

Unfortunately, all this does not work. I am really at a loss.
Is there any other way to make the running titles lowercase?

Regrads

C. Schiller

Christian Ebert

unread,
Sep 7, 2005, 4:31:41 PM9/7/05
to
* chri_s...@yahoo.com on Wed, Sep 07, 2005:

> Unfortunately, all this does not work. I am really at a loss.

Did you try my complete example in
Message-ID: <2005-09-0...@krille.blacktrash.org>?

Works fine here.

> Is there any other way to make the running titles lowercase?

errrmh, do you mean by chance lowercase and *not* smallcaps? then
leave out all \scshape.

chri_s...@yahoo.com

unread,
Sep 8, 2005, 2:48:52 PM9/8/05
to

The fancyheader issue is not solved at all. Now the older problem
(firstletter of rightmark)
does not work any more either. I do not know why.

I found part of the problem: In the index, all the items in file.ind
are converted to something like

\foreignlanguage{UKenglish} indexitem

Something similar might also appear in the the general case, outside
the index.

\Makelowercase has horrible results: it changes the whole expression
into
{ukenglish} which Latex does not understand. There seems to be a
problem with babel.


Thus I am again at the starting point

(1) My \firstrightmark = \rightmark which should be the first word of
an index entry
from file.ind does not appear on the header because of the
\foreignlanguage command,

(2) lowercase in fancyheder (combined WITH smallcaps) does not work

Any ideas?

Regards

Christoph


The aim is the following:


(1) Have something like

A
----
Abbot

in the left margin of the name index (where "A" is teh first letter of
the first
index item on that page)

(2) Have lowercase smallcaps sectionmarks in all running headers

This somehow must interfere with one of the other 50 packages I use,
grrrr.

chri_s...@yahoo.com

unread,
Sep 8, 2005, 3:41:45 PM9/8/05
to

For the index and fancyheadr, the manual of fancyhdr says to use
markboth for every item.
An *.ind file typically contains lines such as

\item Abbot, George \hyperpage{564}
\item Aristotle \hyperpage{222}

What is the best way to redefine \item so that it also produces a

\markboth{Abbot}{Abbot} % no first name, no comma
\markboth{Aristotle}{Aristotle}

and in particular, no \foreignlanguage{UKenglish}
inside the markboth?

Christoph

chri_s...@yahoo.com

unread,
Sep 10, 2005, 12:17:56 PM9/10/05
to

I solved the index problem by setting
\foreignlanguage to a noop inside the index.

Thanky for all the help.

Christoph

Piet van Oostrum

unread,
Sep 11, 2005, 2:40:32 PM9/11/05
to
>>>>> chri_s...@yahoo.com (cs) wrote:

>cs> I solved the index problem by setting
>cs> \foreignlanguage to a noop inside the index.

Maybe you can solve the header problem by

\renewcommand{\FOREIGNLANGUAGE}[1]{}
\expandafter\let\csname FOREIGNLANGUAGE \endcsname\FOREIGNLANGUAGE

after the \usepackage{babel}

0 new messages