Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Math symbols in listings

I have a problem with LaTeX – I don't know how to put mathematical equations and symbols in listings. I use the listings package and it's offers great looking listings, but it doesn't allow math symbols in $ ... $. Another package, algorithms, allows math, but listings doesn't look as good as with listings (the problem is that algorithms demands to get new line after every if, then, etc.)

like image 390
Michal Avatar asked May 11 '10 10:05

Michal


People also ask

What does ∈ mean in logic?

The symbol ∈ indicates set membership and means “is an element of” so that the statement x∈A means that x is an element of the set A. In other words, x is one of the objects in the collection of (possibly many) objects in the set A.

What does the symbol ∩ indicate?

∩ The symbol ∩ means intersection. Given two sets S and T, S ∩ T is used to denote the set {x|x ∈ S and x ∈ T}. For example {1,2,3}∩{3,4,5} = {3}.

What does ∧ mean in math?

∧ or (English symbol name wedge) (mathematics, logic) The conjunction operator, forming a Boolean-valued function, typically with two arguments, returning true only if all of its arguments are true.


1 Answers

You can use the option mathescape for your environment which gives you the ability to use the normal latex behavior of the $-signs. Try:

\begin{lstlisting}[mathescape] ... \end{lstlisting} 

For more info, take a look into the listings package manual.

like image 64
mropa Avatar answered Oct 14 '22 14:10

mropa