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

I am using the listings package to include sample Perl source code in LaTeX. I included the package with \usepackage{listings}, and used the following code:

$subject = "<owamp:subject xmlns:owamp=\"http://ggf.org/ns/nmwg/tools/owamp/2.0/\" id=\"subject\">\n";

The resulting output is:

Screenshot of the output

The line doesn't seem to breaking, but I read that lines break automatically when using the listings package. This line is the entire PDF snapshot of the code.

Am I doing anything wrong as far as the code is concerned?

share|improve this question

migrated from stackoverflow.com May 13 '12 at 20:33

This question came from our site for professional and enthusiast programmers.

up vote 11 down vote accepted

Use breaklines=true:

enter image description here



\begin{lstlisting}[numbers=left, breaklines=true]
$subject = "<owamp:subject xmlns:owamp=\"http://ggf.org/ns/nmwg/tools/owamp/2.0/\" id=\"subject\">\n";
share|improve this answer
Thanks! I thought line breaks are true by default... – user840546 May 13 '12 at 17:15

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.