0

This question already has an answer here:

How to handle the 'underscore' and the special character in latex listing. I am working on a simple prolog style code

\begin{lstlisting}[label=LE, name=R_E]
    $\alpha_{1}$ = *M1*  °h1°(^A^, ^B^) :- °b1,1°(^B^, ^A^), °b1,2°(X).
    $\alpha_{2}$ = *M2*  °h2°(^A^, ^B^) :- °b2,1°(^B^, ^A^), °b2,2°(X).
\end{lstlisting}

This produces an output as shown below:

enter image description here

Below is my latex listing command:

\lstset{language=Prolog,
numbers=left, numberstyle=\scriptsize, numbersep=3pt,
basicstyle=\scriptsize \ttfamily,
tabsize=3,
captionpos=t,
stepnumber=1,
frame=lines,
breaklines=true,
showspaces=false,
commentstyle=\scriptsize\ttfamily \color{mygreen},
moredelim=**[is][\color{vc}]{°}{°}, % To use text color inside a listing, we use a dilimiter
moredelim=**[is][\color{kw}]{*}{*},
moredelim=**[is][\color{darkgreen}]{^}{^},
%moredelim=**[is][\color{cyan}]{<?}{?>},
keywordstyle=\color{cyan},
morekeywords={type,value,href,xmlns,owl,/owl,rdf,/rdf,date,source,start,id,name,language,as, refersTo},
morecomment=[s]{<!--}{-->},
morecomment=[s][\color{grey}]{<<}{>>}
escapeinside={} 
}

But its not printing the character 'α' nor the underscore next to it. Similaryl, also next to 'h' and further 'b'

marked as duplicate by egreg tex-core Jul 17 '15 at 15:23

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

0

Using 'mathescape'

\begin{lstlisting}[label=LE, name=R_E, mathescape]
    $\alpha_{1}$ = *M1*  °h1°(^A^, ^B^) :- °b1,1°(^B^, ^A^), °b1,2°(X).
    $\alpha_{2}$ = *M2*  °h2°(^A^, ^B^) :- °b2,1°(^B^, ^A^), °b2,2°(X).
\end{lstlisting}

Not the answer you're looking for? Browse other questions tagged or ask your own question.