突出显示引用的方程式编号

突出显示引用的方程式编号

我要演讲,我使用的是 LaTeX 纸,我会把它写在黑板上。但是,把所有方程式的数字都写在黑板上很烦人,但我确实想把它们都写在我的文档里。因此,禁用所有未引用的数字不是一个选择。

我的问题是:有没有办法为引用的公式定义另一种样式,而不是未引用的公式?假设我想要直立的正常公式数字,并且引用它们时使用斜体。通过这种方式,我可以看到哪些数字需要写在黑板上。

答案1

如果不加载 amsmath,以下代码就会在引用方程编号的情况下在其周围绘制一个 fbox。但是,这不能与 amsmath 一起使用,应该进行修改以使用 mathtools,这样使用起来会更方便,但目前我不知道如何在打印出方程编号后将样式切换回来。

\makeatletter
% overwrite the reference mechanism: ref shall also create a label where a label has first been referenced. The next time LaTeX is run, \label will recognized that the created eq. number is referenced later on and make it being formatted accordingly. A macro is defined so that no multiple labels for referenced to the same eq. label are defined.
\let\old@ref\ref
\def\ref#1{%
    \write\@auxout{%
        \string\used@label{#1}%
    }%
  \old@ref{#1}%
}
% overwrite the label mechanism: if a label has been created by a former run of LaTeX that indicates that there has been made use of the actual label ought to be created, the next print of the eq. number via \@eqnum is redirected to a new command
\let\old@label\label
\def\label#1{%
    \@ifundefined{used@label@#1}%
        {}%
        {\let\@eqnnum\new@eqnum}%
    \old@label{#1}
}
% overwrite the equation number mechanism: the new@eqnum prints the equation number in another style and then switches back to the default style. 
\let\old@eqnnum\@eqnnum
\def\new@eqnum{%
    \refeqnum%
    \let\@eqnnum\old@eqnum%
}
% this macro marks the label given as used in the aux file.
\def\used@label#1{%
    \@ifundefined{used@label@#1}{%
        \expandafter\gdef\csname used@label@#1\endcsname{}%
    }%
    {}%
}
\makeatother
% this macro holds the \theequation-definition for referenced equations.
\def\refeqnum{\fbox{\theequation}}

相关内容