]> git.lyx.org Git - lyx.git/blobdiff - src/LaTeXFeatures.C
citation patch from Angus
[lyx.git] / src / LaTeXFeatures.C
index 61dd8a821c805cd042ae91892a89d603fc88b45e..eeecf32930c83c07c6e0243ca32caa95df498f06 100644 (file)
@@ -29,8 +29,10 @@ LaTeXFeatures::LaTeXFeatures(BufferParams const & p, int n)
        : layout(n, false), params(p)
 {
        // packages
+       array = false;
        color = false;
-       graphics = false;
+       graphics = false; // INSET_GRAPHICS: remove this when InsetFig is thrown.
+    graphicx = false;
        setspace = false;
        makeidx = false;
        verbatim = false;
@@ -73,14 +75,13 @@ LaTeXFeatures::LaTeXFeatures(BufferParams const & p, int n)
 }
 
 void LaTeXFeatures::require(string const & name) {
-       if (name == "color") {
+       if (name == "array") {
+               array = true;
+       } else if (name == "color") {
                color = true;
        } else if (name == "graphics") {
-#ifdef USE_GRAPHICX
                graphicx = true;
-#else
-               graphics = true;
-#endif
+               graphics = true;// INSET_GRAPHICS: remove this when InsetFig is thrown.
        } else if (name == "setspace") {
                setspace = true;
        } else if (name == "makeidx") {
@@ -126,6 +127,10 @@ string LaTeXFeatures::getPackages()
        LyXTextClass const & tclass =
                textclasslist.TextClass(params.textclass);
 
+       // array-package
+       if (array)
+               packages += "\\usepackage{array}\n";
+
        // color.sty
        if (color) {
                if (params.graphicsDriver == "default")
@@ -144,6 +149,16 @@ string LaTeXFeatures::getPackages()
                packages += "\\makeindex\n";
        }
 
+       // graphicx.sty
+       if (graphicx && params.graphicsDriver != "none") {
+               if (params.graphicsDriver == "default")
+                       packages += "\\usepackage{graphicx}\n";
+               else
+                       packages += "\\usepackage[" 
+                               + params.graphicsDriver + "]{graphicx}\n";
+       }
+
+    // INSET_GRAPHICS: remove this when InsetFig is thrown.
        // graphics.sty
        if (graphics && params.graphicsDriver != "none") {
                if (params.graphicsDriver == "default")
@@ -245,6 +260,13 @@ string LaTeXFeatures::getPackages()
        if (prettyref)
                packages += "\\usepackage{prettyref}\n";
 
+       // float.sty
+       // This is not correct and needs fixing.
+       // We don't need float.sty if we only use unchanged
+       // table and figure floats. (Lgb)
+       if (!usedFloats.empty())
+               packages += "\\usepackage{float}\n";
+       
        packages += externalPreambles;
 
        return packages;
@@ -298,6 +320,12 @@ string LaTeXFeatures::getMacros()
         if (NeedLyXFootnoteCode) 
                macros += floatingfootnote_def;
 
+       // floats
+       // Here we will output the code to create the needed float styles.
+       // We will try to do this as minimal as possible.
+       // \floatstyle{ruled}
+       // \newfloat{algorithm}{htbp}{loa}
+       // \floatname{algorithm}{Algorithm}
        return macros;
 }
 
@@ -319,6 +347,18 @@ string LaTeXFeatures::getTClassPreamble()
 }      
 
 
+string LaTeXFeatures::getIncludedFiles()
+{
+       string sgmlpreamble;
+       FileMap::const_iterator end = IncludedFiles.end();
+       for(FileMap::const_iterator fi=IncludedFiles.begin(); fi != end; ++fi)
+               sgmlpreamble += "\n<!entity " + fi->first
+                       + " system \"" + fi->second + "\">";
+
+       return sgmlpreamble;
+}
+
+
 void LaTeXFeatures::showStruct() {
        lyxerr << "LyX needs the following commands when LaTeXing:"
               << "\n***** Packages:" << getPackages()