]> git.lyx.org Git - lyx.git/blobdiff - src/LaTeXFeatures.C
Fix working of the spellchecker dialog with ispell when there are no
[lyx.git] / src / LaTeXFeatures.C
index 9b4d15f29a230bd6db1730529615485b2c4c3d08..d24614d4611231cdafbe4122cbd923c74afe498a 100644 (file)
@@ -22,6 +22,7 @@
 #include "bufferparams.h"
 #include "layout.h"
 #include "support/filetools.h"
+#include "support/lstrings.h"
 #include "FloatList.h"
 #include "language.h"
 
@@ -51,6 +52,7 @@ LaTeXFeatures::LaTeXFeatures(BufferParams const & p, LyXTextClass::size_type n)
        prettyref = false;
        chess = false;
        natbib = false;
+       floats = false;
        
        // commands
        lyx = false;
@@ -125,6 +127,8 @@ void LaTeXFeatures::require(string const & name)
                binom = true;
        } else if (name == "natbib") {
                natbib = true;
+       } else if (name == "float") {
+               floats = true;
        }
 }
 
@@ -259,34 +263,35 @@ string const LaTeXFeatures::getPackages() const
                packages << "\\usepackage{prettyref}\n";
 
        // float.sty
-       // We only need float.sty if we use non builtin floats. This includes
-       // modified table and figure floats. (Lgb)
+       // We only need float.sty if we use non builtin floats, or if we
+       // use the "H" modifier. This includes modified table and
+       // figure floats. (Lgb)
        if (!usedFloats.empty()) {
-               bool use_float = false;
                UsedFloats::const_iterator beg = usedFloats.begin();
                UsedFloats::const_iterator end = usedFloats.end();
                for (; beg != end; ++beg) {
                        Floating const & fl = floatList.getType((*beg));
                        if (!fl.type().empty() && !fl.builtin()) {
-                               use_float = true;
+                               const_cast<LaTeXFeatures *>(this)->floats = true;
                                break;
                        }
                }
-               if (use_float)
-                       packages << "\\usepackage{float}\n";
        }
-
+       if (floats) {
+               packages << "\\usepackage{float}\n";
+       }
+       
        // natbib.sty
        if (natbib) {
-               string options("[]");
-               if (params.use_numerical_citations)
-                       options.insert(1, "numbers");
-               else
-                       options.insert(1, "authoryear");
-               packages << "\\usepackage" << options << "{natbib}\n";
+               packages << "\\usepackage[";
+               if (params.use_numerical_citations) {
+                       packages << "numbers";
+               } else {
+                       packages << "authoryear";
+               }
+               packages << "]{natbib}\n";
        }
        
-
        packages << externalPreambles;
 
        return packages.str().c_str();