I'd like to have code in a PDF that someone can simply copy, paste, and use. Currently, \lstlisting
is converting '-' to em dashes. Then when I paste the output into the Python interpreter or MATLAB, I get syntax errors. None of the solutions I've looked at on here seem to work.
myvar = 9
myvar = myvar - 2
The '-' ends up as '−' in the output.
I have the following settings
\lstset{breakatwhitespace,
language=MATLAB,
columns=fullflexible,
keepspaces,
breaklines,
tabsize=3,
showstringspaces=false,
extendedchars=true,
basicstyle=\fontfamily{pcr}\selectfont\scriptsize,
keywordstyle=\color{orange},
upquote=true}
I am using \documentclass{beamer}
I've looked at
- listings package changes hyphens to minus signs
- less relevant since i'm focusing on code, not comments: Avoiding "minus sign" dash in listings commentstyle