如何拆分具有條件或限定符的長方程式?

如何拆分具有條件或限定符的長方程式?

我正在寫幾個方程式,它是從背頁的專欄中出來的。

在此輸入影像描述

\begin{equation}
Loss_{\text {de}}=\sum_{i=1}^{N_{\text {steps}}} \sum_{b=1}^{B} \sum_{j=1}^{D} \frac{-\mathbf{M}_{\mathbf{b}, \mathbf{j}}[\mathbf{i}]}{N_{\text {steps}} \cdot B} \log \left(\mathbf{M}_{\mathbf{b}, \mathbf{j}}[\mathbf{i}]+\epsilon\right)
\end{equation}

在此輸入影像描述

\begin{equation}
X(k)=\sum_{n=0}^{N-1} x(n) w(n) e^{\frac{-2 \pi i k n}{N}}, \quad k=0,1, \ldots, N-1
\end{equation}

在此輸入影像描述

\begin{equation}
\hbar_{k}=-\sum_{n=1}^{N-1}\left(\hat{s}_{k}(n)^{2}\right) \ln \left(\hat{s}_{k}(n)^{2}\right), \quad 1 \leq n \leq N-1
\end{equation}

我該如何修改這些方程,使其看起來又好又小,可以輕鬆地放入一列中?

如何將第一個方程式轉換為這種格式?

在此輸入影像描述

答案1

(根據OP的要求,我編輯了我的答案,以提供第一個方程式的版本,該方程式將求和的限制置於右側。毫不奇怪,這一更改的結果是可怕的。)

  • 對於第一個方程,我建議您省略\left\right大小調整指令(它們除了擴大水平間距、替換\cdot\,、更改Loss\mathrm{Loss}並使用\smashoperator{...}在第一個求和項上使用包裝器(讓求和的上限突出到左側) - 手空間)。添加,和之間有一點空白\mathbf{j},以避免字形的視覺衝突。

  • 要將求和限制置於右側而不是第一個方程中符號的上方和下方,只需更改to\sum的 3 個實例(並刪除該指令)。毫不奇怪,方程式不再適合一條線。此外,從印刷的角度來看,它看起來很糟糕。但是,正如俗話所說,口味是沒有爭議的......\sum\sum\nolimits\smashoperator

  • 對於第二個方程,我建議使用 2 行multline環境,編寫\exp(...)而不是e^{\frac{...}{...}},並將總和項包含在\smash[b]{...}指令中,以減少到下一行的距離。

  • 對於第三個方程,去掉\leftand\right指令並去掉第一個乘法項周圍的多餘括號。

在此輸入影像描述

\documentclass[twocolumn]{article} % or some other suitable document class
\usepackage{mathtools} % for '\smashoperator' macro
\usepackage{lipsum}    % for filler text
\begin{document}
\lipsum[1] % produce a paragraph of filler text
\begin{equation}
\mathrm{Loss}_{\mathrm{de}}=
\smashoperator{\sum_{i=1}^{N_{\mathrm{steps}}}}
\sum_{b=1}^{B} \sum_{j=1}^{D} 
\frac{-\mathbf{M}_{\mathbf{b},\mkern1.5mu \mathbf{j}}[\mathbf{i}]}{%
   N_{\mathrm{steps}}\, B} 
\log (\mathbf{M}_{\mathbf{b},\mkern1.5mu \mathbf{j}}[\mathbf{i}]+\epsilon)
\end{equation}

\begin{equation} \tag{$1'$}
L_{\mathrm{sparse}}=
\sum\nolimits_{i=1}^{N_{\mathrm{steps}}}
\sum\nolimits_{b=1}^{B} \sum\nolimits_{j=1}^{D} 
\frac{-\mathbf{M}_{\mathbf{b},\mkern1.5mu \mathbf{j}}[\mathbf{i}]}{%
   N_{\mathrm{steps}}\, B} 
\log (\mathbf{M}_{\mathbf{b},\mkern1.5mu \mathbf{j}}[\mathbf{i}]+\epsilon) 
\end{equation}

\begin{multline}
X(k)=\smash[b]{\sum_{n=0}^{N-1}} x(n) w(n) \exp(-2 \pi i k n/N), \\
   k=0,1, \ldots, N-1
\end{multline}

\begin{equation}
\hbar_{k}=-\sum_{n=1}^{N-1}\hat{s}_{k}(n)^{2} \ln (\hat{s}_{k}(n)^{2}), 
   \quad 1 \leq n \leq N-1
\end{equation}
\lipsum[2-10] % more filler text
\end{document}

相關內容