I am having trouble getting cross-referencing to work. I am using the package xr-hyper. I have a 'main' file called main.tex and two subfiles called intro.tex (Introduction) and app.tex (Appendix A). I want to refer to an equation defined in intro.tex in Appendix A.
Either I have made an error in my code or its an issue with my build process. I am very confused about the build process for this. I'm using TeXstudio and I have set up my build process to run PdfLaTeX two times, which I do on main.tex. Is this correct?
I once got the numbers to appear correctly, but I'm not sure how I managed this. But, when I then added a new chapter ahead of intro.tex, the numbers of the references in Appendix A did not update when I re-built the file main.tex.
Any advice would be much appretiated.
The errors I am getting are:
main.tex
\documentclass[12pt,a4paper]{report}
\usepackage{subfiles}
\usepackage[titletoc]{appendix}
\usepackage{xr-hyper}
\usepackage{hyperref}
\begin{document}
\tableofcontents
\subfile{intro.tex}
\begin{appendices}
\subfile{app.tex}
\end{appendices}
\end{document}
intro.tex
\documentclass[main.tex]{subfiles}
\begin{document}
\chapter{Introduction}
\begin{equation}\label{eqn:newton}
F = ma
\end{equation}
Equation~\ref{eqn:newton}
\end{document}
app.tex
\documentclass[main.tex]{subfiles}
\externaldocument[I-]{intro}
\begin{document}
\chapter{Talking about Equation~\ref{I-eqn:newton}}
Let's refer to Equation~\ref{I-eqn:newton}.
\end{document}




introbeforeapp? – samcarter_is_at_topanswers.xyz Jun 05 '18 at 21:04introandappin the first place, before compilingmain.tex– Milo Jun 05 '18 at 21:07introandapp, TeXstudio instead compilesmain. But, if I restart TeXstudio and openintroandappwithout openingmainthen I can get TeXstudio to compileintroandappindividually. Is this normal behaviour? – Milo Jun 05 '18 at 21:11introandappsaved in individual subfolders. If I write\IfEq{\jobname}{\detokenize{main}}{}{%\externaldocument{intro}}inapp.texthis works fine even whenintro.texis saved in a subfolder. Why does this work? I thought I might have to tell it where to findintro. – Milo Jun 05 '18 at 22:28