I would like to use simple example environment with listing package for printing C-code snippets, like this
\begin{example}
\lstinputlisting[caption=Hello.c]{../C/hello.c}
\end{example}
This works well with the exception of the selected font. I use
\lstset{basicstyle=footnotesize\ttfamily}.
but, as you can see on the figure below, which does not match with selected shape. It seems that font shape selected for example environment has higher priority. How can I properly set font shape for code snippet in the example environment, that match with \lstset command.
Note: I use czech language: Příklad = Example
MNWE
\documentclass[12pt,a4paper]{scrbook}
\usepackage{amsthm}
\usepackage{xltxtra}
\usepackage{listings}
\newtheorem{example}{Příklad}
\begin{document}
\lstset{ %
language=C, % choose the language of the code
basicstyle=\footnotesize\ttfamily, % the size of the fonts that are used for the code
}
\begin{example}
text text text
\begin{lstlisting}
#include <stdio.h>
int main(void)
{
int c;
while ((c = getchar()) != EOF)
putchar(c);
return 0;
}
\end{lstlisting}
\end{example}
\end{document}