TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

With the following example

Some text
A test

Some text
A test

Some text
A test

the first two code blocks are typeset below the text, but the last one is to the side: Example output

I have Pymentize v1.4 installed, and \listfiles gives

 *File List*
 article.cls    2007/10/19 v1.4h Standard LaTeX document class
  size10.clo    2007/10/19 v1.4h Standard LaTeX file (size option)
  minted.sty    2010/01/27 v1.6 Yet another Pygments shim for LaTeX
  keyval.sty    1999/03/16 v1.13 key=value parser (DPC)
fancyvrb.sty    2008/02/07
   color.sty    2005/11/14 v1.0j Standard LaTeX Color (DPC)
   color.cfg    2007/01/18 v1.5 color configuration of teTeX/TeXLive
  pdftex.def    2010/11/26 v0.05c Graphics/color for pdfTeX
   float.sty    2001/11/08 v1.3d Float enhancements (AL)
  ifthen.sty    2001/05/26 v1.1c Standard LaTeX ifthen package (DPC)
    calc.sty    2007/08/22 v4.3 Infix arithmetic (KKT,FJ)
ifplatform.sty    2010/10/22 v0.4 Testing for the operating system
pdftexcmds.sty    2010/04/01 v0.9 Utility functions of pdfTeX for LuaTeX (HO)
infwarerr.sty    2010/04/08 v1.3 Providing info/warning/message (HO)
ifluatex.sty    2010/03/01 v1.3 Provides the ifluatex switch (HO)
 ltxcmds.sty    2010/04/26 v1.7 LaTeX kernel commands for general use (HO)
catchfile.sty    2010/04/28 v1.5 Catches the contents of a file (HO)
etexcmds.sty    2010/01/28 v1.3 Prefix for e-TeX command names (HO)

This seems like something that would have been noticed as a bug, so what have I got wrong?

share|improve this question
up vote 5 down vote accepted

minted uses the following macro internally if a background colour is selected:



Without further testing I’m assuming that the use of a minipage doesn’t introduce a new paragraph. If so, a simple \par command before the box should correct the problem.

This seems like something that would have been noticed as a bug,

It should have. The fact is, the documentation minted.pdf pretty much serves as the only test case at the moment and in the documentation the bgcolor option is only used in a single example without surrounding text, so the lack of a paragraph break makes no difference.

share|improve this answer
Thanks for that Konrad: I'll use a patched version of the environment for the moment. I'm quite familiar with 'use the documentation as a test file' as that is what I do for siunitx. The reason I thought other people might have noticed is that coloured background for code snippets is reasonably common. – Joseph Wright Jan 17 '11 at 8:16
@Joseph: the problem is that coloured background is kind of broken in minted: try having your code span over a page break. This only works properly without background colour, unfortunately, and I’m at a complete loss how to fix that. :-( – Konrad Rudolph Jan 17 '11 at 9:37

You can solve this issue by making use of mdframed package (\usepackage{mdframed}), this way:


        your code
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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