I was wondering if it is possible to refer to the lines of the code enclosed in lstlisting environment rather than just manually write a number of the line I want to describe. I have never met with this feature, is this available?
Asked
Active
Viewed 7,542 times
14
1 Answers
29
At page 53 in the manual you will find the section How to reference line numbers with the following example:
\lstset{escapeinside={(*@}{@*)}}
\begin{lstlisting}
for i:=maxint to 0 do begin
{ comment }(*@\label{comment}@*)
end;
\end{lstlisting}
Line \ref{comment} shows a comment.
Jeremy Smyth
- 648
Marco Daniel
- 95,681