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:

\documentclass{article}
\usepackage{nicefrac}
\usepackage{amsmath,amssymb}
\begin{document}

\begin{align*}
f_X(x)&=\frac{1}{2 \pi} \exp ( -x^2/2 )   &\forall x \in \mathbb{R} \\
g(x)&=(x^2-1)/2   &\forall x \in \mathbb{R} \\
\intertext{ so}
g'(x) &= x\\
g^{-1}(y)&= \pm \sqrt{2y+1}\\
\intertext{ Then}
f_Y(y) &= \frac{f_X(g^{-1}(y))}{g'(g^{-1}(y))}\\
&=  \frac{1}{|\pm \sqrt{2y+1}|}   \frac{1}{\sqrt{2 \pi}} \exp \left( -y-\nicefrac{1}{2} \right)\\
\intertext{where the support for $f_Y$ is $ y \in [(0-1)/2, \infty) = [-\nicefrac{1}{2} , \infty)$}
&= \frac{2}{\sqrt{2y+1}\sqrt{2 \pi}}  \exp \left( -y-\nicefrac{1}{2} \right)  &\forall y \in  [-\nicefrac{1}{2} , \infty) 
\end{align*}

\end{document}

The problem is that I would like all the \forall to be aligned, but only the top 2 are, and the one on the bottom line is positioned to the left of the 2 at the top. I was under the impression that using & would cause the relevant items immediately following to be aligned, which is working fine for the = but not the \foralls.

share|improve this question
4  
The rule for the align environments is: rlrlrl…. You need an additional & in front of \forall. –  Qrrbrbirlbel Oct 13 '12 at 21:31
    
Are you sure you want to use \nicefrac? The result doesn't seem good at all. –  egreg Oct 13 '12 at 21:32
    
@egreg thanks for your comment (much appreciated as I am a beginner in LaTeX). Do you think this is better $\left[-\frac{1}{2} , \infty \right)$ ? –  Robert Long Oct 13 '12 at 21:52
    
@egreg Actually, it was the \nicefrac after the exp that seemed better to me. This didn't look good to me: ` \exp \left( -y-\frac{1}{2} \right)` –  Robert Long Oct 13 '12 at 22:01
    
@longrob Definitely $[-1/2,\infty)$ or, less preferably, $[-\frac{1}{2},\infty)$. I'd perhaps use \frac{1}{2} in the arguments to \exp. Your usages of \left and \right are not needed and should be avoided here and in these situations. –  egreg Oct 13 '12 at 22:01
show 2 more comments

1 Answer 1

up vote 10 down vote accepted

You just need an additional & before the \foralls.

The reason for this is given in Qrrbrbirlbel's comment to the question, the alignment of an align are rlrlrl..., a right-aligned column followed by a left-aligned column, right, left etc. Hence, with just one &, the \foralls end up in a right-aligned column, while you want them left-aligned.

See also section 3.6 Equation groups with mutual alignment in the amsmath manual.

\documentclass{article}
\usepackage{nicefrac,amsmath,amssymb}
\begin{document}

\begin{align*}
f_X(x)&=\frac{1}{2 \pi} \exp ( -x^2/2 )  & &\forall x \in \mathbb{R} \\
g(x)&=(x^2-1)/2   & &\forall x \in \mathbb{R} \\
\intertext{ so}
g'(x) &= x\\
g^{-1}(y)&= \pm \sqrt{2y+1}\\
\intertext{ Then}
f_Y(y) &= \frac{f_X(g^{-1}(y))}{g'(g^{-1}(y))}\\
&=  \frac{1}{|\pm \sqrt{2y+1}|}   \frac{1}{\sqrt{2 \pi}} \exp \left( -y-\nicefrac{1}{2} \right)\\
\intertext{where the support for $f_Y$ is $ y \in [(0-1)/2, \infty) = [-\nicefrac{1}{2} , \infty)$}
&= \frac{2}{\sqrt{2y+1}\sqrt{2 \pi}}  \exp \left( -y-\nicefrac{1}{2} \right) & &\forall y \in  [-\nicefrac{1}{2} , \infty) 
\end{align*}

\end{document}

enter image description here

share|improve this answer
    
Brilliant ! +1 thanks so much for the explanation. –  Robert Long Oct 13 '12 at 21:54
add comment

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.