2

I am writing few equations and it's coming out of column in overleaf.

enter image description here

\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}

enter image description here

\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}

and

enter image description here

\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}

How can I modify those equations to make it looking good and small to fit in one column easily?

How to convert the first equation like this format?

enter image description here

Davislor
  • 44,045

1 Answers1

3

(At the OP's request, I've edited my answer to provide a version of the first equation that places the limits of summation off to the right. Unsurprisingly, the result of this change is awful.)

  • For the first equation, I suggest you omit the \left and \right sizing directives (they do nothing but inflate the horizontal spacing, replace \cdot with \,, change Loss to \mathrm{Loss}, and use a \smashoperator{...} wrapper on the first summation term (to let the upper limit of summation protrude into the left-hand space). Conversely, I would add a bit of whitespace between , and \mathbf{j} in order to avoid a visual collision of the glyphs.

  • To place the limits of summation off to the right instead of above and below the \sum symbols in the first equation, simply change the 3 instances of \sum to \sum\nolimits (and remove the \smashoperator directive). Unsurprisingly, the equation no longer fits in a single line. Moreover, it just looks awful from a typographic perspective. But, as the saying goes, there's no arguing about tastes...

  • For the second equation, I suggest using a 2-row multline environment, writing \exp(...) instead of e^{\frac{...}{...}}, and encasing the sum term in a \smash[b]{...} directive in order to reduce the distance to the next row.

  • For the third equation, get rid of the \left and \right directives and get rid of the redundant parentheses around the first multiplicative term.

enter image description here

\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}

Mico
  • 506,678
  • Hi, I am using first equation and getting "undefined control sequence" error. – Aaditya Ura Sep 23 '20 at 22:41
  • Can you please take a look at edited question, how can I use N steps, B, D front of \sum as shown in new image? – Aaditya Ura Sep 23 '20 at 23:01
  • @AadityaUra - On your first question: Did you load the mathtools package? – Mico Sep 24 '20 at 00:02
  • Yes, I used both mathtools and mathptmx. Can you edit your answer to show an example How to make that new equation image small with N steps, B, D front of \sum to fit in one column easily? – Aaditya Ura Sep 24 '20 at 00:56
  • @AadityaUra - The code I posted above does not generate any "undefined control sequence" errors. My psychic abilities are sadly (but probably not surprisingly) simply rubbish. Do provide more information about this "undefined control sequence" error you've encountered, as the odds that I'll be able to guess successfully on my own what this error may be about are not even infinitesimal; they are nil. – Mico Sep 24 '20 at 04:25
  • @AadityaUra - I've gone ahead and addressed your follow-up request by posting a version of the first equation that uses \sum\nolimits instead of \sum. The result is just awful. I really don't recommend it. – Mico Sep 24 '20 at 05:11
  • I agree with you, I also tried from the link you shared, your answer was quite helpful. I tried with that and it was looking disturbed between two columns, so I am using the old one which you answered here. – Aaditya Ura Sep 24 '20 at 05:25