summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/xsim/examples/xsim.listings.tex
blob: a5fe951bebfafe85e182f7fbc707ec835c9174de (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
% http://tex.stackexchange.com/questions/131546/
\documentclass{article}

\usepackage{xcolor}
\usepackage{listings}
\usepackage[use-files]{xsim}

\lstset{
  frame=single,
  xleftmargin=20pt,
  numbers=left,
  numberstyle=\small,
  tabsize=2,
  breaklines,
  showspaces=false,
  showstringspaces=false,
  language=C,
  basicstyle=\small\ttfamily,
  commentstyle=\itshape\color{gray}
}

\begin{document}

\begin{exercise}[points=6]
Consider the following C program.
\begin{lstlisting}
#include <stdio.h>

int main(int argc, char *argv[]) {
  printf("hello, world\n");
}
\end{lstlisting}
\end{exercise}
\begin{solution}
Consider the following C program.
\begin{lstlisting}
#include <stdio.h>

int main(int argc, char *argv[]) {
  printf("hello, world\n");
}
\end{lstlisting}
\end{solution}

\pagebreak
\printsolutions 

\end{document}