Lisa Kolinski
Lisa Kolinski

Reputation: 1

Defining a header with a vertical line

Is any possibility to define a header with a vertical line separating the chapter name from the page number, as shown here (page 2):

enter image description here

I would like to use the package fancyhdr but all I could find were solutions with a horizontal line. Also I just need to display the chapter name on every page and not the section name.

Upvotes: 0

Views: 1578

Answers (1)

Werner
Werner

Reputation: 15065

Here an option using fancyhdr:

enter image description here

\documentclass[twoside]{book}

\usepackage{blindtext}

\usepackage{fancyhdr}

\newcommand{\vrulesep}{\smash{%
  \rule[\dimexpr-\headsep-.3\baselineskip]{1pt}{\dimexpr\headsep+\baselineskip}}}
\fancyhf{}% Clear header/footer
\fancyhead[LE]{% Left header on Even page
  \makebox[0pt][r]{{\bfseries\thepage\space
                   \vrulesep
                   \space}}%
  \leftmark
}
\fancyhead[RO]{% Right header on Odd page
  \makebox[0pt][l]{{\bfseries\space
                   \vrulesep
                   \space\thepage}}}
\renewcommand{\headrulewidth}{0pt}%

\pagestyle{fancy}% Set page style to fancy

\begin{document}

\blinddocument

\end{document}

Upvotes: 2

Related Questions