IEEEtran cls 和 cleveref:IEEEeqnarray 的特殊情况

IEEEtran cls 和 cleveref:IEEEeqnarray 的特殊情况

如何使用 cleveref 包正确引用 IEEEeqnarray 中的方程式?

可能的 MWE 如下:

\documentclass[a4paper,10pt,conference,twocolumn,twoside]{IEEEtran}
\usepackage[utf8]{inputenc}
\usepackage[cmex10]{amsmath}
\usepackage{mathtools}
\usepackage{cleveref}
\crefname{equation}{eq.}{eqs.}
\crefname{figure}{fig.}{figs.}

\begin{document}
While referencing is not working for \Cref{Eq:not_working}, it is for \Cref{Eq:working}
\begin{IEEEeqnarray}{rCl}
  a &=& b\nonumber\\
  c &=& d
\label{Eq:not_working}
\end{IEEEeqnarray}

\begin{subequations}
\begin{IEEEeqnarray}{rCl}
  a &=& b\\
  c &=& d
\end{IEEEeqnarray}
\label{Eq:working}
\end{subequations}
\end{document}

答案1

IEEEtrantools.sty包使用\stepcounter{equation}\stepcounter{IEEEsubequation}而不是\refstepcounter,因此cleveref无法猜测涉及什么计数器。

\stepcounter这是一个将所有命令更改为 的补丁\refstepcounter。它对 的宏没有影响IEEEtrantools,因为它们设置为“手动” \@currentlabel

\documentclass[a4paper,10pt,conference,twocolumn,twoside]{IEEEtran}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{mathtools}
\usepackage{etoolbox}

\makeatletter
\patchcmd{\@IEEEyesnumber}
  {\stepcounter}
  {\refstepcounter}
  {}{}
\patchcmd{\@@IEEEeqnarray}
  {\stepcounter}
  {\refstepcounter}
  {}{}
\patchcmd{\@@IEEEeqnarraycr}
  {\stepcounter{IEEEsubequation}}
  {\refstepcounter{IEEEsubequation}}
  {}{}
\patchcmd{\@@IEEEeqnarraycr}
  {\stepcounter{IEEEsubequation}}
  {\refstepcounter{IEEEsubequation}}
  {}{}
\patchcmd{\@@IEEEeqnarraycr}
  {\stepcounter{IEEEequation}}
  {\refstepcounter{IEEEequation}}
  {}{}
\patchcmd{\@@IEEEeqnarraycr}
  {\stepcounter{IEEEequation}}
  {\refstepcounter{IEEEequation}}
  {}{}
\makeatother

\usepackage{cleveref}
\crefname{equation}{eq.}{eqs.}
\crefname{figure}{fig.}{figs.}


\begin{document}

While referencing is not working for \Cref{Eq:not_working}, 
it is for \cref{Eq:working}
\begin{IEEEeqnarray}{rCl}
  a &=& b\nonumber\\
  c &=& d
\label{Eq:not_working}
\end{IEEEeqnarray}

\begin{subequations}
\begin{IEEEeqnarray}{rCl}
  a &=& b\\
  c &=& d
\end{IEEEeqnarray}
\label{Eq:working}
\end{subequations}

\end{document}

在此处输入图片描述

相关内容