Latex Cross References, citations etc not working

Click For Summary

Discussion Overview

The discussion revolves around issues related to using LaTeX for creating PDFs, specifically focusing on problems with cross-references and citations appearing as question marks in the output. Participants explore the necessary compilation steps and formatting options to resolve these issues.

Discussion Character

  • Technical explanation
  • Debate/contested

Main Points Raised

  • One participant describes their experience with LaTeX, noting that cross-references and citations appear as question marks despite successfully generating a bibliography using Bibtex.
  • Another participant suggests that running pdflatex twice in succession is necessary to resolve undefined references, detailing the compilation steps required.
  • A later reply questions whether referencing equations with \ref will automatically include parentheses, suggesting that explicit parentheses may be needed.
  • Another participant proposes using the amsmath package to utilize \eqref, which would automatically include parentheses around equation references.
  • One participant explains that LaTeX requires multiple compilation runs because it needs to gather references that are often located at the end of the document.

Areas of Agreement / Disagreement

Participants generally agree on the need to run pdflatex multiple times to resolve reference issues, but there is some uncertainty regarding the formatting of equation references and whether parentheses are included automatically.

Contextual Notes

Participants mention various LaTeX packages and commands, indicating potential dependencies on specific configurations or document classes that may affect the behavior of references and citations.

ChrisJ
Messages
70
Reaction score
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 tags, is there a way I can get it to parse it as plaintext?
 
Last edited:
Physics news on Phys.org
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   Reactions: ChrisJ and BvU
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?
 
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   Reactions: ChrisJ
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   Reactions: ChrisJ
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   Reactions: ChrisJ

Similar threads

  • · Replies 11 ·
Replies
11
Views
6K
  • · Replies 7 ·
Replies
7
Views
15K
  • · Replies 5 ·
Replies
5
Views
4K
  • · Replies 4 ·
Replies
4
Views
3K
  • · Replies 3 ·
Replies
3
Views
6K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 4 ·
Replies
4
Views
5K
  • · Replies 2 ·
Replies
2
Views
6K
  • · Replies 2 ·
Replies
2
Views
4K