I'm currently using the listings package to display my matlab code in Latex.
However, when trying to add new keywords to the package, nothing happens. Here's a MWE:
\documentclass[a4paper,12pt,parskip,bibtotoc,liststotoc]{article}
\usepackage[usenames,dvipsnames]{color}
\usepackage{listings}
\definecolor{javaBlue}{RGB}{42,0.0,255}
\definecolor{javaGreen}{RGB}{63,127,95}
\definecolor{javaLila}{RGB}{127,0,85}
\lstloadlanguages{Matlab} % load java, needed because of option 'savemem'
\lstset{
morekeywords={classdef}
}
\lstset{
language=Matlab,
keywordstyle=\color{javaLila},
commentstyle=\color{javaGreen},
stringstyle=\color{javaGreen},
numbers=left,
stepnumber=1,
numbersep=5pt,
numberstyle=\tiny,
breaklines=true,
breakautoindent=true,
breakatwhitespace=false,
postbreak=\space,
tabsize=2,
basicstyle=\ttfamily\scriptsize,
showspaces=false,
showstringspaces=false,
extendedchars=true,
backgroundcolor=\color{white}}
\begin{document}
\lstinputlisting[language=Matlab]{"E:/Program Files/MATLAB/projects/master/classes /Customer.m"}
\end{document}
I have no idea why it doesn't work, as all respective threads in this forum just tell me to use "morekeywords". Seems like no one has my problem.
Best Answer
When loading a language specifically as the optional argument of a listings environment, the language defaults are being used. Define your own style. Right now, everything you set using lstset i completely ignored. You can even define a new environment saving you some typing.