0

I know, that this error has been answered in various forms here, but I was unable to find a solution to my problem.

The following code gives me errors:

There were undefined references. LaTeX [1,1]

Label(s) may have changed. Rerun to get cross-references right. LaTeX [1,1]

Reference `equality' on page 1 undefined. LaTeX [10,1]

The "LaTeX[r,c]" just refers to the r-th line and c-th column of the code. My code is:

\documentclass{article}
\usepackage{bookmark}
\usepackage{hyperref}
\begin{document}

Hello.

\begin{equation}
x=y\label{equality}
\end{equation}
Refer \ref{equality}.
\end{document}

I do pdflatex -> bibtex -> pdflatex -> pdflatex. Also, I ran it several times in a row and none of the warnings go away.

My output has ??, where my code has \ref{}. It looks like this:

Output_image

Any help is appreciated. EDIT: I am posting the log after my second compile, in case it is needed.

This is pdfTeX, Version 3.14159265-2.6-1.40.20 (MiKTeX 2.9.7050 64-bit)
entering extended mode
("c:/Users/adamy/OneDrive/TeX/Tests/New folder/Test file 2.tex"
LaTeX2e <2018-12-01>
("C:\Users\adamy\AppData\Local\Programs\MiKTeX 2.9\tex/latex/base\article.cls"
Document Class: article 2018/09/03 v1.4i Standard LaTeX document class
("C:\Users\adamy\AppData\Local\Programs\MiKTeX 2.9\tex/latex/base\size10.clo")) ("C:\Users\adamy\AppData\Local\Programs\MiKTeX 2.9\tex/latex/oberdiek\bookmark.sty" ("C:\Users\adamy\AppData\Local\Programs\MiKTeX 2.9\tex/generic/oberdiek\pdfescape.sty" ("C:\Users\adamy\AppData\Local\Programs\MiKTeX 2.9\tex/generic/oberdiek\ltxcmds.sty") ("C:\Users\adamy\AppData\Local\Programs\MiKTeX 2.9\tex/generic/oberdiek\pdftexcmds.sty" ("C:\Users\adamy\AppData\Local\Programs\MiKTeX 2.9\tex/generic/oberdiek\infwarerr.sty") ("C:\Users\adamy\AppData\Local\Programs\MiKTeX 2.9\tex/generic/oberdiek\ifluatex.sty") ("C:\Users\adamy\AppData\Local\Programs\MiKTeX 2.9\tex/generic/oberdiek\ifpdf.sty"))) ("C:\Users\adamy\AppData\Local\Programs\MiKTeX 2.9\tex/generic/ifxetex\ifxetex.sty") ("C:\Users\adamy\AppData\Local\Programs\MiKTeX 2.9\tex/generic/oberdiek\ifvtex.sty") ("C:\Users\adamy\AppData\Local\Programs\MiKTeX 2.9\tex/latex/hyperref\hyperref.sty" ("C:\Users\adamy\AppData\Local\Programs\MiKTeX 2.9\tex/generic/oberdiek\hobsub-hyperref.sty" ("C:\Users\adamy\AppData\Local\Programs\MiKTeX 2.9\tex/generic/oberdiek\hobsub-generic.sty")) ("C:\Users\adamy\AppData\Local\Programs\MiKTeX 2.9\tex/latex/graphics\keyval.sty") ("C:\Users\adamy\AppData\Local\Programs\MiKTeX 2.9\tex/latex/oberdiek\auxhook.sty") ("C:\Users\adamy\AppData\Local\Programs\MiKTeX 2.9\tex/latex/oberdiek\kvoptions.sty") ("C:\Users\adamy\AppData\Local\Programs\MiKTeX 2.9\tex/latex/hyperref\pd1enc.def") ("C:\Users\adamy\AppData\Local\Programs\MiKTeX 2.9\tex/latex/00miktex\hyperref.cfg") ("C:\Users\adamy\AppData\Local\Programs\MiKTeX 2.9\tex/latex/url\url.sty")) ("C:\Users\adamy\AppData\Local\Programs\MiKTeX 2.9\tex/latex/hyperref\hpdftex.def" ("C:\Users\adamy\AppData\Local\Programs\MiKTeX 2.9\tex/latex/oberdiek\rerunfilecheck.sty")) ("C:\Users\adamy\AppData\Local\Programs\MiKTeX 2.9\tex/latex/oberdiek\bkm-pdftex.def"))
No file "Test file 2".aux.
("C:\Users\adamy\AppData\Local\Programs\MiKTeX 2.9\tex/latex/hyperref\nameref.sty" ("C:\Users\adamy\AppData\Local\Programs\MiKTeX 2.9\tex/generic/oberdiek\gettitlestring.sty"))

LaTeX Warning: Reference `equality' on page 1 undefined on input line 10.

