On Mon, Mar 10, 2008 at 10:30:41AM +0100, Jean-Marc Lasgouttes wrote:

> Enrico Forestieri <[EMAIL PROTECTED]> writes:
> 
> > The attached patch is better, IMO. There's no reason to require
> > the \boldsymbol definition every time a math inset is used.
> 
> Looks good IMO.

I think that this needs to be discussed some more. ATM, we have
support for bold math through two different ways:

 1) Via InsetMathBoldSymbol.cpp and \boldsymbol
    a) When amsmath is not loaded, LyX provides a custom definition.
    b) Otherwise, the definition of \boldsymbol provided by amsmath
       is used.
 2) Via InsetMathBM.cpp and \bm

Method 1a) is flawed and should be ditched. Method 2) is better and
produces correct results whether or not amsmath is loaded.

However, note that both 1) and 2) provide the same exact functionality,
so I don't understand why it was done in such a way. I think that the
two methods should be merged as done in the attached patch and
propose to do the same in 1.5.x, i.e., providing \boldsymbol through
the bm.sty package.

-- 
Enrico
Index: src/mathed/InsetMathHull.cpp
===================================================================
--- src/mathed/InsetMathHull.cpp        (revision 23651)
+++ src/mathed/InsetMathHull.cpp        (working copy)
@@ -570,7 +570,6 @@ void InsetMathHull::validate(LaTeXFeatur
        //if (features.amsstyle)
        //  return;
 
-       features.require("boldsymbol");
        //features.binom      = true;
 
        InsetMathGrid::validate(features);
Index: src/mathed/InsetMathBM.h
===================================================================
--- src/mathed/InsetMathBM.h    (revision 23651)
+++ src/mathed/InsetMathBM.h    (working copy)
@@ -1,47 +0,0 @@
-// -*- C++ -*-
-/**
- * \file InsetMathBM.h
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author Bernhard Roider
- *
- * Full author contact details are available in file CREDITS.
- */
-
-#ifndef MATH_BMINSET_H
-#define MATH_BMINSET_H
-
-#include "InsetMathNest.h"
-
-
-namespace lyx {
-
-
-/// Inset for \bm
-class InsetMathBM : public InsetMathNest {
-public:
-       ///
-       InsetMathBM();
-       ///
-       void metrics(MetricsInfo & mi, Dimension & dim) const;
-       ///
-       void draw(PainterInfo & pi, int x, int y) const;
-       ///
-       void metricsT(TextMetricsInfo const & mi, Dimension & dim) const;
-       ///
-       void drawT(TextPainter & pi, int x, int y) const;
-       ///
-       void validate(LaTeXFeatures & features) const;
-       ///
-       void write(WriteStream & os) const;
-       ///
-       void infoize(odocstream & os) const;
-private:
-       virtual Inset * clone() const;
-};
-
-
-} // namespace lyx
-
-#endif
Index: src/mathed/InsetMathBM.cpp
===================================================================
--- src/mathed/InsetMathBM.cpp  (revision 23651)
+++ src/mathed/InsetMathBM.cpp  (working copy)
@@ -1,86 +0,0 @@
-/**
- * \file InsetMathBM.cpp
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author Bernhard Roider
- *
- * Full author contact details are available in file CREDITS.
- */
-
-#include <config.h>
-
-#include "InsetMathBM.h"
-
-#include "MathStream.h"
-#include "MathData.h"
-#include "LaTeXFeatures.h"
-
-#include <ostream>
-
-
-namespace lyx {
-
-InsetMathBM::InsetMathBM()
-       : InsetMathNest(1)
-{}
-
-
-Inset * InsetMathBM::clone() const
-{
-       return new InsetMathBM(*this);
-}
-
-
-void InsetMathBM::metrics(MetricsInfo & mi, Dimension & dim) const
-{
-       //FontSetChanger dummy(mi.base, "mathbf");
-       cell(0).metrics(mi, dim);
-       metricsMarkers(dim);
-       ++dim.wid;  // for 'double stroke'
-}
-
-
-void InsetMathBM::draw(PainterInfo & pi, int x, int y) const
-{
-       //FontSetChanger dummy(pi.base, "mathbf");
-       cell(0).draw(pi, x + 1, y);
-       cell(0).draw(pi, x + 2, y);
-       drawMarkers(pi, x, y);
-}
-
-
-void InsetMathBM::metricsT(TextMetricsInfo const & mi, Dimension & /*dim*/) 
const
-{
-       // FIXME: BROKEN!
-       Dimension dim;
-       cell(0).metricsT(mi, dim);
-}
-
-
-void InsetMathBM::drawT(TextPainter & pain, int x, int y) const
-{
-       cell(0).drawT(pain, x, y);
-}
-
-
-void InsetMathBM::validate(LaTeXFeatures & features) const
-{
-       InsetMathNest::validate(features);
-       features.require("bm");
-}
-
-
-void InsetMathBM::write(WriteStream & os) const
-{
-       os << "\\bm{" << cell(0) << "}";
-}
-
-
-void InsetMathBM::infoize(odocstream & os) const
-{
-       os << "bm ";
-}
-
-
-} // namespace lyx
Index: src/mathed/MathFactory.cpp
===================================================================
--- src/mathed/MathFactory.cpp  (revision 23651)
+++ src/mathed/MathFactory.cpp  (working copy)
@@ -14,7 +14,6 @@
 
 #include "InsetMathAMSArray.h"
 #include "InsetMathArray.h"
-#include "InsetMathBM.h"
 #include "InsetMathBoldSymbol.h"
 #include "InsetMathBox.h"
 #include "InsetMathCases.h"
@@ -376,10 +375,8 @@ MathAtom createInsetMath(docstring const
                return MathAtom(new InsetMathFrac(InsetMathFrac::ATOP));
        if (s == "lefteqn")
                return MathAtom(new InsetMathLefteqn);
-       if (s == "boldsymbol")
+       if (s == "boldsymbol" || s == "bm")
                return MathAtom(new InsetMathBoldSymbol);
-       if (s == "bm")
-               return MathAtom(new InsetMathBM);
        if (s == "color" || s == "normalcolor")
                return MathAtom(new InsetMathColor(true));
        if (s == "textcolor")
Index: src/mathed/InsetMathBoldSymbol.cpp
===================================================================
--- src/mathed/InsetMathBoldSymbol.cpp  (revision 23651)
+++ src/mathed/InsetMathBoldSymbol.cpp  (working copy)
@@ -67,7 +67,7 @@ void InsetMathBoldSymbol::drawT(TextPain
 void InsetMathBoldSymbol::validate(LaTeXFeatures & features) const
 {
        InsetMathNest::validate(features);
-       features.require("amssymb");
+       features.require("bm");
 }
 
 
Index: src/Makefile.am
===================================================================
--- src/Makefile.am     (revision 23651)
+++ src/Makefile.am     (working copy)
@@ -329,7 +329,6 @@ SOURCEFILESMATHED = \
        mathed/InsetMathAMSArray.cpp \
        mathed/InsetMathArray.cpp \
        mathed/InsetMathBig.cpp \
-       mathed/InsetMathBM.cpp \
        mathed/InsetMathBoldSymbol.cpp \
        mathed/InsetMathBox.cpp \
        mathed/InsetMathBrace.cpp \
@@ -395,7 +394,6 @@ HEADERFILESMATHED = \
        mathed/InsetMathAMSArray.h \
        mathed/InsetMathArray.h \
        mathed/InsetMathBig.h \
-       mathed/InsetMathBM.h \
        mathed/InsetMathBoldSymbol.h \
        mathed/InsetMathBox.h \
        mathed/InsetMathBrace.h \
Index: src/LaTeXFeatures.cpp
===================================================================
--- src/LaTeXFeatures.cpp       (revision 23651)
+++ src/LaTeXFeatures.cpp       (working copy)
@@ -136,10 +136,6 @@ static string const floatingfootnote_def
        "  \\expandafter\\noexpand\\csname [EMAIL PROTECTED]@opt \\endcsname}\n"
        "[EMAIL PROTECTED]@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";
@@ -664,8 +660,6 @@ string const LaTeXFeatures::getMacros() 
                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"))

Reply via email to