Python code in LaTeX

share on google plus share on facebook share on twitter share on linkedin share via email

Including Python code in LaTeX papers is very simple and convenient with the “listings” package. Documentation of the package is part of the (awesome) LaTeX wikibook

First, include the package in your document:




And then insert code directly in the document:

\lstset{caption={Insert code directly in your document}}
from brg.datastructures import Mesh

mesh = Mesh.from_obj('faces.obj')

Or add code from a file:


Leave a response

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>