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?
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 .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.