I have to insert some mathematica code in my latex document. For that, I'm using the answer given here by user Ronny. Is it possible to add sth that would make my comments look grey in the resulting pdf document?
Thanks
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It only takes a minute to sign up.
Sign up to join this communityI have to insert some mathematica code in my latex document. For that, I'm using the answer given here by user Ronny. Is it possible to add sth that would make my comments look grey in the resulting pdf document?
Thanks
You can use commentstyle=\color{gray}
. Taking the code from answer linked by OP in the question:
\documentclass{article}
\usepackage{listings,framed,xcolor,amsmath}
\colorlet{shadecolor}{blue!20}
\lstnewenvironment{mat}
{\lstset{language=mathematica,mathescape,columns=flexible,commentstyle=\color{gray}}}
{}
\begin{document}
\begin{align}
\nonumber W_{r → ∞}=&-∫_{r}^{∞}\!F\,\mathrm{d}y=- ∫_r^∞ \! \dfrac{1}{4π\epsilon₀} \dfrac{q²}{\alpha²} \dfrac{\alpha³}{y³}\left(1- \dfrac{\alpha²} {y²}\right)⁻²\,\mathrm{d}y\\
=&-\dfrac{1}{4π\epsilon₀} \dfrac{q²}{\alpha²}\alpha³ \underbrace{∫_r^∞ \! y⁻³ \left(1-\dfrac{\alpha²} {y²}\right)⁻² \,\mathrm{d}y}_{I} \label{eq:WcondI}
\end{align}
\begin{shaded}
\begin{mat}
In[1]:= Integrate[{y^(-3)*(1-(a/y)²)^(-2)},{y,r,Infinity}]
Out[1]= {ConditionalExpression[$\displaystyle-\frac{1}{2(a²-r²)}$, Im[r]
Re[a] $ ≠ $ Im[a] Re[r] || (( $a+r>0$ || $a+r ∉ $ Reals) && ($a<r$ ||
$a-r ∉ $ Reals) || $r ∉ $ Reals )]} (* this is a comment *)
\end{mat}
\end{shaded}
\end{document}