2

How would one modify memoirs madsen chapter style for the index so that on the first page of the index, the title "Index" would appear above the usual start-of-chapter rule?

Example source:

% file indexpageone.tex
\documentclass{memoir}
\usepackage{graphicx} % need for madsen chapter style

\begin{filecontents}{indexpageone.ist}
headings_flag 1
\end{filecontents}

\chapterstyle{madsen}
\renewcommand*{\printchapternum}{\chapnumfont \space\thechapter\space}

\copypagestyle{indexfirstpage}{madsen}
%% NOW WHAT??

\makeindex

\begin{document}

\chapter{One}

apple\index{apple}, bag\index{bag}, 
\newpage
color\index{color}, dog\index{dog}.

\backmatter
\printindex

\end{document}

The (top parts of) the first page of the chapter and the first page of the index look like this:

First page chapter, madsen style First page index, madsen style

Thus on the index first page, the "INDEX" title should move above the rule, staying in the font size, etc., it already has; and no title should appear directly below the rule.

Since I want to do the same thing with the first page of a separate index of names and a separate index of notation, the modification would, I presume, somehow referencing the current value of \indexname.

I did examine the definition of page style madsen in memoir.sty to try to see just what determines that the "Chapter"name and chapter number are placed above the rule, and the chapter title below, but I'm out of my depth here.

Style I chose

Not having seen an answer here for some months, and in any case, I decided to go with a style that does not use any rule on the first page of starred "chapters", namely, Preface, Index, Index of Names, Index of Notation. Here's the style I cooked up (I'm using LucidaBright fonts, so of course the result will be somewhat different with other fonts:

