[Tex/LaTex] Difference between \framebox{$$} and \boxed{}


I want to put an equation in a frame box. Is it the same that if I create a framed text box environment first then put the equation inside or use the environment \boxed{}?





Best Answer

Package amsmath defines \boxed:


\framebox and \fbox are just different interfaces for the same internal \@frameb@x, which actually makes the box. \framebox has more options.

Thus, the main difference between \framebox{$...$} and $\boxed{...}$ is that \boxed sets \displaystyle, whereas it had to be done manually in the former variant: \framebox{$\displaystyle ...$}.

Another difference appears, if \mathsurround is not zero. This space is set, when TeX enters and leaves inline math mode. It is intended as separation of math from the surrounding text. Inside the box it does not make sense and \boxed removes it by setting \mathsurround to zero by \m@th.

A test file, which illustrates the differences:


    \text{\ttfamily\string\framebox\{\$\dots\$\}} &\vs
    \framebox{$\frac{123}{456}$} &\vs \boxed{\frac{123}{456}}
    \setlength{\mathsurround}{1em}\framebox{$X$} &\vs


A simulation of \boxed would be:

  $\displaystyle ...$%
Related Question