# [Tex/LaTex] How to include Mathematica code in a document

wolfram-mathematica

I want to include some Mathematica code in a LaTeX document.

It's along the lines of
f[a_,b_]:=a^2+b^2+4b^3+25a*b*c ;

However, when I build my PDF, the _ and ^ always render. Is there a way to get it to just show up as it shows above?

As rdhs mentionned, you can use the listings package. A sample example is:

\documentclass{article}

\usepackage{listings}

\begin{document}

\begin{lstlisting}
f[a_,b_]:=a^2+b^2+4b^3+25a*b*c ;
\end{lstlisting}

For inline stuff you can use \lstinline$f[a_,b_]:=a^2+b^2+4b^3+25a*b*c ;$