MathJax and bbox support

295 views
Skip to first unread message

Stephan Claus

unread,
Feb 25, 2012, 7:17:05 AM2/25/12
to MathJax Users
Hello,

I'm currently switching from mathjs to mathjax and ran into a little
problem using the bbox extension mentioned here:

http://groups.google.com/group/mathjax-users/browse_thread/thread/d597f7b4a7d5da1e/4a09a8e72eeb2422?lnk=gst&q=bbox#4a09a8e72eeb2422

The height of the created boxes are not always right with the hight of
its content:

\begin{align*}
\int \sin{(x)}\text{\boxe{$\cos{(x)}$}} \text{\boxe{$d x$}} &= \int
\cancel{\sin{(x)}}*\text{\boxe{$z$}} \text{\boxe{$\lb -\frac{d z }
{\cancel{\sin{(x)}}}\rb$}} \\
&= \int -z d z\\
&= -\frac{1}{2} z^2 + c
\end{align*}

the last box with the fraction in it get the same height as the other
boxes with just one Element in it.

Is there a way to fix this? Or is it planned for a future release?



Thanks for your help best begards
stephan c.

Davide P. Cervone

unread,
Feb 25, 2012, 9:20:07 AM2/25/12
to mathja...@googlegroups.com
Since MathJax doesn't process macros within \text{} (except within any
math delimiters it contains), I don't see how your \boxe macro is
going to be used at all. I'm also confused by the need for \text in
the first place. What are you trying to accomplish?

Note that \bbox and \cancel are included in MathJax v2.0, so you won't
have to add them yourself once that it released this weekend.

In any case, you will need to give us your definition of \boxe before
we can determine anything. Also, what are \lb and \rb? If you could
point to a page the includes this code, that might help.

Davide

Stephan Claus

unread,
Feb 25, 2012, 11:34:24 AM2/25/12
to MathJax Users
Hello Davide,

okay, this post was sloppy, I try to explain:

\lb and \rb are just short commands for \left( and \right).

What I try to acomplish is to put parts of displayed math in a box
with a certain border color - I therefore defined myself
boxa,boxb,boxc,boxd,boxe for the colors I want to use:

% Colors
\colorlet{c1}{blue}

\newcommand{\boxa}[1]{\color{c1}{{\ovalbox{\color{black}#1}}}
\color{black}}
...

this is the only way (as far as i know) to get colored boxes in latex
math enviroment.

Before I inserted this code into my former jsMath enviroment I parsed
the files and created something like this:

begin{align*}
\text{\boxa{$5$}}
\end{align*}

\bbox[#ffffff,1pt,border:2px solid blue;border-radius:5px;]{5}

(the border-radius was just a css hack to get the rounded corners. the
color is replaced by a mapping of the letter attached to the box, in
this case "a" means blue)

I did all that to get a similar representation in my latex-pdf files
AND on the website.

I'm really looking forward to test MathJax v2.0 to see how bbox works
- and if there is a way to get the height of boxes matches to the
height of the content.
Or is there a misstake on my side?

best regards
stephan c.

On 25 Feb., 15:20, "Davide P. Cervone" <d...@union.edu> wrote:
> Since MathJax doesn't process macros within \text{} (except within any
> math delimiters it contains), I don't see how your \boxe macro is
> going to be used at all.  I'm also confused by the need for \text in
> the first place.  What are you trying to accomplish?
>
> Note that \bbox and \cancel are included in MathJax v2.0, so you won't
> have to add them yourself once that it released this weekend.
>
> In any case, you will need to give us your definition of \boxe before
> we can determine anything.  Also, what are \lb and \rb?  If you could
> point to a page the includes this code, that might help.
>
> Davide
>
> On Feb 25, 2012, at 7:17 AM, Stephan Claus wrote:
>
>
>
>
>
>
>
> > Hello,
>
> > I'm currently switching from mathjs to mathjax and ran into a little
> > problem using the bbox extension mentioned here:
>
> >http://groups.google.com/group/mathjax-users/browse_thread/thread/d59...

Stephan Claus

unread,
Feb 25, 2012, 11:42:40 AM2/25/12
to MathJax Users
Here is the translated code of my former example which i want to be
rendered by MathJax - the problem is that the height of the box
containg the fraction has the same height as the other boxes just
containing a one-line element.

\begin{align*}
\int \sin{(x)}\text{\boxa{$\cos{(x)}$}} \text{\boxa{$d x$}} &= \int
\cancel{\sin{(x)}}*\text{\boxa{$z$}} \text{\boxa{$\lb -\frac{d z }
{\cancel{\sin{(x)}}}\rb$}} \\
\end{align*}

\begin{align*}
\int \sin{(x)}\bbox[#ffffff,1pt,border:2px solid blue;border-radius:
5px;]{\cos{(x)}} \bbox[#ffffff,1pt,border:2px solid blue;border-
radius:5px;]{d x} &= \int \cancel{\sin{(x)}}*\bbox[#ffffff,1pt,border:
2px solid blue;border-radius:5px;]{z} \bbox[#ffffff,1pt,border:2px
solid blue;border-radius:5px;]{\left( -\frac{d z }
{\cancel{\sin{(x)}}}\right)}
\end{align*}

stephan

Davide P. Cervone

unread,
Feb 27, 2012, 2:38:07 PM2/27/12
to mathja...@googlegroups.com
I had forgotten that the proper handling of bounding boxes was part of
v2.0 (since I had written it so long ago), and that is why your
fraction wasn't being handle well. This should work better in v2.0
(now released). The only thing that isn't supported is the border-
radius. I will put that on the list for future inclusion.

The heights of the boxes should work as you hope in v2.0.

Davide

Stephan Claus

unread,
Feb 28, 2012, 5:47:44 AM2/28/12
to MathJax Users
Hello Davide,

yes, it works perfectly. A parameter (or simply a class attached for
the boxes) would be great to enable the rounded corners.
I think the second version would be even better because you could
handle the diffrent browser displays just from the css side.

Thanks for the great work
stephan
Reply all
Reply to author
Forward
0 new messages