2

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.

  • There is a title option but that's not what you want, most likely? – user31729 Jun 12 '17 at 14:27
1

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

  • The first solution posted worked well. The solution given after the edit would be preferable but it causes \chapter{Foobar} not to display. I am using lualatex if that possibly makes a difference. – Michael Buckley Jun 12 '17 at 14:56
  • @MichaelBuckley: Yes, I forgot \fi in the first \xpatchcmd for \@makechapterhead. Please use the updated code, it should work with lualatex as well now – user31729 Jun 12 '17 at 15:32
  • This does not seem to do anything if you have \include{appendix} where the appendix is in another .tex. I placed the patch before my \begin{document}. Compiles without a warning or error. But I still have Appendix A and then the chapter with no Appendix title at the very top. – Frikster Aug 16 '17 at 1:38
  • @DirkHaupt: Works for me out of the box even with \include although I never claimed it would work with \include (which I basically never use for my purposes). There's nothing I can do for you here – user31729 Aug 16 '17 at 6:12

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.