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
116 && !params.spacing.isDefault())
118 packages += "\\usepackage{setspace}\n";
120 switch (params.spacing.getSpace()) {
121 case Spacing::Default:
122 case Spacing::Single:
123 // we dont use setspace.sty so dont print anything
124 //packages += "\\singlespacing\n";
126 case Spacing::Onehalf:
127 packages += "\\onehalfspacing\n";
129 case Spacing::Double:
130 packages += "\\doublespacing\n";
134 std::ostringstream value;
137 ostrstream value(val, 30);
140 value << params.spacing.getValue(); // setw?
142 packages += string("\\setstretch{")
143 + value.str().c_str() + "}\n";
146 packages += string("\\setstretch{")
147 + value.str() + "}\n";
154 packages += "\\usepackage{longtable}\n";
158 packages += "\\usepackage{rotating}\n";
162 packages += "\\usepackage{amssymb}\n";
166 packages += "\\usepackage{latexsym}\n";
170 packages += "\\usepackage{pifont}\n";
174 packages += "\\usepackage{subfigure}\n";
178 packages += "\\usepackage{floatflt}\n";
181 if (url && ! tclass.provides(LyXTextClass::url))
182 packages += "\\IfFileExists{url.sty}{\\usepackage{url}}\n"
183 " {\\newcommand{\\url}{\\texttt}}\n";
189 string LaTeXFeatures::getMacros()
193 // always include this
195 macros += lyx_def + '\n';
198 macros += lyxline_def + '\n';
201 macros += noun_def + '\n';
205 macros += lyxarrow_def + '\n';
210 macros += quotesinglbase_def + '\n';
212 macros += quotedblbase_def + '\n';
214 macros += guilsinglleft_def + '\n';
216 macros += guilsinglright_def + '\n';
218 macros += guillemotleft_def + '\n';
220 macros += guillemotright_def + '\n';
223 if (boldsymbol && !amsstyle)
224 macros += boldsymbol_def + '\n';
225 if (binom && !amsstyle)
226 macros += binom_def + '\n';
229 if (NeedLyXMinipageIndent)
230 macros += minipageindent_def;
231 if (LyXParagraphIndent)
232 macros += paragraphindent_def;
233 if (NeedLyXFootnoteCode)
234 macros += floatingfootnote_def;
240 string LaTeXFeatures::getTClassPreamble()
242 // the text class specific preamble
243 LyXTextClass const & tclass =
244 textclasslist.TextClass(params.textclass);
245 string tcpreamble = tclass.preamble();
247 for (unsigned int i = 0; i < tclass.numLayouts(); ++i) {
249 tcpreamble += tclass[i].preamble();
257 void LaTeXFeatures::showStruct() {
258 lyxerr << "LyX needs the following commands when LaTeXing:"
259 << "\n***** Packages:" << getPackages()
260 << "\n***** Macros:" << getMacros()
261 << "\n***** Textclass stuff:" << getTClassPreamble()
262 << "\n***** done." << endl;
266 BufferParams const & LaTeXFeatures::bufferParams() const