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.

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

1 Answer 1

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
    }
}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .