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"
27 LaTeXFeatures::LaTeXFeatures(int n)
53 quotesinglbase = false;
55 guilsinglleft = false;
56 guilsinglright = false;
57 guillemotleft = false;
58 guillemotright = false;
66 LyXParagraphIndent = false;
67 NeedLyXFootnoteCode = false;
68 NeedLyXMinipageIndent = false;
72 string LaTeXFeatures::getPackages(BufferParams const & params)
75 LyXTextClass const & tclass = textclasslist.TextClass(params.textclass);
79 if (params.graphicsDriver == "default")
80 packages += "\\usepackage{color}\n";
82 packages += "\\usepackage["
83 + params.graphicsDriver + "]{color}\n";
88 if (! tclass.provides(LyXTextClass::makeidx)
89 && params.language != "french") // french provides
91 packages += "\\usepackage{makeidx}\n";
92 packages += "\\makeindex\n";
96 if (graphics && params.graphicsDriver != "none") {
97 if (params.graphicsDriver == "default")
98 packages += "\\usepackage{graphics}\n";
100 packages += "\\usepackage["
101 + params.graphicsDriver + "]{graphics}\n";
106 packages += "\\usepackage{verbatim}\n";
109 packages += "\\usepackage{algorithm}\n";
113 if ((params.spacing.getSpace() != Spacing::Single)
115 packages += "\\usepackage{setspace}\n";
117 switch (params.spacing.getSpace()) {
118 case Spacing::Single:
119 // we dont use setspace.sty so dont print anything
120 //packages += "\\singlespacing\n";
122 case Spacing::Onehalf:
123 packages += "\\onehalfspacing\n";
125 case Spacing::Double:
126 packages += "\\doublespacing\n";
130 //sprintf(value, "%.2f", params.spacing.getValue());
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(BufferParams const & /* params */)
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(BufferParams const & params)
240 // the text class specific preamble
241 LyXTextClass const & tclass = textclasslist.TextClass(params.textclass);
242 string tcpreamble = tclass.preamble();
244 for (unsigned int i = 0; i < tclass.numLayouts(); ++i) {
246 tcpreamble += tclass[i].preamble();
254 void LaTeXFeatures::showStruct(BufferParams const & params) {
255 lyxerr << "LyX needs the following commands when LaTeXing:"
257 << "\n***** Packages:" << getPackages(params)
258 << "\n***** Macros:" << getMacros(params)
259 << "\n***** Textclass stuff:" << getTClassPreamble(params)
260 << "\n***** done." << endl;