Monday, January 24, 2011

The awesome weirdness of latex... On \begin{table} cross references

In Latex2e, always remember to put \label in the \caption command or just after it. Else latex might get the cross-references wrong!

Example: In a recent paper, I created this table: 

     \caption[]{my caption}  


And, I referenced it in the document as \ref{tab:agg}. Even though it was the first table, the compiled version read "Table 4"!! After cracking my head against this by resetting counters and creating new counters for the table, I found that the real problem was the placement of the \label. Once placed like this below, the cross-references work just fine:

   \caption{my caption}      
   \caption{my caption%  

No comments: