How to adjust \listing package width in Latex Editor (LEd)
I am trying to use the \listing package to include some 开发者_JAVA技巧.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.
精彩评论