I'm using this \lstinputlisting[float=h,frame=tb,caption= {Normal model},label= {lst:Norm}, language = {R}]{Model.glm1.txt} and I've got a labelled table in the same chapter of my essay, but referencing both result in a conflicting reference number. How do I solve this problem?

For the lstlisting It was labelled Listing 4.1 and the table have got label Table 4.1. Referencing both each gives 4.1

closed as unclear what you're asking by Stefan Pinnow, Bobyandbob, egreg, Zarko, Schweinebacke Jan 1 '18 at 14:52

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • 1
    Welcome to TeX.SX! Please post a full minimal working example (MWE) to help us help you. – TeXnician May 28 '17 at 7:43
  • 1
    What is the conflict here? Both having the same reference number? – user31729 May 28 '17 at 8:07
  • Exactly, both are having the same reference number. Though, clicking on each one of them direct me to the right table but I the reference number in both cases to be different. – Usman May 28 '17 at 9:19
  • 1
    @Usman I don't understand the problem. If you have see listing~\ref{lst:foo} and table~\ref{tab:bla} then from the context it is clear if you mean the listing or the table, regardless if they have the same number or not. (You probably also have a section 4.1, haven't you? Is it a problem, too?) – clemens May 28 '17 at 9:32
  • 1
    I'm voting to close this question as off-topic because the OP misunderstood numbering scheme of listings and tables. – Schweinebacke Jan 1 '18 at 14:52

Such ambiguities with respect to the referred entity can be solved by either manual specification of the related entity as Clemens suggested or use cleveref, for example, that has a built-in 'database' of counters:




See \cref{tab:nice} and \cref{lst:Norm} 

  \caption{dummy table}\label{tab:nice}

\lstinputlisting[float=h,frame=tb,caption= {Normal model},label= {lst:Norm}, language = {C}]{helloworldexample.c}



int main(int argc,char **argv)
  printf("Hello World!\n");

enter image description here

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