TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

The desired header style is like: page number is sans serif even in the first page of the chapter, because


\fancyhead[LE]{\sffamily \thepage  }
\fancyhead[RO]{\sffamily \thepage  }

could not change the font of the page number in the first page of each chapter.

In even page: Page number | Chapter title

enter image description here

In odd page: Section title | Page number

enter image description here

Using \fancyheadoffset[RE,LO]{-0.5\textwidth} could not get this effect, so how to achieve this style?

Minimal page:

\usepackage[ ]{titlesec} 

\renewcommand{\chaptermark}[1]{\markboth{\if@mainmatter \fi#1}{}}

% head setting
\fancyhead[LE]{ \sffamily \thepage $|$ } 
\fancyhead[RE]{  \leftmark  }
\fancyhead[LO]{  \rightmark  }
\fancyhead[RO]{ $|$ \sffamily\thepage}   %odd page

\renewcommand{\headrulewidth}{ 0.5 pt}

\section{This is a extremely  long ........... title}
\section{Short title}

In the MWE, you will find the font of the page number, is still serif in the first page of Introduction.

Another style (see below) which is similar to the first one, the only difference is that the vertical line | up to the top edge.

Even page: enter image description here

Odd page: enter image description here

Is it possible to make the second style?

share|improve this question
up vote 3 down vote accepted

I would suggest using titleps for this, since it allows easy access to sectional titles:

enter image description here
Click to enlarge

\usepackage{titleps,lipsum}% http://ctan.org/pkg/{titleps,lipsum}
    [\thepage\quad$\vert$\quad\chaptertitle]% even-left
    []% even-centre
    []% even-right
    {}% odd-left
    {}% odd-centre
    {\thesection~\sectiontitle\quad$\vert$\quad\thepage}% odd-right
\chapter{A chapter}\lipsum[1-10]
\section{A section}\lipsum[1-10]

Of course, you can add your own formatting, as needed. For example, replacing $\vert$ with \smash{\rule[-.5ex]{1pt}{5in}} produces a vertical rule that sticks down/up -0.5ex/5in. With everything outside the page boundary being clipped, a long enough vertical rule is okay.

share|improve this answer

Using fancyhdr, put this into your preamble:

\fancyhead[RO]{\rightmark{} $|$ \thepage}
\fancyhead[LE]{\thepage{} $|$ \leftmark}
share|improve this answer
I corrected the commands: \fancyhead[LO]{ \thepage{} $|$ \leftmark} \fancyhead[RE]{ \rightmark $|${} \thepage } – KOF Feb 8 '13 at 20:30
@KOF That depends on what you want. Since odd pages are right, RO and LE are outer heads, which is what I supposed is correct. – yo' Feb 8 '13 at 20:33
Yes, I like the Chapter on the Even page and the Section Odd page – KOF Feb 8 '13 at 20:36
This does not really work for a book class. See this chat message: chat.stackexchange.com/transcript/message/18561046#18561046 – Enthusiastic Student Nov 11 '14 at 10:47
You're missing \pagestyle{fancy} I would say (I didn't test though). Well, I'm missing that too, so I'll add it. – yo' Nov 11 '14 at 13:02

Your Answer


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.