Nice display of proof steps without eqnarray
Sorry, eqnarray
has so many limitations that even being forced to do some tricks has its advantages. For instance, eqnarray
can never be broken across pages, whereas your proof steps might be so long that a page break could become necessary.
\documentclass{article}
\usepackage{mathtools}
\newcommand{\alignedrel}[2]{%
\Cen{2}{\overset{#1}{#2}{}}%
}
\makeatletter
\newcommand{\Cen}[2]{% see http://tex.stackexchange.com/a/209732/4427
\ifmeasuring@
#2%
\else
\makebox[\ifcase\expandafter #1\maxcolumn@widths\fi][c]{$\displaystyle#2$}%
\fi
}
\makeatother
\begin{document}
\begin{alignat*}{2}
f(x,y,z)
& \alignedrel{}{=}
&& \frac{g(x,y,z)}{h(x,y,z)}\\
& \alignedrel{}{=}
&& \left\lfloor\frac{\frac{\frac{x}{z}}{y}+\frac{y}{z}}{\frac{z}{y} + \frac{y}{x}}\right\rfloor\\
& \alignedrel{\text{(condition1)}}{=}
&& \left\lfloor\frac{\frac{a}{b}+\frac{\frac{c}{a}}{b}}{\frac{c}{a} + \frac{b}{a}}\right\rfloor\\
& \alignedrel{\text{(condition2)}}{=}
&& 42
\end{alignat*}
\end{document}
Rather than overburden some of the =
symbols with too much information, I would recommend that you provide a normal-language sentence after the group of equations to explain, in words, why the final two equalities hold.
Oh, and I would definitely use an align*
environment, not an eqnarray*
environment.
\documentclass{article}
\usepackage{mathtools}
\DeclarePairedDelimiter{\floor}{\lfloor}{\rfloor}
\begin{document}
\begin{align*}
f(x,y,z)
&= \frac{g(x,y,z)}{h(x,y,z)}\\
&= \floor*{\frac{\frac{x/z}{y}+\frac{y}{z}}{\frac{z}{y} + \frac{y}{x}}}\\
&= \floor*{\frac{\frac{a}{b}+\frac{c/a}{b}}{\frac{c}{a} + \frac{b}{a}}}\\
&= 42.
\end{align*}
The second-to-last equality follows because the sky is red (Condition~1), and the final equality holds because it is the answer (Condition~2).
\end{document}
Addendum to address the OP's follow-up comment: If you have relation symbols that have different widths, e.g., =
and \hookrightarrow
, you could still use an align environment, by reversing the order of the relation symbols and the &
symbols, as is shown in the following example. (The {}
particle are there to get the right amount of spacing.)
\begin{align*}
f(x,y,z)
={}& \frac{g(x,y,z)}{h(x,y,z)}\\
={}& \floor*{\frac{\frac{x/z}{y}+\frac{y}{z}}{\frac{z}{y} + \frac{y}{x}}}\\
\hookrightarrow{}& \floor*{\frac{\frac{a}{b}+\frac{c/a}{b}}{\frac{c}{a} + \frac{b}{a}}}\\
={}& 42.
\end{align*}
some possibilities
\documentclass{article}
\usepackage{array}
\usepackage{mathtools}
\newlength\mylength
\begin{document}
eqnarray
\begin{eqnarray*}
f(x,y,z) & = & \frac{g(x,y,z)}{h(x,y,z)}\\
& = & \left\lfloor\frac{\frac{\frac{x}{z}}{y}+\frac{y}{z}}{\frac{z}{y} + \frac{y}{x}}\right\rfloor\\
& \stackrel{(\mathit{condition1})}{=} & \left\lfloor\frac{\frac{a}{b}+\frac{\frac{c}{a}}{b}}{\frac{c}{a} + \frac{b}{a}}\right\rfloor\\
& \stackrel{(\mathit{condition2})}{=} & 42
\end{eqnarray*}
array in display
{\setlength\extrarowheight{10pt}
\[\begin{array}{@{} >\displaystyle r @{\;}
>{\displaystyle{}} c <{{}} @{\;}
>\displaystyle l @{}}
f(x,y,z) & = & \frac{g(x,y,z)}{h(x,y,z)}\\
& = & \left\lfloor\frac{\frac{\frac{x}{z}}{y}+\frac{y}{z}}{\frac{z}{y} + \frac{y}{x}}\right\rfloor\\
& \stackrel{(\mathit{condition1})}{=} & \left\lfloor\frac{\frac{a}{b}+\frac{\frac{c}{a}}{b}}{\frac{c}{a} + \frac{b}{a}}\right\rfloor\\
& \stackrel{(\mathit{condition2})}{=} & 42
\end{array}\]
\renewcommand{\arraystretch}{1}}
align
\begingroup
\settowidth\mylength{$\scriptstyle(\mathit{condition2})$}
\newcommand\condeq[1]{\stackrel{\makebox[\mylength]{$\scriptstyle#1$}}{=}}
\begin{align*}
f(x,y,z) & \condeq{} \frac{g(x,y,z)}{h(x,y,z)}\\
& \condeq{} \left\lfloor\frac{\frac{\frac{x}{z}}{y}+\frac{y}{z}}{\frac{z}{y} + \frac{y}{x}}\right\rfloor\\
& \condeq{(\mathit{condition1})} \left\lfloor\frac{\frac{a}{b}+\frac{\frac{c}{a}}{b}}{\frac{c}{a} + \frac{b}{a}}\right\rfloor\\
& \condeq{(\mathit{condition2})} 42
\end{align*}
\endgroup
$(\mathit{condition1})$ holds since the sky is red and $(\mathit{condition2})$ because this is the answer.
\end{document}