]> git.lyx.org Git - lyx.git/blobdiff - src/LaTeXFeatures.C
add missing writeNormal() methods to some insets
[lyx.git] / src / LaTeXFeatures.C
index 31b4fe16b940155a4396336578da14d60fcbbcc2..0f4d8dd2faad20570f8f4022233fcc8f5a5cb473 100644 (file)
@@ -1,11 +1,10 @@
-// -*- C++ -*-
 /* This file is part of
  * ====================================================== 
  * 
  *           LyX, The Document Processor
  *        
  *           Copyright 1995 Matthias Ettrich
- *           Copyright 1995-2000 the LyX Team.
+ *           Copyright 1995-2001 the LyX Team.
  *
  * ====================================================== */
 
@@ -23,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 +51,8 @@ LaTeXFeatures::LaTeXFeatures(BufferParams const & p, LyXTextClass::size_type n)
        varioref = false;
        prettyref = false;
        chess = false;
+       natbib = false;
+       floats = false;
        
        // commands
        lyx = false;
@@ -72,7 +74,7 @@ LaTeXFeatures::LaTeXFeatures(BufferParams const & p, LyXTextClass::size_type n)
        boldsymbol = false;
     
        // special features
-       LyXParagraphIndent = false;
+       ParagraphIndent = false;
        NeedLyXFootnoteCode = false;
        NeedLyXMinipageIndent = false;
 }
@@ -123,6 +125,10 @@ void LaTeXFeatures::require(string const & name)
                boldsymbol = true;
        } else if (name == "binom") {
                binom = true;
+       } else if (name == "natbib") {
+               natbib = true;
+       } else if (name == "float") {
+               floats = true;
        }
 }
 
@@ -149,10 +155,7 @@ string const LaTeXFeatures::getPackages() const
                
        // makeidx.sty
        if (makeidx) {
-               if (! tclass.provides(LyXTextClass::makeidx)
-                   && params.language->babel() != "french") // french provides
-                                                            // \index !
-                       // French should not be hardcoded. (Lgb)
+               if (! tclass.provides(LyXTextClass::makeidx))
                        packages << "\\usepackage{makeidx}\n";
                packages << "\\makeindex\n";
        }
@@ -257,21 +260,33 @@ 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) {
+               packages << "\\usepackage[";
+               if (params.use_numerical_citations) {
+                       packages << "numbers";
+               } else {
+                       packages << "authoryear";
+               }
+               packages << "]{natbib}\n";
        }
        
        packages << externalPreambles;
@@ -322,7 +337,7 @@ string const LaTeXFeatures::getMacros() const
        // other
         if (NeedLyXMinipageIndent) 
                macros << minipageindent_def;
-        if (LyXParagraphIndent) 
+        if (ParagraphIndent) 
                macros << paragraphindent_def;
         if (NeedLyXFootnoteCode) 
                macros << floatingfootnote_def;
@@ -360,6 +375,20 @@ string const LaTeXFeatures::getTClassPreamble() const
 }      
 
 
+string const LaTeXFeatures::getLyXSGMLEntities() const
+{
+       // Definition of entities used in the document that are LyX related.
+       ostringstream entities;
+
+       if (lyxarrow) {
+               entities << "<!ENTITY lyxarrow \"-&gt;\">"
+                        << '\n';
+       }
+
+       return entities.str().c_str();
+}
+
+
 string const LaTeXFeatures::getIncludedFiles(string const & fname) const
 {
        ostringstream sgmlpreamble;
@@ -391,7 +420,7 @@ BufferParams const & LaTeXFeatures::bufferParams() const
 }
 
 
-void LaTeXFeatures::getFloatDefinitions(ostream & os) const
+void LaTeXFeatures::getFloatDefinitions(std::ostream & os) const
 {
        // Here we will output the code to create the needed float styles.
        // We will try to do this as minimal as possible.