I am trying to align an expression that extends over multiple lines in such a way that certain terms in the expression are aligned with respect to each other. So far I am using the following with IEEEeqnarray:

    \phi(x, y, z) & = & \frac{V}{2\pi}\left( & \arctan\left[\frac{(x_2-x) (z_2-z)}{y\,\sqrt{y^2+(x_2-x)^2+(z_2-z)^2}}\right]\right.\nonumber\\
    && -\> & \arctan\left[\frac{(x_1-x)(z_2-z)}{y\,\sqrt{y^2+(x_1-x)^2+(z_2-z)^2}}\right]\nonumber\\
    && -\> & \arctan\left[\frac{(x_2-x)(z_1-z)}{y\,\sqrt{y^2+(x_2-x)^2+(z_1-z)^2}}\nonumber\right]\\
    && +\> & \left.\arctan\left[\frac{(x_1-x)(z_1-z)}{y\,\sqrt{y^2+(x_1-x)^2+(z_1-z)^2}}\right]\right)

which results in enter image description here

However, there are two things that I would like to improve:

1) I want to avoid aligning the "-" and "+" signs in lines 2-4 with the V/(2pi) in line 1. All the arctan functions should be aligned with each other (I have achieved that) and the "-" and "+" signs should have the normal distance from the arctan functions. So the signs should be indented relative to V/(2pi), while the arctan should remain aligned with each other. How can I do this?

2) The left parenthesis on the first line should be of the correct size to match the size of the right parenthesis. I suspect the problem is that \left( comes before & in the code for the first line, so the \right. at the end of the first line is somehow discarded. How can this be done?

  • 1
    Can you use one of the amsmath environments? – Bernard Jul 20 '18 at 18:44

You can simply use the align environment from amsmath. Alignment inside \left and \right doesn't work, so, it's better use manual sizes like \big, \Big,\bigg,\Bigg, these allow alignment marks & and are manually fine tuned (automatic \left and \right tend to be too large). Also, use {}-{} and {}+{} for correct spacing around the binary operators - and +.


\phi(x, y, z) = \frac{V}{2\pi}\biggl( 
{}-{} &\arctan\biggl[\frac{(x_1-x)(z_2-z)}{y\,\sqrt{y^2+(x_1-x)^2+(z_2-z)^2}}\biggr]\nonumber\\
{}-{} &\arctan\biggl[\frac{(x_2-x)(z_1-z)}{y\,\sqrt{y^2+(x_2-x)^2+(z_1-z)^2}}\biggr]\nonumber\\
{}+{} &\arctan\biggl[\frac{(x_1-x)(z_1-z)}{y\,\sqrt{y^2+(x_1-x)^2+(z_1-z)^2}}\biggr]\biggr)


enter image description here


Here is a possibility with the fleqn environment and the \medmath command (medium-sized formulæ, ~ 80 % of display style), both from nccmath (which loads amsmath). If you absolutely want the formula in normal, display size, you'll have either to align arctan only in the last three equations, or add a fifth line.

\usepackage{nccmath, mleftright}


    \phi(x, y, z) = \frac{V}{2\pi} \Biggl(\! &\arctan\mleft[\frac{(x_2-x) (z_2-z)}{y\,\sqrt{y^2+(x_2-x)^2+(z_2-z)^2}}\mright] \\
    {}-{} &\arctan\mleft[\frac{(x_1-x)(z_2-z)}{y\,\sqrt{y^2+(x_1-x)^2+(z_2-z)^2}}\mright] \\
   {} - {}&\arctan\mleft[\frac{(x_2-x)(z_1-z)}{y\,\sqrt{y^2+(x_2-x)^2+(z_1-z)^2}} \mright]\\
   {} + {}&{\mleft.\arctan\mleft[\frac{(x_1-x)(z_1-z)}{y\,\sqrt{y^2+(x_1-x)^2+(z_1-z)^2}}\mright]\mright)}


enter image description here

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.