0

I am trying to do 2 final things for my dissertation and I can not figure out how to do them. I have looked at all the other answers to this question and I can't seem to get anything to work from what I've researched. I apologize that this may be a repeat question but again I haven't found a solution.

I have a main Latex file that I am including all my chapters and appendixes in. I need to generate a list of appendixes (like a list of figures) and also I need to remove the appendixes from my toc.

This is the basic structure:

    \documentclass[12pt, oneside]{memoir}

    \begin{document}
    %%%% Front Matter %%%% 
    \frontmatter 
    \include{Front_Matter}

    %%%% Chapters %%%% 
    \mainmatter 
    \include{Introduction}
    ...        
    \include{Conclusion}

    %%%% Appendixes %%%% 
    \addcontentsline{toc}{chapter}{Appendixes}
    \part*{Appendixes}

    \appendix
    \include{Appendix1}
    \include{Appendix2}

    \end{document}

I need to keep the reference to where the appendixes begin in the toc, which is why I have the \part* and the \addcontentsline. I need the appendix parts (section, subsection) removed from the TOC and a separate List of Appendixes to go after my lists of tables and figures.

The appendixes are structured like:

    \chapter{Appendix 1}

    \section{Section 1}

    ...text...

    \subsection{Subsection 1}

    ...text...

Any help would be greatly appreciated

  • where should the appendix list be located? It can be done with a little extra work. Also are the appendices the very last ting in the doc or does, say the bibliography come after it? – daleif Sep 7 '16 at 10:25
  • @daleif the two appendixes listed above should be at the end of the dissertation before the references. These are technical appendixes for data and other items that span all the chapters. I do have an appendix at the end of each chapter for extra figures (I used the \subappendices for those). Not sure if that matters or not. – MJH Sep 7 '16 at 10:29
  • Ok, that complicates things a little, but not much. I'll see what I can come up with. memoir has a feature where we can insert hooks into the toc file. This hooks can then be used to enable and disable various stuff – daleif Sep 7 '16 at 10:30
  • BTW: see \appendixpage in the manual, I'd also recommend having a pointer to the appendices in the main toc – daleif Sep 7 '16 at 10:32
1

Here is my solution to this problem. I think I've answered it here before, just did not bother to search for it.

The idea is to use \cftinserthook to create trigger points in the .toc file. This triggers or hooks can then run code at that particular place in the .toc which we can use to alter how the TOC is formated.

So basically we enclose the appendix section with a pair of hooks plus add a hook at the start for later. Then in the normal state ask it to ignore the appendix section.

For making the appendix list, we locally redefined the hook code to do something else, and then rerun \tableofcontents.

\documentclass[a4paper]{memoir}

% normal settings for the A,B,C hooks
% A does nothing by default
% B disable the toc from this point
\cftinsertcode{B}{\protect\setcounter{tocdepth}{-10}}
% in C we'd like the normal tocdepth
\newcounter{normaltocdepth}
\AtBeginDocument{
  \setcounter{normaltocdepth}{\value{tocdepth}}
}
\cftinsertcode{C}{\protect\setcounter{tocdepth}{\value{normaltocdepth}}}

% ned we build the macro for the list of appendencies
\newcommand\listofappendencies{
  \begingroup % keep changes local
  % the idea is to just use \tableofcontents* again, but with
  % different values for the hooks
  \cftinsertcode{A}{\protect\setcounter{tocdepth}{-10}}
  % or what ever explicit depth you want
  \cftinsertcode{B}{\protect\setcounter{tocdepth}{\value{normaltocdepth}}}
  % all after the C hook is ignored
  \cftinsertcode{C}{\protect\setcounter{tocdepth}{-10}}
  % different name for the list
  \renewcommand\contentsname{List of Appendencies}
  \tableofcontents% add * if not wanted in main toc
  \endgroup
}



\settocdepth{subsubsection}

\begin{document}


\tableofcontents*

\cftinserthook{toc}{A}


\chapter{Test}

\section{T1}

\subsection{T11}

\subsubsection{T111}


\appendix
\appendixpage


\listofappendencies

\cftinserthook{toc}{B}


\chapter{App 1}

\section{T1}

\subsection{T11}

\subsubsection{T111}


\chapter{App 2}

\section{T1}

\subsection{T11}

\subsubsection{T111}



\cftinserthook{toc}{C}

\begin{thebibliography}{9}
\bibitem{A} Test
\end{thebibliography}


\end{document}
  • 1
    Your solution worked great. Thank you very much for your help. You've saved me a lot of hassle. Also, I tried to up vote your answer but my rep isn't high enough for it to count sadly :/ – MJH Sep 7 '16 at 11:06

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.