1

After I used the answer posted to this question of mine: How to show similar display of codes of different programming languages in LaTeX, it seems that the package and styles I use have problems with packages \usepackage{xcolor} and \usepackage{listings}.

As far as my thesis report is in black and white colors, I only need that the codes I want to bring to my report be the same as the Mathematica codes in the font aspect.

How can I copy some codes in a document very similar to the fonts in the Mathematica software?

If it is possible, please post some answers which do not require defining styles and be easy to use in the main document. I mean, defining styles seems to be much more problematic for the document class I am using than using in-situ codes such as {\bf ... }.

enthu
  • 3,795

1 Answers1

3
\documentclass[12pt]{book}

\usepackage{listings}

\usepackage{accsupp}
\newcommand*{\noaccsupp}[1]{\BeginAccSupp{ActualText={}}#1\EndAccSupp{}}


\lstdefinestyle{Common}
{
    basicstyle=\scriptsize\ttfamily\null,
    numbers=left,
    numbersep=1em,
    frame=single,
    framesep=\fboxsep,
    framerule=\fboxrule,
    xleftmargin=\dimexpr\fboxsep+\fboxrule,
    xrightmargin=\dimexpr\fboxsep+\fboxrule,
    breaklines=true,
    breakindent=0pt,
    tabsize=5,
    columns=flexible,
    showstringspaces=false,
    captionpos=b,% or t for top (default)
    abovecaptionskip=0.5\smallskipamount,   % there is also belowcaptionskip
}


\lstdefinestyle{Mathematica}
{
    style=Common,
    language={Mathematica},
    alsolanguage={[LaTeX]TeX},
    morekeywords=
    {
        Animate,
        AnimationRunning,
    },
}





\lstdefinestyle{MathPlain}
{
    style=Mathematica,
    keywordstyle=\bf,
    %identifierstyle=\color{ForestGreen},
    %backgroundcolor=\color{Cyan!10},
    %numberstyle=\color{Black}\tiny\noaccsupp,
    %rulecolor=\color{Maroon},
}



\lstnewenvironment{MathPlain}
{\lstset{style=MathPlain}}
{}


\usepackage{lipsum}

\begin{document}
\chapter{I am a PSTricks evangelist}
\lipsum[1]

\begin{MathPlain}
Do[i^j, {i,1,10}, {j,1,10}];
Animate[Plot[Sin[x + a], {x, 0, 10}], {a, 0, 5}, AnimationRunning -> False] 
\end{MathPlain}

\lipsum[2]
\end{document}

enter image description here