[Tex/LaTex] New chapter after Appendix in LyX

lyx

Is it possible in LyX to start a new chapter after Appendix??? seems like no matter if I start a new chapter or paragraph, it continues writing in Appendix.

Best Answer

This probably should be a duplicate but I couldn't find it. I also don't have lyx installed but I imagine that the solution should be the same (so this is a latex solution). Apologies if lyx is honestly different.

The problem is that \appendix redefines how chapters are printed. It also resets the chapter counter. You have not said how the next chapter should be numbered but it seems reasonable to keep the same numbering which means that we need to save the current chapter number when \appendix is called (I do this using \preto from the etoolbox package) and then we need to restore the value of the chapter counter when we switch back to chapters.

Below I define a \resumechapters command that does these things. Here is the output (with the page breaks suppressed):

enter image description here

and here is the code:

\documentclass[a4paper,12pt]{book}
\makeatletter
\usepackage{etoolbox}
\newcounter{savedchapter}% for remembering the last chapter number
\preto\appendix{\setcounter{savedchapter}{\arabic{chapter}}}% remembering!
\newcommand\resumechapters{% the \appendix command with some tweaks
  \setcounter{chapter}{\arabic{savedchapter}}% restore chapter number
  \setcounter{section}{0}% reset section counter
  \gdef\@chapapp{\chaptername}% reset chapter name
  \gdef\thechapter{\@arabic\c@chapter}% make chapter numbers arabic
}
\makeatother

\let\cleardoublepage\relax% compressed output of MWE

\begin{document}
   \chapter{A chapter}
   \appendix
   \chapter{An appendix}
   \resumechapters
   \chapter{Another chapter}
\end{document}