1

I came across this problem when I tried to write my dissertation.

Figures were not showing in contents: List of Figures. Neither were the tables. When I tried to compile with \caption{some figure} added, I had an error message.

! Undefined control sequence.
\l@figure #1#2->\ifnum \c@lofdepth 
                                   >\z@ \vskip \cftbeforefigskip {\leftskip ...
l.2 ...paces normal \relax }}{3}{figure.caption.6}
                                                  %
?

I tried and found a helpful question that was answered by others. Include Appendix as a Chapter in LOF and LOT, and chapters formatting in both lof and lot

So I loaded the code before \begin{document}.

\makeatletter
\def\thisparttitle{}\def\thispartnumber{}
\newtoggle{noFigs}

\apptocmd{\@part}%
  {\gdef\thisparttitle{#1}\gdef\thispartnumber{\thepart}%
    \global\toggletrue{noFigs}}{}{}

\AtBeginDocument{%
  \AtBeginEnvironment{figure}{%
    \iftoggle{noFigs}{
      \addtocontents{lof}{\protect\contentsline {part}%
        {\protect\numberline {\thispartnumber} {\thisparttitle}}{}{} }
      \global\togglefalse{noFigs}
    }{}
  }%
}

\makeatother

However, after loading the helpful setting code into my code before \begin{document}. I found the package subcaption was not compatible. The subfigure package can be an alternative, but its not as good. Additionally, I found the \floatfoot command also produced an error message after I compiled with setting code.

Any thoughts? Thank you!

2
  • What do you want to achieve? Why do you need the code that you copied?
    – Werner
    Feb 20, 2019 at 5:57
  • @Werner I edited my question and add the error message. My goal is to load the subcaption package meanwhile preambled the code I copied. I use the codes as I got the error message I posted when trying to add figure/table captions.. Thanks! Feb 20, 2019 at 17:22

1 Answer 1

2

I Just found a solution to the question that I posted.

Copy the following code into the preamble:

\usepackage{subcaption}

\captionsetup[subfigure]{list=false}

\usepackage[subfigure]{tocloft}

\newcounter{lofdepth}
\setcounter{lofdepth}{2}

\cftpagenumbersoff{subfigure}

You must log in to answer this question.

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