开发者

Pygments to latex better formatting for py code

I am trying to include python code in my lyx document by inserting a file. I began by trying开发者_JAVA技巧 to use listings but this was causing code to overflow pages. Now I'm using pygments setting it up as described in this tutorial, http://wiki.lyx.org/Examples/IncludeExternalProgramListingUsingPygments. This appears to work fairly well but the code highlighting is off. for instance def and elif keywords are not highlighted and docstrings do not highlight if they are split over multiple lines. I have tried changing the style to a few different built in ones but this hasn't worked. Has anyone got a/ knows of a good way to highlight python code in the same way as idle does. Thanks.


You should check out package called minted, although I don't know how well it works together with Lyx. But in regular latex file you can just do:

\usepackage{minted}
...
\inputminted[]{python}{python_file.py}
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