Is there a LaTeX package that can generate code in PDF file and allow users to copy-paste the generated code?
I have tried the lstlisting
environment. This is my test code:
\documentclass{article}\usepackage{listings}\lstset{basicstyle=\ttfamily,columns=fixed}%%\lstset{basicstyle=\ttfamily,columns=flexible}%%\lstset{basicstyle=\ttfamily,columns=fullflexible}\begin{document}\begin{lstlisting}print("helloworld")print("hello world")print("hello world")print("hello world")\end{lstlisting}\end{document}
When columns
is set to fixed
, the package inserts extra spaces into the PDF file. When set to flexible
or fullflexible
, multiple spaces are reduced into one. The latter is obviously unacceptable. So I think the only usable option is fixed
. But the extra spaces are very annoying and I don't know how to deal with them.