Debian Codegraph @

texmf-dist/doc/latex/xsim/examples/xsim.listings.tex

raw
1 % http://tex.stackexchange.com/questions/131546/
2 \documentclass{article}
3
4 \usepackage{xcolor}
5 \usepackage{listings}
6 \usepackage[use-files]{xsim}
7
8 \lstset{
9 frame=single,
10 xleftmargin=20pt,
11 numbers=left,
12 numberstyle=\small,
13 tabsize=2,
14 breaklines,
15 showspaces=false,
16 showstringspaces=false,
17 language=C,
18 basicstyle=\small\ttfamily,
19 commentstyle=\itshape\color{gray}
20 }
21
22 \begin{document}
23
24 \begin{exercise}[points=6]
25 Consider the following C program.
26 \begin{lstlisting}
27 #include <stdio.h>
28
29 int main(int argc, char *argv[]) {
30 printf("hello, world\n");
31 }
32 \end{lstlisting}
33 \end{exercise}
34 \begin{solution}
35 Consider the following C program.
36 \begin{lstlisting}
37 #include <stdio.h>
38
39 int main(int argc, char *argv[]) {
40 printf("hello, world\n");
41 }
42 \end{lstlisting}
43 \end{solution}
44
45 \pagebreak
46 \printsolutions
47
48 \end{document}