I am using \boxed to draw a small box around a symbol in math mode. I would, however, like to decrease the padding between the symbol and the box. While I found solutions involving other commands/packages, I'd prefer to stuck to stick to \boxed. Also, adding \smash does not work.



\[ \boxed{\leq} \quad \boxed{\smash{\leq}} \]


enter image description here


\boxed in amsmath is defined using a regular \fbox:


So, setting \fboxsep would modify the gap. Here is an example:

enter image description here

\usepackage{amsmath}% http://ctan.org/pkg/amsmath

  \boxed{\leq} \quad 
  \setlength{\fboxsep}{.5\fboxsep}\boxed{\leq} \quad
  \setlength{\fboxsep}{.5\fboxsep}\boxed{\leq} \quad


In that sense it's possible to redefine \boxed to take an optional argument that sets the width:


This allows one to use, for example, \boxed[-\fboxrule]{\leq} to see the bounding box around \leq.

  • But your first example above seems to make the change to \boxed somewhat permanent, i.e. if I later use another plain \boxed without changes to \fboxsep, the padding is still decreased. How would I make the one-shot padding-decreased smaller box without affecting future ones? - Other than that, the solution works perfectly, thanks! – Bernd Jul 17 '13 at 12:45
  • 1
    @Bernd: I've added an example of how to update \boxed to take an optional argument which does a local change to \fboxsep. However, if you wish to do this manually, surround the \setlength...\boxed.. with braces: {\setlength...\boxed..}. That defines the scope for the change. – Werner Jul 17 '13 at 12:47
  • Ah, the braces did the trick. Still know so little about how the LaTeX syntax works. Thanks! – Bernd Jul 17 '13 at 12:49

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.