Generalsubfig, tocloft error: \if@cftsubfigopt\else ...

LaTeX specific issues not fitting into one of the other forums of this category.
Post Reply
User avatar
Cham
Posts: 937
Joined: Sat Apr 02, 2011 4:06 pm

subfig, tocloft error: \if@cftsubfigopt\else ...

Post by Cham »

I'm now getting a compilation error and I'm yet unable to find why. Here's the gibberish "error" message from the tocloft.sty file, and I don't know how to interpret it :
\if@cftsubfigopt\else
\newcounter{lofdepth}\setcounter{lofdepth}{1}
\newcounter{lotdepth}\setcounter{lotdepth}{1}
\fi
What is happening here ?

EDIT 1 : Weird ! Apparently, it's related to the subfig package. I didn't had any problem with it before, and suddenly it gives me troubles at compilation !? Desactivating it solves the compilation halting, but reactivating it (without any other changes) stop the compilation with an error. What the ... !?

EDIT 2 : It's also apparently related to the tocloft package in some subtle way that I don't undertand.

This begins to make me very nervous, since my document is now very advanced. The preamble is very complicated ! :cry: :?
Last edited by Cham on Fri Feb 17, 2012 1:34 am, edited 1 time in total.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org
LaTeX books
User avatar
Cham
Posts: 937
Joined: Sat Apr 02, 2011 4:06 pm

subfig, tocloft error: \if@cftsubfigopt\else ...

Post by Cham »

?? What the .. !?? :? I need an explanation on this :

Loading the subfig package AFTER the tocloft package solves my compilation problem. What is happening here ? :?:
User avatar
Stefan Kottwitz
Site Admin
Posts: 10308
Joined: Mon Mar 10, 2008 9:44 pm

subfig, tocloft error: \if@cftsubfigopt\else ...

Post by Stefan Kottwitz »

That's because tocloft and subfig use the same counter names lofdepth and lotdepth. Name conflicts happen sometimes, also package dependencies, sometimes we have to take care of the package loading order in our document.

As you noticed, loading subfig after tocloft works. Btw. tocloft knows the (older) subfigure package, which uses the same counters, and provides an option which avoids the definition of the new counter, so there's no error if you provide the subfigure option, even in the other loading order.

Code: Select all

\usepackage{subfig}
\usepackage[subfigure]{tocloft}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
But, this is intended for subfigure instead of subfig. So I would just change the order and omit that option.

Stefan
LaTeX.org admin
User avatar
Cham
Posts: 937
Joined: Sat Apr 02, 2011 4:06 pm

Re: Compilation error

Post by Cham »

Thanks for the explanation Stefan.

How should we know that there may be packages clashes like this, before loading them ? Is it just a matter of trial and error ? This makes preamble configuration more complicated than what it should.

I may have another kind of weird clash/conflict (?), since some of my index entries don't point to the right page. I'm unable to find the reason (I don't see any error message in the console related to the index generation). This one is very hard to solve. Almost all of my index entries are working great (they point to the proper page), but a few aren't.
User avatar
Stefan Kottwitz
Site Admin
Posts: 10308
Joined: Mon Mar 10, 2008 9:44 pm

subfig, tocloft error: \if@cftsubfigopt\else ...

Post by Stefan Kottwitz »

Compatibility issues are usually mentioned in the package documentation. For example, the tocloft package documentation speaks about compatibility with the subfigure package. subfig as the successor is perhaps a bit too new.

It's a general issue that there can be conflicts with names, since there are thousands of packages developed over many years. Often the package documentation mentions that. Often they can be solved, for example by using a certain loading order. The best would be if package authors would use package specific names, such as using a package name prefix. Not many authors do that.

Regarding your new question, perhaps open a new thread with as much information as possible, especially with a hacked down copy as a Infominimal working example.

Stefan
LaTeX.org admin
Post Reply