tags:

views:

18

answers:

1

Hi,

I am trying to use the \listing package to include some .cpp files into my article.

I add:

\usepackage{listings}

And then I use \lstinputlisting[language=c++]{File.cpp}

The problem is that the width is not adjusted, so the code is cutted.

Which is the solution?

+1  A: 

You'll be looking for the setting breaklines set in \lstset like so:

\documentclass{article}
\usepackage{listings}
\begin{document}
\lstset{breaklines=true}
\lstinputlisting[language=c++]{File.cpp}
\end{document}

Now listings will try and break the lines neatly.

For more information about what can be set with \lstset, see the article on LaTeX Wikibook.

progo