From 30deb83dcb443834312571b88c535784f0e1b65d Mon Sep 17 00:00:00 2001 From: Enrico Forestieri Date: Wed, 12 Mar 2008 22:07:50 +0000 Subject: [PATCH] Provide \boldsymbol through the bm package. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/branches/BRANCH_1_5_X@23696 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/LaTeXFeatures.cpp | 7 +------ src/mathed/InsetMathBoldSymbol.cpp | 24 +++++++++++++++++++----- src/mathed/InsetMathBoldSymbol.h | 9 ++++++++- src/mathed/InsetMathHull.cpp | 1 - src/mathed/MathFactory.cpp | 6 ++++-- status.15x | 3 +++ 6 files changed, 35 insertions(+), 15 deletions(-) diff --git a/src/LaTeXFeatures.cpp b/src/LaTeXFeatures.cpp index e022b03c97..23ced3de5b 100644 --- a/src/LaTeXFeatures.cpp +++ b/src/LaTeXFeatures.cpp @@ -145,10 +145,6 @@ static string const floatingfootnote_def = " \\expandafter\\noexpand\\csname SF@gobble@opt \\endcsname}\n" "\\def\\SF@gobble@twobracket[#1]#2{}\n"; -static string const boldsymbol_def = - "%% Bold symbol macro for standard LaTeX users\n" - "\\providecommand{\\boldsymbol}[1]{\\mbox{\\boldmath $#1$}}\n"; - static string const binom_def = "%% Binom macro for standard LaTeX users\n" "\\newcommand{\\binom}[2]{{#1 \\choose #2}}\n"; @@ -441,6 +437,7 @@ char const * simplefeatures[] = { "mathrsfs", "ascii", "url", + "bm" }; int const nb_simplefeatures = sizeof(simplefeatures) / sizeof(char const *); @@ -666,8 +663,6 @@ string const LaTeXFeatures::getMacros() const macros << guillemotright_def << '\n'; // Math mode - if (mustProvide("boldsymbol") && !isRequired("amsmath")) - macros << boldsymbol_def << '\n'; if (mustProvide("binom") && !isRequired("amsmath")) macros << binom_def << '\n'; if (mustProvide("mathcircumflex")) diff --git a/src/mathed/InsetMathBoldSymbol.cpp b/src/mathed/InsetMathBoldSymbol.cpp index 7e2ba27a51..cd5826eee5 100644 --- a/src/mathed/InsetMathBoldSymbol.cpp +++ b/src/mathed/InsetMathBoldSymbol.cpp @@ -22,8 +22,8 @@ namespace lyx { using std::auto_ptr; -InsetMathBoldSymbol::InsetMathBoldSymbol() - : InsetMathNest(1) +InsetMathBoldSymbol::InsetMathBoldSymbol(Kind kind) + : InsetMathNest(1), kind_(kind) {} @@ -70,19 +70,33 @@ void InsetMathBoldSymbol::drawT(TextPainter & pain, int x, int y) const void InsetMathBoldSymbol::validate(LaTeXFeatures & features) const { InsetMathNest::validate(features); - features.require("amssymb"); + features.require("bm"); } void InsetMathBoldSymbol::write(WriteStream & os) const { - os << "\\boldsymbol{" << cell(0) << "}"; + switch (kind_) { + case BOLD: + os << "\\boldsymbol{" << cell(0) << "}"; + break; + case HEAVY: + os << "\\heavysymbol{" << cell(0) << "}"; + break; + } } void InsetMathBoldSymbol::infoize(odocstream & os) const { - os << "Boldsymbol "; + switch (kind_) { + case BOLD: + os << "Boldsymbol "; + break; + case HEAVY: + os << "Heavysymbol "; + break; + } } diff --git a/src/mathed/InsetMathBoldSymbol.h b/src/mathed/InsetMathBoldSymbol.h index 229f28c985..26e8795457 100644 --- a/src/mathed/InsetMathBoldSymbol.h +++ b/src/mathed/InsetMathBoldSymbol.h @@ -22,7 +22,12 @@ namespace lyx { class InsetMathBoldSymbol : public InsetMathNest { public: /// - InsetMathBoldSymbol(); + enum Kind { + BOLD, + HEAVY + }; + /// + InsetMathBoldSymbol(Kind kind = BOLD); /// bool metrics(MetricsInfo & mi, Dimension & dim) const; /// @@ -37,6 +42,8 @@ public: void write(WriteStream & os) const; /// void infoize(odocstream & os) const; + /// + Kind kind_; private: virtual std::auto_ptr doClone() const; }; diff --git a/src/mathed/InsetMathHull.cpp b/src/mathed/InsetMathHull.cpp index 0d9c790f2e..ec88fd3e8c 100644 --- a/src/mathed/InsetMathHull.cpp +++ b/src/mathed/InsetMathHull.cpp @@ -518,7 +518,6 @@ void InsetMathHull::validate(LaTeXFeatures & features) const //if (features.amsstyle) // return; - features.require("boldsymbol"); //features.binom = true; InsetMathGrid::validate(features); diff --git a/src/mathed/MathFactory.cpp b/src/mathed/MathFactory.cpp index 92d8b04a0d..6b6b17a8f2 100644 --- a/src/mathed/MathFactory.cpp +++ b/src/mathed/MathFactory.cpp @@ -379,8 +379,10 @@ MathAtom createInsetMath(docstring const & s) return MathAtom(new InsetMathFrac(InsetMathFrac::ATOP)); if (s == "lefteqn") return MathAtom(new InsetMathLefteqn); - if (s == "boldsymbol") - return MathAtom(new InsetMathBoldSymbol); + if (s == "boldsymbol" || s == "bm") + return MathAtom(new InsetMathBoldSymbol(InsetMathBoldSymbol::BOLD)); + if (s == "heavysymbol" || s == "hm") + return MathAtom(new InsetMathBoldSymbol(InsetMathBoldSymbol::HEAVY)); if (s == "color" || s == "normalcolor") return MathAtom(new InsetMathColor(true)); if (s == "textcolor") diff --git a/status.15x b/status.15x index 04e242c4c3..e755ba41d7 100644 --- a/status.15x +++ b/status.15x @@ -80,6 +80,9 @@ What's new - Fix LaTeX error "unknown color 'ignore'" when setting text style attributes in mathed (bug 4091). +- Use package bm for bold math symbols obtained through the \boldsymbol + macro, such that bold super and subscripts have the correct size even + when not using amsmath. * USER INTERFACE: