From 4f2d5f39eeff132a1ed725f231046258e32e89ac Mon Sep 17 00:00:00 2001 From: Enrico Forestieri Date: Tue, 31 Mar 2009 11:29:31 +0000 Subject: [PATCH] New simplified definition of \lyxmathsym and better re-import from latex. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/branches/BRANCH_1_6_X@28989 a592a061-630c-0410-9148-cb99ea01b6c8 --- lib/chkconfig.ltx | 2 +- lib/doc/LaTeXConfig.lyx | 8 ++++---- lib/doc/ja/LaTeXConfig.lyx | 8 ++++---- src/Encoding.cpp | 2 +- src/LaTeXFeatures.cpp | 17 ++++++++--------- src/mathed/MathParser.cpp | 23 ++++++++++++----------- status.16x | 3 +++ 7 files changed, 33 insertions(+), 30 deletions(-) diff --git a/lib/chkconfig.ltx b/lib/chkconfig.ltx index 317e2d8f6b..8d7960c0cd 100644 --- a/lib/chkconfig.ltx +++ b/lib/chkconfig.ltx @@ -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} diff --git a/lib/doc/LaTeXConfig.lyx b/lib/doc/LaTeXConfig.lyx index 9cafc3debc..cfb3fd153a 100644 --- a/lib/doc/LaTeXConfig.lyx +++ b/lib/doc/LaTeXConfig.lyx @@ -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. diff --git a/lib/doc/ja/LaTeXConfig.lyx b/lib/doc/ja/LaTeXConfig.lyx index e151ce0a42..f398df9717 100644 --- a/lib/doc/ja/LaTeXConfig.lyx +++ b/lib/doc/ja/LaTeXConfig.lyx @@ -3277,14 +3277,14 @@ longtable \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 diff --git a/src/Encoding.cpp b/src/Encoding.cpp index 7cf055e962..e529d7192a 100644 --- a/src/Encoding.cpp +++ b/src/Encoding.cpp @@ -601,7 +601,7 @@ void Encodings::validate(char_type c, LaTeXFeatures & features, bool for_mathed) } } if (for_mathed && isMathSym(c)) { - features.require("relsize"); + features.require("amstext"); features.require("lyxmathsym"); } #endif diff --git a/src/LaTeXFeatures.cpp b/src/LaTeXFeatures.cpp index 810f06634c..8f8e8b141d 100644 --- a/src/LaTeXFeatures.cpp +++ b/src/LaTeXFeatures.cpp @@ -201,11 +201,8 @@ static string const textcyr_def = "\\AtBeginDocument{\\DeclareFontEncoding{T2A}{}{}}\n"; static string const lyxmathsym_def = - "\\DeclareRobustCommand{\\lyxmathsym}[1]{\\ifmmode\\begingroup\\def\\b@ld{bold}\n" - " \\def\\rmorbf##1{\\ifx\\math@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\\b@ld{bold}\n" + " \\text{\\ifx\\math@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() const && 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 diff --git a/src/mathed/MathParser.cpp b/src/mathed/MathParser.cpp index 6c9e880587..ff9917f9c9 100644 --- a/src/mathed/MathParser.cpp +++ b/src/mathed/MathParser.cpp @@ -1659,17 +1659,18 @@ bool Parser::parse1(InsetMathGrid & grid, unsigned flags, 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()) { diff --git a/status.16x b/status.16x index 801bdc9e89..1592d89010 100644 --- a/status.16x +++ b/status.16x @@ -49,6 +49,9 @@ What's new - Quotes in InsetListings are now plain quotes, rather than InsetQuote entries (bug 5782). +- Improved re-import from LaTeX of documents containing unadorned unicode + symbols in math. + * USER INTERFACE