We are converting our course slides from Powerpoint to LaTeX, to be able to offer all code in a more open format and to let students easily copy code from the slides. However, the latter does not seem to work: LaTeX or listings or beamer transform all code into more beautiful characters, which can not be copied anymore. Consider this LaTeX code:
\documentclass{beamer}
\usepackage{listings}
\begin{document}
\lstset{breakatwhitespace=true,
language=C++,
columns=fullflexible,
keepspaces=true,
breaklines=true,
tabsize=3,
showstringspaces=false,
extendedchars=true}
\begin{frame}[fragile]
\begin{lstlisting}
const char *processing() const{
somestring = "-1";
}
\end{lstlisting}
\end{frame}
\end{document}
Copying the code from a PDF opened in OSX Preview will result in a special asterisk, special quotes and even a different minus sign. How can this be avoided, how can we make sure all code can be copied immediately as-is?
Or is the PDF viewer to blame? Then which format should we render out LaTeX to, to make sure the code can be copied: HTML?
Best Answer
use the
\defverbatim[...]\command
definition:it is a problem with
beamer
which ignores the tabs. However, the above works