[texhax] naming of figures after \ref{} order

Martin Wegmann wegmann at biozentrum.uni-wuerzburg.de
Fri Feb 6 13:40:26 CET 2004


On Friday 06 February 2004 12:04, Philip G. Ratcliffe wrote:
> > > > I set my figures and tables to be numbered continously but
> > > > realized that the order of the figures/tables assigns the
> > > > number and not the position of the \ref{} in the text. So when I
> > > > \ref{} on the first page several big figure which I put
> > > > in a separate section but add one figure right on the first page
> > > > even when named at last it is labelled fig. 1.
> > > > Neither in the FAQ nor google prompted an appropriate result
> > > > concerning this problem. I would appreciate if you
> > > > point me to the correct "naming" , FAQ number or command
> > > > respectively modification of the one below,
> > >
> > > But this is the correct behaviour; figures are numbered
> >
> > according to their
> >
> > > appearance in the text and not according to when they are
> >
> > referenced.  It
> >
> > > would be very odd to have Fig. 10 on page one followed at a
> >
> > later stage by
> >
> > > Fig. 1, 2 etc.  Why on earth should you want such a numbering
> >
> > scheme.  Or
> >
> > > have I misunderstood something?
> >
> > Perhaps what he wants,  which in fact I also would like, is a treatment
> > of tables and figures something like bibtex with references.
> > In other words, something that rearranges the order of figures and tables
> > to correspond to the order in which they are referenced in the text.
>
> I've thought about this a little and it would seem to require quite a major
> rewrite of various parts of LaTeX: \ref, \caption, and the treatment of
> floats in general.
>
> What shouldn't be too difficult, however, would be something along the
> following lines:
>
> 1.  Save each float (figure or table), with NO
> \begin{figure}...\end{figure} enclosure and NO \label, in a separate file
> (only one float per file).  [I usually do something similar anyway to leave
> the main file less cluttered.]
>
> 2. Define, say,
>
>    \newcommand\FloatRef[3]{\ref{#1}\begin{#3}\input{#2}\label{#1}\end{#3}}
>
>    where, #1 is then the label, #2 is the file name and #3 is the
> environment (figure or table).
>
> N.B. This should, of course, be used ONLY ONCE for any given label (the
> first reference).  However, with a smidgen more work one could add an
> automatic check to see if the given label has already been used (though
> this is not entirely trivial!) and thus allow it to always be used.
>
> Any volunteers to write a package?  If I find time (!) and if someone else
> adds their name to the would-be users list, maybe I could do something
> distributable.

Concerning my questions, I agree that it would be odd to have fig. 10 on page 
1 and fig. 1 on page 2 - I assumed that my \ref{}'s are necessarily infront 
of my figures - well I understood the point and dropped my idea. 

This idea of a new command (bibtex for figures and tables (?)) sounds very 
useful! 
Unfortunately I have neither experiences in writing packages nor in any kind 
of programming, sorry. But I would like to do some testing if that helps. 
 

regards Martin Wegmann



More information about the texhax mailing list