將方程式與條件和另一個方程式對齊

將方程式與條件和另一個方程式對齊

我想將 6 和 7 與方程式 8 和 9 對齊。

我現在擁有的:

在此輸入影像描述

我使用下面的程式碼得到的:

    \begin{numcases}{O(t) =}
        \textbf{W}^T S(t), & $\text{if } S(t) \in Signal$; \\
        \textbf{0}, & \text{if } otherwise,
    \end{numcases}

    \begin{align}
        CSM &= \pi_{1} (O(t)) \label{eq:pi1} \\[10pt]
        K &= \pi_{2} (O(t)) \label{eq:pi2} \
    \end{align}

我需要的:

在此輸入影像描述

答案1

這只是一種選擇:

在此輸入影像描述

\documentclass{article}

\usepackage{mathtools,cases,xparse,eqparbox}

% https://tex.stackexchange.com/a/34412/5764
\makeatletter
\NewDocumentCommand{\eqmathbox}{o O{c} m}{%
  \IfValueTF{#1}
    {\def\eqmathbox@##1##2{\eqmakebox[#1][#2]{$##1##2$}}}
    {\def\eqmathbox@##1##2{\eqmakebox{$##1##2$}}}
  \mathpalette\eqmathbox@{#3}
}

\newcommand{\startsubequations}{%
  \refstepcounter{equation}%
  \protected@xdef\theparentequation{\theequation}%
  \global\let\theoldequation\theequation
  \setcounter{parentequation}{\value{equation}}%
  \setcounter{equation}{0}%
  \gdef\theequation{\theparentequation\alph{equation}}%
}

\newcommand{\stopsubequations}{%
  \protected@xdef\theequation{\theparentequation}%
  \global\let\theequation\theoldequation
  \setcounter{equation}{\value{parentequation}}%
}

\makeatother

\newcommand{\LBRACE}{
  \left\lbrace\begin{array}{@{}c@{}}
    \strut \\ \strut
  \end{array}\right.\kern-\nulldelimiterspace
}

\begin{document}

\begin{numcases}{O(t) =}
  \mathbf{W}^T S(t), & if $S(t) \in \text{Signal}$; \\
         \mathbf{0}, & otherwise,
\end{numcases}
\begin{align}
  CSM &= \pi_1 (O(t)) \\
    K &= \pi_2 (O(t))
\end{align}

\noindent\hrulefill

\begin{align}
  %\startsubequations % Start subequation numbering
    & \hphantom{\LBRACE}\eqmathbox[nc][l]{\mathbf{W}^T S(t), \quad} \text{if $S(t) \in \text{Signal}$;} \\
  \raisebox{.5\dimexpr\baselineskip+\jot}[0pt][0pt]{$O(t) ={}$} &
  \raisebox{.5\dimexpr\baselineskip+\jot}[0pt][0pt]{$\LBRACE$}
    \eqmathbox[nc][l]{\mathbf{0},} \text{otherwise,} \\
  %\stopsubequations % Stop sub-equation numbering
  CSM ={} & \pi_1 (O(t)) \\
    K ={} & \pi_2 (O(t))
\end{align}

\end{document}

此方法numcases透過將四個正則方程式放入一個align.前兩個的分組是透過將左側O(t) =和左側分隔符號{從第二個方程式移動到位(垂直向上)來完成的。

一些框寬度計算是使用自動計算的eqparbox針對不同的條件。

如果需要,可以變更左大括號分組以及條件和文字元件之間的間距。


\startsubequations....如果您想要對方程式進行子編號,您可以使用...的 ConTeXt 式方法\stopsubequations

在此輸入影像描述

答案2

我可以用一個可怕的程式碼來得到你想要的,調整假長度:

\documentclass{article}
\usepackage[showframe]{geometry}
\usepackage[table]{xcolor}
\usepackage{mathtools}
\usepackage{cases}
\begin{document}

\begin{align}%
O(t) &= {} \hspace*{-1.35cm}\makebox[0.3\linewidth]{\begin{subnumcases}{\hspace*{3.08cm}}
\textbf{W}^T S(t), & if $S(t) \in$ Signal; \\
\textbf{0}, & otherwise,
\end{subnumcases} }\notag
\\[1ex]
CSM &= \pi_{1} (O(t)) \label{eq:pi1}
\\[1ex]
K &= \pi_{2} (O(t)) \label{eq:pi2} \
\end{align}% \end{subequations}

\end{document} 

在此輸入影像描述

相關內容