I want to write a long division equation upside down in Mathjax.
However, googling with similar keywards like 'longdiv upside down' did not give me a good solution.
A solution in Write this division method in latex has vertical bar, but I want a bent bar.
I found another solution from the link and modified \longdiv form to )\underbar form. This is the most similar to what I wanted, but both \underline{sth} and \underline{\smash{sth}} have a little gap at the edge. Their edge don't fit as good as \longdiv.
This is my question.
Can you tell me a grammar of this if it exist? Actually, I don't know whether this grammar exists.
The following is part of Mathjax code I made and the image of actual result.
Sorry for the wrong way of numbers written, as it is a prototype. Please focus on the division symbol.
$$
\require{enclose}
\begin{array}{rll}
4 \underline{\smash{)500\phantom{0}}} && \hbox{($4 \times 1 = 4$)} \[-3pt]
10\phantom{00} && \hbox{($5 - 4 = 1$)} \[-3pt]
\underline{) \phantom{0}8\phantom{00}} && \hbox{($4 \times 2 = 8$)} \[-3pt]
\phantom{00}20 \phantom{0} && \hbox{($10 - 8 = 2$)} \[-3pt]
\underline{)\phantom{0}20 \phantom{0}} && \hbox{($4 \times 5 = 20$)} \[-3pt]
\phantom{0}0 \phantom{0}
\end{array}
$$

longdivisionpackage? – Jasper Habicht Jul 05 '23 at 10:31