开发者

How to adjust \listing package width in Latex Editor (LEd)

开发者 https://www.devze.com 2023-01-15 11:23 出处:网络
I am trying to use the \\listing package to include some 开发者_JAVA技巧.cpp files into my article.

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号