备选子方程编号和参考

备选子方程编号和参考

我知道如何将一组方程编号为子方程:

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\begin{document}

Some text here 
\begin{subequations}\label{eq:full}
    \begin{align}
        y_1 &= f_1(x) \label{eq:first} \\
        y_2 &= f_2(x) \label{eq:second} \\
        y_3 &= f_3(x) \label{eq:third}
    \end{align}
\end{subequations}
\dots and now I can reference the full set as equations~(\ref{eq:full})
and for example the first as equation~(\ref{eq:first}). 

\end{document}

这使:

子方程作为输出

是否可以将方程式标记为以下形式:

假妆

...并使对单个方程的引用保持不变?(或者可能将“全局”的改为1a--c,不确定)。

答案1

这是可以做到的,但是我给环境起的名字应该可以澄清我的看法。;-)

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{environ}

\makeatletter
\newsavebox{\horriblesubequationsbox}
\NewEnviron{horriblesubequations}[1]{%
  \setbox\horriblesubequationsbox=\vbox{
    \hsize=\dimexpr\linewidth-8em\relax
    \begin{subequations}
    \renewcommand{\theequation}{\alph{equation}}
  \vspace*{-\baselineskip}\vspace*{-\abovedisplayskip}
    \noindent\strut
    \begin{align}
    \BODY
    \end{align}
    \end{subequations}
    \addtocounter{equation}{-1}%
  }%
  \begin{equation}\label{#1}
  \hspace*{4em}\left.\vcenter{\unvbox\horriblesubequationsbox\unskip}\right\rbrace
  \end{equation}
}
\makeatother

\begin{document}

Some text here 
\begin{horriblesubequations}{eq:full}
  y_1 &= f_1(x) \label{eq:first} \\
  y_2 &= f_2(x) \label{eq:second} \\
  y_3 &= f_3(x) \label{eq:third}
\end{horriblesubequations}
\dots and now I can reference the full set as equations~(\ref{eq:full})
and for example the first as equation~(\ref{eq:first}). 

Some text here 
\begin{horriblesubequations}{eq:full+}
  y_1 &= f_1(x) \label{eq:first+} \\
  y_2 &= f_2(x) \label{eq:second+} \\
  y_3 &= f_3(x) \label{eq:third+} \\
  y_4 &= f_4(x) \label{eq:fourth+}
\end{horriblesubequations}
\dots and now I can reference the full set as equations~(\ref{eq:full+})
and for example the first as equation~(\ref{eq:first+}). 

\end{document}

请注意,按照代码规定,全局标签是强制性的。

在此处输入图片描述

答案2

这是设置标签和指定参考文献的手动方法。这似乎是合适的,因为标签和参考文献之间存在脱节。通常它们是相同的,因此读者不会产生歧义,但在这种情况下没有(例如)方程式(1a)。

在此处输入图片描述

\documentclass{article}

\usepackage{amsmath}
\makeatletter
\newcommand{\ltxlabel}{\ltx@label}
\newcommand{\settag}[1]{
  \tag*{(#1)\qquad}
  \edef\@currentlabel{\theequation#1}}
\newcommand{\setmaintag}[1]{
  \tag*{(#1)\qquad\llap{(\theequation)}}
  \edef\@currentlabel{#1}}
\newcommand{\setref}[1]{\edef\@currentlabel{#1}}
\makeatother

\begin{document}

Some text here 
\begin{align}
  \stepcounter{equation}
  y_1 &= f_1(x) \settag{a}\ltxlabel{eq:first} \\
  y_2 &= f_2(x) \setmaintag{b}\ltxlabel{eq:second}\setref{\theequation}\ltxlabel{eq:full} \\
  y_3 &= f_3(x) \settag{c}\ltxlabel{eq:third}
\end{align}
\dots and now I can reference the full set as equations~\eqref{eq:full}
and for example the first as equation~\eqref{eq:first}. 

\end{document}

\ltxlabel允许立即设置\label,否则将推迟到\tag在内设置align

不考虑hyperref给出,也没有测试。问题中的“可能”选项也是如此。


对于偶数个方程式,您可以根据需要将主方程式向上/向下移动:

在此处输入图片描述

Some text here 
\begin{align}
  \stepcounter{equation}
  y_1 &= f_1(x) \settag{a}\ltxlabel{eq:first} \\
  y_2 &= f_2(x) \setmaintag{b}\ltxlabel{eq:second}\setref{\theequation}\ltxlabel{eq:full} \\
  y_3 &= f_3(x) \settag{c}\ltxlabel{eq:third}
\end{align}
\dots and now I can reference the full set as equations~\eqref{eq:full}
and for example the first as equation~\eqref{eq:first}. 
\begin{align}
  \stepcounter{equation}
  y_1 &= f_1(x) \settag{a}\ltxlabel{eq:first2} \\
  y_1 &= f_2(x) \settag{b}\ltxlabel{eq:second2} \\
  y_2 &= f_3(x) \setmaintag[\dimexpr.5\normalbaselineskip+.5\jot]{c}\ltxlabel{eq:third2}
    \setref{\theequation}\ltxlabel{eq:full2} \\
  y_3 &= f_4(x) \settag{d}\ltxlabel{eq:fourth2}
\end{align}

相关内容