标题和 \figurelistpage 中的 \overset 错误

标题和 \figurelistpage 中的 \overset 错误

我有以下 tex 文档:

\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}

我收到以下错误,当我注释掉\figurelistpage或将标题更改为不相关的内容时\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.
)

我不需要图形列表页,但是在我的完整文档中,\overset在注释掉之后,在包含标题的行上仍然出现以下错误\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.

我无法在简化的示例中重现此错误。有任何线索吗?我可以用其他方式定义命令\squig来解决这个问题吗?

编辑:替换\overset\stackrel消除错误,但我被告知我不应该使用 stackrel

答案1

如果您计划在标题中频繁使用该符号,请在标题中使用\protect\squigwhen,或在一开始就使用:\DeclareRobustCommand

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

虚拟命令\newcommand{\squig}{}用于确保命令尚未定义(可能是由您加载的包定义),因为它会\DeclareRobustCommand默默覆盖现有命令。

既不加载graphics(它已被加载graphicx)也不加载epsfig,这只是为了与 1995 年之前编写的文档兼容。

Alsosubfigure已过时;请使用subfigsubcaption

相关内容