[Tex/LaTex] Using the xr package and – missing aux file? “Warning: No file SupplementalMaterial.aux LABELS NOT IMPORTED”

#refhyperrefxr

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.

Best Answer

The set-up described by overleaf did not work for me. I had to make a relative file reference:

\myexternaldocument{./file_to_reference}