# How to embed figure short descriptions (as would be displayed in the List of Figures) within the table of contents in LaTeX?

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

-

## migrated from stackoverflow.comMar 20 '12 at 19:41

This question came from our site for professional and enthusiast programmers.

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}


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

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

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

[...]
\appendix
\makeatletter
\long\def\@caption#1[#2]#3{%
\par
{\protect\numberline{\csname the#1\endcsname}{\ignorespaces #2}}%
{\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
[...]

-