I am unable to get keywords to be highlighted in typeset Python.
Latex source:
\documentclass{minimal}
\usepackage{listings}
\usepackage{xcolor}
\lstset{
language=Python,
frame=single,
numbers=left,
showspaces=false,
showstringspaces=false,
basicstyle=\ttfamily,
captionpos=t,
caption=\lstname
keywordstyle=\ttfamily \color{blue},
keywordstyle=[2]\ttfamily \color{blue},
stringstyle=\color{green}\ttfamily,
commentstyle=\color{red}\ttfamily
}
\begin{document}
Keywords are not highlighted properly in the below segment:
\begin{lstlisting}
# This is a comment
print("Latex keywordstyles not working?")
if this_is_highlighted:
print("Yay, this works!")
else:
print("Why isn't this working?")
\end{lstlisting}
\end{document}
Typeset output:
Why isn't the keywordstyle
coloring working when the keywords are properly defined in lstlang1.sty
?