Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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?

share|improve this question

migrated from stackoverflow.com Nov 28 '12 at 1:53

This question came from our site for professional and enthusiast programmers.

2 Answers 2

up vote 8 down vote accepted

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}
share|improve this answer

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}
\]

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

share|improve this answer
    
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? –  Caspar Aleksander Bang Jespers Nov 26 '12 at 12:29
    
I just edited. Now you can avoid \dfrac. –  888 Nov 26 '12 at 13:49
    
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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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