Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I'm using the listings package to include some source code files in a LaTeX document.

I'm having 2 problems:

  1. characters - are not shown in the resulting file
  2. characters % are shown overlapped with characters that appear after it.

This is my lstset:

\lstset{
showstringspaces=false,
extendedchars=true,
frameround=fttt,
frame=single,
upquote=true,
breaklines=true
}

And this is how I insert listings:

\begin{figure}[t]
{\small{
\lstinputlisting[language=Python,numbers=left, numberstyle=\tiny]{modProblem.txt}
\caption{\label{fig:modProblem} El problema del operador \%}
}}
\end{figure}
share|improve this question

closed as unclear what you're asking by Jubobs, Charles Stewart, Svend Tveskæg, Peter Jansson, OSjerick Jan 15 at 21:01

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question.If this question can be reworded to fit the rules in the help center, please edit the question.

3  
Please provide a minimal working example. Moreover the command \lstinputlisting has the option caption. –  Marco Daniel Jun 16 '12 at 17:24
1  
Welcome to TeX.SE. While code snippets are useful in explanations, it is always best to compose a fully compilable MWE that illustrates the problem including the \documentclass and the appropriate packages so that those trying to help don't have to recreate it. In this case it will actually help to ensure that the solution actually solves your specific problem. –  Peter Grill Jun 16 '12 at 18:48

1 Answer 1

Tried to make you MWE:

\documentclass{article}
\usepackage{listings}
\usepackage{textcomp}

\lstset{
showstringspaces=false,
extendedchars=true,
frameround=fttt,
frame=single,
upquote=true,
breaklines=true
}

\begin{document}
\lstinputlisting[caption=El problema del operador \%  resuelto,language=Python,numbers=left, numberstyle=\small]{primes.py}
\end{document}

It produces normal output (on Windows, using both pdfLaTeX and XeLaTeX on TexWorks):

Listing of Python code

Only thing that needed to be added was \usepackage{textcomp} in order to use upquote=true,.

share|improve this answer

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