Troubleshooting LaTeX Referencing Issues for Your Third Year Project Report

  • Context: LaTeX 
  • Thread starter Thread starter ajclarke
  • Start date Start date
  • Tags Tags
    Latex
Click For Summary

Discussion Overview

The discussion revolves around troubleshooting referencing issues in LaTeX for a third-year project report. Participants explore the correct placement of labels and captions in LaTeX tables to ensure proper referencing throughout the document.

Discussion Character

  • Technical explanation
  • Exploratory

Main Points Raised

  • One participant shares a code snippet for a table and describes an issue where the reference to the table appears as "Table 1.2" instead of "Table 1".
  • Another participant suggests checking if the table is in section 1.2 and recommends placing the \label command after or inside the \caption.
  • A participant confirms that changing the label placement resolved the issue and speculates that sections may automatically become labels, leading to the confusion.
  • Another participant explains the function of the \label command, noting that it assigns a name to the last value of an internal counter, which is influenced by sections and chapters, and emphasizes that the \caption command is crucial for incrementing the table-number counter.
  • There is a suggestion that placing the \label command after the \caption may also work, though it may not align with expectations.

Areas of Agreement / Disagreement

Participants generally agree on the importance of the placement of the \label command in relation to the \caption command, but there is no consensus on the implications of section numbering on label referencing.

Contextual Notes

The discussion highlights the dependency of LaTeX referencing on the order of commands and the structure of the document, but does not resolve all potential implications of section numbering on label assignments.

ajclarke
Messages
34
Reaction score
1
Hey guys.

I recently went into a foray in learning LaTeX for my third year project report, because I want it to look professional and it's a good skill to say I have for PhD application.

I have however hit a stumbling block. Below is some sample code:

Code:
\begin{table}[!h]
	\begin{center}
	\begin{tabular}{|c|c|}

		\hline
		\bf{Name} & \bf{J1501-434} \\\hline
		RA & 15 01 \\\hline
		Dec & -43 \\\hline
		Mag & 12 \\\hline
		Spec Type. & dM0e \\\hline
	\end{tabular}
	\end{center}
		\label{j1501}
		\caption{Observational Data for J1501}
\end{table}

and

Code:
Table \ref{j1501} specifies the data required for observation.

However When I compile this is what I get as output. (Note: the reference isn't in the place i specified, its elsewhere in the document, I just moved it so that you didnt have to troll through my code)

Pretty Table of Data Looking as Expected
Table 1: Observational Data for J1501

And then later on:

Table 1.2 specifies the data required for observation.


I don't understand why its clearly made the table, numero uno, which is right since its the first table I have added, but then when i ref back to it, it thinks its table 1.2 :/

Thanks
 
Physics news on Phys.org
Does the table happen to be in section 1.2?

If so, try putting the \label command after (or inside) the \caption...
 
You sir, are a genius =D Thank you very much. Changed it to

\caption{\label{j1501}Observational Data for J1501}

And had to compile twice for it to register but it worked fine. So I am guessing that sections automatically become labels, and since I have a section named J1501 its thinking i was referencing to that instead?
 
Well, basically what \label does is assign the name you give it ("j1501") to the last value that some internal counter was set to. This counter is set, among other things, by chapters and sections.
The table environment does basically nothing except create a floating frame. The incrementing of the table-number counter is done by the \caption command, and this also sets this special counter. So \label only works inside, or after, \caption.
I bet you that
Code:
\begin{table}[!h]
   ...
   \caption{Observational Data for J1501}
\end{table}
\label{j1501}

also does what you want (although maybe not what you expect).
 

Similar threads

  • · Replies 0 ·
Replies
0
Views
3K
  • · Replies 2 ·
Replies
2
Views
6K
  • · Replies 2 ·
Replies
2
Views
4K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 9 ·
Replies
9
Views
2K
  • · Replies 3 ·
Replies
3
Views
3K
  • · Replies 3 ·
Replies
3
Views
3K
  • · Replies 2 ·
Replies
2
Views
4K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 2 ·
Replies
2
Views
6K