Looking for a way to customise a table of contents, I came across this recommendation to use tocloft. As per the suggestion (and the documentation), I've put a conditional in place which tests for the presence of subfig and loads the package appropriately.

This Minimum [non-]Working Example:


    \section{Section 1}
    Hello 1
    \section{Section 2}
    Hello 2
    \section{Section 3}

Produces several errors including:

./tocloft.tex:3: You can't use `\spacefactor' in vertical mode.
Removing the call to `\@ifpackageloaded` and explicitly specifying 


Missing character: There is no è in font cmex10!
/usr/local/texlive/2011/texmf-dist/tex/latex/tocloft/tocloft.sty:35: You can't 
use `\spacefactor' in vertical mode.

Looking around for a solution, the TeX FAQ suggests this is the result of the package using "... an internal command without taking 'precautions'". Explicitly calling either \usepackage[titles,subfigure]{tocloft} or \usepackage[titles]{tocloft} works as advertised and is how I'm currently working around the problem. I would, however, like to implement the conditional loading as a safety precaution.

In an effort to learn more about (La)TeX internals, I'd like to know what's the root cause of this error. Is this a problem specific to my (MacTeX 2011) installation, or can others reproduce it? Also, what can be done to fix it in this particular incidence? Maybe the package's current maintainer could provide some insight into this.

  • I've edited the question you link to so that others don't fall into the same trap that you did. – Alan Munn Sep 28 '11 at 4:10

The problem here is a common one. The use of @ is restricted to style files. If you want to use it in your document preamble (or elsewhere), you need to encompass it using the


pair. So, in your preamble, use


Read the entries \@ and @ in macro names and \spacefactor complaints on the UK TeX FAQ, as well as the discussion What do \makeatletter and \makeatother do?

  • After making my post, I followed the "\@ and @ in macro names" link and was just reading through it. Thanks for clarifying this. – coffeebucket Sep 28 '11 at 3:28
  • @Wermer: You want to add a link to What do \makeatletter and \makeatother do? in your answer, and then I can delete my answer. – Peter Grill Sep 28 '11 at 4:37
  • @PeterGrill: Thanks - just did that. – Werner Sep 28 '11 at 4:51

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.