[Tex/LaTex] Appendices title on first page of Appendices and not separate page

appendices

I have used the appendix package like this.

\usepackage[toc, page]{appendix}

This puts the title 'appendix' on its own page. Now I want to have this title, but I would rather if it put on the same page as the first chapter of the appendix, so you would have it just above chapter title of the first appendix.

I tried to read the manual, but I did not see an option for this.

Best Answer

A version with patching of \@makechapterhead:

The patch checks whether the chapter number is 1, i.e. meaning the first appendix chapter and insertes the Appendix line accordingly, taking the values of \abovefirstappchapskip etc. into account -- those values can be changed at will.

\documentclass{book}


\usepackage{xpatch}
\usepackage[toc]{appendix}

\makeatletter
\newlength{\abovefirstappchapskip}
\newlength{\belowfirstappchapskip}
\AtBeginEnvironment{appendices}{%
  \xpatchcmd{\@makechapterhead}{%
    \vspace*{50\p@}%
  }{%
    \ifnum1=\c@chapter
    \vskip\abovefirstappchapskip%
    \fi
  }{}{}
  \xpatchcmd{\@makechapterhead}{%
    \parindent \z@ \raggedright \normalfont
  }{%
    \parindent \z@ \raggedright \normalfont
    \ifnum1=\c@chapter
    \begingroup 
    \centering \Huge\bfseries \appendixname
    \vskip\belowfirstappchapskip
    \endgroup
    \fi
  }{}{}
}
\makeatother

\setlength{\abovefirstappchapskip}{30pt}
\setlength{\belowfirstappchapskip}{30pt}

\begin{document}
\tableofcontents

\begin{appendices}
\chapter{Foo}

\chapter{Foobar}

\end{appendices}

\end{document}

enter image description here

Related Question