0

I want to insert Scilab code in a listing environment

\begin{lstlisting}[]
function y = f(x)
y = 1/sqrt(2*\%pi) * exp(-x^2/2)
endfunction
\end{lstlisting}

but it then displays "\%" whereas I would like it to display "%" only ... Has anyone ever encountered this problem?

thanks !

2 Answers 2

1

lslisting environment is similar to verbatim environment. So just use %:

\documentclass{article}
\usepackage{listings}             % Include the listings-package
\begin{document}

\begin{lstlisting}[]
function y = f(x)
y = 1/sqrt(2*%pi) * exp(-x^2/2)
endfunction
\end{lstlisting}
\end{document}
0

I found !

just write

%

it sounds like a comment, but is not interpreted...

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .