4

I want that my PDF document contains a code snippet that looks like this:

char charValue = 'X';

I am using this code here:

\begin{lstlisting}[language=java,escapechar=|]
    char charValue = 'X';
\end{lstlisting}

Unfortunately, the output in the PDF looks like this:

char charValue = ’X’;

' has been changed to

How can this be avoided?

3

From LaTeX forum ⇒ Fonts & Character Sets ⇒ Listing package displays curly 'quotes' and tiny tildes ~:

\documentclass{article}
\usepackage{listings}
% http://latex-community.org/forum/viewtopic.php?t=4413
\usepackage{textcomp}
\lstset{basicstyle=\ttfamily,upquote=true}
\begin{document}
What's the following code do?
\begin{lstlisting}[language=java,escapechar=|]
    char charValue = 'X';
\end{lstlisting}
\end{document}

enter image description here

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.