The code is not wrapped and overlaps over the second column of text, as shown in the next image.

Overlap problem Currently I'm just using it as follows:


Is there any easy way to make the text wrap, so it doesn't overlap over the second column in the article?

Thanks for the help!

Here's what the code in the document is like:


\usepackage{xcolor, soul}





When a line of code is long enough, it just overlaps towards the second column of the document. In the image I show, due to the indentation (tabs) the text goes far enough to the right to overlap.

  • Welcome! Please edit your post to provide code which we can compile to reproduce the problematic output you show. – cfr Jan 12 '17 at 2:13
  • Have you tried \begin{minted}[breaklines]{<language>}, perhaps with some additional line breaking options or a slightly smaller font size for code? – G. Poore Jan 12 '17 at 13:01
  • @G.Poore Thanks, that solved it! I put \setminted{style=pastie,breaklines=true} so it works on every highlighted code. If you add an answer I will accept it. – Kevin Van Ryckegem Jan 12 '17 at 14:50

Using the breaklines option, either globally (\setminted{breaklines=true}) or on a per-environment basis (\begin{minted}[breaklines]{<language>}), will cause lines to be wrapped.

If the line wrapping still causes some code to overlap the column margin (for example, due to long variable names or runs of text without spaces), you could look into the breakbefore and breakafter options, or perhaps breakbytokenanywhere. You might also consider a smaller font size for code in that case, or adjust the indentation of wrapped lines (breakindent and breakautoindent)

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.