2

When I use \section*{namename}, if I want to insert it in the toc, I will use \addcontentsline{toc}{section}{namename}

So, I want to know, if I want insert some figure name (I don't use \caption{} for some special figure) in the list of figure, what command should be using?

Is there some way just like use addcontentsline???

  • try \addcontentsline{lof}{figure}{namename} – touhami Jul 2 '18 at 19:01
1

The \caption does not have a *-version, so you would have to make it.

Furthermore, you'd have to replicate \addcontentsline to behave like \caption does.

This is one way to implement the \addcontentsline for \listoffigures:

\makeatletter
\newcommand\addtoLOF[1]{\refstepcounter\@captype%
    \addcontentsline{\csname ext@figure\endcsname}{figure}{\protect\numberline{\csname thefigure\endcsname}{\ignorespaces #1}}
}
\makeatother

Further, here is also an implementation of a starred version of caption:

This is one way to do that:

\documentclass{article}
\makeatletter
% Redefine @caption
\let\original@caption\caption%
\let\original@@caption\@caption%
\long\def\@caption@star#1[#2]#3{%
    \par
    \begingroup
    \@parboxrestore
    \if@minipage
        \@setminipage
    \fi
    \normalsize
    \@makecaption{\csname fnum@#1\endcsname}{\ignorespaces #3}\par
    \endgroup}
% Make a starred version of \caption
\long\def\caption{\@ifstar{\let\@caption\@caption@star\original@caption}{\let\@caption\original@@caption\original@caption}}
% If you don't care about the star thing, the command below is all you need:
\newcommand\addtoLOF[1]{\refstepcounter\@captype%
    \addcontentsline{\csname ext@figure\endcsname}{figure}{\protect\numberline{\csname thefigure\endcsname}{\ignorespaces #1}}
}
\begin{document}
    \listoffigures\clearpage
    \begin{figure}
        \centering
        \Huge{A}
        \addtoLOF{Not caption}
        \caption*{test}
    \end{figure}
\end{document}

Edit: Fixed recursion.

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.