1

I have the following tex document:

\documentclass[phd,tocprelim]{cornell}

\usepackage{amsmath,amssymb}
\usepackage{graphicx,pstricks}
\usepackage{graphics}
\usepackage{epsfig}
\usepackage{subfigure}
\usepackage{hangcaption}
\renewcommand{\caption}[1]{\singlespacing\hangcaption{#1}\normalspacing}

\newcommand{\squig}[2]{\overset{ #1 }{\rightsquigarrow}_{ #2 }}

\begin{document}

\figurelistpage

\begin{figure}
\includegraphics[scale=1]{test.png}
\caption{$\squig{1}{2}$}
\label{my fig}
\end{figure}

\end{document}

And I get the following errors, which disappear when I comment out \figurelistpage OR if I change the caption to something not involving \overset:

! Missing control sequence inserted.
<inserted text>
\inaccessible
l.1 ...\rightarrow }\limits ^{n\to \infty }}$}}{2}
%
Please don't say `\def cs{...}', say `\def\cs{...}'.
I've inserted an inaccessible control sequence so that your
definition will be completed without mixing me up too badly.
You can recover graciously from this error, if you're
careful; see exercise 27.2 in The TeXbook.
! Missing \endgroup inserted.
<inserted text>
\endgroup
l.1 ...\rightarrow }\limits ^{n\to \infty }}$}}{2}
%
I've inserted something that you may have forgotten.
(See the <inserted text> above.)
With luck, this will get me unwedged. But if you
really didn't forget anything, try typing `2' now; then
my insertion and my current dilemma will both disappear.
)

I don't need the figure list page, however in my full document I still get the following error on the line containing the caption with \overset after commenting out \figurelistpage:

! Undefined control sequence.
\@tempa ->\catcode `\<
12\relax \catcode `\>12\relax \catcode `\=12\relax
l.2975 ... $\rightsquigarrow_2$. $\overset{1}{=}$}
The control sequence at the end of the top line
of your error message was never \def'ed. If you have
misspelled it (e.g., `\hobx'), type `I' and the correct
spelling (e.g., `I\hbox'). Otherwise just continue,
and I'll forget about whatever was undefined.

I have not been able to reproduce this error in the pared-down example. Any clue what is going on? Is there a different way I could define my \squig command to get around this?

Edit: Replacing \overset with \stackrel gets rid of the error, but I'm told I shouldn't use stackrel.

kccu
  • 133

1 Answers1

1

Either use \protect\squig when in captions, or use \DeclareRobustCommand at the outset, if you plan to frequently use the symbol in captions:

\newcommand{\squig}{}% just to make sure it is not defined
\DeclareRobustCommand{\squig}[2]{\overset{ #1 }{\rightsquigarrow}_{ #2 }}

The dummy \newcommand{\squig}{} is used to ensure the command is not already defined (maybe by a package you load), because \DeclareRobustCommand silently overwrites existing commands.

Load neither graphics (it is already loaded by graphicx) nor epsfig, which only exists for compatibility with documents written pre-1995.

Also subfigure is obsolete; use either subfig or subcaption.

egreg
  • 1,121,712