[1{C:/Users/adamy/AppData/Local/MiKTeX/2.9/pdftex/config/pdftex.map}] ("Test file 2.aux")

LaTeX Warning: There were undefined references.


LaTeX Warning: Label(s) may have changed. Rerun to get
cross-references right.

 )<C:/Users/adamy/AppData/Local/Programs/MiKTeX
2.9/fonts/type1/public/amsfonts/cm/cmbx10.pfb><C:/Users/adamy/AppData/Local/Programs/MiKTeX
2.9/fonts/type1/public/amsfonts/cm/cmmi10.pfb><C:/Users/adamy/AppData/Local/Programs/MiKTeX
2.9/fonts/type1/public/amsfonts/cm/cmr10.pfb> Output written on "Test file 2.pdf" (1 page, 30446 bytes). SyncTeX written on "Test file
2.synctex.gz" Transcript written on "Test file 2.log". This is BibTeX, Version 0.99d (MiKTeX 2.9.7050 64-bit) The top-level auxiliary file:
Test file 2.aux I found no \citation commands---while reading file
Test file 2.aux I found no \bibdata command---while reading file Test
file 2.aux I found no \bibstyle command---while reading file Test file
2.aux (There were 3 error messages)
Mico
  • 506,678
  • Welcome to TeX.SE. The issue you're experiencing is not related to the hyperref package. When creating cross-references via LaTeX's \label-\ref mechanism, it's crucial to compile the document (at least) twice in order to resolve the cross-references. To be sure, I get ?? along with a "There were undefined references" warning the first time I compile your MWE, and I get 1 (surrounded by a red rectangle, a hyperref is loaded) the second time I compile the test document. If you keep getting ??, you must check if the aux file is somehow being deleted between compilation runs. – Mico Jul 06 '19 at 18:19
  • 2
    Are you cleaning up between the compilations? – Ulrike Fischer Jul 06 '19 at 18:20
  • I am not cleaning up between compilations as far as I know. But, I do see that ALL my files (including the aux file) get recreated when I compile. Should this not be the case? As in, should my aux file not get a new time stamp every time I compile? – odomosis Jul 06 '19 at 18:25
  • 1
    Show the log-file of your example after the second compilation. – Ulrike Fischer Jul 06 '19 at 18:30
  • You know what, I just recompiled it using a different LaTeX editor and noticed that the aux file does not get a new time stamp this time. Some of the others files did, but some (like the aux) did not. And my output PDF has the correct equation number!! No "??". Thus, the issue, as you pointed out, could be how I am compiling. Let me post the log files after my second compile, just in case. – odomosis Jul 06 '19 at 18:34
  • 1
    can't reproduce your problem. MWE works fine for me. – naphaneal Jul 06 '19 at 18:38
  • @naphaneal Does your aux file get a new time stamp every time you compile? I think it might have to do with my compile process because my aux file - in fact ALL my files - gets recreated on each compile i.e. their timestamp is updated on each compile. Does this happen for you too? – odomosis Jul 06 '19 at 18:49
  • 1
    There is no aux-file No file "Test file 2".aux., this means that something has deleted it. Don't use texify to compile, use pdflatex directly. – Ulrike Fischer Jul 06 '19 at 18:51
  • 1
    the files are supposed to get regenerated each run – David Carlisle Jul 06 '19 at 18:51
  • @UlrikeFischer Got it. Let me fiddle around with my compilation process and see how it goes. I am pretty sure it has to with deletion of the aux file as you pointed out. – odomosis Jul 06 '19 at 18:56
  • @DavidCarlisle I see. Let me play around with this, based on Ulrike's suggestion and see if it works. I'll get back with an update! Thanks. – odomosis Jul 06 '19 at 18:57
  • Thank you everyone for your help! The suggestions worked! I tweaked a setting in my compiling process. I think it had to do with my compilation process deleting all the files during each compilation run and recreating them from scratch, instead of just updating them. This is not a problem for usual runs without references etc. But, I guess, hyperref needs the previous files to exist and be updated rather than recreate them from scratch. Does this explanation fit in? Recreating from scratch vs updating files? – odomosis Jul 06 '19 at 20:11
  • Thanks @Mico for your input. – odomosis Jul 06 '19 at 20:14
  • @odomosis - As i wrote in my earlier comment, the issue you were experiencing (and which is now resolved, right?) is in no way related to hyperref. – Mico Jul 06 '19 at 20:43
  • 1
    you always need the files from the last run for any non trivial document, references, tables of contents, indices etc all require this (whether or not you use hyperref) – David Carlisle Jul 06 '19 at 23:37

0 Answers0