4

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?

2

1 Answer 1

3

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}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .