# Insert source code listings using esami package

Is it possible to insert source code listings in test problems created using esami package?

I've tried using verbatim environment or listings package, but I get no output.

MWE:

\documentclass{article}
\nonstopmode
\usepackage[utf8]{inputenc}
\usepackage[randomize,shuffle,nosolutions,twocolumns]{esami}

\def\numcompiti{2}
\date{2016/12/17}%%% THE DATE IN THE FORMAT YYYY/MM/DD
\def\Data{\longdate}%%% or \shortdate: the date in the heading

\begin{document}
\pagestyle{esame}

\whiledo{\thevers<\numcompiti}{\stepvers

\FPeval\seme{round((\thenomefile+\thevers):0)}
\randomi=\seme

\permuta
\testa
\istruzionii

\begin{test}
\begin{questions}
\esercizi{
prob1
}
\end{questions}
\end{test}

\closevers
}
\end{document}


and this is prob1.tex:

\newproblem{
\item My problem

\begin{verbatim}
This is
my code
\end{verbatim}
}

• Can you provide a sample of code - preferably a minimal example - that we can play with? – Werner Dec 16 '16 at 19:23
• Yes, I've edited my post – totera Dec 18 '16 at 9:54

I think that the problem is the use of the verbatim environment, which is also used by the package for many purposes. You can try to use the cprotect package and write, just after \begin{document}, \cMakeRobust{\newproblem}. I hope this helps.
• Thanks, it works! Actually, I had to switch to alltt environment because I needed esami parameters inside the source code. Your workaround works for both verbatim and alltt. – totera Dec 24 '16 at 18:28