latex 运用引用功能,给公式添加标签 \label,就不用因为公式的编号变动而麻烦地更改大量数字了。
1. 一般情况下,可以用 \ref 命令
例如,下面一个公式:
\ begin{equation}
I_{t}=I_{0}+\sum_{i=1}^{t}(Q_{i}-d_{i})\label{con:inventoryflow}
\ end{equation}
Equation \ ref{con:inventoryflow} is the inventory flow formula.
显示效果:
2. 若要在引用的编号两边显示括号或中括号,则可以用 (\ref) 或 [\ref] 命令:
\ begin{equation}
I_{t}=I_{0}+\sum_{i=1}^{t}(Q_{i}-d_{i})\label{con:inventoryflow}
\ end{equation}
Equation (\ ref{con:inventoryflow}) is the inventory flow formula.
3. 或加载 amsmath 工具包,使用 \eqref 命令:
\ begin{equation}
I_{t}=I_{0}+\sum_{i=1}^{t}(Q_{i}-d_{i})\label{con:inventoryflow}
\ end{equation}
Constraint \ eqref{con:inventoryflow} is the inventory flow formula.
显示效果:
4. 自定义引用样式,可以用 newcommand 自定义一个引用样式。
newcommand 函数的格式为:\newcommand{新命令}[参数数量][默认值]{定义内容}。默认值一般可以省略,只给出参数数量。#1表示参数内容。
\newcommand{\myref}[1]{Eq.\ ref{#1}}
\ myref{con:inventoryflow} is the inventory flow formula.
显示效果:
中文排版时一般需要编译两次才能正确引用。