# [OS X TeX] Coloring a line in listings environment

Peter Vamos P.Vamos at exeter.ac.uk
Thu Nov 11 19:43:04 CET 2010

Here is a (very) dirty hack, just by looking at your code - I don't
know anything about the listings package. Will do for a one off. If
you need this sort of thing more often then you should try to find
out how to redefine the font used by Beamerm for listings and/or
\verb. This is really a LaTeX/Beamer/listings question.

Only append below the end of your file where the changes I made
occur. Hope that this helps

Peter

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

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

\begin{frame}[fragile]
\frametitle{Using Tikz}
Create a new file and save it as \verb+workshop4.tex+. Enter the
following lines.
\medbreak
\begin{lstlisting}[frame={trl}]
\documentclass{article}
\usepackage[nosolutions,pointsonleft]{eqexam}
\end{lstlisting}\vspace{-12pt}
\begin{lstlisting}[keywordstyle=\color{red},frame={rl}, escapeinside=!~]
!\color{red}$\backslash$\,~use!\hspace{-0.1mm}~package!\,\color{red}\{~tikz!\color{red}\}
\end{lstlisting}\vspace{-12pt}
\begin{lstlisting}[frame={brl}]
\title{Exam \#2A}
\subject{Math 120}
\author{David Arnold}
\date{November 20, 2010}

\begin{document}
\maketitle
\end{document}\end{lstlisting}

\medbreak

\noindent Compile \verb+workshop4.tex+.

\end{frame}
\end{document}



More information about the macostex-archives mailing list