Skip to content

Instantly share code, notes, and snippets.

@silgon
Created May 21, 2018 13:33
Show Gist options
  • Save silgon/88ac6399d2a80d869b2a72911e9ff739 to your computer and use it in GitHub Desktop.
Save silgon/88ac6399d2a80d869b2a72911e9ff739 to your computer and use it in GitHub Desktop.
create pdf python code with latex
\documentclass{article}
\usepackage{listings}
\input{listings-python.prf} % defines the python-idle-code style
\usepackage{textcomp} % Needed for straight quotes
\lstset{
basicstyle=\normalsize\ttfamily, % size of the fonts for the code
language={Python},style={python-idle-code},
showstringspaces=false,
tabsize=4,
upquote=true, % Requires textcomp
}
\oddsidemargin=-0.5cm
\textwidth=7in % This just fits 80 characters at 10pt
\begin{document}
\lstinputlisting{myscript.py}
\end{document}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment