I'm using the appendix
and titlesec
packages to control section titles and formatting. I would like to redefine the appearance of appendix section titles: How can I define the appendix title style to be (1) flush right, (2) centered vertically, and, (3) appear on one page by itself?. How do I accomplish this without redefining the appearance of the section titles in the body of the document?
Here is the MWE:
\documentclass{article}
\usepackage[title,toc,titletoc]{appendix}
\usepackage{titlesec}
\newcommand{\sectionbreak}{\clearpage} % To make each section start on a new page
\usepackage{lipsum}
\begin{document}
\section{Section title}
\lipsum[4]
\begin{appendices}
\section{Appendix title}
\lipsum[4]
\end{appendices}
\end{document}
Best Answer
This is a result of my trying out the suggestion in comments to use an option from
appendix
to create the page before the appendices. Unfortunately, that is not as straightforward as one might have thought....As a first step, the documentation suggested that adding the
page
option when loading the class might do the trick. For monitoring, I also added a\tableofcontents
since the MWE in the question suggested this is desired.The result:
this is because
appendix
uses the document class's\part
to produce the appendix page andarticle.cls
does not start a new page for a new part.I thought this might not be so terrible since
titlesec
can redefine\part
as well as other sectional divisions. However, that did not work. It worked for\part{}
but not for the appendix page.I also tried
etoolbox
's\apptocmd
and\pretocmd
. This, however, turned out to be incompatible withtitlesec
and did not, in any case, have the desired result.Looking at the code for
appendix.sty
, it turns out that the documentation is a bit misleading. What it does is uses the format for the 'page' which it thinks must be in place given the document class. If there are chapters, it issues a\clearpage
. Otherwise, it does not.appendix
is not, it seems designed for flexibility.I then tried redefining
\appendixpage
to issue an explicit\part*{}
. Together withtitlesec
, this let me get the format for the page itself right.Sadly, this played havoc with the contents. Rather than being added to the contents once, the appendices were added four times.
Finally, I opted for a brute force approach. First, the package:
We don't use
titletoc
as we'll add this ourselves. Now, redefine the command used to create the page:This is really doing all the work.
\addappheadtotoc
is adding the appendices stuff to the contents. The rest is just formatting the page. You can adjust the formatting here as you wish.For a little more flexibility in the title, it would be nice to be able to get something like 'Appendices Title of Appendices' in the same way that you get 'Appendix A Title of Appendix'. To do this, we save the current definitions of
\appendixpagename
and\appendixtocname
:and then redefine them in terms of a new
\appendixtitle
command:Finally, create the new command to hold the title with a placeholder:
Final result:
Complete code: