lstlisting_mathematica

../_images/sphx_glr_lstlisting_mathematica.svg
%
% Reference https://newbedev.com/highlighting-mathematica-code-in-latex-document
%

\documentclass[]{standalone}

\usepackage[]{graphicx}

\usepackage{tikz}
\usepackage{pgfplots}
\pgfplotsset{compat=1.18}
\usepackage{beramono}

\usepackage[T1]{fontenc}
\usepackage{color}

\definecolor{identifiercolor}{rgb}{.4,.6,.56}
\definecolor{stringcolor}{gray}{0.5}
\definecolor{inactivecolor}{rgb}{0.15,0.15,0.5}
\usepackage{listings}
\lstset{basicstyle={\footnotesize\def\fvm@Scale{.85}\fontfamily{fvm}\selectfont},
  breaklines=true,
  escapeinside={\%*}{*)},
  keywordstyle={\bfseries\color{inactivecolor}},
  stringstyle={\bfseries\color{stringcolor}},
  identifierstyle={\bfseries\color{identifiercolor}},
  language=Mathematica,
  otherkeywords={DiscretizeRegion},
  showstringspaces=false}
\renewcommand{\lstlistingname}{Listing}

\begin{document}

\begin{lstlisting}[extendedchars=true,language=Mathematica]
In[1]:= Sum[Sin[n*x], {n, 1, N}]
Out[1]= Csc[x/2] Sin[(N x)/2] Sin[1/2 (1 + N) x]
\end{lstlisting}


\end{document}