我想使用我在一些旧论文中见过的一种参考样式,作者会在同一行中列出几个方程式,但所有方程式只有一个参考编号。然后,如果作者只想引用该行中的一个方程式,他们会使用下标或上标来引用。示例:
a+b=c ; a*b=d .................. (1)
因此,带有和的方程由方程 (1) aa+b=c
给出。
以下是 MWE:
\documentclass[12pt]{article}
\usepackage{amsmath} % Extra Math Stuff
\begin{document}
I would like to have 3 equations together like this
\begin{equation}
A+B=C %\label{eq:sum}
\quad\textrm{,}\quad
A\times B=D %\label{eq:mul}
\qquad\textrm{,}\quad
A/B=D %\label{eq:div}
\label{eq:tog}
\end{equation}
And now I would like to either reference all equations in \eqref{eq:tog} or each of them individually, which should look like \eqref{eq:tog}$_a$, \eqref{eq:tog}$_b$ and \eqref{eq:tog}$_c$.
\end{document}
答案1
\eqref
使用双重嵌套设置引用\upshape
(来自amsmath.dtx
):
\newcommand{\eqref}[1]{\textup{\tagform@{\ref{#1}}}}
下面我所做的是创建一个手册参考,假设您将使用\eqref{<subref>}
,因此将子方程编号的打印延迟两组(使用嵌套\AfterGroup
的etextools
):
\documentclass{article}
\usepackage{amsmath,etextools}
\newcounter{subeqn}[equation]
\renewcommand{\thesubeqn}{\alph{subeqn}}
\makeatletter
\newcommand{\sublabel}[1]{{%
\stepcounter{subeqn}
\def\@currentlabel{\theequation\protect\AfterGroup{\protect\AfterGroup{\protect\textsubscript{\thesubeqn}}}}%
\ltx@label{#1}%
}}
\makeatother
\begin{document}
I would like to have 3 equations together like this:
\begin{equation}
A + B = C \sublabel{eq:sum}
\textrm{,}\qquad
A \times B = D \sublabel{eq:mul}
\textrm{,}\qquad
A \div B = D \sublabel{eq:div}
\label{eq:tog}
\end{equation}
And now I would like to either reference all equations in \eqref{eq:tog}
or each of them individually, which should look like \eqref{eq:tog}$_a$,
\eqref{eq:tog}$_b$ and \eqref{eq:tog}$_c$.
And now I would like to either reference all equations in \eqref{eq:tog}
or each of them individually, which should look like \eqref{eq:sum},
\eqref{eq:mul} and \eqref{eq:div}.
\end{document}