On Tue, Mar 31, 2009 at 12:40:28AM +0200, for...@lyx.org wrote:

> Author: forenr
> Date: Tue Mar 31 00:40:27 2009
> New Revision: 28981
> URL: http://www.lyx.org/trac/changeset/28981
> 
> Log:
> Partly revert r28731 (see discussion in bug 5836).
> Essentially, it is not true that Cyrillic characters in math are to be typeset
> in italic by default, and LyX already permits to style them as desired.

Jürgen, may I apply the good bits of r28731 to branch? Patch attached.
This patch provides a simplified definition of \lyxmathsym (leaving the
output unchanged) and better reimport from latex. ATM, when importing
from latex $\lyxmathsym{\textdegree§}$ one gets $°\lyxmathsym{§}$, i.e.,
an ugly red \lyxmathsym macro, because only latex commands were recognized.
Example latex file attached, too.

-- 
Enrico
Index: src/mathed/MathParser.cpp
===================================================================
--- src/mathed/MathParser.cpp   (revisione 28980)
+++ src/mathed/MathParser.cpp   (copia locale)
@@ -1659,17 +1659,18 @@ bool Parser::parse1(InsetMathGrid & grid
                                return success_;
                        }
                        docstring rem;
-                       cmd = Encodings::fromLaTeXCommand(cmd, rem);
-                       for (size_t i = 0; i < cmd.size(); ++i)
-                               cell->push_back(MathAtom(new 
InsetMathChar(cmd[i])));
-                       if (rem.size()) {
-                               MathAtom at = createInsetMath(t.cs());
-                               cell->push_back(at);
-                               MathData ar;
-                               if (!mathed_parse_cell(ar, '{' + rem + '}', 
mode_))
-                                       success_ = false;;
-                               cell->append(ar);
-                       }
+                       do {
+                               cmd = Encodings::fromLaTeXCommand(cmd, rem);
+                               for (size_t i = 0; i < cmd.size(); ++i)
+                                       cell->push_back(MathAtom(new 
InsetMathChar(cmd[i])));
+                               if (rem.size()) {
+                                       char_type c = rem[0];
+                                       cell->push_back(MathAtom(new 
InsetMathChar(c)));
+                                       cmd = rem.substr(1);
+                                       rem.clear();
+                               } else
+                                       cmd.clear();
+                       } while (cmd.size());
                }
 
                else if (t.cs().size()) {
Index: src/LaTeXFeatures.cpp
===================================================================
--- src/LaTeXFeatures.cpp       (revisione 28980)
+++ src/LaTeXFeatures.cpp       (copia locale)
@@ -201,11 +201,8 @@ static string const textcyr_def =
        "\\AtBeginDocument{\\DeclareFontEncoding{T2A}{}{}}\n";
 
 static string const lyxmathsym_def =
-       
"\\declarerobustcommand{\\lyxmathsym}[1]{\\ifmmode\\begingroup\\def...@ld{bold}\n"
-       "  
\\def\\rmorbf##1{\\ifx\\m...@version\\b@ld\\textbf{##1}\\else\\textrm{##1}\\fi}\n"
-       "  \\mathchoice{\\hbox{\\rmorbf{#1}}}{\\hbox{\\rmorbf{#1}}}\n"
-       "  
{\\hbox{\\smaller[2]\\rmorbf{#1}}}{\\hbox{\\smaller[3]\\rmorbf{#1}}}\n"
-       "  \\endgroup\\else#1\\fi}\n";
+       "\\newcommand{\\lyxmathsym}[1]{\\ifmmode\\begingroup\\def...@ld{bold}\n"
+       "  
\\text{\\ifx\\m...@version\\b@ld\\bfseries\\fi#1}\\endgroup\\else#1\\fi}\n";
 
 static string const papersizedvi_def =
        "\\special{papersize=\\the\\paperwidth,\\the\\paperheight}\n";
@@ -513,7 +510,6 @@ char const * simplefeatures[] = {
        // listings is handled in BufferParams.cpp
        "bm",
        "pdfpages",
-       "relsize",
        "amscd",
        "slashed"
 };
@@ -585,9 +581,12 @@ string const LaTeXFeatures::getPackages(
                && params_.use_esint == BufferParams::package_off
                && params_.use_amsmath != BufferParams::package_off)) {
                packages << "\\usepackage{amsmath}\n";
-       } else if (mustProvide("amsbsy")) {
-               // amsbsy is already provided by amsmath
-               packages << "\\usepackage{amsbsy}\n";
+       } else {
+               // amsbsy and amstext are already provided by amsmath
+               if (mustProvide("amsbsy"))
+                       packages << "\\usepackage{amsbsy}\n";
+               if (mustProvide("amstext"))
+                       packages << "\\usepackage{amstext}\n";
        }
        
        // wasysym is a simple feature, but it must be after amsmath if both
Index: src/Encoding.cpp
===================================================================
--- src/Encoding.cpp    (revisione 28980)
+++ src/Encoding.cpp    (copia locale)
@@ -601,7 +601,7 @@ void Encodings::validate(char_type c, La
                }
        }
        if (for_mathed && isMathSym(c)) {
-               features.require("relsize");
+               features.require("amstext");
                features.require("lyxmathsym");
        }
 #endif
Index: lib/chkconfig.ltx
===================================================================
--- lib/chkconfig.ltx   (revisione 28980)
+++ lib/chkconfig.ltx   (copia locale)
@@ -228,6 +228,7 @@
 %%% Packages
 \TestPackage{accents}
 \TestPackage{algorithm}
+\TestPackage{amstext}
 \TestPackage{array}
 \TestPackage{babel}
 \TestPackage{bibtopic}
@@ -262,7 +263,6 @@
 \TestPackage{pdfpages}
 \TestPackage{prettyref}
 \TestPackage{preview}
-\TestPackage{relsize}
 \TestPackage{rotating}
 \TestPackage{rotfloat}
 \TestPackage{setspace}
Index: lib/doc/ja/LaTeXConfig.lyx
===================================================================
--- lib/doc/ja/LaTeXConfig.lyx  (revisione 28980)
+++ lib/doc/ja/LaTeXConfig.lyx  (copia locale)
@@ -3277,14 +3277,14 @@ パッケージは、 LyXが複数ペー
 \end_layout
 
 \begin_layout Subsection
-relsize
+amstext
 \end_layout
 
 \begin_layout Description
 検出: 
 \begin_inset Info
 type  "package"
-arg   "relsize"
+arg   "amstext"
 \end_inset
 
 
@@ -3293,13 +3293,13 @@ arg   "relsize"
 \begin_layout Description
 CTAN: 
 \family typewriter
-macros/latex/contrib/misc/
+macros/latex/required/amslatex/math/
 \end_layout
 
 \begin_layout Description
 備考: 
 \family sans
-relsize
+amstext
 \family default
 
パッケージは、unicodeシンボルを数式内で上付きや下付き文字にする際、LyXが正しい寸法に調整するのに必要とします。
 \end_layout
Index: lib/doc/LaTeXConfig.lyx
===================================================================
--- lib/doc/LaTeXConfig.lyx     (revisione 28980)
+++ lib/doc/LaTeXConfig.lyx     (copia locale)
@@ -3537,14 +3537,14 @@ longtable
 \end_layout
 
 \begin_layout Subsection
-relsize
+amstext
 \end_layout
 
 \begin_layout Description
 Found: 
 \begin_inset Info
 type  "package"
-arg   "relsize"
+arg   "amstext"
 \end_inset
 
 
@@ -3553,13 +3553,13 @@ arg   "relsize"
 \begin_layout Description
 CTAN: 
 \family typewriter
-macros/latex/contrib/misc/
+macros/latex/required/amslatex/math/
 \end_layout
 
 \begin_layout Description
 Notes: The package 
 \family sans
-relsize
+amstext
 \family default
  is needed by LyX to correctly size unicode symbols used as super or subscripts
  in math.

Attachment: testimport.tex
Description: TeX document

Reply via email to