[OS X TeX] Listings package

David Arnold dwarnold45 at suddenlink.net
Sun Nov 7 18:20:38 CET 2010


All,

I'm trying to get the 2in in the line \begin{solution}[2in] to show up in red. But I'm having no success. Can someone suggest how I might do this using the listings package?

Thanks.

D.

\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{Space for Student Work}
Add space for student work by changing \verb+\begin{solution}+ to \verb+\begin{solution}[2in]+.

\medbreak

\lstset{classoffset=1,
	otherkeywords={2in},
	keywordstyle=\color{red}}

\begin{lstlisting}
\begin{solution}[2in]
First, factor out the GCF, then use the 
$ac$-test to factor the resulting trinomial.
\begin{align*}
p(x)&=x^3-2x^2-3x\\
    &=x(x^2-2x-3)\\
    &=x(x-3)(x+1)
\end{align*}
\end{solution}
\end{lstlisting}

\medbreak

\noindent Now, copy the entire content of the problem, everything between and including the \verb+\begin{problem}[10]+ ... \verb+\end{problem}+ pair, including the solution, and paste it six additional times in your document.

\end{frame}

\end{document}


More information about the macostex-archives mailing list