# Avoiding column alignment in IEEEeqnarray

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:

\begin{IEEEeqnarray}{rCll}
\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)
\end{IEEEeqnarray}


which results in

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?

• 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 +.

\documentclass[a4paper]{IEEEtran}
\usepackage{amsmath}
\begin{document}

\begin{align}
\phi(x, y, z) = \frac{V}{2\pi}\biggl(
&\arctan\biggl[\frac{(x_2-x)(z_2-z)}{y\,\sqrt{y^2+(x_2-x)^2+(z_2-z)^2}}\biggr]\nonumber\\
{}-{} &\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)
\end{align}

\end{document}


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.

\documentclass{ieeetran}
\usepackage{nccmath, mleftright}
\usepackage{lipsum}

\begin{document}

\lipsum[4]
\begin{fleqn}\setcounter{equation}{19}
\medmath {\begin{aligned}[b] \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)} \end{aligned}}
\end{fleqn}

\end{document}