Skip to content

Instantly share code, notes, and snippets.

@ethanal
Created June 25, 2015 03:19
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ethanal/3597401113e6821e9224 to your computer and use it in GitHub Desktop.
Save ethanal/3597401113e6821e9224 to your computer and use it in GitHub Desktop.
A LaTeX template for printing syntax-highlighted code nicely in grayscale
\documentclass[11pt]{article}
\usepackage[letterpaper]{geometry}
\geometry{top=0.5in, bottom=0.5in, left=0.7in, right=0.7in}
\usepackage{courier}
\usepackage{listings}
\usepackage{fancyhdr}
\pagestyle{fancy}
\lhead{}
\chead{}
\rhead{\texttt{Lowman \thepage}}
\lfoot{}
\cfoot{}
\rfoot{}
\renewcommand{\headrulewidth}{0pt}
\renewcommand{\footrulewidth}{0pt}
\setlength\headsep{0in}
\setlength{\headheight}{0.5in}
\usepackage{color}
\definecolor{lightGray}{rgb}{0.5,0.5,0.5}
\definecolor{mediumGray}{rgb}{0.3,0.3,0.3}
\begin{document}
\lstinputlisting[
language=Python,
basicstyle=\footnotesize\ttfamily,
commentstyle=\color{lightGray},
breaklines=true,
numbers=left,
numbersep=10pt,
numberstyle=\footnotesize\ttfamily\color{mediumGray},
showspaces=false,
showstringspaces=false,
stringstyle=\color{lightGray}
]{<%= filename %>}
\end{document}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment