Following code cant highlight as keyword. What am I doing wrong?
Shouldn't as be bold like import?
\documentclass[a4paper,10pt]{article}
\usepackage[utf8]{inputenc}
\usepackage{listings}
\lstset{morekeywords={as}}
\title{Python listings}
\author{me}
\begin{document}
\maketitle
\section{Introduction}
Python example
\begin{lstlisting}[language=Python]
#!/usr/bin/env python
"""
An animated image
"""
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.animation as animation
\end{lstlisting}
done with the example.
\end{document}
Best Answer
The
morekeyword=as
option works if you declare it after tellinglistings
that the language to be used is Python:It's perhaps better to define an own environment for Python:
so that it will be possible to write
possibly giving other local options, say