开发者

Writing a LaTeX document with Python code snippets

开发者 https://www.devze.com 2022-12-16 00:46 出处:网络
I am using LaTeX to write a document about Python. This document will contain code snippets (examples).

I am using LaTeX to write a document about Python. This document will contain code snippets (examples).

I could use the v开发者_JAVA技巧erbatim environment, but before I embark onto it, I'd like to know if you are aware of any LaTeX style file which provides an environment for Python code. Syntax highlight would be a plus.

Thanks.

Edit:

I must point out that the package minted is exactly what I was looking for. It has beautiful syntax highlighting and it is very simple to use. Check this question to know more about it.


Take a look at this question Source code highlighting in LaTeX for more information.

You should also look at the pygments program for source code highlighting.

I personally use Emacs org-mode with #+BEGIN_SRC python and let htmlize.el take care of the highlighting during export. You can see a sample here (This is an HTML export but with the latest version of org-mode, it can use the listings LaTeX package to colourise exported PDFs too).


Use Docutils and RST for this. It has Latex with Syntax highlighting.

http://docutils.sourceforge.net/docs/user/latex.html


The LaTeX Listings package seems to know about Python. Worth taking a look at.

Mark

0

精彩评论

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