0

If I label something with a command like this:

\label{lst:\mycommand}

Because \mycommand changes for everything I'm labelling in a particular repetitive section.

When I'm using \ref{lst:abcd} for the part where \mycommand actually is abcd I seem to get nothing. Not even "??". Just void.


Here is an example:

\newcommand{\codigoname}{}
\newcommand{\codigonameu}{\something{\codigoname}}


\renewcommand{\codigoname}{filename}
\section*{\codigonameu.m}
\label{cod:\codigoname.m}
\lstinputlisting[caption={\codigonameu.m},captionpos=b,nolol]{codigos/\codigoname.m}

\renewcommand{\codigoname}{anotherfilename}
    \section*{\codigonameu.m}
    \label{cod:\codigoname.m}
    \lstinputlisting[caption={\codigonameu.m},captionpos=b,nolol]{codigos/\codigoname.m}

\renewcommand{\codigoname}{andanotherfilename}
    \section*{\codigonameu.m}
    \label{cod:\codigoname.m}
    \lstinputlisting[caption={\codigonameu.m},captionpos=b,nolol]{codigos/\codigoname.m}

and so on.

When I try to get \ref{cod:filename} or \nameref{cod:filename}... there's where the problem lies. It compiles, but there is just no reference to it.

  • Make a complete example demonstrating the problem. – Ulrike Fischer Sep 12 at 14:01
  • 2
    That example is not complete, there is is no preamble. It can not be compiled or tested like this. It also has no \ref command and so doesn't show the problem. And remove the input commands if there are not needed - we don't have the files. – Ulrike Fischer Sep 12 at 15:16

Your Answer

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

Browse other questions tagged or ask your own question.