Aligning 3 Columns In LaTeX Eqnarray


Answer :

You should avoid eqnarray. See \eqnarray vs \align.

I'd recommend using align or alignat from amsmath package:

enter image description here

Both align and alignat provide pairs of rl alignment columns. So, I used a && before the \Leftrightarrow assuming that the next column was to be right aligned.

Code:

\documentclass{article} \usepackage{amsmath}  \begin{document}\noindent Using \verb|align|:  \begin{align}     \int ( D \frac{d^2 P(x)}{dx^2}-\frac{d}{dx}[u(x)P(x)] ) &= \int 0 &&\Leftrightarrow \\     D \frac{d}{dx} P(x) - u(x)P(x)                          &= C      &&\Leftrightarrow \\     D \frac{d}{dx} P(x) - K_0P(x) - \frac{K_1}{x}P(x)       &= C      &&\Leftrightarrow \\     \frac{dP(x)}{dx} - k_0P(x) - \frac{k_1}{x} P(x)         &= C, \end{align} Using \verb|alignat|:  \begin{alignat}{4}     \int ( D \frac{d^2 P(x)}{dx^2}-\frac{d}{dx}[u(x)P(x)] ) &= \int 0 &&\Leftrightarrow \\     D \frac{d}{dx} P(x) - u(x)P(x)                          &= C      &&\Leftrightarrow \\     D \frac{d}{dx} P(x) - K_0P(x) - \frac{K_1}{x}P(x)       &= C      &&\Leftrightarrow \\     \frac{dP(x)}{dx} - k_0P(x) - \frac{k_1}{x} P(x)         &= C, \end{alignat} \end{document} 

The equationarray doesn't allow more than 3 columns, but you can get what you want with the array environment.

\[    \begin{array}{cccc}       \int ( D \frac{d^2 P(x)}{dx^2}-\frac{d}{dx}[u(x)P(x)] ) & = & \int 0 & \Leftrightarrow \\       D\frac{d}{dx} P(x) - u(x)P(x) & = & C & \Leftrightarrow \\       D\frac{d}{dx} P(x) - K_0P(x) - \frac{K_1}{x}P(x) & = & C & \Leftrightarrow \\       \frac{dP(x)}{dx} - k_0P(x) - \frac{k_1}{x} P(x) & = & C &,    \end{array} \] 

result

If you dont like the alignment obtained you can modify it for example replacing {cccc} with {rclr}, or whatever you prefer.


Comments

Popular posts from this blog

Are Regular VACUUM ANALYZE Still Recommended Under 9.1?

Can Feynman Diagrams Be Used To Represent Any Perturbation Theory?