I am using the minted package for syntax highlighting code in my slides, but I have some problem to make this code easily copyable directly from the PDF to the console. it seems that the whitespaces used to format the code totally disappear when we select the code on the screen.
I was used to the option keepspaces=true and columns=flexible in the lstlisting package but I cannot find anything similar in the minted package documentation.
Did I miss something or is it just impossible with minted ?
Here is a code sample:
\documentclass{article}
\usepackage{minted}
\begin{document}
\begin{minted}{c}
int main(int argc, char *argv[])
{
extern int var;
return var;
}
\end{minted}
\end{document}
Compiled with: pdflatex -shell-escape sample.tex, it will produce:
But, when we copy-paste itdirectly from the PDF, we will get:
int main(int argc, char *argv[])
{
extern int var;
return var;
}
You should have noticed that all the white spaces formatting has been lost in the process.
What I would like to have is a copyable code with a copy-paste selection.

\attachfile). This also avoids things such as selecting the header and footer when copy pasting directly from the pdf. I am sure there will be an equivalent method in LaTeX. – Aditya Nov 12 '18 at 13:15\startcode ... \stopcode. It is relatively straight-forward to implement for someone who knows the innards ofminted(mintedsaves the file to disk in order to runpygments; you just need to attach that file). – Aditya Nov 12 '18 at 13:32