Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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}
\newlistof[chapter]{answer}{ans}{\listanswername}

\newcommand{\answer}[1]{%
 \refstepcounter{answer}
 \par\noindent\textbf{Answer  \theanswer.  #1}
 \addcontentsline{ans}{answer}{\protect\numberline{\theanswer}#1}\par}

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.

share|improve this question
    
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
1  
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

3 Answers 3

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}
%     "toc=flat,numbers=noenddot" ADDED, "scrartcl" INSTEAD OF "scrbook"

\usepackage[english]{babel}% "english" INSTEAD OF "ngerman"
\usepackage{blindtext}

\makeatletter
\newcommand*{\maintoc}{% main table of contents
  \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
}
\newcommand*{\appendixtoc}{% table of contents for appendix
  \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
}
\g@addto@macro\appendix{% augment \appendix
%  \if@openright\cleardoublepage\else\clearpage\fi% new page; DELETED
  \clearpage% new page; ADDED
  \addcontentsline{toc}{section}{\appendixname}% entry into main ToC;
%     "section" INSTEAD OF "chapter"
  \addtocontents{toc}{\protect\appendixattoc}% macro for separation into ToC file
  \renewcommand*{\thesection}{Appendix~\Alph{section}}% ADDED
}
\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
% \tableofcontents instead of \maintoc.
share|improve this answer
1  
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}

\newcommand{\listanswername}{List of Answers}

\newlistof[section]{answer}{ans}{\listanswername}% "section" instead of  "chapter"
\cftsetindents{answer}{0em}{1.8em}% Optional

\newcommand{\answer}[1]{%
  \refstepcounter{answer}%
  \bigskip% Optional
  \par\noindent
  \textbf{Answer~\theanswer. #1}%
  \addcontentsline{ans}{answer}{\protect\numberline{\theanswer}#1}%
  \par
}

\newlistentry[answer]{subanswer}{ans}{2}% "{ans}" added (!); "2" instead of "1"
\cftsetindents{subanswer}{1.8em}{2.9em}% Optional
\renewcommand{\thesubanswer}{\theanswer.\alph{subanswer}}

\newcommand{\subanswer}[1]{%
  \refstepcounter{subanswer}%
  \smallskip% Opional
  \par
  \textbf{\thesubanswer) #1}%
  \addcontentsline{ans}{subanswer}% "}"after "subanswer" added (!)
      {\protect\numberline{\thesubanswer}#1}%
  \quad\ignorespaces% Optional
}

\setcounter{ansdepth}{3}% "3" instead of "2"

\begin{document}

\section{foo}

Making a custom list with \texttt{tocloft}.

\answer{Harder} The \dots

\subanswer{Reformulate the problem } It assists \dots

\listofanswer

\end{document}
share|improve this answer
    
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:

List of Appendices and Subappendices

\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}%
  \addcontentsline{app}{appendix}{\protect\numberline{\theappendix}#1}%
  \par
}

\newcommand{\subappendix}[1]{%
  \refstepcounter{subappendix}%
  \subsection*{\thesubappendix\space #1}%
  \addcontentsline{app}{subappendix}{\protect\numberline{\thesubappendix}#1}%
}

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

\listofappendix

\myappendix{Baz} \lipsum[5]
\subappendix{Qux} \lipsum[6]
\myappendix{Additional Baz} \lipsum[7]
\subappendix{Additional Qux} \lipsum[8]
\end{document}
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.