I'm using Overleaf to write a paper with supplementary material and have been having substantial trouble with separating out Supplemental Material while maintaining references. My MWE is as follows - in Main.tex:
\documentclass{article}
\usepackage[hidelinks]{hyperref}
\usepackage{xr}
\externaldocument{SupplementalMaterial}
\begin{document}
This is text
\begin{equation} \label{eqn}
1+1=2
\end{equation}
Look at Eq.~(\ref{suppeqn})
\end{document}
In SupplementalMaterial.tex:
\documentclass{article}
\usepackage[hidelinks]{hyperref}
\usepackage{xr}
\externaldocument{Main}
\begin{document}
This is text
\begin{equation} \label{eqn}
1+1=2
\end{equation}
Look at Eq.~(\ref{suppeqn})
\end{document}
When I try to compile Main.tex, I get "Warning: No file SupplementalMaterial.aux LABELS NOT IMPORTED" and of course no references properly refer back to their labels. I've tried to find a solution online but frankly have not found an explanation as to where the aux file is supposed to come from, or what exactly it is. I think it's an auxiliary file used to hold information from the "first pass" for documents that take multiple iterations to compile.
How can I get my references to appear properly?
EDIT: Overleaf requires a special set-up to use xr, as detailed here. I was able to use the example linked in that page and port it to another documentclass for my specific uses without much trouble. I will leave this as an update, not an answer, because I do not yet understand why Overleaf requires this approach.
\documentclassso it can not be run (so will not have generated an aux) – David Carlisle Feb 07 '20 at 20:32xris for refering to labels in a different document but I suspect here that you simply want the supplementary material at teh end in which case remove xr package and remove\begin{document} \end{document}from suppementalmaterial.tex, and put\input{SupplementalMaterial}before the end of your main document. – David Carlisle Feb 07 '20 at 20:53\externaldocument??? Assuming you didn't mean that (a) usexr-hyperpackage notxras you are using hyperref, then make two overleaf projects and save the aux file (in the logs and output menu) from supplemental and upload it as SupplementalMaterial/aux to the project for the main file – David Carlisle Feb 08 '20 at 00:05