# Creating a separate list of appendices with tocloft

I'm very sorry but I have to ask for urgent help as I could not make sense of the individual questions I asked previously.

I'm required a separate list of appendices, i.e. the appendix is not to show up in the TOC except for the item Appendix, which can be manually created with

\addcontentsline{toc}{section}{Appendix}


The appendix itself is supposed to be structured like

Appendix A
A.1 Title
A.2 Title
..

Appendix B
B.1 Title
B.2 Title
..


Tocloft provides a means to manually create a list, this example is taken from the documentation:

\newcommand{\listanswername}{List  of  Answers}



creates the command \listofanswer which items are added to with

\answer{Hard}


This results in

List of Answers
1 Hard ....... pageno


Several problems arise for me:

• Decimal counter instead of alphabetic
• no sub environment for the A.n scheme
• no prefix like "Appendix A.1 Hard .... pageno"

So I need a list such as

List of Appendices

Appendix A    Code listings   ................. 187
Appendix A.1  Stackexchange generator ........  187
Appendix A.2  Stackexchange hack function .... 2179

Appendix B    Misc            ................ 2180
Appendix B.1  Overview Q&A Sites      ........ 2181
Appendix B.2  User psychoanalysis         .... 2378


I assume this may be solved by adding a second command in the manner presented by the tocloft documentation but I'm currently not capable of spending time figuring it out due to my desastrous state of the paper (of course, due tomorrow).

So if someone could provide the sub-command and a way to change enumeration to literals I'd greatly appreciate it. Sorry again, I'm in a state of mind where only a a bullet-proof for-dummies solution will get me somewhere.

-
Here's a related thread: mail-archive.com/lyx-users@lists.lyx.org/msg83178.html Also I forgot to mention I'm using scrartcl –  None Jan 17 '11 at 11:37
Maybe a related question: How do I get \chaptername to appear in the table of contents? –  Juan A. Navarro Jan 17 '11 at 11:59
I just saw that an example for sublevels is given in the documentation. –  None Jan 17 '11 at 12:10
But I cannot get it to work on the section level. –  None Jan 17 '11 at 12:26
Please see tex.stackexchange.com/q/39896/10425 for refinement on this approach to include chapters and pdfbookmarks. –  user10425 Jan 3 '12 at 14:35

Here's a solution that doesn't involve tocloft. The author is Markus Kohm; I have taken the code from this site, made minor modifications and translated Markus Kohm's comments.

\documentclass[toc=flat,numbers=noenddot]{scrartcl}

\usepackage{blindtext}

\makeatletter
\begingroup
\@fileswfalse% don't open new ToC file
\renewcommand*{\appendixattoc}{% macro for separation of ToC contents
\value{tocdepth}=-10000 % set tocdepth to very small value locally
}%
\tableofcontents% output ToC
\endgroup
}
\begingroup
\edef\@alltocdepth{\the\value{tocdepth}}% save tocdepth
\setcounter{tocdepth}{-10000}% no ToC entries
\renewcommand*{\contentsname}{% change ToC name
List of Appendices}% "List of Appendices" INSTEAD OF "Verzeichnis der Anh\"ange"
\renewcommand*{\appendixattoc}{% macro for separation of ToC contents
\setcounter{tocdepth}{\@alltocdepth}% restore tocdepth
}%
\tableofcontents% output ToC
\setcounter{tocdepth}{\@alltocdepth}% restore tocdepth
\endgroup
}
\newcommand*{\appendixattoc}{% macro for separation of ToC contents
}
%  \if@openright\cleardoublepage\else\clearpage\fi% new page; DELETED
\addtocontents{toc}{\protect\appendixattoc}% macro for separation into ToC file
}
\makeatother

\begin{document}

\maintoc
\blinddocument
% \blinddocument% DELETED

\appendix
\appendixtoc
\blinddocument
% \blinddocument% DELETED

\end{document}

% Note that \maintoc only works if \appendixtoc is also present. Otherwise,
% the ToC will never be updated. If \appendixtoc is removed, one should use

-
It seems, that Appendix bookmark doesn't link on the correct page. In my case it is the subsubsection before List of Appendices. Adding \phantomsection after \clearpage% new page; ADDED solved the problem. –  CSchulz Aug 5 '11 at 11:45
@lockstep I also need to use seperate list of appendixes.can i change above code for \documentclass[12pt,a4paper,oneside]{report} ?I try it .but errors... –  Emalka May 13 '13 at 7:16

I managed to correct the example from the tocloft documentation.

• Two codelines are actually faulty -- one mandatory argument of \newlistentry is missing, as well as a closing brace in \addcontentsline. I have marked these corrections with "(!)".

• Because you are using a document class without \chapter, some parameters had to be changed.

I have also taken the liberty to make changes in the vertical and horizontal spacing (marked with "Optional").

\documentclass[toc=flat,numbers=noenddot]{scrartcl}

\usepackage{tocloft}

\bigskip% Optional
\par\noindent
\par
}

\smallskip% Opional
\par
}

\begin{document}

\section{foo}

Making a custom list with \texttt{tocloft}.

\subanswer{Reformulate the problem } It assists \dots

\end{document}

-
Thanks so much for getting it to work. It's not quite what I need yet but I'll try to figure it out. Will get back to this in <24 hrs. Thanks again. –  None Jan 17 '11 at 17:43
This results in 6.1.j Sublevel . .. . . . . . . . . . 66 6.2 Nexttoplevel . . . . . . . . . 66 6.2.a Nextsublevel . . . . . . . . . xx Could someone please help me out and tell me how to create the list as shown in my question? Sorry about the desparation :-( –  None Jan 18 '11 at 8:09

This might be too late for the original poster, but here's what I came up with. Largely adapted from lockstep's answer, but matches the Appendix/Subappendix model, and follows the ToC style requested:

\documentclass[toc=flat,numbers=noenddot]{scrartcl}
\usepackage{lipsum}
\usepackage{tocloft}

\newcommand{\listappendixname}{List of Appendices}
\newlistof{appendix}{app}{\listappendixname}
\setcounter{appdepth}{2}
\renewcommand{\theappendix}{\Alph{appendix}}
\renewcommand{\cftappendixpresnum}{Appendix\space}
\setlength{\cftbeforeappendixskip}{\baselineskip}
\setlength{\cftappendixnumwidth}{1in}
\newlistentry[appendix]{subappendix}{app}{1}
\renewcommand{\thesubappendix}{\theappendix.\arabic{subappendix}}
\renewcommand{\cftsubappendixpresnum}{Appendix\space}
\setlength{\cftsubappendixnumwidth}{1in}
\setlength{\cftsubappendixindent}{0em}

\newcommand{\myappendix}[1]{%
\refstepcounter{appendix}%
\section*{\theappendix\space #1}%
\par
}

\newcommand{\subappendix}[1]{%
\refstepcounter{subappendix}%
\subsection*{\thesubappendix\space #1}%
}

\begin{document}
\tableofcontents
\section{Foo} \lipsum[1]
\subsection{Bar} \lipsum[2]