Skip to content

Instantly share code, notes, and snippets.

@ainsleyrutterford
Created April 30, 2019 22:06
Show Gist options
  • Save ainsleyrutterford/810c8fec4dc0e751cb8f6aafb2be08cd to your computer and use it in GitHub Desktop.
Save ainsleyrutterford/810c8fec4dc0e751cb8f6aafb2be08cd to your computer and use it in GitHub Desktop.
Simple example of the listings package in latex.
\usepackage{listings}
\lstset{language=C,
basicstyle=\ttfamily,
keywordstyle=\color{blue}\ttfamily,
stringstyle=\color{red}\ttfamily,
commentstyle=\color{green}\ttfamily,
morecomment=[l][\color{magenta}]{\#}}
% Do everything above in your preamble
\begin{lstlisting}
if (obstacles[i + j*nx]) tot_u = 0;
else tot_u = sqrt(u_sq);
\end{lstlisting}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment