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.

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

share|improve this question

migrated from stackoverflow.com Mar 20 '12 at 19:41

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

add comment

2 Answers 2

up vote 1 down vote accepted

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.

share|improve this answer
    
The \makeatletter segment worked perfectly, thanks! –  Overlord_Dave Mar 20 '12 at 23:11
add comment

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
[...]
share|improve this answer
add comment

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.