Inappropriate spaces on computer programming scripts in a latex generated text file

534 Views Asked by At

Here a sample code

\documentclass{article}

\usepackage{listings}


\begin{document}
\lstset{language=Python}
\lstset{frame=lines}
\lstset{caption={Insert code directly in your document}}
\lstset{label={lst:code_direct}}
\lstset{basicstyle=\footnotesize}
\begin{lstlisting}

x = np.arange(-3, 3, 0.01)
y = np.sin(np.pi*x)/(np.pi*x)

plt.plot(x, y)
\end{lstlisting}


\end{document}

which provides me a pdf file with a python code inside.

In what follows I copy and paste the result from the generated pdf file

x = np . a r a n g e ( −3 , 3 , 0 . 0 1 )
y = np . s i n ( np . p i ∗x ) / ( np . p i ∗x )
plt . plot (x , y)

For most of the letters, in this case EACH of the latters, a space is added, which makes the code not suitable to be tested or used.

How can I remove that space?

0

There are 0 best solutions below