tags:

views:

215

answers:

1

At the top of my tex document, I set my sourcecode listing format by

\lstset{language=java}
\lstset{numbers=left, numberstyle=\tiny, numbersep=5pt, breaklines=true}
\lstset{emph={square}, emphstyle=\color{red}, emph={[2]root,base}, emphstyle={[2]\color{blue}}}

because I merely list Java source code. At one point in my document, I had to reformat for a single listing by

\lstset{commentstyle=\footnotesize\textit}
\lstset{basicstyle=\ttfamily\fontsize{11}{12}\selectfont}
\lstset{literate= {!=} {$\neq$}{2}}

Now I have the problem that my previous Java formatting for listings is destroyed, and I dont know how to reset the lst settings to default. How can this be avoided?

+2  A: 

If you need to modify only one listing, you can pass the options as an optional argument:

\begin{lstlisting}[commentstyle=\footnotesize\textit]
...
\end{lstlisting}

will only affect that particular listing.

Aniko