I tried to customize a code listing to support some pseudo-code format that suited me best. It was easy to add keywords using otherkeywords
or morekeywords
, but the opposite, the deletekeywords
did not work as expected. If the stem of a word was defined as a keyword, the word would be highlighted. For example, if create is in morekeywords
, then created is also highlighted except the d in the end. Adding created to the deletekeywords
list is not helping.
Please suggest how I could solve this problem.
\documentclass[12pt]{article}
\usepackage{fancyhdr}
\usepackage[ansinew]{inputenc} %Windows-1252 encoding
\usepackage{listings}
\usepackage[english]{babel}
\usepackage[usenames,dvipsnames]{color}
\definecolor{dkgreen}{rgb}{0,0.6,0}
\definecolor{gray}{rgb}{0.4,0.4,0.4}
\definecolor{lightgray}{rgb}{0.9,0.9,0.9}
\definecolor{mauve}{rgb}{0.58,0,0.82}
\lstset{numbers=left,
numbersep=5pt,
basicstyle=\sffamily\tiny,
numberstyle=\tiny\color{gray},
keywordstyle=\color{blue},
commentstyle=\color{dkgreen},
stringstyle=\color{mauve},
backgroundcolor=\color{lightgray},
frame=single,
columns=fullflexible
}
\begin{document}
\title{}
\author{}
\maketitle
\section{somesection}
\lstset{language=Python, caption=somecaption, otherkeywords={smooth}, deletekeywords={smoothed, is, not}}
\begin{figure}[h]
\begin{lstlisting}
smooth is welcome
smoothed is not
\end{lstlisting}
\end{figure}
\end{document}
\documentclass
and the appropriate packages so that those trying to help don't have to recreate it.keywords={smooth}
instead, everything works fine. Moreover,otherkeywords
is defined for keywords containing non-letter elements. Is there any reason why you're usingotherkeywords
?keywords
. I thoughtotherkeywords
ormorekeywords
is the one I should use to add more keywords to the set. Thank you very much!keywords
is not what I want, because it resets the list of keywords and the ones listed insidekeywords
are the only keywords that get highlighted.