0

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?

3
  • 1
    How does latex know where a chapter ends?
    – daleif
    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
    – daleif
    Sep 7 '19 at 12:35
1

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{adforn}
\usepackage{etoolbox}
\pretocmd{\chapter}{\ifnum\value{chapter}>0\adfhangingleafright\fi}{}{}
\AtEndDocument{\adfhangingleafright}
\begin{document}
\chapter{First chapter}
\lipsum[1]
\chapter{Second chapter}
\lipsum[2]
\chapter{Last chapter}
\lipsum[3]
\end{document}

Result:

enter image description here

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.

1
  • 1
    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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.