On 07/15/2010 03:57 PM, Jean-Pierre Chrétien wrote:
Richard Heck a écrit :
(ii) Switch from prettyref to refstyle, as in the patch attached to
#6609. Jurgen has an objection to this, namely, that it will
inevitably break some customized prettyref formats. I.e., if you have
declared in some style file you import
\newrefformat{for}{...}
then this will do nothing, at best, and cause a compilation error at
worst (if \newrefformat is undefined). In layout files, we could deal
with this, by replacing
\newrefformat{for}{...}
with
\newref{for}{refcmd = {...}}
which is easy enough. But this approach has the same problems as the
next one.
We could do it \AtBeginDocument,
Too late if \newrefformat comes in a style file included from the
preamble. What we can do (eventually) is put something like:
\newcommand\newrefformat[2]{\newref{#1}{refcmd={$2}}
into LyX's preamble, which will be loaded before the user's. The only
thing this won't catch is then stuff in the class file itself.
I think the proposal on the table at the moment is something like:
Support both for 2.0, and declare prettyref...not degraded, what is the
word? Anyway, then we remove it for 2.1, say. We can do lots of layout
stuff then.
(iii) Set up a document option for using prettyref or refstyle and
support both, leaving older documents to use prettyref by default.
The fix noted in (i) could be used as well, or we could suggest using
refstyle if you want babel support.
This is easy in a way, and I've adapted the earlier patch to
allow both. But it does cause some problems. E.g, prettyref uses
"cha" for the chapter prefix, whereas refstyle uses "chap". The user
can switch to refstyle, but then the cha:whatever labels don't work
right. And what do we automatically generate? We can see whether
prettyref or refstyle is in use and do "cha" or "chap", as
appropriate, but then what if the user changes her mind? It seems
ugly to go through and try to change these.
This is really a mess, rewiting cha as chap via lyx2lyx and redefining
accordingly the prettyref commands seems appropriate there.
Maybe even easier is just adding:
\newrefformat{chap}{Chapter \ref{#1}}
when prettyref is used? Old cha labels can then be left as is, and new
prettyref documents will use the chap label.
bit more messy to generate the LaTeX for an InsetRef. What is an
issue is that it becomes easy to generate uncompilable documents.
Suppose we auto-generate the label for a corollary, say, as
"cor:thisone" and the user selects a formatted reference. Then we
generate: \corref{thisone}. But maybe \corref doesn't exist, as it
isn't a standard refstyle format. So the document doesn't compile.
That seems to me pretty bad.
There are two ways there:
- contact Danie Els to enhance the refstyle.cfg file with all the
variants of the theorem environment currently available in modules;
This would help, for sure...
- provide the necessary commands in the modules themselves.
...and we should do this, too, but even that isn't quite sufficient.
Someone could create a label "silly:label" by chance and then make a
formatted reference to it. LyX should not output an uncompilable
document in that case.
So anyway au upgrade of refstyle.cfg is needed for new languages.
So we need to work with Els as much as possible on refstyle issues.
There is currently another pitfall, as pro: is ambiguous: it is a
shortcut for proof, proposition and problem. IMHO, this should be
solved as soon as possible, whatever the solution chosen to improve
smart referencing in LyX.
This has been addressed for 2.0. Whereas LyX used to calculate the
prefix from the layout name, there is now a RefPrefix layout command
that allows it to be set explicitly.
In addition, the reference interface should allow for ranges and
plurals to take advantage of the refstyle flexibility.
This will be for later, at this point.
Do you want to contact Els? You seem to know more about refstyle than
any of us right now.
Richard