6

I have a large formula in align:

\begin{align*}
log \mathcal{L}(\alpha,\beta,\mu,\delta|  l_1,...,l_n)&=\\\sum_{i=1}^n  \left( log \left(\frac{\sqrt{\alpha^2-\beta^2}}{2\alpha \delta K_1 (\delta\sqrt{\alpha^2-\beta^2})} exp\left(-\alpha\sqrt{\delta^2+(l-\mu)^2}+\beta(l-\mu)\right)\right) \right) 
\end{align*}

Currently, this looks like

te

But I want to have the first equation, the logL a bit pushed to the left. Now it is on the right side, what I don't like. I tried to insert a & before the exp to align it on that point, but this does not work.

 \begin{align*}
    log \mathcal{L}(\alpha,\beta,\mu,\delta|  l_1,...,l_n)&=\\\sum_{i=1}^n  \left( log \left(\frac{\sqrt{\alpha^2-\beta^2}}{2\alpha \delta K_1 (\delta\sqrt{\alpha^2-\beta^2})} &exp\left(-\alpha\sqrt{\delta^2+(l-\mu)^2}+\beta(l-\mu)\right)\right) \right) 
    \end{align*}

How can I get the first part of the equation aligned in the center?

2
  • 5
    You don't need align for a single equation... maybe the {multline} environment is better here, see mathmode for reference.
    – cgnieder
    Commented Aug 8, 2013 at 17:18
  • And how can I solve my problem? What code should I use instead?
    – Jen Bohold
    Commented Aug 8, 2013 at 17:22

5 Answers 5

4

To obtain a centred "first part" and only have two parts, I assume you just want the whole things centred. For this you just have to gather* the contents:

enter image description here

\documentclass{article}
\usepackage{amsmath}% http://ctan.org/pkg/amsmath
\begin{document}
\begin{gather*}
  \log \mathcal{L}(\alpha,\beta,\mu,\delta|  l_1,...,l_n) = \\
  \sum_{i=1}^n  \left( \log \left(\frac{\sqrt{\alpha^2-\beta^2}}{2\alpha \delta K_1 (\delta\sqrt{\alpha^2-\beta^2})} \exp\left(-\alpha\sqrt{\delta^2+(l-\mu)^2}+\beta(l-\mu)\right)\right) \right)
\end{gather*}
\end{document}

Note the use of \log as an operator for logarithm.

2
  • thanks, but what is the difference between \log and log? I like the cursive log?
    – Jen Bohold
    Commented Aug 8, 2013 at 17:27
  • 1
    @JenBohold: \log prints log as an operator in upright font. log in math mode is similar to the multiplication of three variables l, o and g. The same goes for \exp (multiplication of e, x and p).
    – Werner
    Commented Aug 8, 2013 at 17:30
8

This is how it looks with multline* (just to let you know):

\documentclass{article}
\usepackage{amsmath}
\begin{document}
\begin{multline*}
  \log\mathcal{L}(\alpha,\beta,\mu,\delta|  l_1,...,l_n)=\\
  \sum_{i=1}^n  \left(\log\left(\frac{\sqrt{\alpha^2-\beta^2}}{2\alpha\delta K_1 (\delta\sqrt{\alpha^2-\beta^2})} \exp\left(-\alpha\sqrt{\delta^2+(l-\mu)^2}+\beta(l-\mu)\right)\right)\right)
\end{multline*}
\end{document} 

enter image description here

3
  • 6
    I'd use this way rather than centering.
    – egreg
    Commented Aug 8, 2013 at 18:03
  • +1 Other tweaks: spacing around |, size of brackets (particularly the one after \exp) and their spacing. Commented May 27, 2017 at 8:50
  • @AndrewSwann thanks, but adding \mid and substituting \left and \right with correct sizes was not the aim of the last edit. Commented May 27, 2017 at 8:57
3

Just to comment on Karls suggestion, this is how I normally do this in order to get a more consistent look and feel. Note that the = is moved to the next line (this is generally a good idea it it may be overlooked overwise)

\documentclass{article}
\usepackage{mathtools} % autoloads amsmath
\begin{document}
\begin{align*}
  \MoveEqLeft\log\mathcal{L}(\alpha,\beta,\mu,\delta|  l_1,\dots,l_n)
 \\
  &=\sum_{i=1}^n  \left(\log\left(\frac{\sqrt{\alpha^2-\beta^2}}{2\alpha
    \delta K_1 (\delta\sqrt{\alpha^2-\beta^2})} \exp\left(-\alpha
  \sqrt{\delta^2+(l-\mu)^2}+\beta(l-\mu)\right)\right)\right)
 \end{align*}
 \end{document} 

\MoveEqLeft has a hidden & inside it, and will pull the line 2em backwards from the alignment point.

enter image description here

0

This stackengine solution has two features to note: 1) you can customize the gap between the lines (currently set to 10pt); and 2) you can choose the alignment of the equations, relative to each other (currently set centered "l", but can be set to "c" or "r").

\documentclass{article}
\usepackage{amsmath}
\usepackage{stackengine}
\begin{document}
\stackMath
\def\stackalignment{l}
\stackanchor[10pt]{\displaystyle%
  \log\mathcal{L}(\alpha,\beta,\mu,\delta|  l_1,...,l_n)=
}{\displaystyle
  \sum_{i=1}^n  \left(\log\left(\frac{\sqrt{\alpha^2-\beta^2}}{2\alpha\delta K_1 (\delta\sqrt{\alpha^2-\beta^2})} \exp\left(-\alpha\sqrt{\delta^2+(l-\mu)^2}+\beta(l-\mu)\right)\right)\right)
}
\end{document} 

enter image description here

The \stackMath macro is recently introduced to the stackengine package, and causes the stacking arguments to be processed in \textstyle math by default.

0

Check with the below tag:

\begin{gather}
log \mathcal{L}(\alpha,\beta,\mu,\delta|  l_1,...,l_n)=\\
\sum_{i=1}^n  \left( log \left(\frac{\sqrt{\alpha^2-\beta^2}}{2\alpha \delta K_1 (\delta\sqrt{\alpha^2-\beta^2})} exp\left(-\alpha\sqrt{\delta^2+(l-\mu)^2}+\beta(l-\mu)\right)\right) \right) 
\end{gather}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .