I don't know whether this is really a good idea or not, but I'm wondering if it's possible to implement a version of \frac where the numerator and denominator can be aligned at an alignment tab (&).
There are many questions about fraction alignment on this site, with the most obvious solution in many cases being to use \hfill. But consider a fraction like this one:
The top one looks, to my eyes, a little messy, but using \hfill moves the numerator too far to the left. What I really want (I think) is to align them exactly at the open bracket. So I'm imagining an \alignedfrac command that would allow me to write
\[
\alignedfrac{q&(x\mid y)}{p_\mathrm{foo}&(w\mid x,y,z)}
\]
and have that align the numerator and denominator at the & characters.
I'm aware that this may or may not actually be a good choice, and that I'm probably solving a non-problem, but still, I'm curious whether it's possible to implement something like this.
Here's the MWE that produces the image above:
\documentclass{article}
\begin{document}
\noindent without any alignment:
[
\frac{q(x\mid y)}{p_\mathrm{foo}(w\mid x,y,z)}
]
using hfill:
[
\frac{q(x\mid y)\hfill}{p_\mathrm{foo}(w\mid x,y,z)}
]
\end{document}



|replaced with\mid. – Mico Apr 01 '22 at 00:40\midor|looks better in any given context. – N. Virgo Apr 01 '22 at 01:57