Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Question

How to define a header/footer style using \fancypagestyle ?

Minimal Code (does not work)

\documentclass{book}

\usepackage{fancyhdr}

\fancypagestyle{ttt}
{%

\fancyhf{}
\renewcommand{\chaptermark}[1]{\markboth{\small\tt\chaptername\ \thechapter.\ #1}{}}
\renewcommand{\sectionmark}[1]{\markright{\small\sf\thesection\ #1}}
\fancyhead[RO,LE]{\rightmark}
\fancyhead[LO,RE]{\leftmark}
}

\pagestyle{ttt}
\usepackage{blindtext}
\usepackage[english]{babel}
\begin{document}

\tableofcontents

\blinddocument

\end{document}
share|improve this question
add comment

2 Answers 2

up vote 2 down vote accepted

Redefine \chaptermark and \sectionmark after choosing \pagestyle{ttt}. Also, did you read this answer?

EDIT: Sorry for being snippy - you may have read my other answer before I edited it.

share|improve this answer
    
thanks for your answer. I already read your prev post. Good! –  xport Jan 17 '11 at 13:02
add comment

Your problem is that inside \fancypagestyle{foo}{<stuff>}, redefining macros that take numbered arguments need to have their #s "escaped" like this:

\fancypagestyle{ttt}{%
  \fancyhf{}%
  \renewcommand{\chaptermark}[1]{\markboth{\small\tt\chaptername\ \thechapter.\ ##1}{}}%
  \renewcommand{\sectionmark}[1]{\markright{\small\sf\thesection\ ##1}}%
  \fancyhead[RO,LE]{\rightmark}%
  \fancyhead[LO,RE]{\leftmark}}
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.