4

Is it possible to use mathematical symbols as keywords in listing? I'm using listings package to typeset Mathematica code and I have used emph parameter of lstset to use blue bold font for some of my functions like

\lstset{
    emph={CoolFun1, CoolOp2},
    emphstyle={\color{blue}\bfseries}
}

I would like also to use some functions named with mathematical symbols, \eg\ Greek names like $\delta$ and so on. So the goal is to have something like

\lstset{
    emph={CoolFun1, $\delta$},
    emphstyle={\color{blue}\bfseries}
}

and obtain Mathematica listings with bold blue mathematical symbols.

  • Welcome to TeX.SX! You can have a look at our starter guide to familiarize yourself further with our format. – Sean Allred Aug 13 '13 at 11:47
1

A feature of listings that can come in handy in these situation is the literate option.

If you are happy with writing delta in your listing instead of $\delta$ and get it replaced with the symbol by listings then here's a solution:

\lstset{
    literate={
        {delta}{{$\color{blue}\delta$}}1
    }
}

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.