[Tex/LaTex] Table of Contents inside an Appendices Environment

appendicestable of contents

I am trying to create a table of contents inside the appendices environment, however I am unable to do so. In the example below I want a table of contents for Section1.

I have tried the minitoc but am having no luck. Any suggestions?

Thanks

\documentclass[12pt,a4paper]{article}
\usepackage[titletoc, title]{appendix}

\begin{document}
...
\tableofcontents\newpage
\listoffigures\newpage
\listoftables\newpage
...
\begin{appendices}
\section{Section1}
...
%Want the toc here
...
\subsection{subSec}
...
\subsubsection{subsubSec}
...
\section{Section2}
...
\end{appendices}
\end{document}

Best Answer

You can use the titletoc package to produce partial ToCs; a little example:

\documentclass[12pt,a4paper]{article}
\usepackage[titletoc, title]{appendix}
\usepackage{titletoc}

\begin{document}

\tableofcontents\newpage
\listoffigures\newpage
\listoftables\newpage

\begin{appendices}

\section{First Appendix}
\startcontents
\printcontents{}{2}{}
\subsection{subSecA1}
\subsubsection{subsubSecA11}
\subsubsection{subsubSecA12}
\stopcontents
\section{Second Appendix}
\subsection{subSecB1}
\subsubsection{subsubSecB11}
\subsubsection{subsubSecB12}

\end{appendices}

\end{document}

An image of the resulting partial ToC:

enter image description here

Of course, you can customize the partcial ToC in many ways; in the following example I changed the indentation for the entries in the partial ToC using the notion of prefixes and added some rules before and after the partial ToC:

\documentclass[12pt,a4paper]{article}
\usepackage[titletoc, title]{appendix}
\usepackage{titletoc}

\titlecontents{lsubsection}
  [2.3em]{}{\contentslabel{2.3em}}
  {\hspace*{-2.3em}}{\titlerule*[9pt]{.}\contentspage}
\titlecontents{lsubsubsection}
  [5.7em]{}{\contentslabel{3.5em}}
  {\hspace*{-3.5em}}{\titlerule*[9pt]{.}\contentspage}

\begin{document}

\tableofcontents\newpage
\listoffigures\newpage
\listoftables\newpage

\begin{appendices}

\section{First Appendix}
\startcontents
\printcontents{l}{2}{\hrulefill}
\vskip-8pt\noindent\hrulefill
\subsection{subSecA1}
\subsubsection{subsubSecA11}
\subsubsection{subsubSecA12}
\subsection{subSecA2}
\subsubsection{subsubSecA21}
\subsubsection{subsubSecA22}
\stopcontents
\section{Second Appendix}
\subsection{subSecB1}
\subsubsection{subsubSecB11}
\subsubsection{subsubSecB12}

\end{appendices}

\end{document}

enter image description here

Using \starlist, \printlist, \stoplist one can also produce partial LoFs and LoTs:

\documentclass[12pt,a4paper]{article}
\usepackage[titletoc, title]{appendix}
\usepackage{titletoc}

\titlecontents{lsubsection}
  [2.3em]{}{\contentslabel{2.3em}}
  {\hspace*{-2.3em}}{\titlerule*[9pt]{.}\contentspage}
\titlecontents{lsubsubsection}
  [5.7em]{}{\contentslabel{3.5em}}
  {\hspace*{-3.5em}}{\titlerule*[9pt]{.}\contentspage}
\titlecontents{lfigure}
  [2.3em]{}{\contentslabel{2.3em}}
  {\hspace*{-2.3em}}{\titlerule*[9pt]{.}\contentspage}
\titlecontents{ltable}
  [2.3em]{}{\contentslabel{2.3em}}
  {\hspace*{-2.3em}}{\titlerule*[9pt]{.}\contentspage}

\begin{document}

\tableofcontents\newpage
\listoffigures\newpage
\listoftables\newpage

\begin{appendices}

\section{First Appendix}
\startcontents
\startlist{lof}
\startlist{lot}
\printcontents{l}{2}{\hrulefill\par\noindent\textbf{Outline}}
\par\noindent\textbf{List of Figures}
\par\printlist{lof}{l}{}
\par\noindent\textbf{List of Tables}
\par\printlist{lot}{l}{}
\vskip-8pt\noindent\hrulefill

\subsection{subSecA1}
\begin{figure}[!ht]
\centering
\rule{2cm}{2cm}
\caption{A test figure}
\end{figure}
\subsubsection{subsubSecA11}
\begin{table}[!ht]
\centering
\rule{2cm}{2cm}
\caption{A test table}
\end{table}
\subsubsection{subsubSecA12}
\subsection{subSecA2}
\begin{figure}[!ht]
\centering
\rule{2cm}{2cm}
\caption{Another test figure}
\end{figure}
\subsubsection{subsubSecA21}
\begin{table}[!ht]
\centering
\rule{2cm}{2cm}
\caption{Another test table}
\end{table}
\subsubsection{subsubSecA22}
\stopcontents
\stoplist{lof}
\stoplist{lot}
\section{Second Appendix}
\subsection{subSecB1}
\subsubsection{subsubSecB11}
\subsubsection{subsubSecB12}

\end{appendices}

\end{document}

enter image description here