GeneralListings Package Question

LaTeX specific issues not fitting into one of the other forums of this category.
Post Reply
gkl
Posts: 28
Joined: Sat Jan 17, 2009 12:21 am

Listings Package Question

Post by gkl »

Dear All,

I am writing my PhD thesis and I need to quote a few code snippets. Some of them I want them not to have captions, so in my \begin{lstlisting} directive there is no caption parameter.

However, when I need to reference them I found that it is not possible without a caption. As an example, if you have a listing like the following:
\begin{lstlisting}[label=lis:hw]
printf("Hello World!\n");
\end{lstlisting}

If later on, you write something like listing~\ref{lis:hw}, this will produce the section number and not the value of the listings counter.

Is there any cure for that?

Regards,
George

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

Post Reply