\makeatletter
\makechapterstyle{my}{%
\renewcommand{\chapnamefont}{\sffamily\bfseries}
\renewcommand{\chapnumfont}{\fontsize{58}{64}\selectfont\sffamily\bfseries}
\renewcommand{\chaptitlefont}{\Huge\sffamily\bfseries}
%
\settoheight{\midchapskip}{\chapnumfont 1}
\setlength{\midchapskip}{0pt}
\setlength{\afterchapskip}{48pt}
%
\renewcommand{\printchaptername}{%
\chapnamefont\centering\MakeUppercase{\@chapapp}\par}
%
\renewcommand*{\printchapternum}{%
\vskip -8pt\centering \chapnumfont\thechapter} % or omit the vskip?
%
\renewcommand{\afterchapternum}{%
\par\nobreak\vskip \midchapskip%
\centering\rule{0.825\textwidth}{\normalrulethickness}%
\newline}
\renewcommand{\printchaptertitle}[1]{\centering\chaptitlefont ##1}
}% end makechapterstyle
\makeatother

\renewcommand*{\cftappendixname}{Appendix\space}

\chapterstyle{my}
  • What about other starred chapters? What should their format be? – cfr Oct 2 '16 at 1:52
  • Preface, Contents could be either like desired index or with no rule at all. All backmatter "chapters" should be like desired index: their name above the rule, nothing (except the body of the index, etc.) below the rule. – murray Oct 2 '16 at 2:36
  • So probably look at how Memoir styles starred chapters, then, since it seems you just want to apply the alternate style to all of them. – cfr Oct 2 '16 at 3:12
  • To clarify: for starred "chapters" such as Index, Bibliography (possibly Preface, Contents), it's only the first page's style I want to change. The remaining pages should have their usual style under madsen (but with headers & footers suitably changed -- e.g., non-first Index pages will have in header the 1st & last index entry on that page -- which I know how do take care of. – murray Oct 2 '16 at 3:19
  • I don't understand the interaction between \pagestyle and \chapterstyle. And in memoir.cls, I'm not finding definitions of starred chapters (or I don't understand exactly what I'm looking form). – murray Oct 2 '16 at 13:29
2

Below is my method for doing the request. In my opinion the proper method is to do a new chapter style. As Johannes mentioned, chapter styles and page styles are not related. There are copy features for page styles, not so for chapter styles.

The easiest is often to copy the code from memoir.cls (the path to which is listed in the log). The main issue here is that the title is placed differently when the non-starred version is used, so we have to get creative. My code is below. Since this answer may be relevant for similar questions, I'll start by explaining a bit on how memoir chapter styles work

There are two pseudo codes for chapters, one for normal \chapter and one for \chapter*

\chapter:

\chapterheadstart
\printchaptername \chapternamenum \printchapternum
\afterchapternum
\printchaptertitle
\afterchaptertitle

\chapter*

\chapterheadstart
\printchapternonum
\printchaptertitle
\afterchaptertitle

Where \chapterheadstart, \afterchapternum and \afterchaptertitle performs the skips with value \beforechapskip, \midchapskip and \aftechapskip

Important to note, \chapternonum is empty by default, thus a starred chapter never runs \afterchapternum unless you remember to include it.

In many complicated designs, one ends up making \printchapternonum into a switch and do all the title design in \printchaptertitle.


Code for the OPs question. Note that the line is not always in the same position (\chapter vs \chapter* since the font size for the chapter title is the same in both cases

 \documentclass{memoir}
\usepackage{graphicx} % need for madsen chapter style


\newif\ifNOSTARCHAP
\makeatletter

% alternative madsen chapter style with a different design for the
% unstarred version

\makechapterstyle{madsenX}{% requires graphicx package
  \chapterstyle{default}
  \renewcommand*{\chapnamefont}{%
    \normalfont\Large\scshape\raggedleft}
  \renewcommand*{\chaptitlefont}{%
    \normalfont\Huge\bfseries\sffamily\raggedleft}
  \renewcommand*{\chapternamenum}{}
  \renewcommand*{\printchapternum}{}
  \renewcommand*{\printchaptername}{}
  \renewcommand*{\printchapternonum}{%
    \NOSTARCHAPtrue%
  }%
  \renewcommand\printchaptertitle[1]{%
    \ifNOSTARCHAP%
      \chaptitlefont ##1%
    \else%
      \chapnamefont \@chapapp \chapnumfont \space\thechapter%
    \fi%
    \par%
    \vskip\midchapskip%
    \hrule\vskip\midchapskip%
    \ifNOSTARCHAP\else%
    \chaptitlefont ##1%
    \fi%
    \NOSTARCHAPfalse%
  }
}
\makeatother

\chapterstyle{madsenX}


\makeindex

\begin{document}

\tableofcontents*

\chapter{One}

apple\index{apple}, bag\index{bag}, 
\newpage
color\index{color}, dog\index{dog}.


\printindex

\end{document}
  • @Johannes_B ^^^^ – daleif May 2 '17 at 10:22
  • Not having seen an answer here for 7 months after I posted, I decided to go with a starred chapter style that omits the rule after all, so it avoids madsen entirely. – murray May 2 '17 at 21:16
  • @murray Johannes have been cleaning up unanswered questions – daleif May 2 '17 at 21:17
  • I surmised that! – murray May 4 '17 at 13:27
2

This redefines how unnumbered (starred) chapters look like. A normal chapter in the frontmatter (for example) will still look like it does now. Lists (created by \newlistof) will also still look the same.

murrayMemoirChapterstyle

\documentclass[oneside]{memoir}
\usepackage{blindtext}
\usepackage{graphicx} % need for madsen chapter style
\chapterstyle{madsen}
\renewcommand*{\printchapternum}{\chapnumfont \space\thechapter\space}
\makeatletter
\def\@makeschapterhead#1{%
  \chapterheadstart
  {%\parindent \z@ \raggedright \normalfont
   \parskip \z@%
   \parindent \z@ \memRTLraggedright \normalfont
   \interlinepenalty\@M
   \printchaptertitle{#1}%
   \afterchapternum
   \afterchaptertitle}%
}
\makeatother

\begin{document}
\backmatter
\chapter{Wombat}
\blindtext
\chapter*{Capybara}
\blindtext
\begin{theindex}
\end{theindex}
\end{document}
  • 1
    I would just make a new chapter style. I'll write an answer when I'm at a pc, probably tomorrow. – daleif May 1 '17 at 12:45

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.