我的目的如下:我有一系列標記為 1.1、1.2、1.3 等的方程1.1'
。我知道我可以通過 來做到這一點\tag{1.1'}
,但是有沒有辦法返回或獲取方程式1.1的標籤,並'
在其後面添加符號?
PS,當然歡迎其他滿足相同需求的解決方案。
PPS,如果我使用\tag{\ref{eq1}'}
,將會有一個指向方程式 1 的超連結。
這是一個範例程式碼,說明了這個想法。
\documentclass{article}
\usepackage{amsmath}
\title{test}
\begin{document}
\maketitle
this is the equation labelled 1
\begin{equation}
a=b \label{eq:eq1}
\end{equation}
here is the equation in between, and I need to label it as 1'.
\begin{equation*}
b=c \tag{1'}
\end{equation*}
this is the equation labelled 2
\begin{equation}
a=c
\end{equation}
\end{document}
答案1
您可以使用\ref
。無需假設特殊標記的方程式最終會在哪裡結束。
\documentclass{article}
\usepackage{amsmath}
\title{test}
\begin{document}
\maketitle
this is the equation labelled 1
\begin{equation}
a=b \label{eq:eq1}
\end{equation}
here is the equation in between, and I need to label it as 1'.
\begin{equation*}
b=c \tag{\ref{eq:eq1}$'$}
\end{equation*}
this is the equation labelled 2
\begin{equation}
a=c
\end{equation}
\end{document}
為了獲得質數(不是撇號),您需要$'$
.
筆記。如果您還加載\hyperref
,\ref
應該成為\ref*
以避免不需要的連結。
我們可以為此編寫一個特殊的命令嗎?是的。
\documentclass{article}
\usepackage{amsmath}
%\usepackage{hyperref}
\makeatletter
\AtBeginDocument{%
\@ifpackageloaded{hyperref}{%
% with hyperref use \ref*
\NewDocumentCommand{\repeateq}{O{$'$}m}{\tag{\ref*{#2}#1}}%
}{% without hyperref use \ref
\NewDocumentCommand{\repeateq}{O{$'$}m}{\tag{\ref{#2}#1}}%
}%
}
\makeatother
\title{test}
\begin{document}
\maketitle
this is the equation labelled 1
\begin{equation}
a=b \label{eq:eq1}
\end{equation}
here is the equation in between, and I need to label it as 1'.
\begin{equation*}
b=c \repeateq{eq:eq1}
\end{equation*}
this is the equation labelled 2
\begin{equation}
a=c
\end{equation}
Another variant of the first equation
\begin{equation}
c=a \repeateq[*]{eq:eq1}
\end{equation}
\end{document}
如果我取消對 的呼叫的註釋hyperref
,則連結是正確的。
答案2
如果確定方程n'
總是緊跟在方程 後面n
,即沒有任何中間編號方程,那麼您確實可以使用\tag{\theequation$'$}
。請注意,我會'
在數學模式而不是文字模式下渲染(“prime”)。
此外,您可能想要執行
\DeclareMathOperator{\numer}{num}
\DeclareMathOperator{\E}{E}
在序言中,E_t
(時間-t條件)期望運算子也是如此;通常使用直立(又稱“羅馬”)字母來表示數學“運算符”,例如\sin
、\exp
、\det
和\log
。另外,寫作\numer
(“numeraire”)比 更容易\operatorname{num}
,不是嗎?
\documentclass{article}
\usepackage{amsmath} % for '\DeclareMathOperator' macro
\DeclareMathOperator{\numer}{num}
\DeclareMathOperator{\E}{E}
\usepackage{mleftright} \mleftright % better spacing around tall delimiters
\usepackage[colorlinks,allcolors=blue]{hyperref}
\begin{document}
The formula holds for every non-dividend-paying asset. Multiplying through by
$S(t)$, we obtain
\begin{equation} \label{eq:fund_pricing_formula}
Y(t)=S(t) \E_t^S \left[\frac{Y(T)}{S(T)}\right]
\end{equation}
It is a present value relation: the value at time $t$ of the asset is the
expectation of its value $Y(T)$ at time $T$ ``discounted'' by the (possibly
random) factor $S(t) / S(T)$.
The formula can be written as
\begin{equation*}
Y(t)=\numer(t) \E_t^{\numer}
\left[\frac{Y(T)}{\numer(T)}\right]
\tag{$\theequation'$}
\end{equation*}
where now $\numer(t)$ denotes the price of the (non-dividend-paying)
numeraire asset at time $t$.
Letting $R(t)$ denote the value $\mathrm{e}^{r t}$ of the risk-free asset and
using it as the numeraire, the equation becomes
\begin{equation}
Y(t)=\mathrm{e}^{r t} \E_t^R
\left[\frac{Y(T)}{\mathrm{e}^{r T}}\right]
=\exp(-r(T-t)) \E_t^R[Y(T)]
\end{equation}
which means that $Y(t)$ is the expected value of $Y(T)$ discounted at the
risk-free rate for the remaining time $T-t$, when the expectation is computed
under the risk-neutral probability measure.
\end{document}
答案3
以下範例說明了我們可以使用 OpTeX 做什麼:
\def\prevmark[#1]{\ea\prevmarkA\expanded{\cs{_lab:#1}}}
\def\prevmarkA(#1){#1}
% \prevmark[label] expands to previously used \eqmark[label] without ().
\noindent
this is the equation labelled 1
$$
a=b \eqmark[first]
$$
here is the equation in between, and I need to label it as 1'.
$$
b=c \eqno (\prevmark[first]')
$$
this is the equation labelled 2
$$
a=c \eqmark[second]
$$
Another variant of the first equation
$$
c=a \eqno (\prevmark[first]\hbox{*})
$$
\bye
答案4
正如 @jlab 和 @cfr 評論的那樣, usebecause\tag{\theequation'}
顯示\theequation
當前方程式編號的值。