您能否提供一个工作示例,其中由listings
环境单词分隔的源代码会换行,而不会破坏列布局sciposter
?
例如,每当我在中间一列放置一条长线时,它就会一直渲染直到结束(这\textwidth
是限制),从而破坏了列布局。
希望这是有意义的。
编辑:
设置breaklines
标志解决了自动换行问题。
https://stackoverflow.com/questions/981020/how-to-force-line-wrapping-in-listings-package
答案1
要获得自动换行,listings
您需要指定breaklines=true
:
\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}