When highlighting text using Style and Background, as in Style["Test ", White, Background -> Lighter@Blue] is there a way to pad (ie, enlarge) the bounding box?

The bottom of the background seems coincident with the base of the text: here


2 Answers 2

Style[Pane[" Test "], White, Background -> Lighter@Blue]

enter image description here


Controlling the padding:

Style[Pane[" Test ", ImageMargins -> 10], White,  Background -> Lighter@Blue]
  • $\begingroup$ Ok that works. But is there no way to parametrically control size? (Other than rendering an independent Rectangle) $\endgroup$ Jul 21, 2012 at 19:22
  • 1
    $\begingroup$ @alancalvitti Add that request to the question. I tried to answer it in its current state $\endgroup$ Jul 21, 2012 at 19:23
  • $\begingroup$ @alancalvitti See edit $\endgroup$ Jul 21, 2012 at 19:25

You could play with the FrameMargins ...

Framed[Style["Test", White], FrameStyle -> None, FrameMargins -> 2, 
 Background -> Lighter@Blue] 



Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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