[Tex/LaTex] Appendix Sections Within Chapters, Alphabetically Numbered

appendicesnumbering

I want to have appendix sections that are alphabetically numbered, within chapters:

Chapter 1
First Chapter
1.1 First Chapter Section
1.A First Chapter Appendix
1.B Second Chapter Appendix

Chapter 2
Second Chapter
2.1 Second Chapter
2.A First Chapter Section

trying this:

\documentclass{book}
\begin{document}
\chapter{First Chapter}
  \section{First Chapter Section}
  \appendix
  \section{First Chapter Appendix}
  \section{Second Chapter Appendix}

\chapter{Second Chapter}
  \section{Second Chapter Section}
  \appendix
  \section{Second Chapter Appendix}
\end{document}

I get:

Chapter 1
First Chapter
1.1 First Chapter Section
.1 First Chapter Appendix
.2 Second Chapter Appendix

Appendix A
Second Chapter
A.1 Second Chapter
.1 First Chapter Section

How can I fix the numbering?

Best Answer

This works out of the box with the appendix package:

\documentclass{book}
\usepackage{appendix}

\begin{document}

\frontmatter

\tableofcontents

\mainmatter

\chapter{First Chapter}

\section{First Chapter Section}

\begin{subappendices}

\section{First Chapter Appendix}

\section{Second Chapter Appendix}

\end{subappendices}


\chapter{Second Chapter}

\section{Second Chapter Section}

\begin{subappendices}

\section{Second Chapter Appendix}

\end{subappendices}

\end{document}

enter image description here