I may be doing something wrong but can't realize what...

I want to set a label for a piece of code represented by:

\lstinputlisting[language=Python, label={lst:control_os_call}, firstline=231, lastline=257]{./code/server.py}

so, I just try to link it using \ref


but I am getting a label missing error all the time (just for labels on \lstinputlisting). So... Should I import any specific package to reference those kind of labels or what am I doing wrong?

Thanks a lot :)

  • Welcome to TeX.SX! You can have a look at our starter guide to familiarize yourself further with our format. – user11232 Apr 23 '15 at 12:48
  • Kindly add a minimal working example (MWE) always as I did in my answer. – user11232 Apr 23 '15 at 12:48

You need to add a caption thats all

This is some python code


\lstinputlisting[language=Python,caption={some python code}, label={lst:control_os_call}, firstline=1, lastline=257]{server.py}

Here is the code~\ref{lst:control_os_call}

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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