I'm trying to paste some R code into my latex file but when I use the listing package it fails to display the - next to the <. My latex file is as follows:
\documentclass[12pt]{article}
\usepackage{listing}
\begin{document}
\begin{lstlisting}[language=R]
ftn_deriv_1 <- function(x) {
# Input: n-dimensional vector x0
# Output: n-dimensional vector x with first derivative
#of scalar function ftn(x)
x1 <- 1/(x[1]*(1+x[2]))-log(x[2])/(1+x[1])^2;
x2 <- -log(x[1])/(1+x[2])^2 + 1/(x[2]*(1+x[1]));
y <- c(x1,x2);
return(y);
}
ftn_deriv_2 <- function(x) {
# Input: n-dimensional vector x0
# Output: n by n matrix with second derivative of scalar function ftn(x)
x11 <- -1/((1+x[2])*x[1]^2)+2*log(x[2])/(1+x[1])^3;
x21 <- -1/(x[1]*(1+x[2])^2) -1/(x[2]*(1+x[1])^2);
x12 <- -1/(x[1]*(1+x[2])^2) -1/(x[2]*(1+x[1])^2);
x22 <- 2*log(x[1])/(1+x[2])^3 -1/((1+x[1])*x[2]^2);
y <- matrix(c(x11,x21,x12,x22),2,2);
return(y);
}
\end{lstlisting}
\end{document}
When I compile this I get the following output:

As you can see the - does not show after the <. I am using TeXstudio version 2.11.2 for macboook. Any remedy for this? Thanks in advance!
listings, notlstlisting; the latter doesn't seem to exist. (2) There is a closing brace missing after\begin{document. With these two changes the code compiles, and the minuses show up. – gernot Oct 25 '16 at 08:26\lstset{basicstyle=\ttfamily}before thelstlistingenvironment; see also the post "missing minus sign in R code using latex". – gernot Oct 25 '16 at 08:32