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)
53 quotesinglbase = false;
55 guilsinglleft = false;
56 guilsinglright = false;
57 guillemotleft = false;
58 guillemotright = false;
66 LyXParagraphIndent = false;
67 NeedLyXFootnoteCode = false;
68 NeedLyXMinipageIndent = false;
77 string LaTeXFeatures::getPackages(BufferParams const ¶ms)
80 LyXTextClass *tclass = lyxstyle.TextClass(params.textclass);
84 if (params.graphicsDriver == "default")
85 packages +="\\usepackage{color}\n";
87 packages += "\\usepackage["
88 + params.graphicsDriver + "]{color}\n";
93 if (! tclass->provides_makeidx
94 && params.language != "french") // french provides
96 packages += "\\usepackage{makeidx}\n";
97 packages += "\\makeindex\n";
101 if (graphics && params.graphicsDriver != "none") {
102 if (params.graphicsDriver == "default")
103 packages += "\\usepackage{graphics}\n";
105 packages += "\\usepackage["
106 + params.graphicsDriver + "]{graphics}\n";
111 packages += "\\usepackage{verbatim}\n";
114 packages += "\\usepackage{algorithm}\n";
118 if ((params.spacing.getSpace() != Spacing::Single)
120 packages += "\\usepackage{setspace}\n";
122 switch (params.spacing.getSpace()) {
123 case Spacing::Single:
124 // we dont use setspace.sty so dont print anything
125 //packages += "\\singlespacing\n";
127 case Spacing::Onehalf:
128 packages += "\\onehalfspacing\n";
130 case Spacing::Double:
131 packages += "\\doublespacing\n";
135 sprintf(value, "%.2f", params.spacing.getValue());
136 packages += string("\\setstretch{")
143 packages += "\\usepackage{longtable}\n";
147 packages += "\\usepackage{rotating}\n";
151 packages += "\\usepackage{amssymb}\n";
155 packages += "\\usepackage{latexsym}\n";
159 packages += "\\usepackage{pifont}\n";
163 packages += "\\usepackage{subfigure}\n";
167 packages += "\\usepackage{floatflt}\n";
170 if (url && ! tclass->provides_url)
171 packages += "\\IfFileExists{url.sty}{\\usepackage{url}}\n"
172 " {\\newcommand{\\url}{\\texttt}}\n";
178 string LaTeXFeatures::getMacros(BufferParams const & /* params */)
182 // always include this
184 macros += lyx_def + '\n';
187 macros += lyxline_def + '\n';
190 macros += noun_def + '\n';
194 macros += lyxarrow_def + '\n';
199 macros += quotesinglbase_def + '\n';
201 macros += quotedblbase_def + '\n';
203 macros += guilsinglleft_def + '\n';
205 macros += guilsinglright_def + '\n';
207 macros += guillemotleft_def + '\n';
209 macros += guillemotright_def + '\n';
212 if (boldsymbol && !amsstyle)
213 macros += boldsymbol_def + '\n';
214 if (binom && !amsstyle)
215 macros += binom_def + '\n';
218 if (NeedLyXMinipageIndent)
219 macros += minipageindent_def;
220 if (LyXParagraphIndent)
221 macros += paragraphindent_def;
222 if (NeedLyXFootnoteCode)
223 macros += floatingfootnote_def;
229 string LaTeXFeatures::getTClassPreamble(BufferParams const ¶ms)
231 // the text class specific preamble
232 LyXTextClass *tclass = lyxstyle.TextClass(params.textclass);
233 string tcpreamble = tclass->preamble;
236 for (l = 0 ; l < tclass->number_of_defined_layouts ; l++) {
238 && !tclass->style[l].preamble.empty())
239 tcpreamble += tclass->style[l].preamble;
246 void LaTeXFeatures::showStruct(BufferParams ¶ms) {
247 lyxerr << "LyX needs the following commands when LaTeXing:"
249 << "\n***** Packages:" << getPackages(params)
250 << "\n***** Macros:" << getMacros(params)
251 << "\n***** Textclass stuff:" << getTClassPreamble(params)
252 << "\n***** done." << endl;