3

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:

\begin{minted}{smalltalk}
\end{minted}

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:

\documentclass[12pt,twocolumn]{article}

\usepackage{color}
\usepackage{xcolor, soul}
\sethlcolor{lightgray}
\usepackage[toc,page]{appendix}
\usepackage[cache=false,outputdir=.texpadtmp]{minted}
\setminted{style=pastie}

\usepackage{url}

\begin{document}

…

\section{Test}
\begin{minted}{ruby}
….
\end{minted}

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
3

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.