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(int n)
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(BufferParams const & params)
76 LyXTextClass const & tclass = textclasslist.TextClass(params.textclass);
80 if (params.graphicsDriver == "default")
81 packages += "\\usepackage{color}\n";
83 packages += "\\usepackage["
84 + params.graphicsDriver + "]{color}\n";
89 if (! tclass.provides(LyXTextClass::makeidx)
90 && params.language != "french") // french provides
92 packages += "\\usepackage{makeidx}\n";
93 packages += "\\makeindex\n";
97 if (graphics && params.graphicsDriver != "none") {
98 if (params.graphicsDriver == "default")
99 packages += "\\usepackage{graphics}\n";
101 packages += "\\usepackage["
102 + params.graphicsDriver + "]{graphics}\n";
107 packages += "\\usepackage{verbatim}\n";
110 packages += "\\usepackage{algorithm}\n";
114 if ((params.spacing.getSpace() != Spacing::Single)
116 packages += "\\usepackage{setspace}\n";
118 switch (params.spacing.getSpace()) {
119 case Spacing::Single:
120 // we dont use setspace.sty so dont print anything
121 //packages += "\\singlespacing\n";
123 case Spacing::Onehalf:
124 packages += "\\onehalfspacing\n";
126 case Spacing::Double:
127 packages += "\\doublespacing\n";
131 //sprintf(value, "%.2f", params.spacing.getValue());
133 std::ostringstream value;
136 ostrstream value(val, 30);
139 value << params.spacing.getValue(); // setw?
141 packages += string("\\setstretch{")
142 + value.str().c_str() + "}\n";
145 packages += string("\\setstretch{")
146 + value.str() + "}\n";
153 packages += "\\usepackage{longtable}\n";
157 packages += "\\usepackage{rotating}\n";
161 packages += "\\usepackage{amssymb}\n";
165 packages += "\\usepackage{latexsym}\n";
169 packages += "\\usepackage{pifont}\n";
173 packages += "\\usepackage{subfigure}\n";
177 packages += "\\usepackage{floatflt}\n";
180 if (url && ! tclass.provides(LyXTextClass::url))
181 packages += "\\IfFileExists{url.sty}{\\usepackage{url}}\n"
182 " {\\newcommand{\\url}{\\texttt}}\n";
188 string LaTeXFeatures::getMacros(BufferParams const & /* params */)
192 // always include this
194 macros += lyx_def + '\n';
197 macros += lyxline_def + '\n';
200 macros += noun_def + '\n';
204 macros += lyxarrow_def + '\n';
209 macros += quotesinglbase_def + '\n';
211 macros += quotedblbase_def + '\n';
213 macros += guilsinglleft_def + '\n';
215 macros += guilsinglright_def + '\n';
217 macros += guillemotleft_def + '\n';
219 macros += guillemotright_def + '\n';
222 if (boldsymbol && !amsstyle)
223 macros += boldsymbol_def + '\n';
224 if (binom && !amsstyle)
225 macros += binom_def + '\n';
228 if (NeedLyXMinipageIndent)
229 macros += minipageindent_def;
230 if (LyXParagraphIndent)
231 macros += paragraphindent_def;
232 if (NeedLyXFootnoteCode)
233 macros += floatingfootnote_def;
239 string LaTeXFeatures::getTClassPreamble(BufferParams const & params)
241 // the text class specific preamble
242 LyXTextClass const & tclass = 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(BufferParams const & params) {
256 lyxerr << "LyX needs the following commands when LaTeXing:"
258 << "\n***** Packages:" << getPackages(params)
259 << "\n***** Macros:" << getMacros(params)
260 << "\n***** Textclass stuff:" << getTClassPreamble(params)
261 << "\n***** done." << endl;