
如何為每個方程式指定一個新數字?
\begin{equation}
i_t = \sigma(W_{xi} * X_t + W_ {hi} * H_{t-1} + W_{ci} \circ C_{t-1} + b_i)
f_t = \sigma(W_{xf} * X_t + W_ {hf} * H_{t-1} + W_{cf} \circ C_{t-1} + b_f)
\end{equation}
還是在新函數中編寫每個方程式的唯一方法?在這種情況下,如何減少每個方程式之間的空白?我怎樣才能對齊每個方程式?
\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}
答案1
除了從一對equation
環境切換到單一align
環境之外,正如已經建議的那樣@Kersouman的回答W
,您可能還需要 (a) 每當後跟_x
or時應用一些負細間距字距調整,_c
並且 (b) 從\mathit
(預設)切換到下\textit
標術語包含兩個或多個字母時。
切換到\textit
這裡會產生明顯的影響,因為\mathit{f}
它佔用的空間比實際上多得多\textit{f}
。
透過進行這些調整所實現的副作用是,這兩個方程式比其他情況下排列得更好。雖然當我開始進行調整時,這種額外的對齊並不是一個目標,但結果想必並不是不受歡迎的。
\documentclass{article}
\usepackage{amsmath} % for 'align' environment
\begin{document}
without any adjustments:
\begin{align}
i_t &= \sigma(W_{xi} * X_t + W_{hi} * H_{t-1} + W_{ci} \circ C_{t-1} + b_i)\\
f_t &= \sigma(W_{xf} * X_t + W_{hf} * H_{t-1} + W_{cf} \circ C_{t-1} + b_f)
\end{align}
with kerning adjustments and \verb+\textit+ instead of \verb+\mathit+:
\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)
\end{align}
\end{document}
答案2
如果您只想對每個方程式進行編號,則可以使用套件gather
中的環境;如果您想添加一些對齊方式(例如,在符號周圍),則可以使用同一包中的環境:amsmath
align
=
\documentclass{article}
\usepackage{amsmath}
\begin{document}
\begin{gather}
i_t = \sigma(W_{xi} * X_t + W_ {hi} * H_{t-1} + W_{ci} \circ C_{t-1} + b_i)\\
f_t = \sigma(W_{xf} * X_t + W_ {hf} * H_{t-1} + W_{cf} \circ C_{t-1} + b_f)
\end{gather}
\begin{align}
i_t & = \sigma(W_{xi} * X_t + W_ {hi} * H_{t-1} + W_{ci} \circ C_{t-1} + b_i)\\
f_t & = \sigma(W_{xf} * X_t + W_ {hf} * H_{t-1} + W_{cf} \circ C_{t-1} + b_f)
\end{align}
\end{document}