22

I am getting this error while trying to build my tex file. As soon as I include the cleveref package, I get this error and it shows cleveref.sty with the cursor at the bolded part of the file.

\def\make@df@tag@@@#1{%
    \gdef\df@tag{\tagform@{#1}%
      \toks@\@xp{\p@equation{#1}}%
      \edef\@currentlabel{\the\toks@}%
      \edef\cref@currentlabel{[equation][2147483647][]\the\toks@}}}
**}{}%  end of \@ifpackageloaded{amsmath}**
\@ifpackageloaded{IEEEtrantools}{%
  \PackageInfo{cleveref}{`IEEEtrantools' support loaded}
  \let\cref@orig@@IEEEeqnarray\@@IEEEeqnarray
  \def\@@IEEEeqnarray[#1]#2{%
    \refstepcounter{equation}%

What could be the reason for this error?

from the comments:

\begin{filecontents*}{example.eps}
gsave newpath 20 20 moveto 20 220 lineto 220 220 lineto 220 20 lineto
closepath 2 setlinewidth gsave .4 setgray fill grestore stroke grestore
\end{filecontents*}
\RequirePackage{fix-cm} 
\documentclass[smallextended]{svjour3} 
\smartqed \let\proof\relax \let\endproof\relax \usepackage{cleveref} 
\begin{document} 
\title{Title} \author{First Author} \date{Received: date / Accepted: date} 
\maketitle 
\begin{abstract} \end{abstract} 
\maketitle 
\section{Introduction} 
\end{document}
  • 1
    Welcome to TeX.sx! if you indent a sample code block by 4 spaces, or click on the {} icon, it will be highlighted. inline code can be highlighted by surrounding it with backticks. (i've edited those code highlighters into your question.) please also include a minimal working example (MWE) that illustrates your problem. It will be much easier for us to reproduce your situation and find out what the issue is when we see compilable code, starting with \documentclass{...} and ending with \end{document}. – barbara beeton Apr 12 '13 at 18:32
  • \begin{filecontents*}{example.eps} gsave newpath 20 20 moveto 20 220 lineto 220 220 lineto 220 20 lineto closepath 2 setlinewidth gsave .4 setgray fill grestore stroke grestore \end{filecontents*} \RequirePackage{fix-cm} \documentclass[smallextended]{svjour3} \smartqed \let\proof\relax \let\endproof\relax \usepackage{cleveref} \begin{document} \title{Title} \author{First Author} \date{Received: date / Accepted: date} \maketitle \begin{abstract} \end{abstract} \maketitle \section{Introduction} \end{document} – Vaibhav Sundriyal Apr 12 '13 at 20:07
  • I have added the MWE, but I dot not know how to properly indent it while submitting. Could you please help me in this regard. – Vaibhav Sundriyal Apr 12 '13 at 20:14
  • 1
    @VaibhavSundriyal code in comments looks horrible:-) You can edit it into the question (but I just did it in this case) – David Carlisle Apr 12 '13 at 20:16
  • 1
    A duplicate of this question has been asked. The fix proposed over there is simpler and less intrusive than the solutions for this question. – Lumen Jan 15 '17 at 12:44
23

svjour3 isn't in texlive but I got a copy from the springer site. It appears to have a bug and your document goes into an infinite loop \cl@chapter is defined to expand to itself. This fixes (or at least avoids) that immediate problem.

\begin{filecontents*}{example.eps}
gsave newpath 20 20 moveto 20 220 lineto 220 220 lineto 220 20 lineto closepath 2 setlinewidth gsave .4 setgray fill grestore stroke grestore \end{filecontents*}
\RequirePackage{fix-cm} 
\documentclass[smallextended]{svjour3} 
\smartqed \let\proof\relax \let\endproof\relax

\makeatletter
%\def\cl@chapter{\cl@chapter \@elt {theorem}}%bug in class
\def\cl@chapter{\@elt {theorem}}
\makeatother

\usepackage{cleveref} 

\begin{document}

\title{Title} \author{First Author} \date{Received: date / Accepted: date} 
\maketitle 
\begin{abstract} \end{abstract} 


\section{Introduction} 
\end{document}
  • 2
    In order to make it clearer, the three lines are required including \makeatletter and \makeatother. A bit late, but this should be marked as the accepted answer. – Javi V Apr 24 '15 at 9:46
8

First, your truely minimal MWE (except for whitespace) would be this:

\documentclass{svjour3}
\usepackage{cleveref}
\begin{document}
    \section{}
\end{document}

Now adding to David Carlisle's answer (but the comment field is too short):

I think the problem is the \@addtoreset{theorem}{chapter} in svjour3.cls. At least, I can reproduce the problem in this MWE independent of svjour3:

\documentclass{article} 
\makeatletter
\@addtoreset{theorem}{chapter}
\makeatother
\usepackage{cleveref} 
\begin{document} 
    \section{}
\end{document}

Of course, article (same as svjour3) does not have a \chapter:

\documentclass{svjour3}
\begin{document}
    \chapter{}
\end{document}

Now, \@addtoreset looks like this in latex.ltx:

\def\@addtoreset#1#2{\expandafter\@cons\csname cl@#2\endcsname {{#1}}}
\def\@cons#1#2{\begingroup\let\@elt\relax\xdef#1{#1\@elt #2}\endgroup}

What it does is nicely explained here: https://www.tug.org/TUGboat/tb18-4/tb57work.pdf It seems to fail, though, when trying to use it on a sectioning element that is not defined; hence, expansion of \cl@chapter fails when redefining \cl@chapter to add \@elt {theorem} to the list.

So one solution would be to patch \@addtoreset/\@cons to check for the existence of \cl@<unit> when redefining \cl@<unit>. This should not be too hard, for example:

\makeatletter
%\def\@cons#1#2{\begingroup\let\@elt\relax\xdef#1{#1\@elt #2}\endgroup}
\def\@cons#1#2{\begingroup\let\@elt\relax\xdef#1{\ifx#1\relax\else#1\fi\@elt #2}\endgroup}
\makeatother
\documentclass{svjour3}
\usepackage{cleveref} 
\begin{document} 
    \section{}
\end{document}

It should still made sure by someone knowing latex better than me whether \@cons still does what it shall do in all circumstances, and whether this patch would make sense in latex.ltx. Follow http://www.latex-project.org/cgi-bin/ltxbugs2html?pr=latex/4427 on that if interested.

Until (or if not) this is done, I propose the following workaround:

\makeatletter
\def\cl@chapter{}
\makeatother
\documentclass{svjour3}
\usepackage{cleveref} 
\begin{document} 
    \section{}
\end{document}

You can easily check by commenting the second line that this reproduces (and fixes, by uncommenting) the error seen.

  • 2
    Nice explanation! – Steven B. Segletes May 8 '15 at 16:09
  • It would be wrong to change \@cons I think, it would perhaps be possible to make \@addtoreset check that cl@#2 is defined. Of course the real fix is to report the bug to Springer and hopefully get the class fixed. – David Carlisle May 9 '15 at 16:10

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.