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 two separated folders, each includes LyX files with the needed attachments (pictures...etc.) , I found that I need to to use zref-xr package to make hyper cross references between those files (non of them included in the other), what i can't understand (or find an answer) is what I should write in \zexternaldocument{????} should It be the full path to the second folder? or something else? some people speaks about .aux files that I don't understand where to find.

Another small question in the context: What is better (or should) use, xr package with hyperref package, or the above mentioned zref-xr ?

share|improve this question
    
thx, but can you please explain which "both files" that was in the same directory? i tried to put both LyX files, and then PDF file of the second document, but in vain, the generated file displays ?? instead of the ref. –  TMS Sep 10 '12 at 18:02
    
Sorry for the question, but what you mean by "latexed" twice? –  TMS Sep 10 '12 at 18:53
    
I exported the file twice to LaTeX, and put it in the same directory with the main doc, but nothing happened :(, still display the ref as ?? , i think the trick should be related to LyX itself because most other similar threads ends when LyX gets into play. –  TMS Sep 10 '12 at 20:01
    
I'm really confused, I tried to put tex,lyx,pdf files in the same directory, I'm already inserted package loading commands (and other commands) and I'm pretty sure that I did that right, but no result. –  TMS Sep 10 '12 at 20:21
1  
There is a recent post on the LyX users mailing list about this. It has no answer yet, but you could watch it and see if anything pops up. mail-archive.com/lyx-users@lists.lyx.org/msg93271.html –  Torbjørn T. Sep 10 '12 at 20:46

2 Answers 2

Imagine you have these two files:

file1.tex

\documentclass{article}
\usepackage{hyperref}

\begin{document}
\pagestyle{plain}
\setcounter{page}{1234}% for the example

A sentence with a label.\phantomsection\label{file1label}%

\end{document}

file2.tex

\documentclass{article}
\usepackage{xr}
\externaldocument{file1}
\usepackage{hyperref}

\begin{document}     
A sentence with a refence to the first file (on p.~\pageref{file1label}).  

Or you can \href{run:file1.pdf}{open} the file directly; 
but I don't think you can't open a specific page via a \verb+\label+ command.

(Compare \href{file:///fake/absolute/path/to/file1.pdf}{this} one.)
% you need to put in your absolute path here

\end{document}

Now 'process' both documents twice (however that is done with Lyx). I'd run pdflatex on both files, first file1.tex then file2.tex: the first time, the label will be written to file1.aux; then when you 'process' file2.tex, it will also find the label from file1.aux to get the right cross-reference.

I'm not sure what you do to a Lyx file to make sure the packages are included along with the \label and \ref` commands, but they need to be present in the files.

share|improve this answer
    
The problem is, I think, that LyX generates tex files from the .lyx file, places them in some obscure directory, and processes them there. I'm not sure if the folder even stays the same for the same document over different sessions, they may be re-generated every new session, or every time a document is opened. I remember I found these files on W7, IIRC they were tucked away somewhere in the appdata folder. This makes it difficult, if not impossible, to create a reference to a different file. –  Torbjørn T. Sep 10 '12 at 20:36
    
Oh finally i found where LyX hiding those aux files (Win7): C:\Users[user name]\AppData\Local\Temp\lyx_tmpdir.Hp2004\lyx_tmpbuf2 , after I added aux & pdf file to the same directory LyX finally generated the right Text-Reference and displayed the right name of label, but I have now another problem, when i click on this link in the pdf, instead of opening the second file he just jumps to the beginning of the current document, why is that? –  TMS Sep 10 '12 at 20:44
    
But i titled the question "hyperref.." ! so what I should do now? I want that by clicking on the link it will open the second file (let's suppose it is in the same dir) and jump to the label, is that possible? –  TMS Sep 10 '12 at 21:05
    
Ok, I will ask about that separately, because MS Word can do that (even after converting to pdf), so i thought xr will do the same, thank you for help jon. –  TMS Sep 10 '12 at 22:00
    
@TMS -- See this answer (by the package author): I don't think the functionality exists yet. –  jon Sep 10 '12 at 22:13

Try putting the .aux file for the second file in the directory of the first file before texing it. (canaaerus: some questions have short answers.)

share|improve this answer
    
thx, but as i pointed above, I couldn't find those files, may LyX don't generate them or generating them as temp files? –  TMS Sep 10 '12 at 18:55
    
Even if this post would help to solve the issue, it is far too minimalistic to be counted as an answer. Please expand it or post it as a comment on the question. –  canaaerus Sep 10 '12 at 20:15

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.