TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

When I gave my code in the exam class like

\part \begin{lstlisting} 
echo The date is $date 
\part \begin{lstlisting} 
echo The date is $(date) 

I want is the line starting with echo in (a) and (b) respectively. Instead that only \part displays only (a)

share|improve this question
Add a blank line or a \par between \end{lstlisting} and \part. – clemens Mar 6 '13 at 8:20
up vote 1 down vote accepted

Putting it in \lstinline solved my problem

\part \lstinline{echo The date is $date}
\part \lstinline{echo The date is $(date)}
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.