1

I want my two-sided pages to have different headers: on the left (even) side, the title of the book, and on the right (odd) side, the chapter title, without number. (This is pretty normal for non-technical books.)

I adapted my code from Werner's answer to Dave's 2015 question "Add Chapter Title to Header - without “Chapter 1” without success. The left (even) header is fine, but all I get is a separation line on the top of the right (odd) pages with no chapter title.

See minimum (non-)working example below. Is the problem in line 6? Do I need to rearrange some lines? I've searched sundry places including the fancyhdr documentation without success. Thanks in advance, Artmancc

\documentclass[12pt]{book}
\usepackage{fancyhdr,lipsum}
\pagestyle{fancy}
\fancyhf{} % clear all header and footer fields
\fancyhead[CE]{T~I~T~L~E~~~~O~F~~~~T~H~I~S~~~~B~O~O~K} 
\fancyhead[CO]{\leftmark}  %%% Is this the problem?
\fancyfoot[LE,RO]{\thepage}

\renewcommand{\chaptermark}[1]{\markboth{\MakeUppercase{#1}}{}}


\begin{document}

\chapter*{First Chapter}
\lipsum[1-9]
\clearpage{\pagestyle{empty}\cleardoublepage}  %% no header on blank left page
\chapter*{Last Chapter}
\lipsum[10-18]

\end{document}
0

It is easy with titleps which comes with titlesec:

\documentclass[12pt]{book}
\usepackage{lipsum}
\usepackage{titleps}
\newpagestyle{myfancy}{%
\sethead[][T~I~T~L~E~~~~O~F~~~~T~H~I~S~~~~B~O~O~K][]{}{\MakeUppercase{\chaptertitle}}{}
\setfoot[\thepage][][]{}{}{\thepage}
}
\renewpagestyle{plain}{%
\setfoot[\thepage][][]{}{}{\thepage}
}

\begin{document}
\pagestyle{myfancy}

\chapter*{First Chapter}
\chaptermark{First Chapter}
\lipsum[1-9]
\clearpage{\pagestyle{empty}\cleardoublepage} %% no header on blank left page
\chapter*{Last Chapter}
\chaptermark{Last Chapter}
\lipsum[10-30]

\end{document} 

enter image description here

| improve this answer | |
  • Thanks, I'm going to try this out. But I still want to know — if only as a learning exercise — why my code failed. – Artmancc Aug 19 at 20:48
  • For your try, don't load both fancyhdr and titleps – they're incompatible. – Bernard Aug 19 at 21:00
0

The starred version \chapter* does not execute \chaptermark. So you have to add this command for each starred chapter:

\documentclass[12pt]{book}
\setlength{\headheight}{15pt}
\usepackage{lipsum}% only for dummy text
\usepackage{emptypage}% page style empty on blank pages

\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhf{} % clear all header and footer fields
\fancyhead[CE]{T~I~T~L~E~~~~O~F~~~~T~H~I~S~~~~B~O~O~K} 
\fancyhead[CO]{\leftmark}
\fancyfoot[LE,RO]{\thepage}

\renewcommand{\chaptermark}[1]{\markboth{\MakeUppercase{#1}}{}}

\begin{document}

\chapter*{First Chapter}\chaptermark{First Chapter}
\lipsum[1-9]
\chapter*{Last Chapter}\chaptermark{Last Chapter}
\lipsum[10-18]

\end{document}

The result for this example is the same as above.

enter image description here

But if there are no numbered chapters, sections etc in the document, it would be better to change counter secnumpdepth and use the unstarred version \chapter:

\documentclass[12pt]{book}
\setlength{\headheight}{15pt}
\usepackage{lipsum}% only for dummy text
\usepackage{emptypage}% page style empty on blank pages

\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhf{} % clear all header and footer fields
\fancyhead[CE]{T~I~T~L~E~~~~O~F~~~~T~H~I~S~~~~B~O~O~K} 
\fancyhead[CO]{\leftmark}
\fancyfoot[LE,RO]{\thepage}

\setcounter{secnumdepth}{-1}% only parts will be numbered

\begin{document}

\chapter{First Chapter}
\lipsum[1-9]
\chapter{Last Chapter}
\lipsum[10-18]

\end{document}
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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