# Making a new style using a existing one through memoir

I'm having some issues while trying to create a new style based on another preexistent in memoir.

After consulting some other threads on this issue, like this or this one, I've tried the following code, using a MWE:

\documentclass{memoir}

\makechapterstyle{test}{%
\chapterstyle{bianchi}
\renewcommand*{\chapnumfont}{%
\normalfont\small\bfseries\flushright}
\renewcommand*{\chaptitlefont}{%
\normalfont\large\bfseries\flushright}
\renewcommand*{\printchapternum}{\flushright\chapnumfont \thechapter}%
}

\chapterstyle{test}
\usepackage{lipsum}

\begin{document}

\chapter{blablabla}
\lipsum[1-2]

\end{document}


How can I make the Chapter and the number of the chapter together aligned to the right? Also, can I do this to all chapter titles instead of doing it locally?

• (1) Welcome, (2) you should use \raggedleft here, not \flushright as \flushright is actually an environment, so does more than you need here. Replace the two first \flushright with \raggedleft and remove the last one as you already set it in the font setting. To reduce the spacing above either use \setlength{\beforechapskip}{some value} or redefine \chapterheadstart to do nothing. Note you have only changed the \chapnumfont, you probably also want to change \chapternamefont. – daleif May 3 '17 at 13:19

This seems to work.

You should use \raggedleft here, not \flushright as \flushright is actually start of an environment, so does more than you need here. Replace the two first \flushright with \raggedleft and remove the last one as you already set it in the font setting. To reduce the spacing above either use \setlength{\beforechapskip}{some value} or redefine \chapterheadstart to do nothing. Note you have only changed the \chapnumfont, you probably also want to change \chapternamefont

\documentclass{memoir}
\makechapterstyle{test}{%
\chapterstyle{bianchi}
\renewcommand*{\chapnumfont}{%
\normalfont\small\bfseries\raggedleft}
\renewcommand*{\chapnamefont}{%
\normalfont\small\bfseries}
\renewcommand*{\chaptitlefont}{%
\normalfont\large\bfseries\raggedleft}
\renewcommand*{\printchapternum}{\chapnumfont \thechapter}%
\setlength\beforechapskip{0pt} % not the same as no space above
% because of \vspace* internally
}

\chapterstyle{test}
\usepackage{lipsum}

% note to show where the text block is
%\aliaspagestyle{chapter}{showlocs}

\begin{document}

\chapter{blablabla}
\lipsum[1-2]

\end{document}

• This is indeed working, although I'm going to ask a bit more on this: (1) Can I define the \setlength\beforechapskip{0pt} as \setlength\beforechapskip{-'somevalue'pt}? (2) Also, the space after the chapter title can be altered with \setlength\afterhapskip? (3) Can I reduce the space of the lines holding the chapter title? Thank you! – Tiago Correia May 3 '17 at 13:26
• Just altered the default style from bianchi to lyhne and it worked. \before and afterhapskip do work, haven't tried negative numbers though. – Tiago Correia May 3 '17 at 14:04
• @TiagoCorreia you generally should not need negative values as you are not adding to the existing lengths (unless you're using \addtolength) – daleif May 3 '17 at 14:10
• Ok, understood. Keeping these values to 0 will respect the document instated in the document, right? If so, will keep them that way. Thank you again for your help! – Tiago Correia May 3 '17 at 14:12
• 'respect the margins instated in the document' and not 'respect the document instated in the document'... – Tiago Correia May 4 '17 at 7:47