Thanks to both Helge and John for clarifying the issues.
One small problem with the "master document" strategy is that the figure
numbering, etc, will (by default) be wrong: when we refer to the first
supplementary figure, unless we manually restart the figure counter, it will
get rendered as Supp. Fig. n+1, where n is the number of figures in the main
text. But we can work around this. In our case, the file sizes are not huge,
so the motivation to split into two documents is simply that it's how we
expect to have to submit the files. As you both say, there are several
possible workarounds.
But I do think there is a way of getting this to work transparently, and maybe
this would be of interest to the developers. Using the simple example files I
sent in my last message, I just opened the doc2.aux file, copied the line:
\newlabel{sec:Results}{{1}{1}}
into doc1.aux, and then re-ran pdflatex on doc1. It worked like a charm.
In general, if LyX can keep track of the document referred to by the
cross-references, then a simple
grep newlabel file2.aux >> file1.aux
would appear to solve the problem. The only issue I see here is that users
might do some manual version control (having files named main_ver1.lyx,
main_ver2.lyx, suppl_ver1.lyx, suppl_ver2.lyx, etc) and that might require
some thought about how to migrate all the cross-references over to a file
with a different name.
Best,
--Tim
On Friday 04 May 2007, John Pye wrote:
> Tim Holy wrote:
> > Hello,
> >
> > I'm relatively new to using LyX. I'd played around with it a year or two
> > ago, but (perhaps out of inertia more than anything else) returned to
> > directly writing the latex with a text editor. Now I'm using LyX 1.4.3,
> > and I have to say that I'm quite impressed. Thanks to the developers for
> > some great work!
> >
> > One of the many things that impressed me was the apparent ability to
> > cross-reference between documents. (Our use case is to refer back and
> > forth between the "main text" and "supplementary information" for a
> > scientific paper.) While LyX makes it easy to insert the cross-document
> > cross-reference, I have yet to figure out how to make that cross
> > reference actually work in the PDF-exported document---it appears as "??"
> > when the PDF is generated.
> >
> > Attached are two small files that illustrate the problem. I open both
> > files, verify that the cross-reference from doc1 points to a label in
> > doc2, and then select View -> PDF (pdflatex). An internal cross-reference
> > works just fine, but the cross-document one does not.
>
> I suggest that, as Helge suggested, you create a master document that
> contains 'Input' tags for the two subdocuments. Then create your PDF by
> calling pdflatex on the master document. Then, if you really want to
> split the resulting sngle document back into separate PDFs, use 'pdftk'
> as a post-processing step.
>
> Cheers
> JP