Using the book class equations, tables, figures and sections have the chapter number as first number of the label (e.g. the first equation of chapter 2 is equation 2.1).

I want to remove the chapter number from the label but I want to keep it when I refer to it (the best would be keeping it if and only if the reference is outside the chapter where the label is)


Here is how I would go:





\ifnum\result=\thechapter \RefNum{#1}\else\ref{#1}\fi}



\caption{\label{fig1}Figure chap 1}




\caption{\label{fig2}Figure chap 2}

Here see the Figure \myref{fig1}.

Here see the Figure \myref{fig2}.

Here for the equation \myref{eq1}

The command \myref acts as the \ref command if you are referring to something in another chapter and suppress the chapter number if you are referring to something in the same chapter.

  • \xspace does nothing there; its usage is only with parameterless macros. – egreg Sep 15 '13 at 15:26
  • @egreg You're right. It remained from a previous attempt to solve the problem. Edited my answer. – Ludovic C. Sep 15 '13 at 15:30

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