0

I'm having a project which having Ten chapters and the project is in Overleaf. Each chapter having two TeX application files, e.g., ch01.tex having the actual content for Chapter 1 and Ch01run.tex having the preamble tags like \documentclass... etc.), sample MWE is:

Ch01.tex

\chapter{Chapter 1}\label{firstchapter}

Test

Ch01run.tex

\documentclass{book}

\includeonly{Ch01}

\begin{document}

\include{Ch01}
\include{Ch02}

\end{document}

The same structure applicable for all chapters, hence group of persons handles each chapters separately. In this, Some times ?? error, happens in some files, but when rerun the particular file solves the issue, but after some time again the same ?? happening to some other chapter. How can I fix this?

I've created a test project (https://www.overleaf.com/project/640708681ddf247f0fe3645a) in Overleaf, and now trying with the file xr.sty, also followed the steps described in https://www.overleaf.com/learn/how-to/Cross_referencing_with_the_xr_package_in_Overleaf but the same error exists, please suggest your valuable suggestions

11
  • 1
    You need to compile the full document before excluding other chapters you reference to?
    – Celdor
    Commented Oct 16, 2023 at 6:45
  • 1
    I don‘t see any \ref statements referring to labels you introduced. Please add so your example works when we copy and compile it. Please recall, referencing is a two step process, requiring two compile runs.
    – MS-SPO
    Commented Oct 16, 2023 at 6:47
  • 2
    you always get ?? on the first run, cross references resolve on later runs. normally overleaf (latexmk) runs latex enough times to resolve all references, but if you have an error that means latex can not reach the end it may not be able to write the data to the aux file until the error is fixed. the error may be unrelated to references Commented Oct 16, 2023 at 6:52
  • 2
    Oh you have \includeonly{Ch01} so you need to make one run of the full document to get all the references, then do \includeonly{Ch01} Commented Oct 16, 2023 at 11:24
  • 1
    Please don't use external links, your question is archived here forever and will not make sense if you change that overleaf project. Just fix your code fragment in the question to be a real example. Commented Oct 16, 2023 at 15:34

2 Answers 2

1

The command \includeonly, to work properly, relies on the auxiliary (.aux) files of the included chapters. These files are produced when compiling the whole project once, without the command \includeonly; in Overleaf, you can see these .aux files under "Show cached files" (see here). In your case, you should find Ch01.aux, Ch02.aux. Without these files, \includeonly does not work as intended and produces ?? and errors (see this answer for how to use \includeonly).

What might be happening to you (probably the same that happened to me) is that Overleaf deletes the .aux files of the included chapters after some time, so even if you re-compile all the chapters, after some time you still get ?? and a bunch of errors. To solve this problem it is possible to add a few lines in the preamble, see this other post.

-2

I found solution based on how to use xr package in overleaf https://www.overleaf.com/learn/how-to/Cross_referencing_with_the_xr_package_in_Overleaf, this helps to solve the issue

1
  • 1
    Please include the relevant parts of the solution directly in your answer so it remains helpful for future users in case the link no longer works. Commented Jan 5 at 17:30

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .