2 /* This file is part of
3 * ======================================================
5 * LyX, The Document Processor
7 * Copyright 1995 Matthias Ettrich
8 * Copyright 1995-1999 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());
132 packages += string("\\setstretch{")
139 packages += "\\usepackage{longtable}\n";
143 packages += "\\usepackage{rotating}\n";
147 packages += "\\usepackage{amssymb}\n";
151 packages += "\\usepackage{latexsym}\n";
155 packages += "\\usepackage{pifont}\n";
159 packages += "\\usepackage{subfigure}\n";
163 packages += "\\usepackage{floatflt}\n";
166 if (url && ! tclass.provides(LyXTextClass::url))
167 packages += "\\IfFileExists{url.sty}{\\usepackage{url}}\n"
168 " {\\newcommand{\\url}{\\texttt}}\n";
174 string LaTeXFeatures::getMacros(BufferParams const & /* params */)
178 // always include this
180 macros += lyx_def + '\n';
183 macros += lyxline_def + '\n';
186 macros += noun_def + '\n';
190 macros += lyxarrow_def + '\n';
195 macros += quotesinglbase_def + '\n';
197 macros += quotedblbase_def + '\n';
199 macros += guilsinglleft_def + '\n';
201 macros += guilsinglright_def + '\n';
203 macros += guillemotleft_def + '\n';
205 macros += guillemotright_def + '\n';
208 if (boldsymbol && !amsstyle)
209 macros += boldsymbol_def + '\n';
210 if (binom && !amsstyle)
211 macros += binom_def + '\n';
214 if (NeedLyXMinipageIndent)
215 macros += minipageindent_def;
216 if (LyXParagraphIndent)
217 macros += paragraphindent_def;
218 if (NeedLyXFootnoteCode)
219 macros += floatingfootnote_def;
225 string LaTeXFeatures::getTClassPreamble(BufferParams const & params)
227 // the text class specific preamble
228 LyXTextClass const & tclass = textclasslist.TextClass(params.textclass);
229 string tcpreamble = tclass.preamble();
231 for (unsigned int i = 0; i < tclass.numLayouts(); ++i) {
233 tcpreamble += tclass[i].preamble();
241 void LaTeXFeatures::showStruct(BufferParams & params) {
242 lyxerr << "LyX needs the following commands when LaTeXing:"
244 << "\n***** Packages:" << getPackages(params)
245 << "\n***** Macros:" << getMacros(params)
246 << "\n***** Textclass stuff:" << getTClassPreamble(params)
247 << "\n***** done." << endl;