Skip to content

Instantly share code, notes, and snippets.

@Liam0205
Created April 23, 2018 09:31
Show Gist options
  • Save Liam0205/bf2498c523219fd511f61e28e2a145db to your computer and use it in GitHub Desktop.
Save Liam0205/bf2498c523219fd511f61e28e2a145db to your computer and use it in GitHub Desktop.
\documentclass{article}
\usepackage{xcolor}
\usepackage{listings}
\lstdefinestyle{lfonts}{
basicstyle = \footnotesize\ttfamily,
stringstyle = \color{purple},
keywordstyle = \color{blue!60!black}\bfseries,
commentstyle = \color{olive}\scshape,
}
\lstdefinestyle{lnumbers}{
numbers = left,
numberstyle = \tiny,
numbersep = 1em,
firstnumber = 1,
stepnumber = 1,
}
\lstdefinestyle{llayout}{
breaklines = true,
tabsize = 2,
columns = flexible,
}
\lstdefinestyle{lgeometry}{
xleftmargin = 20pt,
xrightmargin = 0pt,
frame = tb,
framesep = \fboxsep,
framexleftmargin = 20pt,
}
\lstdefinestyle{lgeneral}{
style = lfonts,
style = lnumbers,
style = llayout,
style = lgeometry,
}
\lstdefinestyle{c}{
language = {c},
style = lgeneral,
}
\begin{document}
\begin{lstlisting}[style = c]
#include <stdio.h>
int main() {
printf("hello world!");
}
\end{lstlisting}
\end{document}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment