Take the 2-minute tour ×
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.

I included some listing in my document using the listings package but some of the lines are rather long and are being truncated. How do I best handle this issue?

share|improve this question
1  
Use breaklines=true and breakwhitespace=true. See this for a good example tex.stackexchange.com/questions/38579/… of settings. –  Yiannis Lazarides Dec 20 '11 at 15:35
    
Since you have some responses below that seem to answer your question, please consider marking one of them as ‘Accepted’ by clicking on the tickmark below their vote count (see How do you accept an answer?). This shows which answer helped you most, and it assigns reputation points to the author of the answer (and to you!). It's part of this site's idea to identify good questions and answers through upvotes and acceptance of answers. –  Jubobs Mar 7 at 10:59
add comment

1 Answer

As Yiannis Lazarides commented, you need to add breaklines=true. Here is an example copied from my earlier answer to this question on Using package listings with sciposter:

enter image description here

\documentclass{article}
\usepackage{listings}

\lstset{basicstyle=\small\sffamily,
  numbers=none,
  frame=tb,
  columns=fullflexible,
  showstringspaces=false,
  breaklines=true
}

\begin{document}
\begin{lstlisting}
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam consectetur nulla a ante ullamcorper sed mattis massa fringilla. Mauris et leo nisl. Sed tortor lorem, vestibulum ut fermentum a, sollicitudin in arcu. Vivamus leo purus, imperdiet quis scelerisque et, varius non enim. Nunc scelerisque velit et dui porttitor at vulputate lorem convallis. Nam vitae erat ac urna semper adipiscing. Proin quis justo nibh. Proin ultricies ultricies libero. Nunc sodales sapien vel purus ultricies sodales. Curabitur non semper magna. Nullam varius dapibus leo, ac imperdiet nulla tempus vitae. In et turpis ut turpis facilisis tristique. Phasellus interdum, justo a semper aliquam, ante diam consequat justo, a egestas nisi lorem sit amet erat. Nam justo nunc, vulputate ac luctus et, ullamcorper eu mi. Pellentesque ut dui nulla, ut sagittis dui. Donec eget ligula non dui tristique auctor at vel sapien. 
\end{lstlisting}
\end{document}
share|improve this answer
add comment

Your Answer

 
discard

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.