tags:

views:

59

answers:

1

Hi

I have the following tex document:

\documentclass[a4paper,11pt,oneside]{book}
\usepackage[usenames,dvipsnames]{color}
\usepackage[T1]{fontenc}
\usepackage[utf8x]{inputenc}
\usepackage{lipsum}
\usepackage[left=2cm,top=3cm,right=1.5cm,bottom=2cm]{geometry}

\renewcommand{\chaptermark}[1]{\markboth{#1}{}}
\renewcommand{\sectionmark}[1]{\markright{#1}{}}
\renewcommand{\subsectionmark}[1]{\markright{\thesubsection}{}}

\usepackage[Lenny]{fncychap}
\usepackage{thumbpdf}
\usepackage[colorlinks]{hyperref}
\setlength\marginparwidth{1cm}
\usepackage{fancyhdr}

\pagestyle{fancy}
\fancyhead[LO,L]{Book template}
\fancyhead[RO,R]{\rightmark}
\fancyfoot[CO,C] {\thepage}

\begin{document}
\chapter{Chapter Intro}
\lipsum
\chapter{Chapter with subsections}
\section{section foo}
\lipsum
\subsection{subsection bar}
\lipsum
\end{document}

A sample can be viewed at http://www.mediafire.com/?0m5mnka32kj

On the top right:

  • How to make it show the chapter title if there is no section, as on page 2?
  • How to make it show the section title and nothing but the section title (no numbers, no subsections, subsubsections, etc) if there is an active section, as it's the case on page 4?

Thanks

+2  A: 

You are almost there!

The following two marks should do the trick:

\renewcommand{\chaptermark}[1]{\markright{#1}{}}
\renewcommand{\sectionmark}[1]{\markright{#1}{}}

Be sure to move them to to a position after \pagestyle{fancy}. Also be sure to remove the custom \subsectionmark, unless you want to use some subsection information in the headers.

earl
Thanks. Have a virtual beer from me. Cheers :-)
Flavius