# Page header as in LaTeX and Friends using memoir class

In Page header of LaTeX and Friends the fancyhdr package is used to create the page header of the LaTeX and Friends book. How can I do it using memoir class and also on first page where chapter begins?

MWE:

\documentclass[a4,twoside]{memoir}
\usepackage{lipsum}
\makepagestyle{mystyle}

\makeatletter
\makepsmarks{mystyle}{%
\createmark{chapter}{left}{nonumber}{\@chapapp\ }{.\ }}
\makeatother

\makepagestyle{plain}
\makerunningwidth{plain}{\dimexpr\marginparsep+\marginparwidth\relax}

\pagestyle{mystyle}

\begin{document}
\chapter{Test Chapter}
\lipsum[1]
\section{Test Section}
\lipsum[1-20]
\end{document}

• Could you say exactly what problem you're having? – cfr Apr 21 '15 at 1:17
• thank you for your comments, but I still don't know how to align vertical line to the edge of body (textmargin)? What I doing wrong in \setlength{\headwidth}{\dimexpr\marginparsep+\marginparwidth\relax} Thanks, tommy – tommy m Apr 21 '15 at 5:13

The memoirclass uses pagestyle chapter for the first page of the chapter. So you can do

...
\pagestyle{mystyle}
\aliaspagestyle{chapter}{mystyle}

\begin{document}
...


I'm not sure why you redefined the plain page style to be the same as mystyle, but it would be better to replace that with \aliaspagestyle{plain}{mystyle} if you still need it.

• This is not an answer to the question, but a (useful) comment. – jon Apr 20 '15 at 22:46
• @jon I dunno. Beats some of David's one-liners... ;). It is, after all, a partial answer to the question. It does not address all parts of the question. But, then, multi-part questions are not really Kosher anyway.... – cfr Apr 21 '15 at 1:19
• Maybe I didn't understand the question, but I thought the OP's MWE showed "how to do it in memoir" already, except for the first page of each chapter. – alephzero Apr 21 '15 at 4:20