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?


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.

  • 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?
    – Cost
    Sep 3 '12 at 14:27

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.