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:
![initial result](https://i.stack.imgur.com/V4hV3.png)
this is because appendix
uses the document class's \part
to produce the appendix page and article.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 with titlesec
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 with titlesec
, 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:
\usepackage[title,toc,page]{appendix}
We don't use titletoc
as we'll add this ourselves. Now, redefine the command used to create the page:
\renewcommand\appendixpage{\clearpage\thispagestyle{empty}\mbox{}\vfill\begin{flushright}\LARGE\bfseries\addappheadtotoc\appendixpagename\vfill\mbox{}\end{flushright}\clearpage}
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
:
\let\oldappendixtocname\appendixtocname
\let\oldappendixpagename\appendixpagename
and then redefine them in terms of a new \appendixtitle
command:
\renewcommand*\appendixtocname{\protect\large \oldappendixtocname\quad \appendixtitle}
\renewcommand*\appendixpagename{\oldappendixpagename\\\appendixtitle}
Finally, create the new command to hold the title with a placeholder:
\newcommand*\appendixtitle{Title of Appendices}% title of appendices goes here
Final result:
![appendices page](https://i.stack.imgur.com/zfkqz.png)
Complete code:
\documentclass{article}
\usepackage{titlesec}
% % wouldn't it be easier to use titlesec to do this rather than a manual intervention for each section? (Assuming that's what this is for)
\newcommand{\sectionbreak}{\clearpage} % To make each section start on a new page
\usepackage[title,toc,page]{appendix}
\renewcommand\appendixpage{\clearpage\thispagestyle{empty}\mbox{}\vfill\begin{flushright}\LARGE\bfseries\addappheadtotoc\appendixpagename\vfill\mbox{}\end{flushright}\clearpage}
\let\oldappendixtocname\appendixtocname
\let\oldappendixpagename\appendixpagename
\renewcommand*\appendixtocname{\protect\large \oldappendixtocname\quad \appendixtitle}
\renewcommand*\appendixpagename{\oldappendixpagename\\\appendixtitle}
\newcommand*\appendixtitle{Title of Appendices}% title of appendices goes here
\usepackage{lipsum}
\begin{document}
\tableofcontents
\section{Section title}
\lipsum[4]
\begin{appendices}
\section{Appendix title}
\lipsum[4]
\end{appendices}
\end{document}
Best Answer
I would second what @egreg said about avoiding the need for underlining. But sometimes it can't be helped (like when you're working with others who insist on particular styling). So I'll help you to get where you want to be.
This solution allows a full [double] underline (just like with the plain solution you had in your MWE), but also gives an alternate option for the reference.
I have redefined things to allow you to continue to use
\section{...}
and\section*{...}
as normal. But now, instead of changing the TOC line, the optional argument is used for the reference:A full example, with the appropriate redefinitions:
This will make the following sections: