Boxing an equation,

117 views
Skip to first unread message

Krix Ian

unread,
May 23, 2013, 9:55:56 PM5/23/13
to mathja...@googlegroups.com
Hi,
I have a question:
How can I box an equation?
Currently I'm using \boxed and \fbox , but I always have problem aligning it
when I try to put it inside \begin{aligned}

Example code I'm making:
\begin{equation}
\begin{aligned}
1+1&=2
2+2&=4
3+3&=6
\boxed{4+4&=8}
\end{aligned}
\end{equation}

There's an error always popping out saying that I misplaced &.
How can I do this just like the same with LaTeX? I think I need the Math Tools
Package (to use \Aboxed) for this but I can't find one.

Thanks!

Davide P. Cervone

unread,
May 24, 2013, 10:07:40 AM5/24/13
to mathja...@googlegroups.com
The \boxed macro can't span multiple columns of an alignment (the same is true in LaTeX).  MathJax doesn't have a means of doing this, because MathJax's internal representation is MathML, and there is no natural way to do this in MathML that I know of.

It is possible to "fake" it,but you won't like it (I don't either).  Here is one possibility:

\begin{equation}
\require{enclose}
\begin{aligned}
1+1&=2\\
2+2&=4\\
3+3&=6\\
\smash{\enclose{top left bottom}{4+4\vphantom{4y}}}\!\!&
  \!\!\smash{\enclose{top right bottom}{=8\vphantom{4y}}}
\end{aligned}
\end{equation}

The \vphantom is to make the two sides of the equation have the same height and depth (and make it the height and depth of a line of text); the \enclose is used to add the border lines; the \smash is to make the row have no height (so it will not have the extra height of the enclosure, and will be formatted using the height and depth of a normal line of text); the \!\! are to remove the extra horizontal space of the enclosure and bring the two halves of the "box" together into one.  Note that this will probably only work well in HTML-CSS or SVG output, and may not work properly in NativeMML output.

Davide


--
You received this message because you are subscribed to the Google Groups "MathJax Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mathjax-user...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

William F Hammond

unread,
May 24, 2013, 10:41:04 PM5/24/13
to mathja...@googlegroups.com
There is a rather straightforward way to do this using MathML and CSS.  While Firefox handles it well with its native MathML rendering, it seems that the MathJax HTML/CSS and SVG modes ignore the CSS construction for the box.  Example attached.
onerowb.html

Frédéric WANG

unread,
May 25, 2013, 2:47:35 AM5/25/13
to mathja...@googlegroups.com
On 25/05/2013 04:41, William F Hammond wrote:
> There is a rather straightforward way to do this using MathML and
> CSS. While Firefox handles it well with its native MathML rendering,
> it seems that the MathJax HTML/CSS and SVG modes ignore the CSS
> construction for the box. Example attached.
>
I don't think the MathJax modes are based on the CSS table model (there
are other MathML tabular attributes to implement that are do not fit
very well in the CSS model) and that's probably why you can't do that.
The situation is a bit like columnspan and rowspan that are easy to
implement when you use CSS tables but are not available in MathJax yet.
BTW, your construction works in WebKit too.


--
Fr�d�ric Wang
maths-informatique-jeux.com/blog/frederic

Reply all
Reply to author
Forward
0 new messages