On 11/16/2009 06:02 PM, Jean-Marc Lasgouttes wrote:
Le 16 nov. 09 à 23:46, rgheck a écrit :
The attached is an initial shot at implementing a kind of
\refstepcounter facility for LyX. The idea is that we can keep track,
as we pass InsetLabels, of which counter is then "active" and use
this information in displaying InsetRefs that reference those labels.
It works reasonably well, in that we have the right sort of
information saved. (Lots of FIXMEs here and there, though.)
This is a feature that is logical, but yet in some sense I wonder
whether it is too wysywig. This is one reason why I never tried to do
it myself.
I don't disagree, though sometimes people ask for this. So I'm not
necessarily suggesting this use. Indeed, probably what I'll do for now
is limit it to my own use and indicate the issues with using it more
broadly in comments.
Speaking of which, to do what I've just suggested, I'd need to add some
kind of argument to updateLabels. It could just be a boolean, to
indicate if we're about to produce output. Does this seem OK? The other
option would be to do all this in validate(), but then the GUI use
wouldn't be possible.
If we don't want to do it every time through, then we can give up on
the in-LyX display, and I can somehow arrange to do all this only on
the updateLabels() run just prior to output, which is what I really
want it for anyway.
No, you want to have HTML/CSS compute the numbers, remember. :)
Yes, I do remember that discussion, and if I ever get XHTML output
working at all, then we can talk again. ;-) But this won't help with
InsetRef, since XHTML has no version of \ref, so far as I know. So we
have to do that manually, if we want to display counter numbers.
Concerning the patch, the part that looks strange to me is the one
about environments. Could you explain?
The thought here is that \refstepcounter is local to environments. So if
you do \begin{this}...\refstepcounter{}...\end{this}, then the counter
is only ref'd local to the environment. (E.g., this is true with
footnotes and theorems.) So, when we hit and environment, we need to
save the currently active counter, and then restore it when we leave
that environment. So when we enter an environment, we push the currently
active counter onto the stack, which will then be replaced if a new
counter is stepped; we pop the stack when we exit the environment.
Richard