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{}?





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 ...$%
  • Thanks for the helpful reply! By the way, would you please tell me where I can find the definition of \boxed?
    – Zhang Ze
    Jul 2 '15 at 10:43
  • @ZhangZe kpsewhich amsmath.sty (or locate the package file amsmath.sty by means of the OS), then line 307 (in version 2013/01/14 v2.14). Jul 2 '15 at 11:06
  • Okay. Gotta it!
    – Zhang Ze
    Jul 2 '15 at 11:17

For such questions I just load the package lua-visual-debug. You can see clearly that they are both the same:

% arara: lualatex



\framebox{$\displaystyle a^2+b^2=c^2$} % displaystyle needed here, as it is set in \boxed by default. It just changes the horizontal spacing of the powers a bit. 



enter image description here

The boxing is equal speaking of spacing and aligning. Therefore, both approaches are similar. For the syntactical equivalence, see Heiko's answer.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.