[OS X TeX] Another listings package question

David Arnold dwarnold45 at suddenlink.net
Sun Nov 7 20:46:12 CET 2010


Hi,

What is the easiest way to include \Ans0 and \Ans1 as keywords to be colored blue and indented?

\documentclass{beamer}
\usepackage{listings}
\usepackage{amsmath,amssymb}

\begin{document}

\lstset{language=[LaTeX]TeX,
	keywordstyle=\color{blue},
	commentstyle=\color{red},
	frame=single}

\lstset{classoffset=0,
	morekeywords={subject, maketitle},
	keywordstyle=\color{blue}}

\begin{frame}[fragile]
\frametitle{Multiple Choice Questions}
Change your exam name and instructions, then delete all existing problems.

\bigbreak

\lstset{classoffset=0,
	morekeywords={\Ans,eAns,bChoices,eChoices}}

\begin{lstlisting}[escapeinside=!~]
\begin{problem}[5] If $f(x)=2x$, find $f(-3)$.
\begin{answers}{3}
\bChoices
	\Ans0 $-3$ \eAns
	\Ans0 $4$  \eAns	
	\Ans1 $-6$ \eAns
	\Ans0 $5$  \eAns
	\Ans0 None of these \eAns
\eChoices
\end{answers}
\end{problem}
\end{lstlisting}

\medbreak

\end{frame}


\end{document}


More information about the macostex-archives mailing list