9

So I'm having a slight problem with the \listoffigures command and the way LaTeX makes the table of contents. In my preamble I'm using \usepackage[nottoc,numbib]{tocbibind} because I want to include the bibliography in the ToC (and with a section-number as well). However, I can't seem to figure out how to do the same for list of figures. The package tocbibind sadly don't have an option like numlof and all results on google either don't give me a working result or has something to do with "how to manually add an item in the ToC", which isn't really what I'm looking for.

In short, how do I add the listoffigures in the ToC with a number attached to it.

Just to add, I can add the list of figures in the ToC without problems, but I'd like a section-number as well. I'm using the article class by the way.

EDIT: Silly me, I was also using the tocloftpackage, in order to make a way to list the source of a bunch of images. The process is described at List of figures: source below image caption?

It seems the two methods conflict each other. I'd really like to have both the numbered LoF in the ToC and a way to list the source of each figure.

1 Answer 1

8

This can be done adding the following lines to your preamble:

\renewcommand{\listoffigures}{\begingroup
\tocsection
\tocfile{\listfigurename}{lof}
\endgroup}

MWE:

\documentclass{article}
\usepackage[nottoc,numbib]{tocbibind}

\renewcommand{\listoffigures}{\begingroup
\tocsection
\tocfile{\listfigurename}{lof}
\endgroup}

\begin{document}

\tableofcontents
\newpage

\listoffigures
\newpage

\section{test}

\end{document} 

Output (ToC):

enter image description here


EDIT

If you are also using tocloft, you have to inform tocloft that you want to use your custom titles by passing the option titles when loading it:

\usepackage[titles]{tocloft}

Complete MWE

\documentclass{article}
\usepackage[titles]{tocloft}
\usepackage[nottoc,numbib]{tocbibind}

\renewcommand{\listoffigures}{\begingroup
\tocsection
\tocfile{\listfigurename}{lof}
\endgroup}

\makeatletter
\newcommand{\figsourcefont}{\footnotesize}
\newcommand{\figsource}[1]{%
  \addtocontents{lof}{%
    {\leftskip\cftfigindent
     \advance\leftskip\cftfignumwidth
     \rightskip\@tocrmarg
     \figsourcefont#1\protect\par}%
  }%
 }
\makeatother

\begin{document}

\tableofcontents
\newpage

\listoffigures
\newpage

\section{test}

\begin{figure}
    \caption{World Targets in Megadeaths}
    \figsource{BLAND Corporation}
\end{figure}

\end{document} 

Output:

enter image description here

4
  • Alright silly me, I was also using the tocloftpackage, in order to make a way to list the source of a bunch of images. The process is described at tex.stackexchange.com/questions/45083/… I'd really like to have both the numbered LoF in the ToC and a way to list the source of each figure. I've updated the OP.
    – Argo
    Dec 18, 2013 at 20:29
  • @Argo I've edited the answer. See if now it is OK. Dec 19, 2013 at 5:00
  • It works! Thanks a ton! Out of curiosity, does one "just" look at the code for each package in order to create macros, that make them work together?
    – Argo
    Dec 19, 2013 at 8:09
  • @Argo Usually, when one uses conflicting packages, tries to find the best compromise. Dec 19, 2013 at 8:23

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .