# Part style in memoir class

I use the \chapterstyle{thatcher} in memoir class. I would like the part style would be similar to the chapter style - but with title centered in the page. As I'm a newbie in LaTeX world, I wonder how should I use the commands which are described in the memoir manual (section 6.4)?

I've tried the following ones in the preamble, and ... it doesn't work...

\renewcommand*{\partnamefont}{\large\centering}
\renewcommand*{\partnumfont}{\large}
\renewcommand*{\printpartnonum}{%
\vphantom{\printpartname}%
\vphantom{\partnumfont 1}%
\afterpartnum
\vskip -\onelineskip}
\renewcommand*{\parttitlefont}{\Large\scshape}
\renewcommand*{\printparttitle}[1]{%
\hrule\vskip\onelineskip \centering\parttitlefont ##1}

-
I have edited my answer so it now works in French as well. – ienissei Mar 28 '12 at 8:24

With the memoir class, there are often easier solutions than rewriting entire macros. How to modify the format of parts is explained at section 6.4 of the manual.

In the example below, I have simply redefined the macros that set the appearance of parts to mimic the ones used by the thatcher chapter style.

\documentclass{memoir}

\usepackage[frenchb]{babel}

% Pour "première partie"
\usepackage{fmtcount}

\chapterstyle{thatcher}

\renewcommand*{\thepart}{\arabic{part}}
\renewcommand*{\parttitlefont}{\normalfont\large\MakeUppercase}
\renewcommand*{\partnamefont}{\normalfont\scshape\MakeLowercase}
\renewcommand*{\partnumfont}{\normalfont\scshape\MakeLowercase}

% Pour "première partie"
\renewcommand*{\printpartname}{\partnamefont{\ordinalstring{part}[f] partie}}
\renewcommand*{\printpartnum}{}

% Pour "partie 1"
%\renewcommand*{\printpartname}{\partnamefont Partie}
%\renewcommand*{\printpartnum}{\partnumfont\thepart}

\renewcommand{\midpartskip}{\par\parbox{0.5in}{\hrulefill}\par}
\renewcommand{\beforepartskip}{\vspace*{\fill}}
\renewcommand{\afterpartskip}{\vspace*{\fill}}

% Pour la table des matières
\renewcommand*{\cftpartname}{Partie}
\renewcommand*{\cftpartpresnum}{\space}
\renewcommand*{\cftpartaftersnum}{.}
\renewcommand*{\cftpartaftersnumb}{\space}

\begin{document}

\tableofcontents

\part{Une partie}

\part*{Une partie sans numéro}

\part[Une autre partie (nom pour la table des matières)]{Une autre partie}

\chapter{Un chapitre}

\end{document}


The names of the macros are quite self-explanatory, but here are some additional comments about what they do: \thepart is used to redefine the format of the part counter; \parttitlefont, \partnamefont and \partnumfont respectively set the font used by for the title, for the "part" word and for the number. In order to insert a line between the "Part N" line and the title line, I modified \midpartskip. Then, I also redefined \beforepartskip and \afterpartskip, which (here) define the white space to add above and below the text.

Since this technique does not rewrite the entire code, you can still use the \part command normally without any restrictions. The only problem encountered is that with \part*, the title of the part will not be exactly in the same place (whereas the thatcher chapter style adds the necessary white space in that case). But there is no easy way to do it because the memoir class does not have a special macro for starred parts (which I have never encountered anywhere, in any event).

And a picture of the result (I only put in one page):

Edit: I have updated my answer so the part name works properly with French babel. Two options there: if you want to write "première partie", leave everything as it is; if you want "partie 1" instead, uncomment the lines I have marked for this (2 lines), and comment the ones marked for the other style (that's 3 lines).

Oh, and as an added bonus, the last lines of the code rewrite the "Part" in the table of contents. You can remove it if you prefer to have just the number, but I thought you might want something of that sort too.

-

In the following minimal example, I've defined \thatcherpart{<part title>} to produce a vertically centred part in the thatcher chapter style. It is assumed that you don't want to use a alternative ToC entry for the part title from what is displayed within the text (that is, something of the form \thatcherpart[<ToC title>]{<part title>}):

\documentclass{memoir}% http://ctan.org/pkg/memoir
\usepackage{lipsum}% http://ctan.org/pkg/lipsum
\chapterstyle{thatcher}

\makeatletter
\long\def\thatcherpart#1{%
\M@gettitle{#1}%
\phantomsection
\ifnum \c@secnumdepth >-2\relax
\refstepcounter{part}%
{\protect\partnumberline{\thepart}#1}%
\mempartinfo{\thepart}{#1}{#1}%
\else
\mempartinfo{}{#1}{#1}%
\fi
\partmark{#1}%
\pagestyle{empty}%
{\centering
\interlinepenalty \@M
\parskip\z@
\null\vfill%
\normalfont\scshape%
\ifnum \c@secnumdepth >-2\relax
\MakeLowercase{Part~\thepart}
\par\centerline{\parbox{0.5in}{\hrulefill}}\par
\fi%
{\normalfont\large\MakeUppercase{#1}\par}%
}%
\vfill}
\makeatother
\begin{document}

\thatcherpart{A part}

\chapter{A chapter}
\lipsum[1]
\end{document}


\thatcherpart is literally a grab from the original \@part in memoir, with the required changes. In the above output, I've omitted page 2 (a blank, verso page). The part page style is set to empty, although this (and other modifications) are easy to incorporate.

-
Does it work with starred parts too? I can't get it to work properly then. – ienissei Mar 26 '12 at 16:36
@ienissei: Of course not, since I only defined \thatcherpart. It would be possible to create a starred variant \thatcherpart* as well. – Werner Mar 26 '12 at 22:10
Memoir being very customisable by design, rewriting half the class just to change a heading sounds like an overkill to me. :) – ienissei Mar 26 '12 at 22:22
@ienissei: We're not talking about half the class though. I like your solution better - cleaner. Mine might be more customizable in terms of its structure for other use. – Werner Mar 26 '12 at 22:27
Yes, it sure is more customisable, indeed. – ienissei Mar 27 '12 at 7:49

In case anyone is interested, the following worked for me:

% ---------------- Styling parts
\renewcommand{\partnamefont}{\Large\scshape\centering\MakeLowercase}
\renewcommand{\partnumfont}{\Large\scshape\centering\MakeLowercase}
\renewcommand{\midpartskip}{\par\rule{1in}{0.5pt}\par}
\renewcommand{\printparttitle}{\HUGE\scshape\centering\MakeLowercase}

-