# Errors with tocloft

I'm trying to use tocloft to create a list of equations in the contents table of my thesis, but it's erroring when I compile the document. I've used \newcounter to define a new list of R scripts for the appendices, and it seems that this new counter is not compatible with tocloft.

  \documentclass[12pt,a4paper]{book}
\usepackage{anysize,array,multirow,graphicx,epstopdf,natbib,caption,color,hhline,symlist,amsmath,acronym,subfig,listings,placeins,hyperref,wrapfig,rotating,tocloft}
\usepackage[svgnames]{xcolor}
\marginsize{3cm}{3cm}{2cm}{2cm}

\captionsetup[table]{skip=4pt,font=footnotesize} %works with package{caption} to skip the height from the table, and to select 10pt as the text size
\captionsetup[figure]{skip=4pt,font=footnotesize} %works with package{caption} to skip the height from the table, and to select 10pt as the text size

\DeclareCaptionType{equationme}[][List of Equations] %this is a work-around to get a list of equations with page numbers in my contents page, however it adds a caption to my equations (not ideal!!)
\captionsetup[equationme]{skip=4pt,font=footnotesize}

\newlength{\Oldarrayrulewidth}

\newcommand{\Cline}[2]{%
\noalign{\global\setlength{\Oldarrayrulewidth}{\arrayrulewidth}}%
\noalign{\global\setlength{\arrayrulewidth}{#1}}\cline{#2}%
\noalign{\global\setlength{\arrayrulewidth}{\Oldarrayrulewidth}}}

%this is the R bit............
\newcounter{Script}[section]
\newenvironment{Script}[1][]{\refstepcounter{Script}\par\medskip
\textbf{Script~\theScript. #1} \rmfamily}{\medskip}

\begin{document}

\listofequationme

\begin{equationme}[!ht]
\caption[Earthquake magnitude affect on landsliding]{Relationship between earthquake magnitude and the potential area affected by landsliding as defined by \hilight{Keefer}, where A' is the potential area affected.}
$$\label{eq:EQMagnitudelsArea} log_{10} \newsym{Potential area affected}{A'} = \newsym{Earthquake magnitude}{M}-3.46(\pm0.47)$$
\end{equationme}

\end{document}


While the list works fine for the equations, I don't want to have to have a caption above it... So can someone either tell me how to edit \captionsetup or how to get tocloft to work alongside the \newcounter{Script}[section] command as this is where I seem to be getting an error...

Error is:

Command \c@lotdepth already defined. \newcounter{lotdepth}


I really hope this makes sense as I'm going a little loopy right now!

• Please provide all information: What is symlist.sty? Where can we find it? – user31729 Jan 16 '15 at 13:49
• subfig package is to blame. Since you don't need it, remove it – user31729 Jan 16 '15 at 13:57
• beware \global\setlength it is not supported syntax, it sort of accidentally works by default but if calc package (at least) is loaded then this will fail. – David Carlisle Jan 16 '15 at 15:20
• So firstly, sorry for not including the things... Christian Here is a link to symlist.sty. I do need the subfig package as I'm including this later in the thesis (I wasn't about to upload all of the document, and I wasn't sure how much I needed to upload...). David I'm not sure about the \global\setlength syntax... Is this something you think I need to address? – user3590510 Jan 17 '15 at 12:37
• Thank you for posting a working example! At the same time, much of your code does not seem to be relevant to the question you're asking here. Please limit the example to only the code required for your issue to appear. You can have a look at this guide for how to prune your code for this purpose. – Martin Schröder Jun 26 '16 at 16:44

The main problem is the loading order of subfig and tocloft.

subfig defines c@lotdepth by a \@nameuse statement - as such it's already defined at the time when tocloft tries to setup this new counter.

The same is true for c@lofdepth, leading to a similar error.

The other way round, using tocloft first before loading subfig poses no problem.

Another solution is to remove the loading of subfig -- it's apparently not used in the 'MWE'

(I also cleaned up the document, slightly)

\documentclass[12pt,a4paper]{book}
\usepackage{anysize}
\usepackage{array}
\usepackage{multirow}
\usepackage{graphicx}
\usepackage{epstopdf}
\usepackage{natbib}
\usepackage{caption}
\usepackage{hhline}
\usepackage{symlist}
\usepackage{amsmath}
\usepackage{acronym}
\usepackage{tocloft}
\usepackage{subfig}

\usepackage{listings}
\usepackage{placeins}
\usepackage{wrapfig}
\usepackage{rotating}
\usepackage[svgnames]{xcolor}
\usepackage{hyperref}

\marginsize{3cm}{3cm}{2cm}{2cm}

% Unused
%\captionsetup[table]{skip=4pt,font=footnotesize} %works with package{caption} to skip the height from the table, and to select 10pt as the text size
%\captionsetup[figure]{skip=4pt,font=footnotesize} %works with package{caption} to skip the height from the table, and to select 10pt as the text size

\DeclareCaptionType{equationme}[][List of Equations] %this is a work-around to get a list of equations with page numbers in my contents page, however it adds a caption to my equations (not ideal!!)
\captionsetup[equationme]{skip=4pt,font=footnotesize}

\newlength{\Oldarrayrulewidth}

\newcommand{\Cline}[2]{%
\noalign{\setlength{\Oldarrayrulewidth}{\arrayrulewidth}}%
\noalign{\setlength{\arrayrulewidth}{#1}}\cline{#2}%
\noalign{\setlength{\arrayrulewidth}{\Oldarrayrulewidth}}}

% this is the R bit............
\newcounter{Script}[section]
\newenvironment{Script}[1][]{%
\refstepcounter{Script}\par\medskip
\textbf{Script~\theScript. #1} \rmfamily}{\medskip}

\providecommand{\hilight}[1]{%
#1%
}

\begin{document}

\listofequationme
$$\label{eq:EQMagnitudelsArea} log_{10} \newsym{Potential area affected}{A'} = \newsym{Earthquake magnitude}{M}-3.46(\pm0.47)$$