I have been using a simple method for adding a framed, colored box around important equations I want to highlight. The empheq package has worked well. However, I am having a lot of trouble figuring out the best way to add some vertical space around the frame.

Here is what I have done to create a new command called "myyellowonebox" -- the color is "myyellow1"


\definecolor{myyellow1}{RGB}{255, 255, 219}


And in the body, I have:

 y = \frac{1}{4p} x^2

This produces the following output:

enter image description here

However, I would like to add a larger gap above and below this equation. I was able to add horizontal padding using the \hspace in the argument of \framebox. But I can't seem to do the same for extra vertical space.

Any help would be greatly appreciated. I'd rather not use a fancy package, as this is about the sophistication I need for highlighting equations!

  • 1
    Since you're using \fcolorbox, adjust \fboxsep: \setlength{\fboxsep}{<len>}... – Werner Feb 15 '17 at 19:25
  • Thank you -- I tried that and it didn't seem to work. Perhaps I did not put the command in the correct place. Where would I insert the \setlength command as you suggested? – G. Khanna Feb 15 '17 at 19:54
  • 1
    Add it in your preamble somewhere so it has the same effect across the whole document. – Werner Feb 15 '17 at 20:17
  • Thank you -- that seemed to work. One last question -- is there a way to override this on an individual basis? – G. Khanna Feb 15 '17 at 20:28

\fcolorbox uses \fboxsep and \fboxrule as the widths of the separation and rule. So, adjusting that (globally) within the preamble would make for a consistent gap in your \myyellowonebox. You can adjust this locally as well and restore it as needed:

enter image description here




\restorefboxsep% Default is 3.0pt


 y = \frac{1}{4p} x^2

\setlength{\fboxsep}{10pt}% Update \fboxsep
 y = \frac{1}{4p} x^2


The suggestion by Werner worked -- thank you! Here is the output I get when I add


in the preamble. It looks like

enter image description here

Now just trying to figure out how I can override this if I need to on an individual basis.

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.