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.

In Showcase of beautiful typography done in TeX & friends Marc van Dongen shows his book LaTeX and Friends, http://tex.stackexchange.com/a/46348/15360.

He uses a specific page header as can be seen in the pictures he shows us.

Page number <vertical rule> Chapter number

or

Chapter name <vertical rule> Page number

I really like it and would like to get the same format or very similar to it if possible and was wondering how this can be achieved?

enter image description here

share|improve this question
add comment

1 Answer 1

up vote 5 down vote accepted

One option using fancyhdr and the offsets provided by the package. Using

\fancyhfoffset[OR,EL]{\dimexpr\marginparsep+\marginparwidth\relax}

the headers are offset by an amount equal to \marginparsep+\marginparwidth to the right on odd-numbered pages and to the left on even-numbered ones. Then the actual headers are placed using

\fancyhead[OR]{\textsc{\leftmark}\quad\smash{\rule[-.2ex]{1pt}{4cm}}\quad\thepage}
\fancyhead[EL]{\thepage\quad\smash{\rule[-.2ex]{1pt}{4cm}}\quad\textsc{\chaptername~\thechapter}}
\renewcommand{\chaptermark}[1]{\markboth{#1}{}}

A complete example code:

\documentclass{book}
\usepackage{fancyhdr}
\usepackage{lipsum}

\pagestyle{fancy}
\fancyhf{}
\fancyhfoffset[OR,EL]{\dimexpr\marginparsep+\marginparwidth\relax}
\fancyhead[OR]{\textsc{\leftmark}\quad\smash{\rule[-.2ex]{1pt}{4cm}}\quad\thepage}
\fancyhead[EL]{\thepage\quad\smash{\rule[-.2ex]{1pt}{4cm}}\quad\textsc{\chaptername~\thechapter}}
\renewcommand\headrulewidth{0pt}
\renewcommand{\chaptermark}[1]{\markboth{#1}{}}

\begin{document}

\chapter{Test chapter}
\lipsum[1-40]

\end{document}

enter image description here

share|improve this answer
    
Instead of \enspace\enspace you could use \quad. By the way, I don't know where I read it (and how “important” it is) but \enskip is the LaTeX preferred way, instead of \enspace. –  Manuel May 26 at 1:48
    
@Manuel I changed to \quad. In this case, there's no difference between \enspace and \enskip; both are kernel commands: the former is a \kern: \def\enspace{\kern.5em } the other is a \hskip: \def\enskip{\hskip.5em\relax}. –  Gonzalo Medina May 26 at 1:57
    
Using \enspace may be dangerous if it happens to fall at where a paragraph should start, because it would issue a vertical space; \enskip would start horizontal mode, instead, but allowing a line break. A header is normally typeset in restricted horizontal mode, so there's no difference between the two, in that case. –  egreg May 26 at 9:27
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.