I have two documents and am trying to use the package xr
to create a reference, in the second document, to a \label
in the first. But ??
appears in the PDF instead. How do I enable the second to see the first's \labels
?
Minimal example:
xr2a.tex
\documentclass[12pt,a4paper]{article}
\begin{document}
\section{A}\label{a}
\end{document}
xr2b.tex
\documentclass[12pt,a4paper]{article}
\usepackage{xr}
\externaldocument{xr2a}
\begin{document}
\ref{a}
\end{document}
I am using pdfLaTeX and TeXworks.
The files are in the same directory.
I don't want hyperlinks.
There is very little in the xr
package's documentation -- have I used it correctly?
Some similar older questions on the same topic have got answers which say that xr
needs to read the .aux
file. pdfLaTeX lately runs OK without any .aux
files. Does xr
still need to read the .aux
file nowadays? If so, how do I get TeXworks to get pdfLaTeX to a) keep the .aux
file b) revert to the default behaviour of not keeping an .aux
file?
.aux
file? Without it, even internal cross references don't work. Anyhow, the example works for me..pdf
, only the.tex
,.synctex.gz
and.pdf
remain. I might have changed a setting, but nothing in TeXworks's Edit\Preferences menus seem relevant. The default with my installation has been to delete the.aux
, since 15 Jun 2018. Behaviour sometimes changes automatically because a new version automatically installs itself. Internal cross-references within a document work fine..aux
files after itself. It must be a setting of your editor or your compilation tool (if you use that). The.aux
file is required not only to get cross references withxr
right, but also to be able to produce proper cross references within the document.xr
otherwise no references or table of contents or lists of tables etc will work.