I think you would have to use two passes of troff. The first pass would
generate the info you needed to define the crossref macro.

For example:

.NH 2
Middle of Paper
.LP
.tm crossref: .if "\\\\$1"middle" see sec. \*(SN

I have the label 'crossref:' in case you are generating definitions for
several
macros, and you want to grep the standard error to treat different lines in
different ways. If you're using -mpm, for example, and you like running
heads
that change with section number changes, you need to use a method like
this to define a running-head macro. If crossrefs turn out to be the only
things
that need this treatment, you can obviously leave the label out.

Do a pass with troff -ms mypaper >[2]crossrefs.

So crossrefs will look like

.de CR
.if "\\$1"middle" see sec. 3.7
.if "\\$1"differentsection" see sec. 7.2.6
.
.
..

Then read in crossrefs on the next pass, and all of your refs in the doc
like
.CR middle
.CR differentsection
should work.

Putting thought into a text processing mkfile is probably worthwhile here.

Although it's another example of bibliographic references, Russ Cox once
posted some scripts using rc, awk and a mkfile that used this two pass idea.
It would probably be worth
looking at his example too. It's quite brief.

http://groups.google.com/group/comp.os.plan9/browse_thread/thread/76ff0d3dc3c49e59/03bfa13f60f56900?lnk=gst&q=rsc+refs#03bfa13f60f56900


I think this is roughly right; I haven't used troff in a while. I'm sure
someone
else will chime in if there's an easier approach.

HTH

Greg


On Thu, Sep 16, 2010 at 11:54 AM, Rudolf Sykora <rudolf.syk...@gmail.com>wrote:

> > There's two versions of refer in contrib. One version is
> forsyth/refer.tgz,
> > which is just refer, 'slightly improved,' and the other version is
> > steve/refer, which is refer from forsyth with bin2ref and the plan 9
> > bibliography from the University of Utah. They can be installed with
> contrib.
> > Hope that's what you need.
>
> If I understand, refer is primarily meant to manage bibliographical
> references.
> I need cross-references within a document, like to pictures, pages,
> figures, equations, ...  --- that's why I mentioned 'lbl' and asked
> whether there is a native port. Or more generally, what others use. I
> can't believe it'd be possible to write a longer document without
> automatically managing such things.
> Ruda
>
>

Reply via email to