6

I have the following LaTeX eqnarray:

\begin{eqnarray}
    \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{eqnarray}

With this outcome:

enter image description here

Is it possible to align my \Leftrightarrow in a 3rd column?

David Carlisle
  • 757,742
casparjespersen
  • 165
  • 1
  • 1
  • 5

2 Answers2

15

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}

Peter Grill
  • 223,288
3

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.

Leone
  • 576
888
  • 153
  • Thanks. That does it. But now the lines are interpreted as text lines (with smaller fractions, integrals, etc.) - is there a way to change it to normal? I know I could use dfrac but how about the integrals? –  Nov 26 '12 at 12:29
  • I just edited. Now you can avoid \dfrac. –  Nov 26 '12 at 13:49
  • 1
    array for equations is just a written-out form of the mistakes of eqnarray — use the amsmath environments mentioned in Peter Grill’s answer. – wasteofspace Nov 28 '12 at 11:38