You can use the macro \addcontentsline
to add a list entry to the List of Figures (or others).
It takes three arguments:
- the filename-extension of the list. (
toc
for Table of Contents, lof
for Lists of Figures, lot
for List of Tables, …)
- the structure level
toc
: part
, chapter
, section
, …
lof
: figure
lot
: table
- the entry itself. Mostly it is preceeded by
\protect\numberline{…}
whose argument is the number for the entry and it aligns the following text.
My code provides two three commands:
\nocaption
that adds only an caption text to the list,
\nocaptionbutnumber
that adds additionally a number to the entry (that is incremented before, and
\nocaptionwithweirdalignment
that doesn't use \numberline
and therefore its entry text is aligned to the left (I wouldn't use it).
Minor Update
I've updated the answer so that the \addcontentsline
macro doesn't have hard-coded first and second parameter. The commands should work now in table
and other environment that define \@captype
and the proper extension macro \ext@<\@captype>
.
Code
\documentclass{article}
\makeatletter
\newcommand*{\nocaption}[1]{%
\addcontentsline{\csname ext@\@captype\endcsname}{\@captype}{\protect\numberline{}#1}%
}
\newcommand*{\nocaptionbutnumber}[1]{%
\refstepcounter{figure}%
\addcontentsline{\csname ext@\@captype\endcsname}{\@captype}{\protect\numberline{\csname the\@captype\endcsname}#1}%%
}
\newcommand*{\nocaptionwithweirdalignment}[1]{%
\addcontentsline{\csname ext@\@captype\endcsname}{\@captype}{#1}%
}
\makeatother
\begin{document}
\listoffigures
\begin{figure}[!ht]
F1
\nocaption{Caption 1}
\end{figure}
\begin{figure}[!ht]
F2
\nocaptionbutnumber{Caption 2}
\end{figure}
\begin{figure}[!ht]
F3
\nocaptionbutnumber{Caption 3}
\end{figure}
\begin{figure}[!ht]
F4
\nocaptionwithweirdalignment{Caption 4}
\end{figure}
\end{document}
Output

\refstepcounter{figure}\addcontentsline{lof}{figure}{\numberline{\thefigure}{Caption}}
instead of\caption
. It increments thefigure
counter and adds a line to\listoffigures
. (\addcontentsline{lof}{figure}{\numberline{}{Caption}}
without the number and without increasing thefigure
counter.)