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 !

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}
| improve this answer | |
0

I found !

just write

%

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

| improve this answer | |

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.