# Renew \chapterheadstart for numbered chapters only (memoir)

I am redefining the chapter styles for my document - one of the tasks I want to achieve is to add an image in front of all numbered chapters. The question / problem I have is, how to target only the numbered chapters (or exclude ToC, bibliography, appendix A-[Z], etc.).

My current code - slightly simplified to include only a chapterheadstart command with an added vspace for 'numbered' chapters. Unfortunately this does not work and instead removes the 'vspace' from all of the chapters;

\makechapterstyle{styleName}{
\ifnum\value{secnumdepth}>-1
\if@mainmatter
\vspace*{5cm}
\noindent
}
\fi
\fi
}


Thank you in advance! Definte beginner in LaTeX here.

• Welcome to TeX.SX! Please help us to help you and add a minimal working example (MWE) that illustrates your problem. It will be much easier for us to reproduce your situation and find out what the issue is when we see compilable code, starting with \documentclass{...} and ending with \end{document}. – user31729 Dec 27 '14 at 16:56
• Why not define two chapter styles, and apply them as needed? All the numbered chapters would be contiguous, and you'd only need three \chapterstyle commands for the whole document (one for the front matter (unnumbered lists of things), one for the main matter (numbered chapters), and one for the bibliography and back matter). – Mike Renfro Dec 27 '14 at 17:17
• @MikeRenfro Thank you for the suggestion! Does that mean adding '\chapterstyle{1}' at the beginning of my .tex document, and adding '\chapterstyle{2}' where my main document text starts? (And adding \chapterstyle{3} for the final chapters) – WalterB Dec 27 '14 at 18:03
• Yes. The truly picky among us could modify the \mainmatter or similar commands with \addtodef to automatically include the \chapterstyle commands. But that's only relevant if you're making a document class for others and want to minimize the amount of code they have to deal with. – Mike Renfro Dec 27 '14 at 18:07
• @MikeRenfro The solution you proposed works for me! If you appreciate it, please post your comment as an answer so I can accept it. – WalterB Dec 28 '14 at 8:01

Add \chapterstyle commands to make transitions from one style to another. They will take effect from that point on in the document.

\documentclass[openany]{memoir} % openany to reduce blank pages
\usepackage{lipsum}
\begin{document}

\chapterstyle{bianchi} % for ToC and other lists

\tableofcontents

\chapterstyle{bringhurst} % for numbered chapters

\chapter{One}
From \cite{golub13}, \lipsum[1]

\chapterstyle{chappell} % for bibliography, appendices, etc. May be same as for ToC.
\bibintoc
\begin{thebibliography}{1}

\bibitem{golub13}
Gene~H. Golub and Charles~F. van Loan.
\newblock {\em Matrix Computations}.
\newblock JHU Press, 4th edition, 2013.

\end{thebibliography}

\appendix

\chapter{Appendix}
\lipsum[2]

\end{document}


Early pages:

Numbered chapters:

Bibliography:

Appendices:

Memoir tests itself if it has to print a chapter number in \@makechapterhead with \ifm@m@And. This only works, though, if not the starred version of \chapter is used. Hence we also test if not a starred chapter is started with \ifm@mpn@new@chap.

\makeatletter
\makechapterstyle{styleName}{
\ifm@m@And % If there is no number to print
\ifm@mpn@new@chap % This is to catch the starred version
\noindent\rule{\textwidth}{.4pt}\\[5cm]
\fi
\fi
}
}
\makeatother


And integrated into the MWE of Mike Renfro:

\documentclass[openany]{memoir} % openany to reduce blank pages
\usepackage{lipsum}

\makeatletter
\makechapterstyle{styleName}{
\ifm@m@And % If there is no number
\ifm@mpn@new@chap % This is to catch the starred version
\noindent\rule{\textwidth}{.4pt}\\[5cm]
\fi
\fi
}
}
\makeatother
\chapterstyle{styleName}

\begin{document}

\tableofcontents

\chapter{One}
From \cite{golub13}, \lipsum[1]

\chapter*{Two}

\bibintoc
\begin{thebibliography}{1}

\bibitem{golub13}
Gene~H. Golub and Charles~F. van Loan.
\newblock {\em Matrix Computations}.
\newblock JHU Press, 4th edition, 2013.

\end{thebibliography}

\appendix

\chapter{Appendix}
\lipsum[2]

\end{document}