0

edit: the duplicated result was great! thanks for finding it for me. I couldn't get the right key-word to search for that but you find it for me after I could not find for 10 minutes. thanks verymuch it works well.

I'm having a weird issue where the referenced label and the actual number displaced on the document do not match. A picture probably help:

figure number mismatch?

I cannot provide a minimal viable example as I am using some template file which probably is causing this issue, so if I start fresh this issue obviously do not manifest.

If anyone is interested here is a link to the template file, maybe there's something that can clue you to help with this issue?

https://gist.github.com/evanthebouncy/b5c3bb991222b1ca280b9bffdcc58e72

thanks in advance. I am very very perplexed why it happens.

Evan Pu
  • 203
  • Please add small document example (MWE: Minimal Working Example),which reproduce your problem, to your question. Your link can be dead after while and after than no one can see what cause your problem. – Zarko Aug 11 '19 at 20:18
  • I assume, you have run latex enough times. Under the hood, one run is used to generate the labels, and another one to include the correct ones. If you use BibTeX or whatever for citations, it's even more complicated. That's the reason latexmk (and I suspect, also arara) exists. You could try these. – Oleg Lobachev Aug 11 '19 at 20:23
  • 1
    that is the most frequent of FAQ for latex: you have the \label before the caption so it picks up the section number not the number from the caption. Please in future show code as text not as an image. – David Carlisle Aug 11 '19 at 20:28
  • ahh i knew the good people here would point out the duplicate for me. it was very hard for me to search for it explicitly but I knew it should exist. thanks guys. I'm out. – Evan Pu Aug 12 '19 at 01:54

1 Answers1

1

In my experience, this can happen if you run LaTeX just once after changing something that gets the reference a new number (shuffle them around, insert/delete some, ...). LaTeX writes the references to a file after processing the document, and reads said file the next run. So the file can contain stale data. You usually have to run LaTeX at least twice. On e.g. Linux, there is a command latexmk(1) that runs LaTeX (and BibTeX, and...) in the right order the required number of times to get everything fully up to date.

vonbrand
  • 5,473
  • 1
    This answer is completely wrong, sorry. The image in the question clearly shows that \label is in the wrong place so \ref will never show the figure number as it is referencing the section. – David Carlisle Aug 12 '19 at 08:52