# How to make all parts of fraction, except numerator, disappear while keeping original position of numerator (or how to align at numerator with &)?

I have split the issue I have into 2 problems and decided to post them at once to avoid semi-duplicate since they are closely related. First is to render all parts of a fraction (including the line) invisible except the numerator (or denominator), retaining position of that numerator. Second is to align a variable of an equation to a numerator of a fraction of another equation using aligned environment (which I failed to do with & character).

### original code:

\documentclass{standalone}
\usepackage[alignedleftspaceno]{amsmath}
\begin{document}
% \begin{aligned} &\frac{a}{\left(\frac{b}{c}\right)}=x\\ &a=x\cdot\frac{b}{c} \end{aligned}
\end{document} # Problem 1

### enclosing entire fraction except numerator (a) into \phantom makes numerator (a) itself disappear along with fraction and distorts alignment

&\frac{a}{\left(\frac{b}{c}\right)}=x\\
&\phantom{\frac{}a\phantom{}{\left(\frac{b}{c}\right)}}=x\cdot\frac{b}{c} ### enclosing denominator into \phantom keeps unwanted fraction-line:

&\frac{a}{\left(\frac{b}{c}\right)}=x\\
&\frac{a}{\phantom{\left(\frac{b}{c}\right)}}=x\cdot\frac{b}{c} # Problem 2

### aligning at numerator with & does not compile:

\frac{&a}{\left(\frac{b}{c}\right)}=x\\
&a=x\cdot\frac{b}{c}


The last piece of code was expected to align second-equation "a" not only horizontally with the first-equation numerator "a" (as shown in the image above) but also properly position it vertically with respect to the "equals" sign.

• you can avoid the fractionbar by using \genfrac from amsmath but I'm struggling to guess what you want \frac{&a} to do (even {&a} would hide the & from the alignment even if there was no fraction you can not align at arbitrary points in a subterm. – David Carlisle Oct 30 '17 at 20:31

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}{%
\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.

• @bp2017 Added some explanations – egreg Oct 31 '17 at 7:34
• you just have to hope that no passing amsmath maintainer sees this and adds an extra group, just to stop people poking in internals... – David Carlisle Oct 31 '17 at 9:20
• @DavidCarlisle I added the double jumping just in case somebody did that. – egreg Oct 31 '17 at 10:02
• I find Werner's genfrac solution for rendering parts of fraction invisible much easier to comprehend but since you also provided solution for numerator alignment, your answer is accepted. Thank you all. – bp2017 Oct 31 '17 at 16:07

You can use \genfrac from amsmath which provides generic fraction 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 \phantoms (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}

• @bp2017: It's defined inside TeX the Program's web code. However, the default is usually .4pt. – Werner Oct 31 '17 at 2:33
• For the reference, it seems that setting line thickness to any(?) negative value retains original spacing. – bp2017 Oct 31 '17 at 15:39

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} • @bp2017 See egreg's answer. – CarLaTeX Oct 31 '17 at 2:46