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)
56 quotesinglbase = false;
58 guilsinglleft = false;
59 guilsinglright = false;
60 guillemotleft = false;
61 guillemotright = false;
69 LyXParagraphIndent = false;
70 NeedLyXFootnoteCode = false;
71 NeedLyXMinipageIndent = false;
75 string LaTeXFeatures::getPackages()
78 LyXTextClass const & tclass =
79 textclasslist.TextClass(params.textclass);
83 if (params.graphicsDriver == "default")
84 packages += "\\usepackage{color}\n";
86 packages += "\\usepackage["
87 + params.graphicsDriver + "]{color}\n";
92 if (! tclass.provides(LyXTextClass::makeidx)
93 && params.language != "french") // french provides
95 packages += "\\usepackage{makeidx}\n";
96 packages += "\\makeindex\n";
100 if (graphics && params.graphicsDriver != "none") {
101 if (params.graphicsDriver == "default")
102 packages += "\\usepackage{graphics}\n";
104 packages += "\\usepackage["
105 + params.graphicsDriver + "]{graphics}\n";
110 packages += "\\usepackage{verbatim}\n";
113 packages += "\\usepackage{algorithm}\n";
117 if ((params.spacing.getSpace() != Spacing::Single
118 && !params.spacing.isDefault())
120 packages += "\\usepackage{setspace}\n";
122 switch (params.spacing.getSpace()) {
123 case Spacing::Default:
124 case Spacing::Single:
125 // we dont use setspace.sty so dont print anything
126 //packages += "\\singlespacing\n";
128 case Spacing::Onehalf:
129 packages += "\\onehalfspacing\n";
131 case Spacing::Double:
132 packages += "\\doublespacing\n";
136 std::ostringstream value;
139 ostrstream value(val, 30);
142 value << params.spacing.getValue(); // setw?
144 packages += string("\\setstretch{")
145 + value.str().c_str() + "}\n";
148 packages += string("\\setstretch{")
149 + value.str() + "}\n";
156 packages += "\\usepackage{longtable}\n";
160 packages += "\\usepackage{rotating}\n";
163 if (amssymb || params.use_amsmath)
164 packages += "\\usepackage{amssymb}\n";
168 packages += "\\usepackage{latexsym}\n";
172 packages += "\\usepackage{pifont}\n";
176 packages += "\\usepackage{subfigure}\n";
180 packages += "\\usepackage{floatflt}\n";
183 if (url && ! tclass.provides(LyXTextClass::url))
184 packages += "\\IfFileExists{url.sty}{\\usepackage{url}}\n"
185 " {\\newcommand{\\url}{\\texttt}}\n";
189 packages += "\\usepackage{varioref}\n";
193 packages += "\\usepackage{prettyref}\n";
199 string LaTeXFeatures::getMacros()
203 // always include this
205 macros += lyx_def + '\n';
208 macros += lyxline_def + '\n';
211 macros += noun_def + '\n';
215 macros += lyxarrow_def + '\n';
220 macros += quotesinglbase_def + '\n';
222 macros += quotedblbase_def + '\n';
224 macros += guilsinglleft_def + '\n';
226 macros += guilsinglright_def + '\n';
228 macros += guillemotleft_def + '\n';
230 macros += guillemotright_def + '\n';
233 if (boldsymbol && !amsstyle)
234 macros += boldsymbol_def + '\n';
235 if (binom && !amsstyle)
236 macros += binom_def + '\n';
239 if (NeedLyXMinipageIndent)
240 macros += minipageindent_def;
241 if (LyXParagraphIndent)
242 macros += paragraphindent_def;
243 if (NeedLyXFootnoteCode)
244 macros += floatingfootnote_def;
250 string LaTeXFeatures::getTClassPreamble()
252 // the text class specific preamble
253 LyXTextClass const & tclass =
254 textclasslist.TextClass(params.textclass);
255 string tcpreamble = tclass.preamble();
257 for (unsigned int i = 0; i < tclass.numLayouts(); ++i) {
259 tcpreamble += tclass[i].preamble();
267 void LaTeXFeatures::showStruct() {
268 lyxerr << "LyX needs the following commands when LaTeXing:"
269 << "\n***** Packages:" << getPackages()
270 << "\n***** Macros:" << getMacros()
271 << "\n***** Textclass stuff:" << getTClassPreamble()
272 << "\n***** done." << endl;
276 BufferParams const & LaTeXFeatures::bufferParams() const