[Tex/LaTex] Remove chapter from header but page number stays intact

header-footer

I want to remove the title of a chapter from the header, but the page number must stay intact.

I'm using a the book class

\documentclass[11pt,a4paper,twoside,openright]{book}
\usepackage{lipsum}
\begin{document}
\chapter{Some title}
\lipsum
\end{document}

The script generates two pages. The second page contains a header, page number and title. Now I want to remove the title from that particular page.

-edit-
I found out that you can use \thispagestyle{plain}, however when I use this the page number, which is located at the top right, is then placed at the bottom.

Best Answer

Assuming that you want to suppress the chapter name from the header lines of all pages (other than pages which contain the chapter title, which are set in a different pagestyle anyway), you could use the following code. It relies on the etoolbox package and its \patchcmd macro.

\documentclass[11pt,a4paper,twoside]{book} 
\usepackage{etoolbox}
\makeatletter
\if@twoside
   \patchcmd{\ps@headings}%
      {\@evenhead{\thepage\hfil\slshape\leftmark}}%
      {\@evenhead{\thepage\hfil}}{}{}
\fi
   \patchcmd{\ps@headings}%
      {\@oddhead{{\slshape\rightmark}\hfil\thepage}}%
      {\@oddhead{\hfil\thepage}}{}{}  
\makeatother
\pagestyle{headings}
\usepackage{lipsum}
\begin{document}
\chapter{Some title}
\lipsum[1-30]
\end{document}

If the twoside option is in effect, LaTeX will typeset the page numbers on the right-hand side of the header line on odd-numbered pages and on the left-hand side of the header line on even-numbered pages. If the oneside document option is set, all page numbers will be set on the right-hand side of the header line (and, of course, without the chapter name on the left-hand side of the header lines).

By the way, this code works with both the book (default document option setting: twoside) and the report (default document option setting: oneside) document classes.

Related Question