auctex
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[AUCTeX] Cross-References in multiple documents AucTeX/RefTeX


From: bnickel
Subject: [AUCTeX] Cross-References in multiple documents AucTeX/RefTeX
Date: Sat, 14 Jan 2012 13:15:01 -0800 (PST)

I'm trying to solve a problem that's come up in producing a large document
that I'm breaking up into smaller ones. The basic structure is this.

A main document (`main.tex`) that includes formatting info for the whole
project, and individual files for chapters (`part1.tex`, `part2.tex`, etc).

I need to produce a lot of cross-references, mostly to enumerate items
within a part, but ideally also to some elements across parts.

My basic workflow is editing LaTeX documents in emacs using the RefTeX
capabilities to produce cross-references. My problem is that when RefTex
automatically supplies me with labels (and I'm not willing to give up that
convenience), it'll start numbering the labels from scratch for each part.

Thus, `part1.tex` might look like this.

    \begin{enumerate}
    \item first thing in part 1.\label{item:1}
    \item second thing in part 1.\label{item:2}
    \end{enumerate}
    Reference to \ref{item:1}

Correspondingly, `part2.tex` might look like this.

    \begin{enumerate}
    \setcounter{enumi}{2}
    \item first thing in part 2.\label{item:1}
    \item second thing in part 2.\label{item:2}
    \end{enumerate}
    Reference to \ref{item:1}

(NB: I've got the `\setcounter` command just to ensure that the numbers
differ between the two parts so I can see whether the cross-referencing
works properly.)

The main document that calls these is the basic `main.tex`.

    \documentclass{book}
    
    \begin{document}
    \input{part1}
    \input{part2}
    \end{document}

The problem is that, because RefTeX starts over in the labels it provides,
the cross-references are screwed up. Both of the references in `part1.tex`
and `part2.tex` shown above will be "3", the number of the enumerate item
the last `\label{item:1}` is attached to.

In the past, I've simply brute-forced the issue. When it came time for a
final compile, I search-and-replaced all of the labels in my code to include
unique prefixes for each input-file. For example, all of the `item:xx`
labels in `part1.tex` would be turned into `item-part1:xx` labels, mutatis
mutandis for `part2.tex`. But that is ugly, and surely there must be a
better way.

I don't know if there are packages that solve this problem for me (I looked
at `xr`, but couldn't get it to work out for me), or if there is a way to
customize RefTeX so that, when it automatically produces labels within one
of the parts, it's automatically aware of the labels that are in use in all
of the other parts and hence ensures that no duplicates will be created.

For what it's worth, I'm running TeX on OSX, in case that matters.

Thanks much,
Bernhard
-- 
View this message in context: 
http://old.nabble.com/Cross-References-in-multiple-documents-AucTeX-RefTeX-tp33140811p33140811.html
Sent from the Gnu - AUCTeX - General mailing list archive at Nabble.com.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]