# "Package xr warning: No file file4.aux LABELS NOT IMPORTED" – What's wrong?

I'm working on an article with tons of appendices that we need a cross referencing system for. Since we user hyperref, I gave the xr-hyper package a try. After MANY attempts, I got it to work with three external documents, but the moment I add a fourth, I get the error message "Package xr warning: No file file4.aux LABELS NOT IMPORTED on input line 30".

Here's the thing: We're using Overleaf (and pdflatex). Doing this locally is unfortunately not an option at this point.

I've read every thread I could find, applying all the working examples I could find, but to no avail.

I'm attaching a MWE of the various pages below. Can anyone figure out why on earth it won't accept references to the fourth file?

% the preamble

%\usepackage{xcite}
\usepackage{xr-hyper}
\usepackage{hyperref}

\makeatletter
\typeout{(#1)}% latexmk will find this if $recorder=0 (however, in that case, it will ignore #1 if it is a .aux or .pdf file etc and it exists! if it doesn't exist, it will appear in the list of dependents regardless) \@addtofilelist{#1}% if you want it to appear in \listfiles, not really necessary and latexmk doesn't use this \IfFileExists{#1}{}{\typeout{No file #1.}}% latexmk will find this message if #1 doesn't exist (yet) } \makeatother \newcommand*{\myexternaldocument}[1]{% \externaldocument{#1}% \addFileDependency{#1.tex}% \addFileDependency{#1.aux}% } % put all the external documents here! \myexternaldocument{file1} \myexternaldocument{file2} \myexternaldocument{file3} \myexternaldocument{file4}  % the latexmkrc file add_cus_dep( 'tex', 'aux', 0, 'makeexternaldocument' ); sub makeexternaldocument { # if the dependency isn't one of the files that this latexmk run will consider, process it # without this test, we would get an infinite loop! if (!($root_filename eq $_[0])) { # PLEASE ENABLE ONLY ONE OF THE FOLLOWING # DEPENDING ON THE ENGINE YOU'RE USING # FOR PDFLATEX system( "latexmk -pdf \"$_[0]\"" );

# FOR LATEX+DVIPDF
# system( "latexmk \"$_[0]\"" ); # FOR XELATEX # system( "latexmk -xelatex \"$_[0]\"" );

# FOR LUALATEX

# FOR LATEX+DVIPDF
# system( "latexmk -cd \"$_[0]\"" ); # FOR XELATEX # system( "latexmk -cd -xelatex \"$_[0]\"" );

# FOR LUALATEX
# system( "latexmk -cd -lualatex \"\$_[0]\"" );
}
}


Also note that the latexmkrc file must be in the root (top) level folder, not inside sub-folder.