Referencing in Latex isn't working


Results 1 to 5 of 5

Thread: Referencing in Latex isn't working

  1. #1
    Join Date
    Jan 2003
    Location
    Austin, Texas
    Posts
    683

    Referencing in Latex isn't working

    I have some strange behavior in Latex. I have added labels to all of my tables (currently there are 3) and my figure (currently there is only 1). So far I only notice this behavior with tables, though it may happen with figures as well...I will have to add another figure to test that.

    However, what is happening is that my list of tables is correctly generating the numbers of the tables (which are 3.1, 3.2, and 4.1). In the resulting PDF document, the tables have the correct numbers in the captions as well. The odd thing is that when I attempt to reference them using \ref, it is printing the Chapter.Section[.Subsection] number the table is located in instead of the table's number itself.

    Right now I have two tables inside of Chapter 3 Section 3. They are as follows:

    Code:
    \begin{table}[htdp]
    \begin{center}
    \caption{Infection rate with 5\% interaction}
    \begin{tabular}{|r|r|}
    \hline
    \multirow{2}{*}{Days} & {Number of} \\
    & {infected users} \\
    \hline
    \hline 1 & 8 \\
    \hline 2 & 72 \\
    \hline 3 & 584 \\
    \hline 4 & 4,680 \\
    \hline 5 & 37,448 \\
    \hline 6 & 299,592 \\
    \hline 7 & 2,396,744 \\
    \hline 8 & 19,173,960 \\
    \hline 9 & 153,391,688 \\
    \hline 
    \end{tabular} 
    \end{center}
    \label{tab:5pctinfection}
    \end{table}
    
    
    \begin{table}[htdp]
    \begin{center}
    \caption{Infection rate with 10\% interaction}
    \begin{tabular}{|r|r|}
    \hline
    \multirow{2}{*}{Days} & {Number of} \\
    & {infected users} \\
    \hline
    \hline 1 & 15 \\
    \hline 2 & 240 \\
    \hline 3 & 3,615 \\
    \hline 4 & 54,240 \\
    \hline 5 & 813,615 \\
    \hline 6 & 12,204,240 \\
    \hline 7 & 183,063,615 \\
    \hline 
    \end{tabular} 
    \end{center}
    \label{tab:10pctinfection}
    \end{table}
    Notice that they all have unique labels on them, but I when I attempt to reference them like:

    Code:
    see Table \ref{tab:5pctinfection} for blah blah blah
    and

    Code:
    see Table \ref{tab:10pctinfection} for even more awesome stuff
    it prints "Table 3.3" for both of them instead of "Table 3.1" for the first table and "Table 3.2" for the second. In Chapter4.tex, when I attempt to reference Table 4.1 using:

    Code:
    Table \ref{tab:avsoftware}
    It prints "Table 4.1.1" in the PDF file! What gives? I am pretty sure I am not referencing these tables incorrectly. I could manually type in the numbers but that defeats the purpose of having \ref!!
    "The author of that poem is either Homer or, if not Homer, somebody else of the same name."

  2. #2
    Join Date
    Jul 2002
    Location
    Vladivostok, Russia
    Posts
    9,053
    "I was pulled over for speeding today. The officer said, "Don't you know
    the speed limit is 55 miles an hour?" And I said, "Yes, but I wasn't going
    to be out that long."

    How To Ask Questions The Smart Way
    COME VISIT ME IN RUSSIA NOW!!

  3. #3
    Join Date
    Jan 2003
    Location
    Austin, Texas
    Posts
    683
    Thanks JohnT...but I already found that page in my google searches. It states that I should be labeling and referencing tables exactly as I am already doing.
    "The author of that poem is either Homer or, if not Homer, somebody else of the same name."

  4. #4
    Join Date
    Jul 2002
    Location
    Vladivostok, Russia
    Posts
    9,053
    Not an expert at LATEX but wouldn't referencing the table number...then the subsection give you the result?
    "I was pulled over for speeding today. The officer said, "Don't you know
    the speed limit is 55 miles an hour?" And I said, "Yes, but I wasn't going
    to be out that long."

    How To Ask Questions The Smart Way
    COME VISIT ME IN RUSSIA NOW!!

  5. #5
    Join Date
    Jun 2015
    Posts
    1

    Same problem

    Yes! I'm having the same problem! It keeps printing the same Table reference numbers for different tables:

    e.g. compiling "see ~\ref{table1name},~\ref{table2name}, and~\ref{table3name) for badassery" will print in the PDF as "see Table 1.1, 1.1, and 1.1 for badassery" INSTEAD of "see Table 1.1, 1.2, and 1.3 for badassery".

    What's really weird about this is that elsewhere in the document, even within the same section, I don't have this issue. That is, it prints accurately elsewhere using the exact same command format. I've compiled 8 million times. no change.

    Has somebody ever solved this!?


    Quote Originally Posted by gamblor01 View Post
    I have some strange behavior in Latex. I have added labels to all of my tables (currently there are 3) and my figure (currently there is only 1). So far I only notice this behavior with tables, though it may happen with figures as well...I will have to add another figure to test that.

    However, what is happening is that my list of tables is correctly generating the numbers of the tables (which are 3.1, 3.2, and 4.1). In the resulting PDF document, the tables have the correct numbers in the captions as well. The odd thing is that when I attempt to reference them using \ref, it is printing the Chapter.Section[.Subsection] number the table is located in instead of the table's number itself.

    Right now I have two tables inside of Chapter 3 Section 3. They are as follows:

    Code:
    \begin{table}[htdp]
    \begin{center}
    \caption{Infection rate with 5\% interaction}
    \begin{tabular}{|r|r|}
    \hline
    \multirow{2}{*}{Days} & {Number of} \\
    & {infected users} \\
    \hline
    \hline 1 & 8 \\
    \hline 2 & 72 \\
    \hline 3 & 584 \\
    \hline 4 & 4,680 \\
    \hline 5 & 37,448 \\
    \hline 6 & 299,592 \\
    \hline 7 & 2,396,744 \\
    \hline 8 & 19,173,960 \\
    \hline 9 & 153,391,688 \\
    \hline 
    \end{tabular} 
    \end{center}
    \label{tab:5pctinfection}
    \end{table}
    
    
    \begin{table}[htdp]
    \begin{center}
    \caption{Infection rate with 10\% interaction}
    \begin{tabular}{|r|r|}
    \hline
    \multirow{2}{*}{Days} & {Number of} \\
    & {infected users} \\
    \hline
    \hline 1 & 15 \\
    \hline 2 & 240 \\
    \hline 3 & 3,615 \\
    \hline 4 & 54,240 \\
    \hline 5 & 813,615 \\
    \hline 6 & 12,204,240 \\
    \hline 7 & 183,063,615 \\
    \hline 
    \end{tabular} 
    \end{center}
    \label{tab:10pctinfection}
    \end{table}
    Notice that they all have unique labels on them, but I when I attempt to reference them like:

    Code:
    see Table \ref{tab:5pctinfection} for blah blah blah
    and

    Code:
    see Table \ref{tab:10pctinfection} for even more awesome stuff
    it prints "Table 3.3" for both of them instead of "Table 3.1" for the first table and "Table 3.2" for the second. In Chapter4.tex, when I attempt to reference Table 4.1 using:

    Code:
    Table \ref{tab:avsoftware}
    It prints "Table 4.1.1" in the PDF file! What gives? I am pretty sure I am not referencing these tables incorrectly. I could manually type in the numbers but that defeats the purpose of having \ref!!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •