Why does Listings package not display anything? [closed]

I'm writing a C++ course for secondary students and wanted to display some source code in a nice way (indenting, eventually coloration) and tried the Listings package. But I have a problem, the file compile with no problem and then, when I look at the place where my code is supposed to appear, it is empty. Neither code or spaces. Why? I am not really a LaTex expert, I just wrote my thesis with it (no source code in it), so maybe it is something very simple I missed... Working on a mac with texmaker in utf8.

-

closed as unclear what you're asking by Jubobs, Martin Schröder, mafp, Speravir, ChrisSJan 16 '14 at 0:53

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.

You should post a minimal example of the code that you're trying to compile. – Juan A. Navarro Jan 20 '11 at 15:06

Seems like listings package doesn't play well with draft option in the document class. I've found solution that works for me:

\documentclass[11pt,a4paper,draft]{article}
...
\usepackage[final]{listings}
...


That way I've got both black marks on overfull lines and listings. The same trick works with graphicx package.

-
Works very well :) – FireFly3000 Nov 25 '14 at 9:53
Fixed my problem as well. Thanks! – Marek Andreansky Dec 2 '14 at 23:55

listings.sty can not handle utf8-characters. If this is your problem use listingsutf8 or alternetively package minted. If this is not an answer to your problem, then as usual: provide a small minimal example ...

-
Thank you very much! That was the problem... I always get problems when I want to use utf8... I will stick to latin1 now :) – Lucas Jan 20 '11 at 15:28
Oops. I answered too early... In fact it does work with the snippet, but not with the code section or inclusion... – Lucas Jan 20 '11 at 17:24
\documentclass[11pt,a4paper,draft]{article} \usepackage[latin1]{inputenc} \usepackage[T1]{fontenc} \usepackage{lmodern} \usepackage{array} \usepackage{listings} \begin{document} \section{Snippet} \lstset{language=C++} \lstinline!void main() {return 0}! \section{section} \lstset{language=C++} \begin{lstlisting}[frame=single] void main() { return 0; } \end{lstlisting} \section{include} \lstinputlisting{ex_comments.cpp} \end{document} – Lucas Jan 20 '11 at 17:30
@Lucas: do not use the option draft in the documentclass – Herbert Jan 20 '11 at 20:18
Ohhh... This time it works perfectly! That happens when you try to use commands you don't know, supposing which is the effect... Anyway, thank you very much! Lucas – Lucas Jan 22 '11 at 8:03