3

Can the list of figure be embedded in the table of contents for the article class?

I tried a variation of the solution here but by replacing chapter with section and then tried using chapter. The only thing that appeared was the list of figures.

To be more clear, I would like for my figures to be combined with the table of contents not a link to the figure sections; that is, if figure 1 is in section 1, the table of contents will look like

1 something
   figure 1 caption

Figures are setup as

\begin{figure}
\subfloat[]{}
...
\end{figure}

So this is my setup:

\documentclass[11pt]{article}

\usepackage[usenames, dvipsnames, svgnames, table]{xcolor}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{eucal}
\usepackage{pxfonts}
\usepackage{setspace}
\usepackage{enumerate}
\usepackage{amscd}
\usepackage{dsfont}
\usepackage{wasysym}
\usepackage{tikz}
\usepackage{tikz-qtree}
\usepackage{mathtools}
\usepackage{kurier}
\usepackage{pgfplots}
\usepackage{listings}
\usepackage{etoolbox}
\usepackage{tikz-3dplot}
\usepackage{float}
\usepackage{wrapfig}
\usepackage{multirow}
\usepackage{array}
\usepackage{tkz-fct}
\usepackage{graphicx}
\usepackage{datetime}
\usepackage[protrusion = true, expansion]{microtype}
\usepackage{marvosym}
\usepackage{starfont}
\usepackage{fixltx2e}
%\usepackage[nottoc]{tocbibind}                                                      
\usepackage{tocloft}
\usepackage{subfig}
%\usepackage{thmtools}                                                               
%\usepackage{amsthm}                                                                 
\usepackage{hyperref}
\usepackage[margin = 0.75in]{geometry}
\usepackage{fancyhdr}
\usepackage[caption = false]{subfig}
\usepackage[all]{hypcap}

%  Figures in TOC                                                                   
\makeatletter
\renewcommand\ext@figure{toc}
\makeatother

\newlength\mylen
\renewcommand\cftfigpresnum{Figure~}
\settowidth\mylen{\bfseries\cftfigpresnum\cftfigaftersnum}
\addtolength\cftfignumwidth{\mylen}

\begin{document}
\cleardoublepage
\tableofcontents

\begin{figure}[H]
  \centering
  \begin{tabular}{cc}
    \subfloat[\(L_1\)]{\includegraphics[width = 3.25in]{L1Contour}} &
    \subfloat[\(L_2\)]{\includegraphics[width = 3.25in]{L2Contour}}\\
    \subfloat[\(L_3\)]{\includegraphics[width = 3.25in]{L3Contour}} &
    \subfloat[\(L_4\) and \(L_5\)]{\includegraphics[width = 3.25in]
      {L4L5Contour}}
  \end{tabular}
  \caption[2-D Zero Velocity Surfaces]
  {2-D zero velocity surfaces for the Earth-Moon Lagrange points.}
  \label{fig:2dzerovelocitysurface}
\end{figure}
\end{document}
3
  • 1
    \usepackage[nottoc]{tocbibind} – egreg Jun 12 '13 at 23:06
  • I believe that tocbibind is sufficient – egreg Jun 12 '13 at 23:09
  • @egreg so \tableofcontents will then have the the sections and figures in their respective locations combined into one? I just tried this setup and it only produced the sections without the figures. – dustin Jun 12 '13 at 23:10
4

You change the extension of the file in which figures are written, from the deafult lof to toc; I also used the tocloft package to add the word "Figure" before the number for the entries:

\documentclass{article}
\usepackage{tocloft}
\usepackage{subfig}

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

\newlength\mylen
\renewcommand\cftfigpresnum{Figure~}
\settowidth\mylen{\bfseries\cftfigpresnum\cftfigaftersnum}
\addtolength\cftfignumwidth{\mylen}

\begin{document}

\tableofcontents
\section{Test Section One}
\begin{figure}[!ht]
A
\caption{test figure}
\end{figure}
\section{Test Section Two}
\begin{figure}[!ht]
A
\caption{another test figure}
\end{figure}
\begin{figure}[!ht]
\subfloat[][A subfigure]{A}
\subfloat[][A subfigure]{B}
\caption{test figure with subfigures}
\end{figure}

\end{document}

enter image description here

Using an empty first argument for \subfloat and reserving the caption for the second optional argument, subfigures won't be listed.

The placement modifier [!ht] was used just for the example; I am not suggesting it should be used in the actual document.

Looking at the preamble added to the question, please notice that you are loading subfig twice: the first time without options and the second one with caption = false and this produces a clash. Load the package only once. Also notice that hyperref must be loaded in last place, just before hypcap.

11
  • There is just one problem. It shows the subfigures in the TOC. Can it ignore the subfigures and just have the main figure in the TOC? – dustin Jun 13 '13 at 0:44
  • @dustin how exactly do you buid your subfigures? – Gonzalo Medina Jun 13 '13 at 0:46
  • @dustin I've fixed the code. Please see my updated answer. – Gonzalo Medina Jun 13 '13 at 0:55
  • I have an option class: l.41 \usepackage[all]{hypcap} – dustin Jun 13 '13 at 0:58
  • 1
    Are you using the second optional argument for the captions and not the first argument? The first optional argument for \subfloat must be empty; the second optional argument must contain the caption. Please see my code. – Gonzalo Medina Jun 13 '13 at 1:12

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.