Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I have been dealing with a Latex bug for the past 4 months that I have been unable to resolve. The issue is that a lot of my cross references come out as ?? when I use \include{filename} from a master file to include multiple .tex files and avoid writing a monolithic .tex file.

I discovered that I can fix the problem by lifting the figures out of the (tributary) files being included via include{filename} and putting the figures in the body of the main .tex file. But, this is not an ideal solution! ?? usually appear for labels that appear in the last few files of my document.

I am including my preamble below and the general form of my document. I thought this was a revtex4.1 problem but it persists when I switch to regular latex document class. I use kile as my TEX compiler on a 64-bit machine operated by Ubuntu 11.10 (yes, I will upgrade to 12.04 soon). My linux kernel is 3.0.0-32.

Please HELP!! I am desperate

\usepackage{bm}
\usepackage{soul}   % for highlighting
\usepackage{url}
\usepackage{varioref}
\usepackage{graphics}
\usepackage{graphicx}
\usepackage{subfigure}
\usepackage{appendix}
\usepackage{color}
\usepackage{hyperref}
\usepackage{amssymb}
\usepackage{dcolumn}
\usepackage[usenames,dvipsnames,svgnames,table]{xcolor}


\includeonly{file1,file2,...}
\begin{documnent}
\maketitle

\let\clearpage\relax

\include{file1}
\include{file2}
.
.
.
share|improve this question
    
Comment out the \includeonly line in order to let LaTeX process all the files. This is necessary if you want to get correct cross references. –  egreg Mar 22 '13 at 9:24
    
A separate, minor comment: don't load both the color and xcolor packages, and don't load both the graphics and graphicx packages. –  Mico Mar 22 '13 at 9:35
3  
\let\clearpage\relax is a rather dangerous command it can put latex into an infinite loop (and it stops the \include system working) –  David Carlisle Mar 22 '13 at 9:41

1 Answer 1

The fact that you wrote \let\clearpage\relax makes me suspect that what you are trying to do is simply to structure your source into several hierarchical files rather than to use the "include" mechanism. To do that simply use \input instead of \include and you should be fine. The \input command can even be nested (\inlcude can't) and will unconditionally load your files.

Disabling \clearpageas you did is not only dangerous as David politely remarked, it is plain wrong and will not only break the "include" meachanism but also lead to other errors depending on the content of your document.

As for \inlcude: it can only be used for parts of a document that start and end a new page, e.g., a whole chapter and it is only there to conditionally process parts of the document while developing. You still need to run the document in total once in a while to ensure that all cross references get properly processed. But if you do not want the \clearpageissued by the "include" mechaism, then it is definitely the wrong tool to use.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.