Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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?

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

4 Answers 4

up vote 4 down vote accepted

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.

share|improve this answer
    
thanks, but what is the difference between \log and log? I like the cursive log? –  Jen Bohold Aug 8 '13 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 Aug 8 '13 at 17:30

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

share|improve this answer
4  
I'd use this way rather than centering. –  egreg Aug 8 '13 at 18:03

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

share|improve this answer

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.