2

I'm trying to compile the following code:

\documentclass{article}
\usepackage{amsmath}

\newcommand{\invexpsqrt}[1]{{#1}^{- \tfrac{1}{2}}}

\begin{document}
\begin{align}
\begin{split}
\rho_{out} &= \exp \left[ - \frac{1}{2} \left( x \cdot \gamma \cdot x + x' \cdot \gamma \cdot x' \right) + x \cdot \beta \cdot x' \right] \\
&= \exp \left[- \frac{1}{2} \left( V \gamma_D^{-\tfrac{1}{2}} y V^T \gamma_D V V^T \gamma_D^{- \tfrac{1}{2}} y + V \invexpsqrt{\gamma_D} y' V^T \gamma_D V V^T \invexpsqrt{\gamma_D} y' \right) \right. \\
&\qquad \qquad \left. + V \invexpsqrt{\gamma_D} y \beta V^T \invexpsqrt{\gamma_D} y' \right] \\
&= \exp \left[ - \frac{1}{2} \left( y \cdot y + y' \cdot y' \right) + y \cdot \left( \invexpsqrt{\gamma_D} V \beta V^T \invexpsqrt{\gamma_D} \right) \cdot y' \right] \\
&= \exp \left[ - \frac{1}{2} \left( y \cdot y + y' \cdot y' \right) + y \cdot \beta' \cdot y' \right]
\end{split}
\end{align}
\end{document}

to get a single, vertically centered equation number. However, my output comes out like this: Misaligned equation number

I have tried replacing the align environment with the equation environment and using \aligned within \equation. All of these yield the same result. Is there a command in my code that messes up the alignment, or is this problem caused by my compiler?

Edit: I just noted that another piece of code like this in the same file does not produce the same problem. Could it be that the second line of equations is too wide and therefore 'pushes' the numbering down?

  • I believe I saw an example using align somewhere when trying to troubleshoot this. As I said, I have used both equation and align, producing the same result. align happened to be the last I tried, after which I didn't change it back. – LSchoon May 26 '14 at 12:05
  • Welcome to TeX.SX! You can have a look at our starter guide to familiarize yourself further with our format. Please refer to the other example if you remember the page. – strpeter May 26 '14 at 12:10
  • @strpeter Thank you for the edit and the link to the starter guide. I unfortunately lost the other example, but the solution I suggested in my edit seems to work. As the starter guide does not say this: is it reasonable to add this solution as an answer, thereby answering my own question? – LSchoon May 26 '14 at 12:14
  • 1
    Yes, the reason the number is pushed down is that the second line is too long. Would also be helpful if you added the definition of \invexpsqrt to the example. Answering your own question is in general perfectly fine, or even recommended. Edit: A similar question was asked here: tex.stackexchange.com/questions/3579/… – Torbjørn T. May 26 '14 at 12:17
  • I don't have enough reputation to answer the question for another 7 hours. Will add the answer then. Thanks for the link @TorbjørnT. I will remember that solution in the future. – LSchoon May 26 '14 at 12:28
2

If you want the single equation number to be centered vertically on the group of aligned equations, it's best to use a single equation environment containing a split environment.

A couple of additional suggestions: (1) Use the macro \invexpsqrt{\gamma_D} consistently (the second line doesn't contain them in your MWE). (2) Don't use auto-sized parentheses and bracket as they're a bit too large for the job at hand; use \Bigl and \Bigr instead.

With these adjustments in place, there's enough room to place the equation number right where you want it to be.

enter image description here

\documentclass{article}
\usepackage{amsmath}
\newcommand{\invexpsqrt}[1]{#1^{-\frac{1}{2}}}
\begin{document}
\begin{equation}
\begin{split}
\rho_{out} 
&= \exp \Bigl[ -\tfrac{1}{2} \Bigl( x \cdot \gamma \cdot x + x' \cdot \gamma \cdot x' \Bigr) + x \cdot \beta \cdot x' \Bigr] \\
&= \exp \Bigl[-\tfrac{1}{2} \Bigl( V \invexpsqrt{\gamma_D} y V^T \gamma_D V V^T \invexpsqrt{\gamma_D} y + V \invexpsqrt{\gamma_D} y' V^T \gamma_D V V^T \invexpsqrt{\gamma_D} y' \Bigr)  \\
&\qquad \qquad  + V \invexpsqrt{\gamma_D} y \beta V^T \invexpsqrt{\gamma_D} y' \Bigr] \\
&= \exp \Bigl[ -\tfrac{1}{2} \Bigl( y \cdot y + y' \cdot y' \Bigr) + y \cdot \Bigl( \invexpsqrt{\gamma_D} V \beta V^T \invexpsqrt{\gamma_D} \Bigr) \cdot y' \Bigr] \\
&= \exp \Bigl[ -\tfrac{1}{2} \Bigl( y \cdot y + y' \cdot y' \Bigr) + y \cdot \beta' \cdot y' \Bigr]
\end{split}
\end{equation}
\end{document}
  • This seems to work. However, it seems that the biggest difference in horizontal space when comparing your code to mine is the result of using tfrac instead of frac and not the different parentheses. – LSchoon May 26 '14 at 13:19
  • You're right, that's another change I would suggest making. Using the smaller fractions makes them better proportioned to the large brackets. – Mico May 26 '14 at 13:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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