# Colored word with listings

I added to the list of keywords by the colorful package listings (python) some functions of scipy.signal library using the otherkeywords control, I added the lti order, this order is put in color but the problem is that the text "lti" is also colored in the word "multi".

• How to avoid this side effect?

• Is it possible to add all the keywords of a library (matplolib for example)?

I used morekeywords option instead of otherkeywords and you probably was loading the default predifined language by specifying \begin{lstlisting}[style=Python], as a first step you should define your listings language style (customize) by lstdefinestyle and then use it in the lstlisting environment as a style style=myPython.

For the second part i am not sure but i am afraid there is no other way to add keywords automatically rather than adding them by collecting, the list of the library keywords and pasting it into morekeywords = {keyword1,...}.

\documentclass{article}
\usepackage{listings}
\usepackage{xcolor}
\usepackage{textcomp} %for upquote

\definecolor{keywords}{rgb}{0,0,0.7}

\lstdefinestyle{myPython} {
language=Python,
keywordstyle=*\color{keywords},
numbers=left,
numberstyle=\scriptsize,
stepnumber=1,
numbersep=8pt,
showstringspaces=false,
breaklines=true,
frameround=ftff,
frame=lines,
morekeywords = {lti},
backgroundcolor=\color{gray!20},
firstnumber=1,
upquote=true  %for straight single quotes
}

\begin{document}
\begin{lstlisting}[style=myPython]
def greet(name):
print 'Hello', name
greet('LaTeX')
multi lti
\end{lstlisting}
\end{document}