5

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}
\nouppercaseheads
\makepagestyle{mystyle} 
\setlength{\headwidth}{\dimexpr\marginparsep+\marginparwidth\relax}
\makerunningwidth{mystyle}{\headwidth}
\makeevenhead{mystyle}{\thepage\quad\smash{\rule[-0.2ex]{1pt}{4cm}}\quad\textsc{\chaptername~\thechapter}}{}{} 

\makeoddhead{mystyle}{}{}{\textsc{\leftmark}\quad\smash{\rule[-0.2ex]{1pt}{4cm}}\quad\thepage} 

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

\makepagestyle{plain}
\makerunningwidth{plain}{\dimexpr\marginparsep+\marginparwidth\relax}
\makeevenfoot{plain}{\textsc{\leftmark}\quad\smash{\rule[-0.2ex]{1pt}{4cm}}\quad\thepage}{}{}

\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
2

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.

  • 1
    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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.