Quantcast
Channel: Active questions tagged copy-paste - TeX - LaTeX Stack Exchange
Viewing all articles
Browse latest Browse all 70

Code environment that supports copy-paste

$
0
0

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.


Viewing all articles
Browse latest Browse all 70

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>