如何才能在不引入额外垂直空间的情况下将两行方程分开对齐?例如,下面的代码给出了以下内容
\documentclass[twocolumn]{article}
\usepackage{amsmath}
\begin{document}
\begin{alignat}{4}
\hat{y}_{\Psi}^t &= \Psi(h^t_\text{h}) + \hat{y}^{t-1} \hspace{-\textwidth} \\
\hat{y}^t_{\Phi,s,i} &= \Phi([\hat{y}_{\Psi}^t \odot m,x_i^t,\mathrm{BPS}_i,s])\hspace{-\textwidth} \label{eq:doublegrabnets} \\
\hat{y}^{'t} &= \hat{y}_{\Psi}^t\odot m_l &&+ \textstyle\sum_{i} \hat{\alpha}^t_{l,i}\hat{y}^t_{\Phi,l,i} &&\odot m_l + \hat{\alpha}^t_{l,\text{h}}\hat{y}_{\Psi}^t &&\odot m_l \label{eq:larmupdate} \\
\hat{y}^t &= \hat{y}^{'t} \odot m_r &&+ \textstyle\sum_{i} \hat{\alpha}^t_{r,i}\hat{y}^t_{\Phi,r,i} &&\odot m_r + \hat{\alpha}^t_{r,\text{h}}\hat{y}^{'t} &&\odot m_r \label{eq:rarmupdate}
\end{alignat}
\end{document}
我想要这样的东西,但没有方程式 1,2 和 3,4 之间的额外间距。
答案1
从您展示的图像来看,我很确定您正在使用IEEEtran
。
在展示我的解决方案之前,请注意
\hat{y}^{'t}
是错误的,应该是\hat{y}'^{t}
(查看图像并与您的输出进行比较)。也\text{h}
应该是\mathrm{h}
。我提供了一种更好的方法来输入较小的\sum
符号。
现在提出建议。
\documentclass{IEEEtran}
\usepackage{amsmath}
\usepackage{lipsum}% for context
\newcommand{\tsum}{\mathop{\textstyle\sum}\nolimits}
\newenvironment{multiplealignment}{%
$$\vbox\bgroup
\setlength{\abovedisplayskip}{\jot}%
\setlength{\belowdisplayskip}{0pt}%
\vspace{-\jot}%
}{\egroup$$}
\begin{document}
\lipsum[1][1-3]
\begin{multiplealignment}
\begin{align}
\hat{y}_{\Psi}^t &= \Psi(h^t_{\mathrm{h}}) + \hat{y}^{t-1}
\\
\hat{y}^t_{\Phi,s,i} &= \Phi([\hat{y}_{\Psi}^t \odot mx_i^t,\mathrm{BPS}_i,s])
\label{eq:doublegrabnets}
\end{align}
\begin{alignat}{5}
\hat{y}'^{t} &= \hat{y}_{\Psi}^t\odot m_l
&&+ \tsum_{i} \hat{\alpha}^t_{l,i}\hat{y}^t_{\Phi,l,i} &&\odot m_l
&&+ \hat{\alpha}^t_{l,\mathrm{h}}\hat{y}_{\Psi}^t &&\odot m_l
\label{eq:larmupdate}
\\
\hat{y}^t &= \hat{y}'^{t} \odot m_r
&&+ \tsum_{i} \hat{\alpha}^t_{r,i}\hat{y}^t_{\Phi,r,i} &&\odot m_r
&&+ \hat{\alpha}^t_{r,\mathrm{h}}\hat{y}'^{t} &&\odot m_r
\label{eq:rarmupdate}
\end{alignat}
\end{multiplealignment}
\lipsum[2][1-3]
\end{document}
答案2
我建议创建一个align
环境alignat
,并用合适的\vspace*
指令将其分隔开。
\documentclass{article}
\usepackage[twocolumn,margin=2cm]{geometry}
\usepackage{amsmath}
\begin{document}
\begin{align}
\hat{y}_{\Psi}^t
&= \Psi(h^t_\mathrm{h}) + \hat{y}^{t-1} \\
\hat{y}^t_{\Phi,s,i}
&= \Phi([\hat{y}_{\Psi}^t \odot m, x_i^t, \mathrm{BPS}_i, s])
\label{eq:doublegrabnets}
\end{align}
\vspace*{-2.5\abovedisplayskip} % or '-2.75\abovedisplayskip'
\begin{alignat}{3}
\hat{y}'^{t}
&= \textstyle \hat{y}_{\Psi}^t\odot m_l
&&+\textstyle \sum_{i} \hat{\alpha}^t_{l,i}\hat{y}^t_{\Phi,l,i} \odot m_l
&&+\textstyle \hat{\alpha}^t_{l,\mathrm{h}}\hat{y}_{\Psi}^t \odot m_l
\label{eq:larmupdate} \\
\hat{y}^t
&= \textstyle \hat{y}'^{t} \odot m_r
&&+\textstyle \sum_{i} \hat{\alpha}^t_{r,i}\hat{y}^t_{\Phi,r,i} \odot m_r
&&+\textstyle \hat{\alpha}^t_{r,\mathrm{h}}\hat{y}'^{t} \odot m_r
\label{eq:rarmupdate}
\end{alignat}
\end{document}