splitting the numerator of a fraction

99 views
Skip to first unread message

Ben Alpert

unread,
Jul 8, 2011, 7:00:37 PM7/8/11
to MathJax Users
I'm looking to do something like:

https://s3.amazonaws.com/uploads.hipchat.com/6574/26709/8hunqux8f4fao9o/upload.png

In the TeXBook, Knuth uses \atop and \hfill, but MathJax doesn't
support \hfill.

I tried to define my own \lrsplit{}{} command that takes the two parts
and turns them into a fraction with this code:

https://gist.github.com/1073033

Now none of my math renders! Can anyone provide some insight into how
to fix this or if there's a better way?

Ben Alpert

unread,
Jul 8, 2011, 9:39:53 PM7/8/11
to MathJax Users
Found my problem. All is good after replacing TEX with
MathJax.InputJax.TeX and MML with MathJax.ElementJax.mml, as defined
at the top of many files in the MathJax source.

On Jul 8, 4:00 pm, Ben Alpert <spicyjalap...@gmail.com> wrote:
> I'm looking to do something like:
>
> https://s3.amazonaws.com/uploads.hipchat.com/6574/26709/8hunqux8f4fao...

Davide P. Cervone

unread,
Jul 9, 2011, 8:15:34 AM7/9/11
to mathja...@googlegroups.com
Glad you were able to work it out.

You might consider defining TEX and MML at the top of your LRSplit
function, as this will be slightly more efficient than using direct
references in the rest of the code. Just a thought.

Davide

aRbEr

unread,
Dec 22, 2011, 10:55:17 AM12/22/11
to mathja...@googlegroups.com
Hi there,
I came through the same problem.... realised that \hfill is not supported. We (I am the cms programmer, but I haven't really worked on learning the mathjax syntax as the rest of "we" enters/produces it) tried the following code:

$t + 1\mathop{\left){\vphantom{1\begin{array}{l}
{t^3}\,\,\,\,\,\,\,\,\,\,\,\,\,\\
\begin{array}{*{20}{c}}
{\underline {{t^3} + {t^2}} \,\,\,\,\,\,\,\,\,\,\,\,\,\,\,}\\
{ - {t^2}\,\,\,\,\,\,\,\,\,}\\
{\underline { - {t^2} - t} }\\
{\,\,\,\,\,\,\,\,\,\,\,t}\\
{\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\underline {t + 1} }\\
{\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\, - 1}
\end{array}
\end{array}}}\right.
\!\!\!\!\overline{\,\,\,\vphantom 1{\begin{array}{l}
{t^3}\,\,\,\,\,\,\,\,\,\,\,\,\,\\
\begin{array}{*{20}{c}}
{\underline {{t^3} + {t^2}} \,\,\,\,\,\,\,\,\,\,\,\,\,\,\,}\\
{ - {t^2}\,\,\,\,\,\,\,\,\,}\\
{\underline { - {t^2} - t} }\\
{\,\,\,\,\,\,\,\,\,\,\,t}\\
{\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\underline {t + 1} }\\
{\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\, - 1}
\end{array}
\end{array}}}}
\limits^{\displaystyle\hfill\,\,\, {{t^2} - t + 1\,\,\,\,\,\,\,\,\,\,}}$

but it did not work cos \hfill failed. Is there any other way of accomplishing this, or should I follow Ben's solution. Ben has there been any other update on your custom command code?? The image below is what we are expecting to see.


image.gif
image.gif

Davide P. Cervone

unread,
Dec 23, 2011, 1:59:10 PM12/23/11
to mathja...@googlegroups.com
I would try something like

\dfrac{\kern .5em t^2-t\phantom{^2}+1\phantom{+0}} {\kern.5em\displaystyle\begin{array}{l} \llap{t+1\kern.5em\smash{\Big)}\raise.15em{\vphantom{\big)}}\atop} \dfrac{t^3+t^2}{\phantom{t^3}-t^2}\\ \hphantom{t^3} \dfrac{{}-t^2-t}{\phantom{{}-t^2-}t}\\ \hphantom{t^3-t^2-{}\!} \dfrac{t+1}{\phantom{t}-1} \end{array}}

but note that this includes spacing hacks, and so might lock slightly different for different viewers.  It works best with the HTML-CSS renderer and the MathJax fonts, somewhat less well with the STIX fonts, and not so good with Firefox's NativeMML rendering.

Davide


Davide P. Cervone

unread,
Dec 23, 2011, 4:40:43 PM12/23/11
to mathja...@googlegroups.com
Here's another possibility, but it requires mathJax v2.0 (because of the [t] option for \begin{array}).  

t-1\; \mathop{\overline{\smash{\Big)}
\begin{array}[t]{l} \,t^3+t^2-1\\ \dfrac{t^3+t^2}{\phantom{t^3}-t^2}\\ \hphantom{t^3} \dfrac{{}-t^2-t}{\phantom{{}-t^2-}t}\\ \hphantom{t^3-t^2-{}\!} \dfrac{t+1}{\phantom{t}-1} \end{array} }}^{\hphantom{\Big)}\,\textstyle t^2-t\phantom{^2}-1\phantom{{}+0}}

It doesn't have as much space hacking, so it works a bit more consistently across output renderers and fonts.  It also is more closely related to your original.  But again it requires MathJax v2.0 (e.g., the v2.0-candidate branch from my fork of MathJax).

Davide


On Dec 22, 2011, at 10:55 AM, aRbEr wrote:

aRbEr

unread,
Dec 29, 2011, 9:58:03 AM12/29/11
to mathja...@googlegroups.com
Thank you Davide,

I will save this and use it with v2.0 when it gets released....our app hasn't been released to public yet so ...that would work. Thank you again.
Reply all
Reply to author
Forward
0 new messages