2

The document I'm writing has all the figures in Appendix A (since there is a lot of source code included in latter appendixes, it would not make sense to put the figures as the final part of the document). I am aware I can have a separate list of figures that lists the caption short descriptions, but what I want is for this to be included in the table of contents itself. For example, instead of:

Table of Contents
1 Section 1 ......... 1
  1.1 subsection .... 1
A Figures ........... 3
B Source Code ....... 5
  B.1 more code ..... 6

List of Figures
Desc. 1 ............. 3
Desc. 2 ............. 4

I want:

Table of Contents
1 Section 1 ......... 1
  1.1 subsection .... 1
A Figures ........... 3
  Desc. 1 ........... 3
  Desc. 2 ........... 4
B Source Code ....... 5
  B.1 more code ..... 6

I've been scouring the internet but can only find information on how to include the List of Figures' page number in the table of contents using \addcontentsline{toc}. Would I manually have to include caption short descriptions with \addcontentsline{toc} for every figure or is there some way I can automate this?

Any help much appreciated

2

Here's a simple solution redefining \ext@figure to toc:

\documentclass{article}

\makeatletter
\renewcommand\ext@figure{toc}
\makeatother

\begin{document}

\tableofcontents

\section{Test Section}

\appendix

\section{Figures}
\begin{figure}[!ht]\caption{Description 1}\end{figure}
\begin{figure}[!ht]\caption{Description 2}\end{figure}
\section{Souce Codes}

\end{document}

enter image description here

I only used the [!ht] modifier for the example's sake; I don't suggest its mandatory use.

1
  • The \makeatletter segment worked perfectly, thanks! – Overlord_Dave Mar 20 '12 at 23:11
0

Write into your document after \appendix, e.g.:

[...]
\appendix
\makeatletter
\long\def\@caption#1[#2]#3{%
  \par
  \addcontentsline{\csname ext@#1\endcsname}{#1}%
    {\protect\numberline{\csname the#1\endcsname}{\ignorespaces #2}}%
  \addcontentsline{toc}{#1}%
    {\protect\numberline{\csname the#1\endcsname}{\ignorespaces #2}}%
  \begingroup
    \@parboxrestore
    \if@minipage
      \@setminipage
    \fi
    \normalsize
    \@makecaption{\csname fnum@#1\endcsname}{\ignorespaces #3}\par
  \endgroup}
\makeatother
[...]

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.