I have an output from R (which is a plain text) that I want to typeset using the listings package. The plain text file involves using special characters like asterisks and quotation marks together and that's where the trouble is happening. Please see the figure below.
For comparison, I typeset the text file using listings package (below) and the verbatim environment (above). You can see that the annotated part differs from the two. How can I fix this?
(FYI: I use XeTeX to compile my documents.)
Here's the MWE:
\documentclass{minimal}
\usepackage{listings}
\begin{document}
\textbf{VERBATIM}.
\begin{verbatim}
Call:
lm(formula = nettfa ~ inc + age, data = subset(data, fsize ==
1))
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 44.68 on 2014 degrees of freedom
\end{verbatim}
\textbf{LISTINGS}.
\begin{lstlisting}
Call:
lm(formula = nettfa ~ inc + age, data = subset(data, fsize ==
1))
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 44.68 on 2014 degrees of freedom
\end{lstlisting}
\end{document}
Follow up
Adding this code to the preamble solved my problem:
\begingroup % properly typesets UNICODE in listings
\catcode0=12 %
\makeatletter
\g@addto@macro\lst@DefEC{%
\lst@CCECUse\lst@ProcessLetter
‘’% *** add Unicode characters ***
^^00% end marker
}%
\endgroup
