I have some cases where I will have an item in between two paragraphs. For example:

Alfa bravo:


charlie delta:

echo foxtrot

golf hotel

the image gets no vertical space at all, the the code block does get some space, but I might want more. I can add some of these:


but is a better option available? Something like one of these:


echo foxtrot

To solve this, I used the tcolorbox package. The beforeafter skip option sets the top and bottom margin. The listing only option to the tcblisting element gives a similar result to verbatim.

This does add a background and border to these elements, but I actually like that. If someone dislikes that, I think it can be disabled in the settings.

\tcbset{beforeafter skip=8mm}
\tcbset{listing only}








| improve this answer | |
  • I usually use much simpler environments: {center} or {flushleft} (depending on desired positioning) to give the standard separation for the document. – Donald Arseneau May 18 at 0:14
  • @DonaldArseneau what do those have to do with vertial margins? – Steven Penny May 18 at 0:52
  • They have vertical separation at top and bottom, \topsep + \parsep (yes at the bottom too). – Donald Arseneau May 18 at 4:08

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.