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.

I want to produce this kind of header. enter image description here

My first attempt includes the use of fancyhdr package but still I can't figure out how it is possible to move the page number in the margin and put the | bold separator. Does anyone know if fancyhdr is capable of this kind of customization or should I look at titlesec – titleps packages?

\documentclass[a4paper, 12pt, twoside, openright, english]{book}
%
\usepackage{lipsum} % to produce dummy text
\usepackage[english]{babel}
%
\usepackage{fancyhdr}
\fancyhead{}
\fancyfoot{}
\pagestyle{fancy}
\renewcommand{\sectionmark}[1]{\markright{\sffamily \itshape \thesection\ #1}}
\renewcommand{\chaptermark}[1]{\markboth{\sffamily \itshape\thechapter\ #1}{}}
\fancyhf{}
\fancyhead[LE,RO]{\sffamily \bfseries \thepage}
\fancyhead[RE]{\footnotesize \leftmark}
\fancyhead[LO]{\footnotesize \rightmark}
\renewcommand{\headrulewidth}{0pt}
%~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
\begin{document}
%
\chapter{Basic principles for multi camera systems}
    \lipsum[3-15] % dummy text
\section{Introduction}
    \lipsum[3-15] % dummy text
\subsection{Image processing}
    \lipsum[3] % dummy text
%
\end{document}
share|improve this question
3  
You only need to give the page number a zero width. E.g. \fancyhead[RO]{\makebox[0pt][l]{\raisebox{-3mm}[0pt][0pt]{\rule{1mm}{1cm}} \sffamily \bfseries \thepage}}. (The left side needs a mirror definition. –  Ulrike Fischer Mar 8 '13 at 12:44
    
@UlrikeFischer oops your comment crossed with my answer, sorry –  David Carlisle Mar 8 '13 at 12:46
    
@DavidCarlisle: It's the other way round: my comment crossed with your answer ;-). –  Ulrike Fischer Mar 8 '13 at 12:53
    
That was really fast. Thank you both ;-) –  dkc Mar 8 '13 at 12:56
add comment

2 Answers

up vote 7 down vote accepted

enter image description here

\fancyhead[LE]{\leavevmode\smash{\llap{\sffamily \bfseries \thepage\ \rule[-1em]{5pt}{2em}}}}
\fancyhead[RO]{\leavevmode\smash{\rlap{\rule[-1em]{5pt}{2em}\ \sffamily \bfseries \thepage}}}
share|improve this answer
add comment

After the helpful comments above and a bit code manipulation, the final result is exactly what I was looking for. After all, fancyhdr can offer this kind of customization and I would like to share it here in case someone else need the final code to work towards something better...

\documentclass[a4paper, 12pt, twoside, openright, english]{book}
%
\usepackage{lipsum} % to produce dummy text
\usepackage[english]{babel}
\usepackage{fancyhdr}
\fancyhead{}
\fancyfoot{}
\pagestyle{fancy}
\renewcommand{\sectionmark}[1]{\markright{\sffamily \itshape \thesection\ #1}{}}
\renewcommand{\chaptermark}[1]{\markboth{\sffamily \itshape\thechapter\ #1}{}}
\fancyhf{}
\fancyhead[LE]{\leavevmode\smash{\llap{\sffamily \bfseries \thepage\ ~\rule[-.5em]{2pt}{2em}} \leftmark}}
\fancyhead[RO]{\leavevmode\smash{\rightmark ~ \rlap{~\rule[-.5em]{2pt}{2em}\ ~\sffamily\bfseries\thepage}}}
\renewcommand{\headrulewidth}{0pt}
\setlength{\headheight}{15pt} 
%~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
\begin{document}
%
\tableofcontents % you can comment this one...
\chapter{Dummy Chapter Title with Many Words}
    \lipsum[3-15] % dummy text
\section{Dummy Section Title with Many Words}
    \lipsum[3-15] % dummy text
\subsection{Dummy Subsection}
    \lipsum[3-5] % dummy text
\section{A Short Dummy Section}    
    \lipsum[3-10] % dummy text
%
\end{document}
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.