Document ClassesMemoir headers, numbered chapter names

Information and discussion about specific document classes and how to create your own document classes.
Post Reply
Klopstick
Posts: 16
Joined: Sat Jan 27, 2007 11:18 pm

Memoir headers, numbered chapter names

Post by Klopstick »

I'm using Memoir for a book, and I am having some difficulty with the headers. I obviously need to change something, but I can't figure out where to make the change.

I want a numbered chapter name.

What I want for the (recto) header is:

Chaptername................Pagenum

and for the verso:

Pagenum.....................Title


I have tried both chapter forms shown below.

Code: Select all

\chapter[ toc-title ][ head-title ]{ title }
\chapter*[ head-title ]{ title }
The first one gives me the numbered chapter at the begining the way I want, but it also puts "Chapter 1. <Chaptername>" in the header! It almost seems to be treating the chapter number as part of the header. If I go with the unnumbered style, I (obviously) don't get the chapter number on the first page of the chapter (or in the header). I can't get the book title on the verso no matter what.

So, how do I get it so I can configure what goes in the heading? Is it straight LaTeX or is it related to the memoir class? If it's important, I'm using chapterstyle VZ21.

I'm still a raw noob at LaTeX, so any help is welcome. Thanks!

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

Klopstick
Posts: 16
Joined: Sat Jan 27, 2007 11:18 pm

Memoir headers, numbered chapter names

Post by Klopstick »

OK, I have been bashing away on this for a day, and it looks like it's not entirely Memoir specific.

Right now I've got it partly solved, but still having problems. I'm using something like the following:

Code: Select all

\pagestyle{myheadings}
\markboth{\thetitle}{\chaptername}
OK on the \thetitle, that works as I expected. But I cannot get the chapter name to show up dynamically. I've tried a bunch of things, and the best I can get on the page is "Chapter" (literally - it says "Chapter" where the actual chapter name should be)

I've looked at fancyhdr as well, but that just baffles me. I can get the chapter name on the recto, but not the book title on the verso pages.

What's my best approach here? How in Hades do I define a variable that is the chapter name, and then how do I call it in the context of the header?
User avatar
countbela666
Posts: 64
Joined: Thu Apr 26, 2007 2:44 pm

Memoir headers, numbered chapter names

Post by countbela666 »

Hi Klopstick,

here is a solution using the fancyhdr package. I think the command you've been looking for so desperately is \leftmark which already contains the chapter counter and its actual name.

Code: Select all

\documentclass[english]{memoir}
\usepackage{babel,blindtext}
\let\footruleskip\relax % for compatibility of memoir and fancyhdr
\let\rm\rmfamily        % for compatibility of memoir and blindtext (demo only)
\usepackage{fancyhdr}
\author{Me}
\title{Some Title}
\pagestyle{fancy}
\fancyhead[LE,RO]{\thepage}
\fancyhead[LO]{\leftmark}
\fancyhead[RE]{\thetitle}
\begin{document}
  \maketitle
  \blinddocument
  \blinddocument
\end{document}
Regards,
Marcel
Listen to me children of the night, beyond the doors of darkness you will find
a thousand worlds for you to see here, take my hand and follow me...
Hokus
Posts: 1
Joined: Wed Mar 07, 2012 5:24 pm

Memoir headers, numbered chapter names

Post by Hokus »

I know this post is 5 years old, but I am replying for future reference.
This is the code for removing "Chapter" from the chapter title in the heading.

No need for using the fancyhdr package, memoir can do it, (and maybe even simpler ^^ )

Code: Select all

% The following code have been found in Peter Wilsons Memoir manual in chapter 7 (page127)

\makepagestyle{YourPagestyleName} % Create a new pagestyle

% Following code to edit the pagestyle
\makepsmarks{YourPagestyleName}{%
\nouppercaseheads

% This is where we specify what \leftmark and \rightmark contains
\createmark{chapter}{both}{shownumber}{}{\space}
\createmark{section}{right}{shownumber}{}{\space}
% Change "shownumber" to "nonumber" if you don't want
%   the chapter/section number displayed at the header.

\createplainmark{toc}{both}{\contentsname}
\createplainmark{lof}{both}{\listfigurename}
\createplainmark{lot}{both}{\listtablename}
\createplainmark{bib}{both}{\bibname}
\createplainmark{index}{both}{\indexname}
\createplainmark{glossary}{both}{\glossaryname}}
% Might want to keep those, see the manual for further information.

% The following is where you tweek your header
\makeevenhead{YourPagestyleName}{%	% For verso pages
\normalfont\bfseries\thepage}{}{\normalfont\bfseries\leftmark}
\makeoddhead{YourPagestyleName}{%	% For recto pages
\normalfont\bfseries\rightmark}{}{\normalfont\bfseries\thepage}

% Activate your new pagestyle
\pagestyle{YourPagestyleName}
Im still a beginner at LaTeX, and the code is essential a copy/place from the manual in memoir =)
Post Reply