Latex 乳胶中的标记常数
我有几个引理,其中我指定了常数$C_1$,$C_2$,以此类推,供以后参考。当然,这是恼人的,当我后来插入一个新的常量定义在中间。我想要的是一个宏,它允许我为常量指定标签,并为我处理编号。我在想一些关于Latex 乳胶中的标记常数,latex,Latex,我有几个引理,其中我指定了常数$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}
%% Pseudocode
\begin{lemma}
\newconstant{important-bound}
We will show that $f(x) \le \ref{important-bound} g(x)$ for all $x$.
\end{lemma}
这可能吗?您正在寻找的是创建自己的计数器。扩展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}}}
(此代码已编辑为允许标签长度超过一个字符)
下面是一段似乎有效的代码片段:
I want to define two constants:\newconstant{A}\newconstant{B}$\useconstant{A}$ and
$\useconstant{B}$. Then I want to use $\useconstant{A}$ again.
根据Aniko的回答,我使用 因此它为标签创建了一个速记
\newcounter{constant}
\newcommand{\newconstant}[1]{\refstepcounter{constant}\label{#1}}
\newcommand{\useconstant}[1]{C_{\ref{#1}}}
\newcommand{\defconstant}[1]{ \newconstant{c_#1}\expandafter\newcommand\csname c#1\endcsname{\useconstant{c_#1}} } %
所以使用这个,你就可以
\defconstant{a}
\defconstant{b}
There exist constant $\ca$ and $\cb$ such that ....
小心不要覆盖现有命令(我相信无论如何它都会警告您)什么是
重要界限
指的是什么?例如,它是引理的数字吗?我相信他想用命令\newconstant
定义重要界
,作为“下一个”C\u I,然后能够\ref
引用它。是的,谢谢finrod。也许\newconstant
应该使用一个参数来指定基本符号(这样就可以使用C_i或C_i或其他什么)。非常好。我考虑过类似的事情,但不确定标签是否能按预期工作。肯定+1。谢谢阿尼科,这就是我要找的。似乎也有类似的东西。ubuntu软件包texlive latex extra也包括这个。