Stefano Franchi wrote:
I am still fighting with LyX/LaTeX cross-referencing facilities. While it's rather clear how to use it to refer to page numbers and equation numbers within a single file, I am in the dark on how:
1. cross-referencing to a separate file
2. having the section title appear in the cross-referencing document.
In fact, I am not even sure whether (1) or (2) are possible at all.
(1) is easy, but not terribly intuitive. You need to have both files open in LyX: The one you want to reference and the one you're editing. Now Insert>Cross-reference, and at the top of the dialog box is a drop-down box marked "Labels in". Choose the target file, and the labels in that file will appear in the dialog box.
Here is what I am trying to do (assuming it's not clear enough from the above description): Say I have chapter 1 and chapter 2 in chapter1.lyx and chapter2.lyx. Chapter1.lyx has sections:
1. Introduction
2. First section
3. Third section
Somewhere in Chapter 2, I want to say: "as I showed in ***Chapter 1, Third section***, etc.etc." I would like to have the text between *** as a cross-reference, so that if I move the Chapter1.lyx section around, change its title, etcetera, the reference would still work. Is there any way to do this?
You may have to play with the reference format to get exactly what you want. By default, I think you'll get something like "Section 1.3".

References to section titles are handled by the nameref package, which is part of the hyperref bundle, so you presumably already have it. (I found this by searching for "cross-reference" on ctan.org and following a few links.) To reference a section by label, just do
\nameref{label}
in ERT. That, of course, is the downside: There's no native support for this in LyX. (I've file an enhancement request. It seems like this would be useful to a lot of people.) You'll need to add
\usepackage{nameref}
to the preamble, too.

That said, however, there is a kludge via the prettyref package. If you're not otherwise using it, you can define
\newrefformat{sec}{\nameref{#1}}
and get the title if you choose "Formatted reference" in the cross-ref dialog box and your label is of the form "sec:label". If you are already using prettyref, you can define another format:
\newrefformat{sect}{\nameref{#1}}
but then you'll have to put both labels: "sec:label" and "sect:label".

Richard

--
Richard G Heck Jr
[EMAIL PROTECTED]
http://bobjweil.com/heck/

Reply via email to