]> git.lyx.org Git - features.git/commitdiff
Nicer previews.
authorAngus Leeming <leeming@lyx.org>
Thu, 17 Oct 2002 15:56:42 +0000 (15:56 +0000)
committerAngus Leeming <leeming@lyx.org>
Thu, 17 Oct 2002 15:56:42 +0000 (15:56 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@5434 a592a061-630c-0410-9148-cb99ea01b6c8

src/graphics/PreviewLoader.C
src/mathed/ChangeLog
src/mathed/formula.C

index d26d1f90ccebb782a7e071b3872b5b5d0430b4a3..97e59adce2d6c3109f89b7735ce7fefbae52ceb4 100644 (file)
@@ -479,9 +479,7 @@ void PreviewLoader::Impl::startLoading()
        string const command = "sh " + LibScriptSearch(cs.str().c_str());
 
        // Initiate the conversion from LaTeX to bitmap images files.
-       Forkedcall::SignalTypePtr convert_ptr;
-       convert_ptr.reset(new Forkedcall::SignalType);
-
+       Forkedcall::SignalTypePtr convert_ptr(new Forkedcall::SignalType);
        convert_ptr->connect(
                boost::bind(&Impl::finishedGenerating, this, _1, _2, _3));
 
index 78e9b93bb1ed7225a65a92312ad0494f33d2952e..69c509ee222cfa6b877c9ee922e754cb9969c855 100644 (file)
@@ -1,3 +1,8 @@
+2002-10-17  Angus Leeming  <leeming@lyx.org>
+
+       * formula.C (latexString): change "\[ ... \]" to "$ \displaystyle ... $"
+       for nicer previews.
+
 2002-10-17  Dekel Tsur  <dekelts@tau.ac.il>
 
        * math_kerninset.C (metrics): Use LyXLength::inPixels.
index 4b8a9eaa76f0adcbea6e4a895ba33fa773a21a5a..d8924ddf89798832bb077f1d1a18286a63ca0a78 100644 (file)
@@ -330,5 +330,20 @@ string const InsetFormula::PreviewImpl::latexString() const
        ostringstream ls;
        WriteStream wi(ls, false, false);
        parent().par_->write(wi);
-       return ls.str().c_str();
+       string str = ls.str().c_str();
+
+       // If we are in displaymode, the preview will include the margins
+       // on either side of the previewed equation.
+       // We can create an image with a tight bounding box by replacing the
+       // "\[ ... \]" delimiters with "$ \displaystyle ... $".
+       // Note that we have to get rid of any trailing '\n's for the fix
+       // to work.
+       if (prefixIs(str, "\\[")) {
+               std::cerr << "before\n" << str << std::endl;
+               str = rtrim(rtrim(ltrim(str, "\\["), "\n"), "\\]");
+               str = "$ \\displaystyle " + str + " $";
+               std::cerr << "after\n" << str << std::endl;
+       }
+
+       return str;
 }