Re: New RefStyle Patch

2010-03-26 Thread Jürgen Spitzmüller
Helge Hafting wrote:

 Compatibility meaning:
 the document still compiles and output still looks good
 or identical printout to within 1/100 of a mm
 or bitwise identical pdf file?
 
 The first one is good enough for me, but maybe not for everybody?

Compatibility means (here): the content of the document is not changed. 
Since the ref packages provide strings (such as section 3.4 on the 
preceeding page), this can happen.

Generally, I also think changes that change the page breaks (and thus the 
document length) are problematic.

Also, of course, old documents should continue to compile without major user 
intervention (which is also probably not possible, at least if the user has 
custom classes).

Jürgen



Re: New RefStyle Patch

2010-03-26 Thread Jürgen Spitzmüller
Helge Hafting wrote:

> Compatibility meaning:
> "the document still compiles and output still looks good"
> or "identical printout to within 1/100 of a mm"
> or "bitwise identical pdf file"?
> 
> The first one is good enough for me, but maybe not for everybody?

Compatibility means (here): the content of the document is not changed. 
Since the ref packages provide strings (such as "section 3.4 on the 
preceeding page"), this can happen.

Generally, I also think changes that change the page breaks (and thus the 
document length) are problematic.

Also, of course, old documents should continue to compile without major user 
intervention (which is also probably not possible, at least if the user has 
custom classes).

Jürgen



Re: New RefStyle Patch

2010-03-25 Thread Helge Hafting

Jürgen Spitzmüller wrote:

rgheck wrote:
Anything seems better to me than allowing the use of both prettyref and 
refstyle. We'd have to support both in 2.0, and I don't see any nice way 
to do that.


If we are not able to provide full compatibility, we must IMHO.


Compatibility meaning:
   the document still compiles and output still looks good
or identical printout to within 1/100 of a mm
or bitwise identical pdf file?

The first one is good enough for me, but maybe not for everybody?

Helge Hafting


Re: New RefStyle Patch

2010-03-25 Thread Helge Hafting

Jürgen Spitzmüller wrote:

rgheck wrote:
Anything seems better to me than allowing the use of both prettyref and 
refstyle. We'd have to support both in 2.0, and I don't see any nice way 
to do that.


If we are not able to provide full compatibility, we must IMHO.


Compatibility meaning:
   "the document still compiles and output still looks good"
or "identical printout to within 1/100 of a mm"
or "bitwise identical pdf file"?

The first one is good enough for me, but maybe not for everybody?

Helge Hafting


Re: New RefStyle Patch

2010-03-24 Thread Jean-Pierre Chrétien
Jürgen Spitzmüller juer...@... writes:

 
 Hm. I have in one of my class files this:
 
 % Prettyref:
 \RequirePackage{prettyref}
 \newrefformat{cha}{Kapitel~\ref{#1}}
 \newrefformat{sec}{Abschnitt~\ref{#1}}
 \newrefformat{sub}{Abschnitt~\ref{#1}}
 \newrefformat{anm}{Anm.~\ref{#1}}
 \newrefformat{fn}{Anm.~\ref{#1}}
 \newrefformat{app}{Anhang~\ref{#1}}
 \newrefformat{tab}{Tabelle~\vref{#1}}
 \newrefformat{fig}{Abbildung~\vref{#1}}
 \newrefformat{exp}{Argumentation~\vref{#1}}
 
 Note that some of these definitions include varioref (the \vref macro), so 
 \prettyref{fig:foo} actually yields see figure X on the following page (or 
 whatever the context requires). I am aware that I will be forced to change 
 that class file if we completely ditch prettyref (which is bad enough), but 
 is 
 refstyle at least able to allow similar inclusion of varioref functionality?

refstyle is internationalized through a configuration file, prettyref is not as
shows the fact that you had to do it in your classes: the strings being
hardcoded in English in prettref.sty.

Currently, Richard's patch aims only to replace the formatted reference choice
in the crossrefs manu.
This will need to distribute an improved refstyle.cfg file
to insure theorem and lemma compatibility with prettyref, as you can see in file
examples_crossrefs_lyx20_thm.pdf attached to bug #6420, where I did yhis in a
local refstyle.cfg file.

IMHO, the fact that refstyle.cfg allows to define in one single place all the
variants of the text added to the reference for various languages offers a frame
to extend the current sophisticated crossref management in LyX:

 - the need for layout level management of prettyref translations would be
transferred to global management in the cfg file. LyX can really benefit from
the numerous translators to improve a lot refstyle.cfg, for the benefit of the
latex community, with each and every variant of theorem-like inserts available
with the modules. Transfer of your class translation above in refstyle.cfg might
insure compatibility.

 - capitalization allows to tune the text to various language rules: e.g. in
French, chapitre should not be capitalized in a sentence, nor at the beginning.
An article could be inserted in that case, e.g.: 
  \def\RSchaptername{chapitre~}%
  \def\RSChaptername{Le chapitre~}%
  \def\RSchaptersname{chapitres~}%
  \def\RSChaptersname{Les chapitres~}%

 - plurals for range and list management with varioref: this requires more than
a checkbox in the menu, like capitalization does: as the selected labels must be
ordered, it would need an interface like the one developed for bibliographic
citations to add/remove labels which should appear in the range or list.

There are limits to what is possible to automate in formatted references, as you
mentioned in another message of this thread: in French again, sectioning
references does not fit well with the current model, as e.g. one should like to
get la première partie instead of Part I, and even la seconde partie if
there are two parts and la deuxième partie if there are more :-)

BTW, I've split up bug #6420 in two bugs, and I have retargeted the varioref bug
#6608 to lyx-1.6.6. Do you think that it should only appear in lyx-2.0.0 to pass
the various alpha, beta, etc. release tests?

-- 
Jean-Pierre







Re: New RefStyle Patch

2010-03-24 Thread Jean-Pierre Chrétien
Jürgen Spitzmüller  writes:

> 
> Hm. I have in one of my class files this:
> 
> % Prettyref:
> \RequirePackage{prettyref}
> \newrefformat{cha}{Kapitel~\ref{#1}}
> \newrefformat{sec}{Abschnitt~\ref{#1}}
> \newrefformat{sub}{Abschnitt~\ref{#1}}
> \newrefformat{anm}{Anm.~\ref{#1}}
> \newrefformat{fn}{Anm.~\ref{#1}}
> \newrefformat{app}{Anhang~\ref{#1}}
> \newrefformat{tab}{Tabelle~\vref{#1}}
> \newrefformat{fig}{Abbildung~\vref{#1}}
> \newrefformat{exp}{Argumentation~\vref{#1}}
> 
> Note that some of these definitions include varioref (the \vref macro), so 
> \prettyref{fig:foo} actually yields "see figure X on the following page" (or 
> whatever the context requires). I am aware that I will be forced to change 
> that class file if we completely ditch prettyref (which is bad enough), but 
> is 
> refstyle at least able to allow similar inclusion of varioref functionality?

refstyle is internationalized through a configuration file, prettyref is not as
shows the fact that you had to do it in your classes: the strings being
hardcoded in English in prettref.sty.

Currently, Richard's patch aims only to replace the formatted reference choice
in the crossrefs manu.
This will need to distribute an improved refstyle.cfg file
to insure theorem and lemma compatibility with prettyref, as you can see in file
examples_crossrefs_lyx20_thm.pdf attached to bug #6420, where I did yhis in a
local refstyle.cfg file.

IMHO, the fact that refstyle.cfg allows to define in one single place all the
variants of the text added to the reference for various languages offers a frame
to extend the current sophisticated crossref management in LyX:

 - the need for layout level management of prettyref translations would be
transferred to global management in the cfg file. LyX can really benefit from
the numerous translators to improve a lot refstyle.cfg, for the benefit of the
latex community, with each and every variant of theorem-like inserts available
with the modules. Transfer of your class translation above in refstyle.cfg might
insure compatibility.

 - capitalization allows to tune the text to various language rules: e.g. in
French, chapitre should not be capitalized in a sentence, nor at the beginning.
An article could be inserted in that case, e.g.: 
  \def\RSchaptername{chapitre~}%
  \def\RSChaptername{Le chapitre~}%
  \def\RSchaptersname{chapitres~}%
  \def\RSChaptersname{Les chapitres~}%

 - plurals for range and list management with varioref: this requires more than
a checkbox in the menu, like capitalization does: as the selected labels must be
ordered, it would need an interface like the one developed for bibliographic
citations to add/remove labels which should appear in the range or list.

There are limits to what is possible to automate in formatted references, as you
mentioned in another message of this thread: in French again, sectioning
references does not fit well with the current model, as e.g. one should like to
get "la première partie" instead of "Part I", and even "la seconde partie" if
there are two parts and "la deuxième partie" if there are more :-)

BTW, I've split up bug #6420 in two bugs, and I have retargeted the varioref bug
#6608 to lyx-1.6.6. Do you think that it should only appear in lyx-2.0.0 to pass
the various alpha, beta, etc. release tests?

-- 
Jean-Pierre







Re: New RefStyle Patch

2010-03-22 Thread rgheck

On 03/21/2010 05:48 AM, Jean-Pierre Chrétien wrote:


I think I found an error:
  - open a new document,
  - set the document class to report
  - type in a new chapter named Test and label it: the label reads cha:Test
instead of chap:Test

Then a formatted reference to the chapter fails.

A label of a part is correct.

   

I forgot to change the RefPrefix definition. That'll be in the final patch.

rh




Re: New RefStyle Patch

2010-03-22 Thread rgheck

On 03/21/2010 09:29 AM, Jürgen Spitzmüller wrote:

rgheck wrote:
   

So I'll go ahead and commit this if it seems good to Jurgen. I'd like
his opinion, too.
 

I didn't have time to test it. I'm fine with it as long as it is guaranteed
that old (prettyref and prettyref/varioref combined) documents come out
identical, at least if people do not use preamble or class tricks.

   
I'm not sure if we can guarantee that they will be identical, only very 
close. This is because the default format for refstyle isn't always (and 
hasn't always) been exactly the same as prettyref's. So you may get 
slightly different text in certain cases.


The real issue is theorems and lemmas, which refstyle does not by 
default define formats for. I guess we could include such definitions 
ourselves in theorems.inc, etc. But then we have to make sure that 
refstyle is loaded, or else wrap the definitions in an if-defined type 
of clause.


Any thoughts?

Richard



Re: New RefStyle Patch

2010-03-22 Thread rgheck

On 03/21/2010 05:26 AM, Jean-Pierre Chrétien wrote:


What should I do on the bugtracker ? Open a fresh bug about varioref targeted to
1.6.6 ? Inserting \usepackage{nameref} (which is just an early loading of the
nameref and refcount packages) should not raise issues, unless it needs a format
change. And with 1.6.6svn, the UserGuide fails to open, with or without hyperref
activated.

   
I think what you suggest here makes sense: Fresh report for the separate 
bug.


rh




Re: New RefStyle Patch

2010-03-22 Thread Jürgen Spitzmüller
rgheck wrote:
 I'm not sure if we can guarantee that they will be identical, only very 
 close. This is because the default format for refstyle isn't always (and 
 hasn't always) been exactly the same as prettyref's. So you may get 
 slightly different text in certain cases.

That's bad. In this case, I vote for keeping prettyref for old documents and 
use refstyle only for new ones (as default).

Jürgen


Re: New RefStyle Patch

2010-03-22 Thread rgheck

On 03/22/2010 08:13 AM, Jürgen Spitzmüller wrote:

rgheck wrote:
   

I'm not sure if we can guarantee that they will be identical, only very
close. This is because the default format for refstyle isn't always (and
hasn't always) been exactly the same as prettyref's. So you may get
slightly different text in certain cases.
 

That's bad. In this case, I vote for keeping prettyref for old documents and
use refstyle only for new ones (as default).

   
Anything seems better to me than allowing the use of both prettyref and 
refstyle. We'd have to support both in 2.0, and I don't see any nice way 
to do that.


I've looked into this, and there are two major differences, both of 
which are fixable, I think.


The first is that prettyref always uses capitals, so you always get 
Section 5, rather than section 5. (This has always annoyed me.) By 
contrast, refstyle provides both the \secref and \Secref commands, which 
give you lowercase or uppercase as you wish. LyX should really support 
this anyway, so I could add that to the cross-reference dialog as an 
option and then we can translate

\prettyref{sec:whatever}
as
\Secref{sec:whatever}
in lyx2lyx.

The other issue is that prettyref gives us these:
\newrefformat{tab}{Table \ref{#1} on page \pageref{#1}}
\newrefformat{fig}{Figure \ref{#1} on page \pageref{#1}}
This can also be handled in lyx2lyx by translating:
\prettyref{tab:what}
as:
\Tabref{tab:what} on page \pageref{tab:what}
i.e., inserting some extra text and an extra cross-reference.

The other issue, as I said, is with theorems and lemmas, which can be 
handled in layout.


rh



Re: New RefStyle Patch

2010-03-22 Thread Jürgen Spitzmüller
rgheck wrote:
 Anything seems better to me than allowing the use of both prettyref and 
 refstyle. We'd have to support both in 2.0, and I don't see any nice way 
 to do that.

If we are not able to provide full compatibility, we must IMHO.

 I've looked into this, and there are two major differences, both of 
 which are fixable, I think.
 
 The first is that prettyref always uses capitals, so you always get 
 Section 5, rather than section 5. (This has always annoyed me.) By 
 contrast, refstyle provides both the \secref and \Secref commands, which 
 give you lowercase or uppercase as you wish. LyX should really support 
 this anyway, so I could add that to the cross-reference dialog as an 
 option and then we can translate
  \prettyref{sec:whatever}
 as
  \Secref{sec:whatever}
 in lyx2lyx.

OK.

 The other issue is that prettyref gives us these:
  \newrefformat{tab}{Table \ref{#1} on page \pageref{#1}}
  \newrefformat{fig}{Figure \ref{#1} on page \pageref{#1}}
 This can also be handled in lyx2lyx by translating:
  \prettyref{tab:what}
 as:
  \Tabref{tab:what} on page \pageref{tab:what}
 i.e., inserting some extra text and an extra cross-reference.

Hm. I have in one of my class files this:

% Prettyref:
\RequirePackage{prettyref}
\newrefformat{cha}{Kapitel~\ref{#1}}
\newrefformat{sec}{Abschnitt~\ref{#1}}
\newrefformat{sub}{Abschnitt~\ref{#1}}
\newrefformat{anm}{Anm.~\ref{#1}}
\newrefformat{fn}{Anm.~\ref{#1}}
\newrefformat{app}{Anhang~\ref{#1}}
\newrefformat{tab}{Tabelle~\vref{#1}}
\newrefformat{fig}{Abbildung~\vref{#1}}
\newrefformat{exp}{Argumentation~\vref{#1}}

Note that some of these definitions include varioref (the \vref macro), so 
\prettyref{fig:foo} actually yields see figure X on the following page (or 
whatever the context requires). I am aware that I will be forced to change 
that class file if we completely ditch prettyref (which is bad enough), but is 
refstyle at least able to allow similar inclusion of varioref functionality?

Jürgen


Re: New RefStyle Patch

2010-03-22 Thread Richard Heck

On 03/22/2010 09:08 AM, Jürgen Spitzmüller wrote:


Hm. I have in one of my class files this:

% Prettyref:
\RequirePackage{prettyref}
\newrefformat{cha}{Kapitel~\ref{#1}}
\newrefformat{sec}{Abschnitt~\ref{#1}}
\newrefformat{sub}{Abschnitt~\ref{#1}}
\newrefformat{anm}{Anm.~\ref{#1}}
\newrefformat{fn}{Anm.~\ref{#1}}
\newrefformat{app}{Anhang~\ref{#1}}
\newrefformat{tab}{Tabelle~\vref{#1}}
\newrefformat{fig}{Abbildung~\vref{#1}}
\newrefformat{exp}{Argumentation~\vref{#1}}

Note that some of these definitions include varioref (the \vref macro), so
\prettyref{fig:foo} actually yields see figure X on the following page (or
whatever the context requires). I am aware that I will be forced to change
that class file if we completely ditch prettyref (which is bad enough), but is
refstyle at least able to allow similar inclusion of varioref functionality?

   
Ultimately, refstyle has much better and more flexible support for this 
sort of thing. Thus, one can write in LaTeX:

\Tabref[vref]{tab:foo}
and then you get:
table 3 on the previous page
or whatever. So we could support that sort of thing directly in LyX. And 
refstyle will do other things, too, like plurals and ranges, e.g., 
sections 3 to 5.


But you can also do the sort of thing you do there. E.g., we can 
redefine figure refs as follows:


  \newref{fig}{%
  name= \RSfigtxt,
  names   = \RSfigstxt,
  Name= \RSFigtxt,
  Names   = \RSFigstxt,
  rngtxt  = \RSrngtxt,
  lsttxt  = \RSlsttxt,
  refcmd = \ref{#1} \vpageref{#1}}

Other than refcmd, this is all just from refstyle.cfg. There isn't any 
straightforward way just to redefine refcmd for figs.


rh



Re: New RefStyle Patch

2010-03-22 Thread Jürgen Spitzmüller
Richard Heck wrote:
 Ultimately, refstyle has much better and more flexible support for this 
 sort of thing. Thus, one can write in LaTeX:
  \Tabref[vref]{tab:foo}
 and then you get:
  table 3 on the previous page

Yes, I know. However, I prefer to customize this globally. If I decide (or the 
publisher urges me) to take out the on page X references completely for 
figures (or add them for chapters), I do not want to revisit any single 
reference.
(that's why I do not much like your proposed solution of letting lyx2lyx 
change global definitions to fixed ones, such as \Tabref{tab:what} on page 
\pageref{tab:what})

 or whatever. So we could support that sort of thing directly in LyX. And 
 refstyle will do other things, too, like plurals and ranges, e.g., 
 sections 3 to 5.

Looks promising. I'm eager to see if this can handle different syntactic cases 
as well (which is slightly more relevant in German than English -- vgl. die 
Abschnitte 3 bis 5 vs. in den Abschnitten 3 bis 5 -- and even more relevant 
in other languages) 

 But you can also do the sort of thing you do there. E.g., we can 
 redefine figure refs as follows:
 
\newref{fig}{%
name= \RSfigtxt,
names   = \RSfigstxt,
Name= \RSFigtxt,
Names   = \RSFigstxt,
rngtxt  = \RSrngtxt,
lsttxt  = \RSlsttxt,
refcmd = \ref{#1} \vpageref{#1}}
 
 Other than refcmd, this is all just from refstyle.cfg. There isn't any 
 straightforward way just to redefine refcmd for figs.

I see. I guess this would do for my case. But anyway, this change will 
probably affect many more documents. So if we come to decide that prettyref 
will be dropped, we will have to add a big fat warning in the release notes. 

Jürgen


Re: New RefStyle Patch

2010-03-22 Thread rgheck

On 03/22/2010 11:59 AM, Jürgen Spitzmüller wrote:

Richard Heck wrote:
   

or whatever. So we could support that sort of thing directly in LyX. And
refstyle will do other things, too, like plurals and ranges, e.g.,
sections 3 to 5.
 

Looks promising. I'm eager to see if this can handle different syntactic cases
as well (which is slightly more relevant in German than English -- vgl. die
Abschnitte 3 bis 5 vs. in den Abschnitten 3 bis 5 -- and even more relevant
in other languages)

   
I don't think it will do this. It's hard to see how any program could 
handle this generally. It'd have to have a lot of information about 
case. Maybe even more than we actually have these days.



But you can also do the sort of thing you do there. E.g., we can
redefine figure refs as follows:

\newref{fig}{%
name= \RSfigtxt,
names   = \RSfigstxt,
Name= \RSFigtxt,
Names   = \RSFigstxt,
rngtxt  = \RSrngtxt,
lsttxt  = \RSlsttxt,
refcmd = \ref{#1} \vpageref{#1}}

Other than refcmd, this is all just from refstyle.cfg. There isn't any
straightforward way just to redefine refcmd for figs.
 

I see. I guess this would do for my case. But anyway, this change will
probably affect many more documents.

   

Well, note that a large part of what you were doing, namely, all of this:

\newrefformat{cha}{Kapitel~\ref{#1}}
\newrefformat{sec}{Abschnitt~\ref{#1}}
\newrefformat{sub}{Abschnitt~\ref{#1}}
\newrefformat{anm}{Anm.~\ref{#1}}
\newrefformat{fn}{Anm.~\ref{#1}}
\newrefformat{app}{Anhang~\ref{#1}}

can simply be deleted, since refstyle has its own mechanism for i18n. 
So, in so far as people were using this sort of thing for that purpose, 
it's unnecessary, except in so far as refstyle could use more 
translations. But we can encourage our own translators to send them in.



So if we come to decide that prettyref will be dropped, we will have to add a 
big fat warning in the release notes.

   
Of course. We could even try translating the \newrefformat stuff in 
lyx2lyx. It is possible, I think, though it'd probably be a bit dangerous.


rh



Re: New RefStyle Patch

2010-03-22 Thread rgheck

On 03/21/2010 05:48 AM, Jean-Pierre Chrétien wrote:


I think I found an error:
  - open a new document,
  - set the document class to report
  - type in a new chapter named Test and label it: the label reads cha:Test
instead of chap:Test

Then a formatted reference to the chapter fails.

A label of a part is correct.

   

I forgot to change the RefPrefix definition. That'll be in the final patch.

rh




Re: New RefStyle Patch

2010-03-22 Thread rgheck

On 03/21/2010 09:29 AM, Jürgen Spitzmüller wrote:

rgheck wrote:
   

So I'll go ahead and commit this if it seems good to Jurgen. I'd like
his opinion, too.
 

I didn't have time to test it. I'm fine with it as long as it is guaranteed
that old (prettyref and prettyref/varioref combined) documents come out
identical, at least if people do not use preamble or class tricks.

   
I'm not sure if we can guarantee that they will be identical, only very 
close. This is because the default format for refstyle isn't always (and 
hasn't always) been exactly the same as prettyref's. So you may get 
slightly different text in certain cases.


The real issue is theorems and lemmas, which refstyle does not by 
default define formats for. I guess we could include such definitions 
ourselves in theorems.inc, etc. But then we have to make sure that 
refstyle is loaded, or else wrap the definitions in an if-defined type 
of clause.


Any thoughts?

Richard



Re: New RefStyle Patch

2010-03-22 Thread rgheck

On 03/21/2010 05:26 AM, Jean-Pierre Chrétien wrote:


What should I do on the bugtracker ? Open a fresh bug about varioref targeted to
1.6.6 ? Inserting \usepackage{nameref} (which is just an early loading of the
nameref and refcount packages) should not raise issues, unless it needs a format
change. And with 1.6.6svn, the UserGuide fails to open, with or without hyperref
activated.

   
I think what you suggest here makes sense: Fresh report for the separate 
bug.


rh




Re: New RefStyle Patch

2010-03-22 Thread Jürgen Spitzmüller
rgheck wrote:
> I'm not sure if we can guarantee that they will be identical, only very 
> close. This is because the default format for refstyle isn't always (and 
> hasn't always) been exactly the same as prettyref's. So you may get 
> slightly different text in certain cases.

That's bad. In this case, I vote for keeping prettyref for old documents and 
use refstyle only for new ones (as default).

Jürgen


Re: New RefStyle Patch

2010-03-22 Thread rgheck

On 03/22/2010 08:13 AM, Jürgen Spitzmüller wrote:

rgheck wrote:
   

I'm not sure if we can guarantee that they will be identical, only very
close. This is because the default format for refstyle isn't always (and
hasn't always) been exactly the same as prettyref's. So you may get
slightly different text in certain cases.
 

That's bad. In this case, I vote for keeping prettyref for old documents and
use refstyle only for new ones (as default).

   
Anything seems better to me than allowing the use of both prettyref and 
refstyle. We'd have to support both in 2.0, and I don't see any nice way 
to do that.


I've looked into this, and there are two major differences, both of 
which are fixable, I think.


The first is that prettyref always uses capitals, so you always get 
"Section 5", rather than "section 5". (This has always annoyed me.) By 
contrast, refstyle provides both the \secref and \Secref commands, which 
give you lowercase or uppercase as you wish. LyX should really support 
this anyway, so I could add that to the cross-reference dialog as an 
option and then we can translate

\prettyref{sec:whatever}
as
\Secref{sec:whatever}
in lyx2lyx.

The other issue is that prettyref gives us these:
\newrefformat{tab}{Table \ref{#1} on page \pageref{#1}}
\newrefformat{fig}{Figure \ref{#1} on page \pageref{#1}}
This can also be handled in lyx2lyx by translating:
\prettyref{tab:what}
as:
\Tabref{tab:what} on page \pageref{tab:what}
i.e., inserting some extra text and an extra cross-reference.

The other issue, as I said, is with theorems and lemmas, which can be 
handled in layout.


rh



Re: New RefStyle Patch

2010-03-22 Thread Jürgen Spitzmüller
rgheck wrote:
> Anything seems better to me than allowing the use of both prettyref and 
> refstyle. We'd have to support both in 2.0, and I don't see any nice way 
> to do that.

If we are not able to provide full compatibility, we must IMHO.

> I've looked into this, and there are two major differences, both of 
> which are fixable, I think.
> 
> The first is that prettyref always uses capitals, so you always get 
> "Section 5", rather than "section 5". (This has always annoyed me.) By 
> contrast, refstyle provides both the \secref and \Secref commands, which 
> give you lowercase or uppercase as you wish. LyX should really support 
> this anyway, so I could add that to the cross-reference dialog as an 
> option and then we can translate
>  \prettyref{sec:whatever}
> as
>  \Secref{sec:whatever}
> in lyx2lyx.

OK.

> The other issue is that prettyref gives us these:
>  \newrefformat{tab}{Table \ref{#1} on page \pageref{#1}}
>  \newrefformat{fig}{Figure \ref{#1} on page \pageref{#1}}
> This can also be handled in lyx2lyx by translating:
>  \prettyref{tab:what}
> as:
>  \Tabref{tab:what} on page \pageref{tab:what}
> i.e., inserting some extra text and an extra cross-reference.

Hm. I have in one of my class files this:

% Prettyref:
\RequirePackage{prettyref}
\newrefformat{cha}{Kapitel~\ref{#1}}
\newrefformat{sec}{Abschnitt~\ref{#1}}
\newrefformat{sub}{Abschnitt~\ref{#1}}
\newrefformat{anm}{Anm.~\ref{#1}}
\newrefformat{fn}{Anm.~\ref{#1}}
\newrefformat{app}{Anhang~\ref{#1}}
\newrefformat{tab}{Tabelle~\vref{#1}}
\newrefformat{fig}{Abbildung~\vref{#1}}
\newrefformat{exp}{Argumentation~\vref{#1}}

Note that some of these definitions include varioref (the \vref macro), so 
\prettyref{fig:foo} actually yields "see figure X on the following page" (or 
whatever the context requires). I am aware that I will be forced to change 
that class file if we completely ditch prettyref (which is bad enough), but is 
refstyle at least able to allow similar inclusion of varioref functionality?

Jürgen


Re: New RefStyle Patch

2010-03-22 Thread Richard Heck

On 03/22/2010 09:08 AM, Jürgen Spitzmüller wrote:


Hm. I have in one of my class files this:

% Prettyref:
\RequirePackage{prettyref}
\newrefformat{cha}{Kapitel~\ref{#1}}
\newrefformat{sec}{Abschnitt~\ref{#1}}
\newrefformat{sub}{Abschnitt~\ref{#1}}
\newrefformat{anm}{Anm.~\ref{#1}}
\newrefformat{fn}{Anm.~\ref{#1}}
\newrefformat{app}{Anhang~\ref{#1}}
\newrefformat{tab}{Tabelle~\vref{#1}}
\newrefformat{fig}{Abbildung~\vref{#1}}
\newrefformat{exp}{Argumentation~\vref{#1}}

Note that some of these definitions include varioref (the \vref macro), so
\prettyref{fig:foo} actually yields "see figure X on the following page" (or
whatever the context requires). I am aware that I will be forced to change
that class file if we completely ditch prettyref (which is bad enough), but is
refstyle at least able to allow similar inclusion of varioref functionality?

   
Ultimately, refstyle has much better and more flexible support for this 
sort of thing. Thus, one can write in LaTeX:

\Tabref[vref]{tab:foo}
and then you get:
table 3 on the previous page
or whatever. So we could support that sort of thing directly in LyX. And 
refstyle will do other things, too, like plurals and ranges, e.g., 
"sections 3 to 5".


But you can also do the sort of thing you do there. E.g., we can 
redefine figure refs as follows:


  \newref{fig}{%
  name= \RSfigtxt,
  names   = \RSfigstxt,
  Name= \RSFigtxt,
  Names   = \RSFigstxt,
  rngtxt  = \RSrngtxt,
  lsttxt  = \RSlsttxt,
  refcmd = \ref{#1} \vpageref{#1}}

Other than refcmd, this is all just from refstyle.cfg. There isn't any 
straightforward way just to redefine refcmd for figs.


rh



Re: New RefStyle Patch

2010-03-22 Thread Jürgen Spitzmüller
Richard Heck wrote:
> Ultimately, refstyle has much better and more flexible support for this 
> sort of thing. Thus, one can write in LaTeX:
>  \Tabref[vref]{tab:foo}
> and then you get:
>  table 3 on the previous page

Yes, I know. However, I prefer to customize this globally. If I decide (or the 
publisher urges me) to take out the "on page X" references completely for 
figures (or add them for chapters), I do not want to revisit any single 
reference.
(that's why I do not much like your proposed solution of letting lyx2lyx 
change global definitions to fixed ones, such as "\Tabref{tab:what} on page 
\pageref{tab:what}")

> or whatever. So we could support that sort of thing directly in LyX. And 
> refstyle will do other things, too, like plurals and ranges, e.g., 
> "sections 3 to 5".

Looks promising. I'm eager to see if this can handle different syntactic cases 
as well (which is slightly more relevant in German than English -- "vgl. die 
Abschnitte 3 bis 5" vs. "in den Abschnitten 3 bis 5" -- and even more relevant 
in other languages) 

> But you can also do the sort of thing you do there. E.g., we can 
> redefine figure refs as follows:
> 
>\newref{fig}{%
>name= \RSfigtxt,
>names   = \RSfigstxt,
>Name= \RSFigtxt,
>Names   = \RSFigstxt,
>rngtxt  = \RSrngtxt,
>lsttxt  = \RSlsttxt,
>refcmd = \ref{#1} \vpageref{#1}}
> 
> Other than refcmd, this is all just from refstyle.cfg. There isn't any 
> straightforward way just to redefine refcmd for figs.

I see. I guess this would do for my case. But anyway, this change will 
probably affect many more documents. So if we come to decide that prettyref 
will be dropped, we will have to add a big fat warning in the release notes. 

Jürgen


Re: New RefStyle Patch

2010-03-22 Thread rgheck

On 03/22/2010 11:59 AM, Jürgen Spitzmüller wrote:

Richard Heck wrote:
   

or whatever. So we could support that sort of thing directly in LyX. And
refstyle will do other things, too, like plurals and ranges, e.g.,
"sections 3 to 5".
 

Looks promising. I'm eager to see if this can handle different syntactic cases
as well (which is slightly more relevant in German than English -- "vgl. die
Abschnitte 3 bis 5" vs. "in den Abschnitten 3 bis 5" -- and even more relevant
in other languages)

   
I don't think it will do this. It's hard to see how any program could 
handle this generally. It'd have to have a lot of information about 
case. Maybe even more than we actually have these days.



But you can also do the sort of thing you do there. E.g., we can
redefine figure refs as follows:

\newref{fig}{%
name= \RSfigtxt,
names   = \RSfigstxt,
Name= \RSFigtxt,
Names   = \RSFigstxt,
rngtxt  = \RSrngtxt,
lsttxt  = \RSlsttxt,
refcmd = \ref{#1} \vpageref{#1}}

Other than refcmd, this is all just from refstyle.cfg. There isn't any
straightforward way just to redefine refcmd for figs.
 

I see. I guess this would do for my case. But anyway, this change will
probably affect many more documents.

   

Well, note that a large part of what you were doing, namely, all of this:

\newrefformat{cha}{Kapitel~\ref{#1}}
\newrefformat{sec}{Abschnitt~\ref{#1}}
\newrefformat{sub}{Abschnitt~\ref{#1}}
\newrefformat{anm}{Anm.~\ref{#1}}
\newrefformat{fn}{Anm.~\ref{#1}}
\newrefformat{app}{Anhang~\ref{#1}}

can simply be deleted, since refstyle has its own mechanism for i18n. 
So, in so far as people were using this sort of thing for that purpose, 
it's unnecessary, except in so far as refstyle could use more 
translations. But we can encourage our own translators to send them in.



So if we come to decide that prettyref will be dropped, we will have to add a 
big fat warning in the release notes.

   
Of course. We could even try translating the \newrefformat stuff in 
lyx2lyx. It is possible, I think, though it'd probably be a bit dangerous.


rh



Re: New RefStyle Patch

2010-03-21 Thread Jean-Pierre Chrétien
rgheck rgh...@... writes:

 
 On 03/20/2010 04:54 AM, Jean-Pierre Chrétien wrote:
  rgheckrgh...@...  writes:

  Then all problems due to : being active in French vanish, either coming
from the
  use of varioref or from the use of formatted references.
  As refstyle make the sensitivity to active characters disappear, it seems
that
  the issue of a change of the labelling disappears as well.
 
 
 Great.

I guess I got enthousiastic a bit early: my test file had hyperref checked, 
when I uncheck it, the varioref issue with : is back.

I understand now that I sould not have mixed varioref and prettyref in bug 6420,
these come from the same active character in labels but are really different, 
as :
 - the varioref bug, e;g. with vpageref in French babel:

! Missing \endcsname inserted.
to be read again 
   :
l.14 ... section \vpageref{sec:Premier-paragraphe}

appears currently in branch and trunk (refstyle patch applied or not).

This one is solved either by adding 

\usepackage{nameref}

before

\usepackage{varioref}

in the preamble (this can only be done currently by modifying the LyX sources),
or by coding in ERT, e.g.

{\shorthandoff{:}{\vpageref{sec:Premier-paragraphe}}}

instead of

\vpageref{sec:Premier-paragraphe}

 - the prettyref bug is solved by going to refstyle, or by the \shorthandoff
command.

So the varioref bug could be retargeted to the 1.6 series (Jürgen ?), while your
refstyle patch solves the prettyref bug (and opens perspectives towards a much
wider coverage of sophisticated crossref coding).

What should I do on the bugtracker ? Open o fresh bug about varioref targeted to
1.6.6 ? Inserting \usepackage{nameref} (which is just an early loading of the
nameref and refcount packages) should not raise issues, unless it needs a format
change. And with 1.6.6svn, the UserGuide fails to open, with or without hyperref
activated.

-- 
Jean-Pierre






Re: New RefStyle Patch

2010-03-21 Thread Jean-Pierre Chrétien
Jean-Pierre Chrétien jeanpierre.chret...@... writes:

 
 rgheck rgh...@... writes:
 
  
  
  Here's a patch updated to current trunk, since I incremented the format 
  for another reason.
 
 There is still a typo which prevents successful conversion: there should be a
 closing  after vreference in line:
 
 +  document.body[k] = reference +  \ + prefix + : + suffix + \
 
 Once corrected, lyx2lyx works fine.

I think I found an error:
 - open a new document,
 - set the document class to report
 - type in a new chapter named Test and label it: the label reads cha:Test
instead of chap:Test

Then a formatted reference to the chapter fails.

A label of a part is correct.

-- 
Jean-Pierre






Re: New RefStyle Patch

2010-03-21 Thread Jürgen Spitzmüller
rgheck wrote:
 So I'll go ahead and commit this if it seems good to Jurgen. I'd like 
 his opinion, too.

I didn't have time to test it. I'm fine with it as long as it is guaranteed 
that old (prettyref and prettyref/varioref combined) documents come out 
identical, at least if people do not use preamble or class tricks.

Jürgen


Re: New RefStyle Patch

2010-03-21 Thread Jean-Pierre Chrétien
rgheck  writes:

> 
> On 03/20/2010 04:54 AM, Jean-Pierre Chrétien wrote:
> > rgheck  writes:

> > Then all problems due to : being active in French vanish, either coming
from the
> > use of varioref or from the use of formatted references.
> > As refstyle make the sensitivity to active characters disappear, it seems
that
> > the issue of a change of the labelling disappears as well.
> >
> >
> Great.

I guess I got enthousiastic a bit early: my test file had hyperref checked, 
when I uncheck it, the varioref issue with ":" is back.

I understand now that I sould not have mixed varioref and prettyref in bug 6420,
these come from the same active character in labels but are really different, 
as :
 - the varioref bug, e;g. with vpageref in French babel:

! Missing \endcsname inserted.
 
   :
l.14 ... section \vpageref{sec:Premier-paragraphe}

appears currently in branch and trunk (refstyle patch applied or not).

This one is solved either by adding 

\usepackage{nameref}

before

\usepackage{varioref}

in the preamble (this can only be done currently by modifying the LyX sources),
or by coding in ERT, e.g.

{\shorthandoff{:}{\vpageref{sec:Premier-paragraphe}}}

instead of

\vpageref{sec:Premier-paragraphe}

 - the prettyref bug is solved by going to refstyle, or by the \shorthandoff
command.

So the varioref bug could be retargeted to the 1.6 series (Jürgen ?), while your
refstyle patch solves the prettyref bug (and opens perspectives towards a much
wider coverage of sophisticated crossref coding).

What should I do on the bugtracker ? Open o fresh bug about varioref targeted to
1.6.6 ? Inserting \usepackage{nameref} (which is just an early loading of the
nameref and refcount packages) should not raise issues, unless it needs a format
change. And with 1.6.6svn, the UserGuide fails to open, with or without hyperref
activated.

-- 
Jean-Pierre






Re: New RefStyle Patch

2010-03-21 Thread Jean-Pierre Chrétien
Jean-Pierre Chrétien  writes:

> 
> rgheck  writes:
> 
> > 
> > 
> > Here's a patch updated to current trunk, since I incremented the format 
> > for another reason.
> 
> There is still a typo which prevents successful conversion: there should be a
> closing " after vreference in line:
> 
> +  document.body[k] = "reference + " \"" + prefix + ":" + suffix + "\""
> 
> Once corrected, lyx2lyx works fine.

I think I found an error:
 - open a new document,
 - set the document class to report
 - type in a new chapter named Test and label it: the label reads cha:Test
instead of chap:Test

Then a formatted reference to the chapter fails.

A label of a part is correct.

-- 
Jean-Pierre






Re: New RefStyle Patch

2010-03-21 Thread Jürgen Spitzmüller
rgheck wrote:
> So I'll go ahead and commit this if it seems good to Jurgen. I'd like 
> his opinion, too.

I didn't have time to test it. I'm fine with it as long as it is guaranteed 
that old (prettyref and prettyref/varioref combined) documents come out 
identical, at least if people do not use preamble or class tricks.

Jürgen


Re: New RefStyle Patch

2010-03-20 Thread Jean-Pierre Chrétien
rgheck rgh...@... writes:

 
 
 Here's a patch updated to current trunk, since I incremented the format 
 for another reason.

There is still a typo which prevents successful conversion: there should be a
closing  after vreference in line:

+document.body[k] = reference +  \ + prefix + : + suffix + 
\

Once corrected, lyx2lyx works fine.

Then all problems due to : being active in French vanish, either coming from the
use of varioref or from the use of formatted references.
As refstyle make the sensitivity to active characters disappear, it seems that
the issue of a change of the labelling disappears as well.

I would like to confirm this on a more complete example, so I'm willing to write
a file (which could be distributed in the examples directory) which includes 
kinds of labels and crossrefs for various kind of insets. This file would allow
to check i18n.

However, IMHO, the explicit loading of nameref with varioref should be added for
the 1.6 series (1.6.6 or 1.6.7) to solve the varioref issue in the current
stable version. Solving the prettyref issue is more problematic (\shorthandoff
fails if : is not active). Editing the manuals maight be enough for this one.

-- 
Jean-Pierre




Re: New RefStyle Patch

2010-03-20 Thread rgheck

On 03/20/2010 04:54 AM, Jean-Pierre Chrétien wrote:

rgheckrgh...@...  writes:

   


Here's a patch updated to current trunk, since I incremented the format
for another reason.
 

There is still a typo which prevents successful conversion: there should be a
closing  after vreference in line:

+document.body[k] = reference +  \ + prefix + : + suffix + 
\

Once corrected, lyx2lyx works fine.

   

Now how did it work here? I did actually test this ;-)


Then all problems due to : being active in French vanish, either coming from the
use of varioref or from the use of formatted references.
As refstyle make the sensitivity to active characters disappear, it seems that
the issue of a change of the labelling disappears as well.

   

Great.


I would like to confirm this on a more complete example, so I'm willing to write
a file (which could be distributed in the examples directory) which includes
kinds of labels and crossrefs for various kind of insets. This file would allow
to check i18n.

   

That would be great.

So I'll go ahead and commit this if it seems good to Jurgen. I'd like 
his opinion, too.



However, IMHO, the explicit loading of nameref with varioref should be added for
the 1.6 series (1.6.6 or 1.6.7) to solve the varioref issue in the current
stable version. Solving the prettyref issue is more problematic (\shorthandoff
fails if : is not active). Editing the manuals maight be enough for this one.

   

This one is definitely for Jurgen.

rh



Re: New RefStyle Patch

2010-03-20 Thread Jean-Pierre Chrétien
rgheck  writes:

> 
> 
> Here's a patch updated to current trunk, since I incremented the format 
> for another reason.

There is still a typo which prevents successful conversion: there should be a
closing " after vreference in line:

+document.body[k] = "reference + " \"" + prefix + ":" + suffix + 
"\""

Once corrected, lyx2lyx works fine.

Then all problems due to : being active in French vanish, either coming from the
use of varioref or from the use of formatted references.
As refstyle make the sensitivity to active characters disappear, it seems that
the issue of a change of the labelling disappears as well.

I would like to confirm this on a more complete example, so I'm willing to write
a file (which could be distributed in the examples directory) which includes 
kinds of labels and crossrefs for various kind of insets. This file would allow
to check i18n.

However, IMHO, the explicit loading of nameref with varioref should be added for
the 1.6 series (1.6.6 or 1.6.7) to solve the varioref issue in the current
stable version. Solving the prettyref issue is more problematic (\shorthandoff
fails if : is not active). Editing the manuals maight be enough for this one.

-- 
Jean-Pierre




Re: New RefStyle Patch

2010-03-20 Thread rgheck

On 03/20/2010 04:54 AM, Jean-Pierre Chrétien wrote:

rgheck  writes:

   


Here's a patch updated to current trunk, since I incremented the format
for another reason.
 

There is still a typo which prevents successful conversion: there should be a
closing " after vreference in line:

+document.body[k] = "reference + " \"" + prefix + ":" + suffix + 
"\""

Once corrected, lyx2lyx works fine.

   

Now how did it work here? I did actually test this ;-)


Then all problems due to : being active in French vanish, either coming from the
use of varioref or from the use of formatted references.
As refstyle make the sensitivity to active characters disappear, it seems that
the issue of a change of the labelling disappears as well.

   

Great.


I would like to confirm this on a more complete example, so I'm willing to write
a file (which could be distributed in the examples directory) which includes
kinds of labels and crossrefs for various kind of insets. This file would allow
to check i18n.

   

That would be great.

So I'll go ahead and commit this if it seems good to Jurgen. I'd like 
his opinion, too.



However, IMHO, the explicit loading of nameref with varioref should be added for
the 1.6 series (1.6.6 or 1.6.7) to solve the varioref issue in the current
stable version. Solving the prettyref issue is more problematic (\shorthandoff
fails if : is not active). Editing the manuals maight be enough for this one.

   

This one is definitely for Jurgen.

rh



Re: New RefStyle Patch

2010-03-18 Thread Julien Rioux
rgheck rgh...@... writes:
 
 Here's a patch updated to current trunk, since I incremented the format 
 for another reason.
 
 There are a couple conceptual issues.
 
 (1) refstyle does not know about theorems and lemmas by default. What 
 mechanism should we use for declaring the reference styles?

Seems to me that this should be fixed upstream, in the refstyle package.

 [...]
 
 (2) Part of the attraction of refstyle is that it doesn't have to use 
 : as a separator, which is bad in French, since the colon is active. 
 Should we just use something else? If so, what? Should we allow it to be 
 customized? The disadvantage in either case is that refstyle by default 
 assumes :, and so either we or the user has to take appropriate steps 
 to tell refstyle about the difference. Unfortunately, there is no easy 
 way to do that. It has to be done for each and every reference style you 
 declare.
 

What are other advantages of refstyle versus prettyref? I will give your patch a
try, but I kind of like prettyref. I sure hope I can produce the same kind of
output, otherwise I would prefer to keep prettyref support next to it.

 rh
 

Cheers,
Julien




Re: New RefStyle Patch

2010-03-18 Thread rgheck

On 03/18/2010 06:36 PM, Julien Rioux wrote:

(1) refstyle does not know about theorems and lemmas by default. What
mechanism should we use for declaring the reference styles?

 

Seems to me that this should be fixed upstream, in the refstyle package.


That's a good idea. I'll write the maintainer.


[...]

(2) Part of the attraction of refstyle is that it doesn't have to use
: as a separator, which is bad in French, since the colon is active.
Should we just use something else? If so, what? Should we allow it to be
customized? The disadvantage in either case is that refstyle by default
assumes :, and so either we or the user has to take appropriate steps
to tell refstyle about the difference. Unfortunately, there is no easy
way to do that. It has to be done for each and every reference style you
declare.

 

What are other advantages of refstyle versus prettyref? I will give your patch a
try, but I kind of like prettyref. I sure hope I can produce the same kind of
output, otherwise I would prefer to keep prettyref support next to it.

   
The main one, right now, is internationalization. The output is 
otherwise pretty similar, and can be customized in similar ways. 
Eventually, though, we can support ranges of references and that kind of 
thing, though that will likely wait for 2.1, since (a) I can't see 
getting it done for 2.0 and (b) it will be a format change.


rh



Re: New RefStyle Patch

2010-03-18 Thread Julien Rioux
rgheck  writes:
> 
> Here's a patch updated to current trunk, since I incremented the format 
> for another reason.
> 
> There are a couple conceptual issues.
> 
> (1) refstyle does not know about theorems and lemmas by default. What 
> mechanism should we use for declaring the reference styles?

Seems to me that this should be fixed upstream, in the refstyle package.

> [...]
> 
> (2) Part of the attraction of refstyle is that it doesn't have to use 
> ":" as a separator, which is bad in French, since the colon is active. 
> Should we just use something else? If so, what? Should we allow it to be 
> customized? The disadvantage in either case is that refstyle by default 
> assumes ":", and so either we or the user has to take appropriate steps 
> to tell refstyle about the difference. Unfortunately, there is no easy 
> way to do that. It has to be done for each and every reference style you 
> declare.
> 

What are other advantages of refstyle versus prettyref? I will give your patch a
try, but I kind of like prettyref. I sure hope I can produce the same kind of
output, otherwise I would prefer to keep prettyref support next to it.

> rh
> 

Cheers,
Julien




Re: New RefStyle Patch

2010-03-18 Thread rgheck

On 03/18/2010 06:36 PM, Julien Rioux wrote:

(1) refstyle does not know about theorems and lemmas by default. What
mechanism should we use for declaring the reference styles?

 

Seems to me that this should be fixed upstream, in the refstyle package.


That's a good idea. I'll write the maintainer.


[...]

(2) Part of the attraction of refstyle is that it doesn't have to use
":" as a separator, which is bad in French, since the colon is active.
Should we just use something else? If so, what? Should we allow it to be
customized? The disadvantage in either case is that refstyle by default
assumes ":", and so either we or the user has to take appropriate steps
to tell refstyle about the difference. Unfortunately, there is no easy
way to do that. It has to be done for each and every reference style you
declare.

 

What are other advantages of refstyle versus prettyref? I will give your patch a
try, but I kind of like prettyref. I sure hope I can produce the same kind of
output, otherwise I would prefer to keep prettyref support next to it.

   
The main one, right now, is internationalization. The output is 
otherwise pretty similar, and can be customized in similar ways. 
Eventually, though, we can support ranges of references and that kind of 
thing, though that will likely wait for 2.1, since (a) I can't see 
getting it done for 2.0 and (b) it will be a format change.


rh