The space above and below the listing can be set using aboveskip
and belowskip
. The default value is \medskipamount
.
\documentclass{article}
\usepackage{tikz}
\usepackage{listings}
\begin{document}
\tikz \node[inner sep=1mm, text width=6cm, draw=green, line width=2pt, rounded corners]
{%
\lstinputlisting[basicstyle=\tiny\ttfamily, columns=fullflexible, breaklines=true,aboveskip=0pt,belowskip=0pt]{data.txt}
};
\end{document}
Rather use keywords={smooth}
instead of otherkeywords
. According to the listings
documentation, the latter
defines keywords that contain other characters, or start with digits.
Here's an updated MWE showing the desired output:
\documentclass[12pt]{article}
\usepackage{listings}% http://ctan.org/pkg/listings
\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, keywords={smooth}}
\begin{figure}[h]
\begin{lstlisting}
smooth is welcome
smoothed is not
\end{lstlisting}
\end{figure}
\end{document}
The above MWE specifies the keyword
s, but subsequently also overwrites the existing keywords supported by the language
setting. To maintain the existing set and add more/remove some, use morekeywords={smooth}, deletekeywords={is,not}
.
Best Answer
I just realized there is a
deletekeywords
option!