Vin*_*Pii 68
我更喜欢将列表作为子文档插入,因此代码直接从文件中获取,您可以进一步编辑并保持更新(避免复制信息和维护更容易).要在Lyx中执行此操作:
Insert-> File-> Child document
 
然后在出现的窗口中将类型更改为程序列表并根据需要进行配置,例如,您可能要输入参数language = Python(您可以键入a ?查看所有参数).
我经常使用的一组参数是:
breaklines=true //--> breaks lines to margin
captionpos=b  //--> caption at the bottom of the listing (default is "t")
frame=tb  //--> frame at the top and at the bottom of the listing
language=Python  //--> syntax highlighting for python
Run Code Online (Sandbox Code Playgroud)
        Alo*_*hal 62
应该有一个Insert - > Program Listing选项.使用列表乳胶包,所以你应该有安装.似乎已经在Lyx 1.5中添加了支持,从它们的截图中,它似乎为您提供了许多自定义选项.
insert-> Program Listing功能很好用。我只想补充一下,如果您在Mac上,并尝试使用Command + V或右键单击+粘贴直接将一部分代码块粘贴到程序列表中,则不会保留空格,您必须手动通过输入制表符,返回等插入空格。
解决此问题的一种非常简单的方法是使用shift + command + V进行粘贴。这将保留原始源代码的所有空格。