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
This commit is contained in:
Enrico Forestieri 2008-03-12 22:07:50 +00:00
parent fed64cdee7
commit 30deb83dcb
6 changed files with 35 additions and 15 deletions

View File

@ -145,10 +145,6 @@ static string const floatingfootnote_def =
" \\expandafter\\noexpand\\csname SF@gobble@opt \\endcsname}\n" " \\expandafter\\noexpand\\csname SF@gobble@opt \\endcsname}\n"
"\\def\\SF@gobble@twobracket[#1]#2{}\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 = static string const binom_def =
"%% Binom macro for standard LaTeX users\n" "%% Binom macro for standard LaTeX users\n"
"\\newcommand{\\binom}[2]{{#1 \\choose #2}}\n"; "\\newcommand{\\binom}[2]{{#1 \\choose #2}}\n";
@ -441,6 +437,7 @@ char const * simplefeatures[] = {
"mathrsfs", "mathrsfs",
"ascii", "ascii",
"url", "url",
"bm"
}; };
int const nb_simplefeatures = sizeof(simplefeatures) / sizeof(char const *); int const nb_simplefeatures = sizeof(simplefeatures) / sizeof(char const *);
@ -666,8 +663,6 @@ string const LaTeXFeatures::getMacros() const
macros << guillemotright_def << '\n'; macros << guillemotright_def << '\n';
// Math mode // Math mode
if (mustProvide("boldsymbol") && !isRequired("amsmath"))
macros << boldsymbol_def << '\n';
if (mustProvide("binom") && !isRequired("amsmath")) if (mustProvide("binom") && !isRequired("amsmath"))
macros << binom_def << '\n'; macros << binom_def << '\n';
if (mustProvide("mathcircumflex")) if (mustProvide("mathcircumflex"))

View File

@ -22,8 +22,8 @@ namespace lyx {
using std::auto_ptr; using std::auto_ptr;
InsetMathBoldSymbol::InsetMathBoldSymbol() InsetMathBoldSymbol::InsetMathBoldSymbol(Kind kind)
: InsetMathNest(1) : InsetMathNest(1), kind_(kind)
{} {}
@ -70,19 +70,33 @@ void InsetMathBoldSymbol::drawT(TextPainter & pain, int x, int y) const
void InsetMathBoldSymbol::validate(LaTeXFeatures & features) const void InsetMathBoldSymbol::validate(LaTeXFeatures & features) const
{ {
InsetMathNest::validate(features); InsetMathNest::validate(features);
features.require("amssymb"); features.require("bm");
} }
void InsetMathBoldSymbol::write(WriteStream & os) const 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 void InsetMathBoldSymbol::infoize(odocstream & os) const
{ {
os << "Boldsymbol "; switch (kind_) {
case BOLD:
os << "Boldsymbol ";
break;
case HEAVY:
os << "Heavysymbol ";
break;
}
} }

View File

@ -22,7 +22,12 @@ namespace lyx {
class InsetMathBoldSymbol : public InsetMathNest { class InsetMathBoldSymbol : public InsetMathNest {
public: public:
/// ///
InsetMathBoldSymbol(); enum Kind {
BOLD,
HEAVY
};
///
InsetMathBoldSymbol(Kind kind = BOLD);
/// ///
bool metrics(MetricsInfo & mi, Dimension & dim) const; bool metrics(MetricsInfo & mi, Dimension & dim) const;
/// ///
@ -37,6 +42,8 @@ public:
void write(WriteStream & os) const; void write(WriteStream & os) const;
/// ///
void infoize(odocstream & os) const; void infoize(odocstream & os) const;
///
Kind kind_;
private: private:
virtual std::auto_ptr<Inset> doClone() const; virtual std::auto_ptr<Inset> doClone() const;
}; };

View File

@ -518,7 +518,6 @@ void InsetMathHull::validate(LaTeXFeatures & features) const
//if (features.amsstyle) //if (features.amsstyle)
// return; // return;
features.require("boldsymbol");
//features.binom = true; //features.binom = true;
InsetMathGrid::validate(features); InsetMathGrid::validate(features);

View File

@ -379,8 +379,10 @@ MathAtom createInsetMath(docstring const & s)
return MathAtom(new InsetMathFrac(InsetMathFrac::ATOP)); return MathAtom(new InsetMathFrac(InsetMathFrac::ATOP));
if (s == "lefteqn") if (s == "lefteqn")
return MathAtom(new InsetMathLefteqn); return MathAtom(new InsetMathLefteqn);
if (s == "boldsymbol") if (s == "boldsymbol" || s == "bm")
return MathAtom(new InsetMathBoldSymbol); return MathAtom(new InsetMathBoldSymbol(InsetMathBoldSymbol::BOLD));
if (s == "heavysymbol" || s == "hm")
return MathAtom(new InsetMathBoldSymbol(InsetMathBoldSymbol::HEAVY));
if (s == "color" || s == "normalcolor") if (s == "color" || s == "normalcolor")
return MathAtom(new InsetMathColor(true)); return MathAtom(new InsetMathColor(true));
if (s == "textcolor") if (s == "textcolor")

View File

@ -80,6 +80,9 @@ What's new
- Fix LaTeX error "unknown color 'ignore'" when setting text style - Fix LaTeX error "unknown color 'ignore'" when setting text style
attributes in mathed (bug 4091). 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: * USER INTERFACE: