On 10/27/2010 12:36 PM, Jean-Marc Lasgouttes wrote:
Le 27/10/2010 15:39, Richard Heck a écrit :
On 10/27/2010 04:17 AM, Jean-Pierre Chrétien wrote:
Tested with French.
The \lyxref encapsulation does not work when ":" is active.
I'm trying to find a workaround, I'll keep you posted.
OK. Please let me know. We may need some \catcode thing in there?
This has probably been explained already, but could you tell me what
is the goal of this \lyxref definition? Could you use something other
than ':' to separate your arguments?
Basically, the problem is this. The refstyle package uses something like
\newref{thm}{...}
to define a whole sequence of commands: \thmref, \Thmref, etc. So when
we output InsetRef, we actually need to construct the relevant command.
E.g., if we see that we're supposed to do a formatted reference to label
"thm:mythm", then what we actually need to output is:
\thmref{thm:mythm}
And the colon, though not absolutely essential as the separator, is
well-established in LyX and definitely part of how refstyle (as well as
prettyref before it) worked.
The issue, then, is that the command \thmref may not exist. In fact, it
is not pre-defined in refstyle.cfg; LyX defines it, via validate(), but
of course there are other cases, e.g., "cor:whatever" for corollaries.
And, obviously, we do not want to output \corref{cor:whatever} if that
command is not defined.
The \lyxref macro was my attempt to deal with this issue. Basically, it
splits on the colon and then checks to see whether the relevant command
exists. If so, it calls it; if not, it issues \ref. So we always output
\lyxref{label}.
Thinking about this again, perhaps there is another way to do things. In
my original patches, I did the split on : in latex() and output the
appropriate command there, e.g., \corref{cor:whatever}. I gave up on
that because of the problem just mentioned. But another solution might
be, in validate(), to include LaTeX roughly like this:
\providecommand\corref[1]{\ref{#1}}
and to do this for any such command we use. Indeed, that seems much
simpler, no?
Shall I change things in that way?
Richard