Possible Duplicate:
Defininglstsetparameters for multiple languages
What's the easiest way to include code, using listings, from more programming languages?
\lstset{ %
language=Python,
basicstyle=\footnotesize\sffamily,
numbers=left,
numberstyle=\tiny\color{gray}\sffamily,
stepnumber=1,
numbersep=5pt,
backgroundcolor=\color{lstbckcolor},
showspaces=false,
showstringspaces=false,
showtabs=false,
frame=top, frame=bottom,
rulecolor=\color{black},
tabsize=2,
captionpos=t,
breaklines=true,
breakatwhitespace=false,
title=\lstname,
keywordstyle=\color{blue},
commentstyle=\color{dkgreen},
stringstyle=\color{mauve},
escapeinside={\%*}{*)},
morekeywords={as,from,odeset}
}
\begin{document}
\section{Examples}
Python example:
\lstinputlisting[language=Python]{python_code.py}
Matlab example
\lstinputlisting[language=Matlab]{spremnik.m}
One more Python example:
\lstinputlisting[language=Python]{python_code2.py}
\end{document}
The style of listing is same for matlab and python, including keywords (why if define python is defined as language in \lstset?).
How to define another \lstset for Matlab?
\lstdefinelanguageto define a new language with its own keywords, style, etc. – sivic Sep 25 '12 at 09:27