我有两个方程,后者是前者的等价形式。因此,我不希望调用 (1) 和 (2),而是希望将 (2) 称为 $(1)'$ 或 $(1)^{*}$ 等(类似于 (1) 的某种形式),并能够标记它,这样我就可以在需要时再次调用它。我该如何实现这一点?感谢您的任何建议。
答案1
我认为,素数应该放在括号内。
\documentclass{article}
\usepackage{amsmath}
\begin{document}
Here is an equation
\begin{equation}\label{eq:nice}
0=0
\end{equation}
and a related one
\begin{equation}\label{eq:niceprimed}
1=1 \tag{\ref{eq:nice}$'$}
\end{equation}
Equations \eqref{eq:nice} and \eqref{eq:niceprimed}
are easily seen to be equivalent to one another.
\end{document}
如果你有多个相关方程,你可以定义
\newcommand{\mytag}[2]{\tag{\ref{#1}$#2$}}
并 调用\mytag{eq:nice}{'}
单素数,\mytag{eq:nice}{''}
调用双素数。
答案2
这里使用我的旧答案的一种方法:https://tex.stackexchange.com/a/377481/120578
\documentclass[a4paper,12pt]{article}
\usepackage{amsmath}
\usepackage{pgffor}
\usepackage{pgf}
\usepackage{lipsum}
\makeatletter
\newcommand*\ifcounter[1]{%
\ifcsname c@#1\endcsname%
\expandafter\@firstoftwo%
\else%
\expandafter\@secondoftwo%
\fi%
}%
\makeatother
\newcounter{testc}
\def\extendmystring#1{\xdef\mystring{\mystring#1}}
\makeatletter
\newcommand\EqFamTag[1]{%
\ifcounter{#1}{%
\expandafter\addtocounter{#1}{1}%
\xdef\ccc{\arabic{#1}}%
\xdef\mystring{}%
\foreach \i in {1,...,\ccc}{\extendmystring{'}}%
\xdef\temp{\csname #1 Eq\endcsname\mystring}%
\xdef\ttemp{(\temp)}
\global\expandafter\let\csname #1\arabic{#1}\endcsname\ttemp%
\tag{\temp}%
}{%
\global\expandafter\newcounter{#1}%
\xdef\temp{\theequation}%
\xdef\eqonfamily{\theequation}%
\global\expandafter\let\csname #1 Eq\endcsname\eqonfamily%
\xdef\ttemp{(\temp)}%
\global\expandafter\let\csname #1\endcsname\ttemp%
\tag{\temp}%
%\expandafter\addtocounter{equation}{0}
}%
}%
\makeatother
\begin{document}
\section{Test}
\lipsum[1]
\begin{equation}
f(x-3)=1\EqFamTag{Const}
\end{equation}
\lipsum[1]
For \(y=x-3\):
\begin{equation}
f(y)=1 \EqFamTag{Const}\label{Second}
\end{equation}
For \(z=x-2\):
\begin{equation}
f(z-1)=1 \EqFamTag{Const}
\end{equation}
The \csname Const\endcsname{} equation is same with \csname Const1\endcsname{} and \csname Const2\endcsname{} equations.
Also I can refer with \verb|\ref| or \verb|\eqref| to \eqref{Second}.
\end{document}
此处的代码产生:
链接答案的代码也可以运行并产生: