0

I want to include a list of appendices after my ToC, which I to some extent have managed, with this code:

\usepackage[titles]{tocloft}
\usepackage{tocloft}

\newcommand{\listappendicesname}{Appendices}
\newlistof{appendices}{apc}{\listappendicesname}
\newcommand{\appendices}[1]{\addcontentsline{apc}{appendices}{#1}}
\parindent0mm

and by using the command

\listofappendices

after my ToC and

\appendices{*name of appendix*}

under the specific appendix section I want to include.

The problem is, that in my text, the appendices is numbered A.1, A.2 etc, but in my tocloft list, they only appear as "name of appendix".

Is there any way I can add the section numbering to my list?

1

As long as \addcontentsline{...}{...}{#1} is used there will be no numbering. The usual way is to use \addcontentsline{...}{...}{\theappendices~#1}, i.e. printing the appendix number before the title.

I hope, that the appendix package is not used as well, otherwise this would cause a conflict with the appendices environment.

The way \appendices (in the OP) was defined is incomplete, it does neither print the title in the text nor does it make any use of the appendices counter by incrementing. Since it is very likely that there might be references to the relevant appendix section I've decided to use \refstepcounter{appendices}.

The \section*{#1 \theappendices} is just for convenience and can be replaced by other typesetting 'eye-candy' at will.

Also use \parindent=0em rather than \parindent=0mm

\documentclass{book}

\usepackage[titles]{tocloft}
\usepackage{tocloft}

\newcommand{\listappendicesname}{Appendices}
\newlistof{appendices}{apc}{\listappendicesname}
\newcommand{\appendices}[1]{%
  \refstepcounter{appendices}%
  \section*{#1 \theappendices}%
  \addcontentsline{apc}{appendices}{\theappendices~ #1}%
}

\usepackage{blindtext}

\parindent=0em

\begin{document}
\tableofcontents
\listofappendices

\blinddocument
\appendices{Foo One}
\appendices{Foo Two}
\end{document}

enter image description here

|improve this answer|||||

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.
https://tex.stackexchange.com/questions/336823/include-section-numbering-in-list-from-tocloft-package
tex.stackexchange.com
crawl=CC-MAIN-2020-16
140131
application/http; msgtype=response
sha1:TOF3PAHRQXDEXVIG5RAHYNIM3KB65FTW
<urn:uuid:235b1677-3305-487b-b068-f40cd141a986>
2020-04-05T13:45:43Z
151.101.129.69
text/html
sha1:6CA72I4GTMVC5QDBB64FDHPAH2ZOA25I
<urn:uuid:bd876244-0d41-45d3-9bfd-47e353e583b4>
https://tex.stackexchange.com/questions/336823/include-section-numbering-in-list-from-tocloft-package
response
<urn:uuid:875ba051-b27c-467d-8933-940e9544c71a>
isPartOf: CC-MAIN-2020-16
publisher: Common Crawl
description: Wide crawl of the web for March/April 2020
operator: Common Crawl Admin (info@commoncrawl.org)
hostname: ip-10-67-67-81.ec2.internal
software: Apache Nutch 1.16 (modified, https://github.com/commoncrawl/nutch/)
robots: checked via crawler-commons 1.1-SNAPSHOT (https://github.com/crawler-commons/crawler-commons)
format: WARC File Format 1.1
conformsTo: http://iipc.github.io/warc-specifications/specifications/warc-format/warc-1.1/