# How to use the \plainfancybreak* command from the memoir class with the book class

I would like to use something similar to \plainfancybreak* as defined in the memoir class doc (pg 99), but in the book class. Is it possible?

FYI: The \plainfancybreak*{<space>}{<num>}{<text>} command in the memoir class can insert a number of blank lines if the break happens in the middle of the page, and a symbol(s) (=) if the break happens at the end of the page. The asterisk in the command simply ensures that the new line starts with no indent. This format is pretty standard in fiction, but I can't figure out how to replicate it in LaTeX without the memoir package.

• You could extract the relevant code from memoir.cls and put it in your preamble. On the other hand why not just use memoir instead of book? – Peter Wilson Jan 21 '19 at 20:23
• I've already created the document with the book class and I'd rather not switch to memoir. As for extracting the code, I'm not sure where to find the memoir.cls file -- I'm afraid not as familiar with the inner workings of TeX. – johnymm Jan 21 '19 at 20:29

I have extracted the PFBreak code from Memoir and gotten it to work using Book class, which is what Peter Wilson said.

% ===============================================
% Bringing PlainFancyBreak from Memoir class.
\makeatletter
\newcommand{\plainfancybreak}{\@ifstar{\@spfbreak}{\@pfbreak}}
\newcommand{\@pfbreak}[3]{\par
\ifdim #1>\@tempdimc \@fbreak{#3}\else \@pbreak{#2}\fi}
\newcommand{\@spfbreak}[3]{\par
\ifdim #1>\@tempdimc \@sfbreak{#3}\else \@spbreak{#2}\fi}

\newcommand*{\pen@ltyabovepfbreak}{2}
\newcommand*{\pen@ltybelowpfbreak}{-4}

\newlength{\pfbreakskip}
\setlength{\pfbreakskip}{2\baselineskip}

\def\pfbre@kdispl@y{\vbox to 1\pfbreakskip{\vss
\hb@xt@ \columnwidth{\hss \pfbreakdisplay \hss}%
\vss}}

\edef\nopfbreakOutput{\the\output}
\def\pfbreakOutput{%
\ifnum\outputpenalty=\pen@ltyabovepfbreak
\nopfbreakOutput
\pfbre@kdispl@y
\nobreak
\vskip-\pfbreakskip
\else\ifnum\outputpenalty=\pen@ltybelowpfbreak
\unvbox 255\relax
\nobreak
\vskip-\pfbreakskip
\pfbre@kdispl@y
\break
\else
\nopfbreakOutput
\fi
\fi}
\output={\pfbreakOutput}

\newcommand{\pfbreak}{\@ifstar{\@spfbreakgap}{\@pfbreakgap}}
\newcommand{\@pfbreakgap}{%
\par {%
\skip@\lastskip
\nobreak
\vskip -\ifdim\prevdepth>\maxdepth \maxdepth
\else\ifdim\prevdepth>-1000pt\prevdepth
\else\ifinner 0pt
\else \pagedepth
\fi \fi \fi
\vskip -\skip@
\ifdim\skip@<\pfbreakskip
\fi
\penalty\pen@ltyabovepfbreak
\vskip\skip@
\penalty\pen@ltybelowpfbreak
}
\@afterindentfalse
}
\newcommand{\@spfbreakgap}{%
\par {%
\skip@\lastskip
\nobreak
\vskip -\ifdim\prevdepth>\maxdepth \maxdepth
\else\ifdim\prevdepth>-1000pt\prevdepth
\else\ifinner 0pt
\else \pagedepth
\fi \fi \fi
\vskip -\skip@
\ifdim\skip@<\pfbreakskip