TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

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

I've been wondering about how to display simple codes. I used verbatim and then found the fancyvrb package which added a lot of nice little features, but then I inserted some code with a long line and it did not break.

I looked around and found that this was apparently a problem with this package, and thus looked for alternative ways to display code, and found listings (I found that it displayed the code strangely, I like the typewriter look of verbatim) and minted coupled with the Pygments Python tool (but I never got it to work with winshell). While looking at the 'listings' documentation I saw the 'fancyvrb' listed as an alternative, and in the description it said

The package provides frames, line numbers on the left or on the right, automatic line breaking (difficult)...

This question does not get an answer to the question of how to break lines using the fancyvrb package. I googled around and found this solution which provides a way to have automatic line-breaking in the verbatim environment, but this solution does not work with the fancyvrb package.

So the question is: The listings documentation hints at a way to have automated line-breaking in the fancyvrb package, does anyone know how?

share|improve this question
up vote 18 down vote accepted

I don't see any major problems with the listings package. See example below for a very basic structure.




The package manual has the details.

share|improve this answer
Ah, this actually looks exactly like I wanted it to. Somehow this columns=fullflexible option fixes this problem I had with the listings package :). – Jóhann Feb 24 '11 at 21:22
Hi, I'm trying to do something similar but I don't understand the answer. I am inserting some codes in my document. I am displaying them within the verbatim environment. How do I break the lines? – Costanza Sep 3 '12 at 14:27

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.