3

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}
4
  • I think all that is needed here isn't a redefiniton of anything, but a simple word written on a single page. Doesn't have appendix a macro for just that purpose?
    – Johannes_B
    Oct 16, 2015 at 17:52
  • appendixpage, is that wat you are looking for?
    – Johannes_B
    Oct 16, 2015 at 17:54
  • Is this supposed to print 'Appendix A Appendix Title' or 'Appendices' or what?
    – cfr
    Oct 19, 2015 at 0:27
  • @Johannes_B It turns out to be rather more complicated than that ;). appendix does not mean by page what most of us do, it seems....
    – cfr
    Oct 19, 2015 at 1:38

2 Answers 2

4

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

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

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}
4
+200

What about this?

\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}
\titleformat{\section}[block]{\null\vfill\hfill}{\thesection}{2em}{}[\vfill\aftergroup\clearpage]
\section{Appendix title}
\lipsum[4]
\end{appendices}

\end{document}

The idea is that you can use \titleformat inside the appendices group to change the format only inside the environment. Sections after the appendices will be formatted normally.

You can adapt the formatting to suit your needs by adding formatting commands after \hfill.

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.