乳胶生成的文本文件中计算机编程脚本上的不当空间

发布于 2025-02-04 10:21:03 字数 670 浏览 3 评论 0原文

在这里,一个示例代码

\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}

为我提供了一个带有Python代码的PDF文件。

在接下来的内容中,我将生成的PDF文件的结果复制并粘贴到

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)

大多数字母中,在这种情况下,添加了一个空间,这使得代码不适合进行测试或使用。

如何删除该空间?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文