# Style end of chapter in memoir?

memoir provides various ways in which the beginning of a chapter can be styled. I cannot find anything in the manual that lets me style the end of a chapter, like adding a fleuron. Is this possible?

• How does latex know where a chapter ends? Sep 7 '19 at 5:59
• I don't know how LaTeX know this. But given that the files are processed multiple times, I could imagine that once you know on which page a new chapter begins, you can infer where the previous chapter ended. Sep 7 '19 at 10:41
• As such latex is not like XML, så by structure alone we do not have control over where a chapter ends. You'll probably be better if inserting these by hand as you are the onl one that knows where a chapter ends Sep 7 '19 at 12:35

A chapter can end in two ways: when the next chapter begins or when the document ends. Therefore, you can modify the \chapter command to add something to the old chapter before the new chapter is started, and moreover use \AtEndDocument to add something to the end of the document. Adding code to \chapter can be done using the etoolbox package, which provides the command \pretocmd which adds code at the start of the command.

Of course you don't want to add anything before the first chapter, because that chapter does not end the previous chapter. To address this you can test for the value of the chapter counter, and only add something when the counter is larger than zero.

I'm not sure what you mean with a fleuron but maybe something like the leaf symbols from the adforn package are suitable.

MWE:

\documentclass{memoir}
\usepackage[nopar]{lipsum}
\usepackage{etoolbox}
\begin{document}
\chapter{First chapter}
\lipsum[1]
\chapter{Second chapter}
\lipsum[2]
\chapter{Last chapter}
\lipsum[3]
\end{document}


Result:

Note that this might not work for more complex document structures, like appendices etc. Also it may not look good when adding the leaf if the chapter ends with a table etc. You could add some code to switch off the leaf at some point, or make it optional.

• Very nice, and coupled with your caveats. Also remember that a \part will end a chapter as will memoir's \book. Seems to me that the fleurons might be better added by hand. Sep 8 '19 at 17:32