This is my first time in this group and i'm a LaTeX newbie, user-wannabe :)
I'm trying to set a footer and header in my "book" with the fancyhdr style
and i'm having some problems i hope some of you can help me with.
The document is defined as follows: \documentclass[10pt, twoside,
a4paper]{book}
I found out how to make the header and footer change side on even and odd
pages so that's not the problem. The problem is sending the right
information to the header and footer.
I need the header to consist of the current Section and Subsection names.
The footer of the Chapter name. When \chapter{} and \section{} is called
\markboth{}{} and \markright{} are called right? setting the \leftmark and
\rightmark values that i have? to use to make the headers and footers look
right? (Sorry i'm trying hard to learn here, but it seems to have a steep
learning curve so i need a bit of help :) Since only two values are stored
(\leftmark and \rightmark) and i need three values shown (Chapter, Section
and Subsection names) in two different places i figures i could save both
the section and subsection names in one value (\rightmark) and let the
captername save in the \leftmark.
The following example is a simplified version of what i really want to do,
but i'm desperate and if anyone can help make this work i bet i can fiddle a
bit more with it and make the fancy :) stuff later.
==============================
[CUT]
\pagestyle{fancy}
\renewcommand{\chaptermark}[1]{\markboth{\chaptername
\ \Alph{chapter}\ (#1)}{}}
\renewcommand{\sectionmark}[1]{\markright{#1}}
%\renewcommand{\subsectionmark}[1]{\let \temp=\rightmark\markright{(\temp)
\\ #1}} % Tested with a temp-variable, don't know if it's nessesary.
\renewcommand{\subsectionmark}[1]{\markright{(\rightmark) \\ #1}}
% Simplest version i could think of :) well except for the parentesis used
for visual output (they end up empty)
\newcommand{\myfunheader} % Header used. Simplified version.
{\textbf{\rightmark}}
\newcommand{\myfunfooter} % Footer used. Simplified version.
{\slshape{\leftmark}}
\fancyhf{}
\fancyhead[LE,RO]{\myfunheader}
\fancyfoot[LE,RO]{\myfunfooter}
[CUT]
\chapter{LaTeX is fun}
\newpage
\section{How to begin}
\subsection{Now is the time}
The real fun begins.......
==============================
This gives me a wierd result... On the second page ("where the real fun
begins" i put a newpage after the chapter page since it won't show headers
on a chapter page right?) i get the right footer (that seems to be no
problem) but the header on the second page shows "How to begin" only storing
the section-name. On the next page and all following pages the header gives
me "()" - then a newline then "Now is the time"... None of the headers are
corrected since i wanted "(How to begin)" - newline then - "Now is the
time"... Please someone tell me what i am doing wrong here?
On the second page where it all begins it seems like \subsectionmark is
never called since the \rightmark doesn't contain the parentesis? Is there
someway to flush that? And on the next pages \markright won't save the value
of \rightmark adding the new value (i tried using a temp-variable as shown
in the commented-line).
I realise this has become a long post and i hope some of you took the time
to read through it all. I would really apreciate any kind of help.
Thanks in advance.
Per Schierbeck
Instead of insisting to save the values right away wtih \markright{} and
\markboth{}{} i ended up saving the values in global variables. When calling
\markboth you automaticly make other calls to \markright invalid if they
happen on the same page. I'm not sure if i see the reason for this, but in
my case that was a big bug (I have to replicate the layout of a "book" i
have so i can't rely on TeX's own way to format my info). The solution then,
was to save the values you want in globals and then when before you exit
the page you call \markboth{}{} with the varibles you want.
In my case it looked something like this:
\renewcommand{\sectionmark}[1]{\gdef\@mysectionvalue{#1}}
\renewcommand{\subsectionmark}[1]{\markboth{\@mysectionvalue}{#1}}
You might want to call \markboth before the end of each page incase you
never got a subsection but i didn't need to because of the layout (there is
some command, i forgot the name, that is envoked before the end of each
page).
Per Schierbeck