Latex Cross References, citations etc not working

In summary: Once it has the references in memory, subsequent uses of pdflatex will just use what it has in memory.
  • #1
ChrisJ
70
3
Hi, not sure if this is the correct section so feel free to move if needed.

First time using latex to create a pdf here, having trouble getting cross-references and citations to work. They just appear in the text as question marks.

I got my bibliography to work, using Bibtex, but when using \cite{key} in it just appears as a question mark. The same goes for labels for headings, equations etc, again, just question marks appear.

My example code is like the below\documentclass{article}
\usepackage{graphicx}

\section{Introduction\label{my_intro}}

text text text text text text \ref{my_intro} text text text text

\begin{equation}
\label{TISE}
(\frac{\hbar^2 }{2m_e} \nabla^2 + V) \phi = E_n \phi_n
\end{equation}

text text text text \ref{TISE} text text text text \cite{bibtexkey}

\begin{figure}
\centering
\includegraphics[width=3.0in]{figure.png}
\caption{Simulation Results\label{myfig}}
\end{figure}

text text \ref{myfig} text text

\section{References}\bibliographystyle{unsrt}
\bibliography{refs}\end{document}
Im on linux and installed texlive, I first run the pdf using "pdflatex myfile.tex" then rub bibtex on the aux file and then recompile the pdf. This generates the pdf, bibliography is there, formatted all nicely, my figure works great etc, everything is great, apart from where I reference stuff in text.

I have tried both the style where the \label{mylabel} bit is both in the argument of \caption and \heading (as is in the example above) and also out of the argument but directly after and both don't work.

Any help is much appreciated!

Thanks :)EDIT: Sorry, I didnt realize the foum would parse the tex code above without the [tex] tags, is there a way I can get it to parse it as plaintext?
 
Last edited:
Physics news on Phys.org
  • #2
For some reason I've never fully understood, you need to run pdflatex twice in succession to fix this problem. The first time it will give an error that says "There are undefined references", but this message should disappear after running it a second time. So you need to run:

pdflatex myfile.tex
bibtex myfile.aux
pdflatex myfile.tex
pdflatex myfile.tex

This should fix the problem.
 
  • Like
Likes ChrisJ and BvU
  • #3
phyzguy said:
For some reason I've never fully understood, you need to run pdflatex twice in succession to fix this problem. The first time it will give an error that says "There are undefined references", but this message should disappear after running it a second time. So you need to run:

pdflatex myfile.tex
bibtex myfile.aux
pdflatex myfile.tex
pdflatex myfile.tex

This should fix the problem.

Thanks you! I think this fixed it. When referencing equations and one does \ ref{equation1key} etc in the middle of text, should that alone come up as (1) or do I need to do (\ ref{equation1key}) to get it in parenthesis? When citing references from my bibliography they automatically come up in square brackets, so I assumed equations should also come in in parenthesis?
 
  • #4
I think equation references will not include the parentheses and you need to explicitly add them as in your second example, but I suggest you try it both ways to be sure.
 
  • Like
Likes ChrisJ
  • #5
ChrisJ said:
Thanks you! I think this fixed it. When referencing equations and one does \ ref{equation1key} etc in the middle of text, should that alone come up as (1) or do I need to do (\ ref{equation1key}) to get it in parenthesis? When citing references from my bibliography they automatically come up in square brackets, so I assumed equations should also come in in parenthesis?

You can use the amsmath package. Put \usepackage{amsmath} after \usepackage{graphicx}. You can then use \eqref instead of \ref . This will put the parenthesis automatically.
 
  • Like
Likes ChrisJ
  • #6
Since LaTeX is a compiled word processor, you need to run the compiler multiple times, the first time thru it is looking for all the references and doesn't have them in memory because they are usually at the end of the document or the last thing included as an include file...
 
  • Like
Likes ChrisJ

1. Why are my cross references not working?

There are a few possible reasons for this issue. One common reason is that the labels for the cross references are not properly defined. Make sure that the label matches the reference exactly, including capitalization and spelling. Another potential issue is that the document's numbering or referencing system may not be set up correctly. Check your document settings and make sure they are consistent throughout the document.

2. How can I fix incorrect citations in my document?

If your citations are not showing up or are incorrect, there are a few steps you can take. First, make sure that you have entered the citation information correctly, including the author's name, publication date, and title. If the citation is still not working, try updating your bibliography or reference list. You may also need to check the citation style you are using and make sure it is appropriate for your document.

3. What should I do if my bibliography is not appearing?

If your bibliography is not showing up at all, check to make sure that you have added the citations correctly and that they are linked to the bibliography. You may also need to update your bibliography or reference list. If the problem persists, check your document settings to make sure the bibliography is set to appear in the correct location.

4. Can I add cross references and citations in different languages?

Yes, most document processing software allows you to add cross references and citations in different languages. However, make sure that your software supports the language you are using and that you have set the language correctly in your document settings. You may also need to install language packs or fonts for certain languages.

5. How can I troubleshoot cross reference and citation errors?

If you are encountering errors with your cross references or citations, start by checking the formatting of your document. Make sure that you have used the correct syntax and that there are no missing or extra characters. You can also try refreshing or updating the citations and cross references, and checking for any software updates. If the issue persists, consult the software's documentation or seek assistance from the support team.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
11
Views
4K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
7
Views
9K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
3
Views
278
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
5K
  • General Discussion
Replies
3
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
5K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
3K
Back
Top