0

I'm trying to create a header in LaTeX, using the memoir class.

If Chapter 3 is called "Nonlinear Dynamics", then even pages should have the page number on the upper left, and "Chapter 3" on the upper right. Odd pages should have "Nonlinear Dynamics" on the upper left, and the page number on the upper right.

So far, I have attempted to create chapter marks as part of a custom page style:

\nouppercaseheads                                                                                                                        
\makeatletter                                                                                                                            
\makepsmarks{yip}{%                                                                                                                      
  \createmark{chapter}{left}{notitle}{\@chapapp\ }{\ }                                                                                   
  \createmark{chapter}{right}{nonumber}{\chaptername\ }{.\ }                                                                             
}          

But whereas I can achieve either the appropriate left or right header, each separate \createmark declaration overwrites the previous one.

I must misunderstand how marks work---it's my first time using these commands. I figured this has already been answered before, but I haven't been able to turn up any precedent.

2
  • 1
    Createmark is for simple applications it cannot straight do what you wanted here. Here you need to define chaptermark manually such that the chaptermark writes the appropriate data to the leftmark and right mark respectively. It is doable, but a bit unusual. I probably will not be at a pc until tomorrow, then I can have a look.
    – daleif
    Jun 6, 2022 at 6:29
  • You have not given an MWE (from \documentclass... to \end{document}) that we can compile that shows your problem. I tried to create one but I'm not good at mind-reading what others have done. Please provide an MWE instead of just a snippet. Did you use memoirs control of page headings? Jun 6, 2022 at 19:04

2 Answers 2

0

if you only need to mark these, this is my solution. Sorry, i don't know much about memoir. then I modified my answer, it work on my pc.

\documentclass{memoir}

\renewcommand{\chaptermark}[1]{\markboth{\chaptername\ \thechapter}{#1}}


\begin{document}
\chapter{Nonlinear Dynamics}
\newpage
page 2
\newpage
page 3
\end{document}
1
  • Proper idea, but note that this is not compilable with frontmatter...
    – daleif
    Jun 6, 2022 at 7:01
0

Here is an addendum to Parks answer:

\makeatletter
\renewcommand{\chaptermark}[1]{%
  \markboth{
    \ifnum \c@secnumdepth >\m@ne
      \if@mainmatter
        \@chapapp\ \thechapter%
      \fi
    \else
    #1  
    \fi
  }{#1}
}
\makeatother

This version now follows secnumdepth and if secnumdepth says that chapter chould not be numbered (e.g. in the front matter), then we just write the title (#1) to both marks.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .