我有这些方程式,并且它们的数字在同一条线上。
\begin{equation}
i_t = \sigma(W_{xi} * X_t + W_ {hi} * H_{t-1} + W_{ci} \circ C_{t-1} + b_i)
\end{equation}
\begin{equation}
f_t = \sigma(W_{xf} * X_t + W_ {hf} * H_{t-1} + W_{cf} \circ C_{t-1} + b_f)
\end{equation}
\begin{equation}
C_t = f_t \circ C_{t-1} + i_t \circ \textnormal{tanh}(W_{xc} * X_t + W_{hc} * H_{t-1} + b_c)
\end{equation}
\begin{equation}
o_t = \sigma(W_{xo} * X_t + W_ {ho} * H_{t-1} + W_{co} \circ C_{t} + b_o)
\end{equation}
但进行这种格式化会导致数字不在同一行。我怎样才能强制数字在同一行?
\begin{align}
i_t &= \sigma(W_{\!\textit{xi}} * X_t + W_{\textit{hi}} * H_{t-1} + W_{\!\textit{ci}} \circ C_{t-1} + b_i)\\
f_t &= \sigma(W_{\!\textit{xf}} * X_t + W_{\textit{hf}} * H_{t-1} + W_{\!\textit{cf}} \circ C_{t-1} + b_f)\\
C_t &= f_t \circ C_{t-1} + i_t \circ \text{tanh}(W_{\!\textit{xc}} * X_t + W_{\!\textit{hc}} * H_{t-1} + b_c)\\
o_t &= \sigma(W_{\!\textit{xo}} * X_t + W_{\!\textit{ho}} * H_{t-1} + W_{\!\textit{co}} \circ C_{t} + b_o)
\end{align}
答案1
除非你能找到一种方法来简化和缩短等式 (3) 右边的材料,否则最好的解决方案就是在该材料中引入刻意的换行符。
\documentclass{article}
\usepackage{amsmath} % for 'align' environment
\newcommand\vn[1]{\textit{#1}}
\usepackage{newtxtext,newtxmath} % optional
\setlength\textwidth{3in} % just for this example
\begin{document}
\begin{align}
i_t &= \sigma(W_{\!\vn{xi}} * X_t + W_{\vn{hi}} * H_{t-1} + W_{\!\vn{ci}} \circ C_{t-1} + b_i)\\
f_t &= \sigma(W_{\!\vn{xf}} * X_t + W_{\vn{hf}} * H_{t-1} + W_{\!\vn{cf}} \circ C_{t-1} + b_{\vn{f}})\\
C_t &= f_t \circ C_{t-1} \notag \\
&\qquad + i_t \circ \text{tanh}(W_{\!\vn{xc}} * X_t + W_{\vn{hc}} * H_{t-1} + b_c)\\
o_t &= \sigma(W_{\!\vn{xo}} * X_t + W_{\vn{ho}} * H_{t-1} + W_{\!\vn{co}} \circ C_{t} + b_o)
\end{align}
\end{document}