General ⇒ Listings Package Question
Listings Package Question
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
Learn LaTeX easily with newest books:
The LaTeX Beginner's Guide: 2nd edition and perfect for students writing a thesis
The LaTeX Cookbook: 2nd edition full of practical examples for mathematics, physics, chemistry, and more
LaTeX Graphics with TikZ: the first book about TikZ for perfect drawings in your LaTeX thesis