I am currently using the code


I have decreased the horizontal size of the box by adding hspace{-0.29cm}. I would like to do something similar for the vertical size of the box...i.e. I would like to include a vspace{-0.1cm} somewhere in this code, but I can't figure out where to put it. Any suggestions? Thanks so much in advance!

Update: the suggestions for the vertical resizing have worked brilliantly. But I have run into an issue with the box extending too far out in front of the enclosed text. Below is an example.

Current Output

I don't like that there is no space before the word "is". Any thoughts on how to fix this? Thanks so much!

  • If I try, I get that the background is too narrow. Can you explain more precisely your goal? – egreg Jul 28 '14 at 14:45
  • If you just want to vertically shift the box (as opposed to resizing it), the following substitution will achieve that: \fcolorbox{blue!0}{gray!30}{\raisebox{0.1cm}{\usebox{\FVerbB}}}. If you want to actually resize a box, the \addvbuffer macro of the verbatimbox package can do that (under certain constraints), but it is not clear, as egreg notes, what exactly you are trying to accomplish. – Steven B. Segletes Jul 28 '14 at 15:07

You have some trailing spaces in your code. However, I suppose you are looking for something like this:



enter image description here

Use \colorbox instead of \fcolorbox if you do not want a frame.

  • Thank you so much for this reply @Herbert! Your code worked wonderfully. I do have two questions though: (1) when I use the text box, any spacing that comes immediately after it becomes erased, i.e. <foo in box> some text is just <foo in box>some text. (2) Latex gives me an error if I write \begin{code} foo \end{code}. I have to put \begin{code} and \end{code} on separate lines. Do you know why this is? Thanks so much for the help though - I'm still new to Latex and Stackexchange, so please forgive me if I have made some obvious mistakes. – user56010 Jul 28 '14 at 17:01
  • use \colorbox{gray!30}{\BUseVerbatim{VerbEnv}}\space}. That depends on how verbatim is read. LaTeX looks for a line with end{...}. If you want inline code then use \verb or \lstinline from package listings – user2478 Jul 28 '14 at 17:29

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.