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?

Sure, that's the only solution I found : encapsulate the \lyxref call between commands deactivating/reactivating ":", which I found last Spring on a forum (see bug #6608) and rewrote a little. I tried the \shorthandoff workaround, but this asks for a lot of testing to know if babel is loaded, and, if the case, if French is the selected language. In addition, this does not work whith ":" being active elsewhere than in French, and even not with babel.

Here is the patch (beware of line cuts):

--- src/LaTeXFeatures.cpp.orig  2010-10-26 14:35:26.000000000 +0200
+++ src/LaTeXFeatures.cpp       2010-10-27 15:37:31.000000000 +0200
@@ -258,6 +258,9 @@

 static docstring const lyxref_def = from_ascii(
        "\\makeatletter\n"
+       "\\newif\\ifcolonActive \\colonActivefalse\n"
+ "\\newcommand*{\\colonoff}{\\ifnum \\catcode`\\:=13 \\catcode`\\:=12 \\colonActivetrue \\fi}\n" + "\\newcommand*{\\colonon}{\\ifcolonActive \\catcode`\\:=13 \\colonActivefalse \\fi}\n"
        "\\def\\lyxref#1...@lyxref#1:@@@@@:}\n"
        "\\de...@lyxref#1:#2:{%\n"
        "\\ifthenelse{\\equal{#2}{@@@@@}}%\n"
--- src/insets/InsetRef.cpp.orig        2010-10-27 14:53:19.000000000 +0200
+++ src/insets/InsetRef.cpp     2010-10-27 15:44:17.000000000 +0200
@@ -95,7 +95,7 @@
                return 0;
        }

-       os << "\\lyxref{" << data << '}';
+       os << "\\colonoff\\lyxref{" << data << "}\\colonon{}";
        return 0;
 }



To be able to test it, you need to have French strings available.
I contacted Danie Els in August about the unability of version 0.3 of refstyle to allow a new language without hacking refstyle.cfg. Following a private discussion with him, I tried a patch on refstyle.sty allowing to \input a local refstyle.def file containing the additional translations, without using the noconfig option. My patch did not work at the time.

Following r35623, I gave a fresh try to this and was able to make it work.
I contacted him again and he sent me an alpha version 0.4 of refstyle implementing a variant of the patch: refstyle.sty loads refstyle.def first, and if no refstyle.def is found, loads refstyle.cfg. So refstyle.def plays the role of a modified refstyle.cfg located in texmf-local.

This allows to load, as refstyle.def, a variant of refstyle.cfg to incude new languages until CTAN refstyle.cfg is updated.

He committed then v0.4 of the refstyle bundle to CTAN
http://www.ctan.org/tex-archive/macros/latex/contrib/refstyle/
with these improvements:

> Changes from version 0.3:
>
> (1) List of references can now distinguish between two and more than two items. For example:
>
>     equation (1)
>     equations (1) and (4)
>     equations (1), (2), and (5)

LyX is not concerned right now.

>
> (2) Option "nokeyprefix" is added to remove all the prefixes in the \<type>label commands. The user has now the option to use the standard latex \label command everywhere (especialy for old documents), for example:
>
>    \label{tab:xxx} and then \tabref{tab:xxx} with refstyle

Again LyX does not use the \seclabel or \eqlabel coding I guess.
May be used for upgrades ??

>
> (3) Languages added: French, Italian and Portuguese
>

Here you are to use my test file (I will upload it with bug #6609).

You provided an English string for theorems, it seems to me that one should be provided for lemmas also, in order to be prettyref-coherent.

In the near future, we will need to create strings for other languages and the whole set of theorem-like stuff...

Do you intend to implement plurals and ranges before 2.0 is released ?

Regards

--
Jean-Pierre

Reply via email to