I am writing a report on ShareLaTeX and when I use lstinputlisting it renders some of my minus signs but not all.

I include my listing with:

\lstinputlisting[label=script:theory,caption={Calculating the expected
proportion of the genome covered by N

in scripts/theory.R I have:

G <- 1000 L <- 50 theoretic_proportion_of_genome_covered =
function(N){   a= N*L/(G-L)   1−exp(−a) }

And it renders like this:

enter image description here

As you can see, the first minus sign shows just fine but the next ones don't. It also has some weird spacings.

I have the following lstset:

\lstset{    language=R,                       
basicstyle=\footnotesize\ttfamily, numbers=left,
numbersep=5pt, backgroundcolor=\color{white}, frame=single,           
captionpos=b,                        keywordstyle=\color{blue},
commentstyle=\color{green}     }

and my imports:


I already looked at the following pages but none of them relieved me:

  • Does the minus sign remain missing even at higher zoom levels?
    – Werner
    Sep 20 '16 at 17:00
  • 1
    The missing minus signs in scripts/theory.R are no minus signs but endashes. Compare - in the arrows and in (G-L) (which are the right characters) to in −exp(−a). The problem is the R code.
    – gernot
    Sep 20 '16 at 17:10

As gernot pointed out, I was using the dash-character "-"

I needed to use the minus character "-"

I did not even realize they were different


Using minus or dash characters did not work for me. But changing the font did. I added \lstset{basicstyle=\ttfamily} to the preamble and it worked fine.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.