How to make all parts of fraction, except numerator, disappear while keeping original position of numerator (or how to align at numerator with `&`)?
You can use \genfrac
from amsmath
which provides gen
eric frac
tion primitives:
\genfrac{<ldelim>}{<rdelim>}{<rule thickness>}{<math style>}{<numerator>}{<denominator>}
This works fine if you wish to hide the rule (setting <rule thickness>
to 0pt
) and \phantom
the denominator (equation (1) below):
However, hiding the numerator in the same way pushes the denominator up by the default rule thickness (equation (2) above). Instead, it's almost easier to use a combination of \phantom
s (for content you want to hide) and colour (for hiding the rule) (equation (3) above):
\documentclass{article}
\usepackage{amsmath,xcolor}
\begin{document}
\begin{align}
% \frac{a}{\left(\frac{b}{c}\right)} &= x \\
% \frac{a}{\phantom{\left(\frac{b}{c}\right)}} &= x \\
% \genfrac{}{}{0pt}{}{a}{\phantom{\left(\frac{b}{c}\right)}} &= x \\
\frac{a}{\left(\frac{b}{c}\right)} =
\frac{a}{\phantom{\left(\frac{b}{c}\right)}} =
\genfrac{}{}{0pt}{}{a}{\phantom{\left(\frac{b}{c}\right)}} &= x \\
\frac{a}{\left(\frac{b}{c}\right)} =
\frac{\phantom{a}}{\left(\frac{b}{c}\right)} =
\genfrac{}{}{0pt}{}{\phantom{a}}{\left(\frac{b}{c}\right)} &= x \\
\frac{a}{\left(\frac{b}{c}\right)} =
\frac{\phantom{a}}{\left(\frac{b}{c}\right)} =
{\color{white}\frac{\phantom{a}}{\color{black}\left(\frac{b}{c}\right)}} &= x
\end{align}
\end{document}
Don't tell anybody, it's a secret trick.
\documentclass[border=4]{standalone}
\usepackage{amsmath}
\newcommand{\latehfil}{\aftergroup\aftergroup\aftergroup\hfil}
\begin{document}
$\begin{aligned}
\frac{a}{\left(\frac{b}{c}\right)} &= x \\
a\latehfil &= x\cdot\frac{b}{c}
\end{aligned}$
\end{document}
If you also want to keep the “a” at the same height, but I can see no reason to,
\documentclass[border=4]{standalone}
\usepackage{amsmath}
\newcommand{\latehfil}{\aftergroup\aftergroup\aftergroup\hfil}
\newcommand{\fraconlynumerator}[2]{%
\begingroup
\sbox0{$\displaystyle\frac{#1}{#2}$}%
\raisebox{\dimexpr\ht0-\height}{$\displaystyle#1$}%
\endgroup
}
\begin{document}
$\begin{aligned}
\frac{a}{\left(\frac{b}{c}\right)} &= x \\
\fraconlynumerator{a}{\left(\frac{b}{c}\right)}\latehfil &=x\cdot\frac{b}{c}
\end{aligned}$
\end{document}
What's \latehfil
? The cells in odd numbered columns of aligned
end up into a box containing
\hfil$\displaystyle{<cell>}$
and we want to add another \hfil
. If we just issue a\hfil
, the \hfil
would end up in the braced subformula and have no effect. However, a\aftergroup\hfil
would save \hfil
for after the }
. With \aftergroup\aftergroup\aftergroup\hfil
, the steps are similar to
\hfil$\displaystyle{a\aftergroup\aftergroup\aftergroup\hfil}$
\hfil$\displaystyle{a}\aftergroup\hfil$
\hfil$\displaystyle{a}$\hfil
because the token following \aftergroup
reappears after the group ends. A single \aftergroup
might suffice, but symmetry is nicer.
The second trick is: measure the height of the full fraction. Then typeset just the numerator, raising it by the height of the full fraction minus its actual height.
Is this what you're looking for?
\documentclass{standalone}
\usepackage[alignedleftspaceno]{amsmath}
\begin{document}
$
\begin{array}{c@{\;=\;}l}
\displaystyle\frac{a}{\left(\frac{b}{c}\right)}&x\\
a &x\cdot\frac{b}{c}
\end{array}
$
\end{document}