2 /* This file is part of
3 * ======================================================
5 * LyX, The Document Processor
7 * Copyright 1995 Matthias Ettrich
8 * Copyright 1995-2000 the LyX Team.
10 * ====================================================== */
15 #pragma implementation "LaTeXFeatures.h"
22 #include "LaTeXFeatures.h"
23 #include "bufferparams.h"
28 LaTeXFeatures::LaTeXFeatures(BufferParams const & p, int n)
29 : layout(n, false), params(p)
54 quotesinglbase = false;
56 guilsinglleft = false;
57 guilsinglright = false;
58 guillemotleft = false;
59 guillemotright = false;
67 LyXParagraphIndent = false;
68 NeedLyXFootnoteCode = false;
69 NeedLyXMinipageIndent = false;
73 string LaTeXFeatures::getPackages()
76 LyXTextClass const & tclass =
77 textclasslist.TextClass(params.textclass);
81 if (params.graphicsDriver == "default")
82 packages += "\\usepackage{color}\n";
84 packages += "\\usepackage["
85 + params.graphicsDriver + "]{color}\n";
90 if (! tclass.provides(LyXTextClass::makeidx)
91 && params.language != "french") // french provides
93 packages += "\\usepackage{makeidx}\n";
94 packages += "\\makeindex\n";
98 if (graphics && params.graphicsDriver != "none") {
99 if (params.graphicsDriver == "default")
100 packages += "\\usepackage{graphics}\n";
102 packages += "\\usepackage["
103 + params.graphicsDriver + "]{graphics}\n";
108 packages += "\\usepackage{verbatim}\n";
111 packages += "\\usepackage{algorithm}\n";
115 if ((params.spacing.getSpace() != Spacing::Single)
117 packages += "\\usepackage{setspace}\n";
119 switch (params.spacing.getSpace()) {
120 case Spacing::Single:
121 // we dont use setspace.sty so dont print anything
122 //packages += "\\singlespacing\n";
124 case Spacing::Onehalf:
125 packages += "\\onehalfspacing\n";
127 case Spacing::Double:
128 packages += "\\doublespacing\n";
132 std::ostringstream value;
135 ostrstream value(val, 30);
138 value << params.spacing.getValue(); // setw?
140 packages += string("\\setstretch{")
141 + value.str().c_str() + "}\n";
144 packages += string("\\setstretch{")
145 + value.str() + "}\n";
152 packages += "\\usepackage{longtable}\n";
156 packages += "\\usepackage{rotating}\n";
160 packages += "\\usepackage{amssymb}\n";
164 packages += "\\usepackage{latexsym}\n";
168 packages += "\\usepackage{pifont}\n";
172 packages += "\\usepackage{subfigure}\n";
176 packages += "\\usepackage{floatflt}\n";
179 if (url && ! tclass.provides(LyXTextClass::url))
180 packages += "\\IfFileExists{url.sty}{\\usepackage{url}}\n"
181 " {\\newcommand{\\url}{\\texttt}}\n";
187 string LaTeXFeatures::getMacros()
191 // always include this
193 macros += lyx_def + '\n';
196 macros += lyxline_def + '\n';
199 macros += noun_def + '\n';
203 macros += lyxarrow_def + '\n';
208 macros += quotesinglbase_def + '\n';
210 macros += quotedblbase_def + '\n';
212 macros += guilsinglleft_def + '\n';
214 macros += guilsinglright_def + '\n';
216 macros += guillemotleft_def + '\n';
218 macros += guillemotright_def + '\n';
221 if (boldsymbol && !amsstyle)
222 macros += boldsymbol_def + '\n';
223 if (binom && !amsstyle)
224 macros += binom_def + '\n';
227 if (NeedLyXMinipageIndent)
228 macros += minipageindent_def;
229 if (LyXParagraphIndent)
230 macros += paragraphindent_def;
231 if (NeedLyXFootnoteCode)
232 macros += floatingfootnote_def;
238 string LaTeXFeatures::getTClassPreamble()
240 // the text class specific preamble
241 LyXTextClass const & tclass =
242 textclasslist.TextClass(params.textclass);
243 string tcpreamble = tclass.preamble();
245 for (unsigned int i = 0; i < tclass.numLayouts(); ++i) {
247 tcpreamble += tclass[i].preamble();
255 void LaTeXFeatures::showStruct() {
256 lyxerr << "LyX needs the following commands when LaTeXing:"
257 << "\n***** Packages:" << getPackages()
258 << "\n***** Macros:" << getMacros()
259 << "\n***** Textclass stuff:" << getTClassPreamble()
260 << "\n***** done." << endl;
264 BufferParams const & LaTeXFeatures::bufferParams() const