Align – Techniques for Aligning Expanded Parts of Fractions

alignfractions

I want to make it easier to see how a fraction has been expanded. I used \hfill to separate the expanded parts, but the "1s" are not in the center anymore.

How can I achieve this?

&= \frac{1}{x-y} - \frac{1}{y-x} \\
&= \frac{1\hfill*(y-x)}{(x-y)*(y-x)} - \frac{1\hfill*(x-y)}{(y-x)*(x-y)} \\

enter image description here

#edit: complete code for compiling

\documentclass{article}
\usepackage{amsmath}

\begin{document}
\begin{align*}
&= \frac{1}{x-y} - \frac{1}{y-x} \\
&= \frac{1\hfill*(y-x)}{(x-y)*(y-x)} - \frac{1\hfill*(x-y)}{(y-x)*(x-y)} \\
\end{align*}
\end{document}

Best Answer

I suggest you place the 1 in the numerator in a centered \parbox whose width is given by the first expression in the denominator. In the example below, that's done with the help of a macro called \onebox.

I would also consider replacing the * multiplication symbols with \cdot.

enter image description here

\documentclass{article} % or some other suitable document class
\usepackage{amsmath}    % for 'align*' environment
\usepackage{calc}
\newcommand\onebox[1]{\parbox{\widthof{$\textstyle #1$}}{\centering $1$}}
\begin{document}

\begin{align*}
&= \frac{1}{x-y} - \frac{1}{y-x} \\
&= \frac{\onebox{(x-y)}*(y-x)}{(x-y)*(y-x)} - \frac{\onebox{(y-x)}*(x-y)}{(y-x)*(x-y)} 
\end{align*}

\begin{align*}
&= \frac{1}{x-y} - \frac{1}{y-x} \\
&= \frac{\onebox{(x-y)}\cdot(y-x)}{(x-y)\cdot(y-x)} - \frac{\onebox{(y-x)}\cdot(x-y)}{(y-x)\cdot(x-y)} 
\end{align*}

\end{document}