我有几个lemmas,我在其中指定常量$ C_1 $,$ C_2 $等等以供稍后参考.当然,当我稍后在中间插入一个新的常量定义时,这很烦人.我想要的是一个宏,它允许我为常量指定标签并为我处理编号.我正在思考一些事情
%% Pseudocode
\begin{lemma}
\newconstant{important-bound}
We will show that $f(x) \le \ref{important-bound} g(x)$ for all $x$.
\end{lemma}
Run Code Online (Sandbox Code Playgroud)
这可能吗?
扩展 rcollyer 使用计数器的建议:
%counter of current constant number:
\newcounter{constant}
%defines a new constant, but does not typeset anything:
\newcommand{\newconstant}[1]{\refstepcounter{constant}\label{#1}}
%typesets named constant:
\newcommand{\useconstant}[1]{C_{\ref{#1}}}
Run Code Online (Sandbox Code Playgroud)
(此代码经过编辑,允许标签长度超过一个字符)
这是一个似乎有效的代码片段:
I want to define two constants:\newconstant{A}\newconstant{B}$\useconstant{A}$ and
$\useconstant{B}$. Then I want to use $\useconstant{A}$ again.
Run Code Online (Sandbox Code Playgroud)