2 * \file LaTeXFeatures.cpp
3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
7 * \author Lars Gullik Bjønnes
8 * \author Jean-Marc Lasgouttes
10 * \author André Pönitz
12 * Full author contact details are available in file CREDITS.
17 #include "LaTeXFeatures.h"
20 #include "BufferParams.h"
21 #include "support/debug.h"
24 #include "FloatList.h"
29 #include "TextClass.h"
31 #include "support/docstream.h"
32 #include "support/filetools.h"
35 using namespace lyx::support;
39 /////////////////////////////////////////////////////////////////////
43 /////////////////////////////////////////////////////////////////////
45 //\NeedsTeXFormat{LaTeX2e}
46 //\ProvidesPackage{lyx}[1996/01/11 LLE v0.2 (LyX LaTeX Extensions)]
47 //\message{LyX LaTeX Extensions (LLE v0.2) of 11-Jan-1996.}
49 static string const lyx_def =
50 "\\providecommand{\\LyX}{L\\kern-.1667em\\lower.25em\\hbox{Y}\\kern-.125emX\\@}";
52 static string const lyxline_def =
53 "\\newcommand{\\lyxline}[1][1pt]{%\n"
55 " \\rule[.5ex]{\\linewidth}{#1}\\par}";
57 static string const noun_def = "\\newcommand{\\noun}[1]{\\textsc{#1}}";
59 static string const lyxarrow_def =
60 "\\newcommand{\\lyxarrow}{\\leavevmode\\,$\\triangleright$\\,\\allowbreak}";
62 // for quotes without babel. This does not give perfect results, but
63 // anybody serious about non-english quotes should use babel (JMarc).
65 static string const quotedblbase_def =
66 "\\ProvideTextCommandDefault{\\quotedblbase}{%\n"
67 " \\raisebox{-1.4ex}[1ex][.5ex]{\\textquotedblright}%\n"
68 " \\penalty10000\\hskip0em\\relax%\n"
71 static string const quotesinglbase_def =
72 "\\ProvideTextCommandDefault{\\quotesinglbase}{%\n"
73 " \\raisebox{-1.4ex}[1ex][.5ex]{\\textquoteright}%\n"
74 " \\penalty10000\\hskip0em\\relax%\n"
77 static string const guillemotleft_def =
78 "\\ProvideTextCommandDefault{\\guillemotleft}{%\n"
79 " {\\usefont{U}{lasy}{m}{n}\\char'50\\kern-.15em\\char'50}%\n"
80 "\\penalty10000\\hskip0pt\\relax%\n"
83 static string const guillemotright_def =
84 "\\ProvideTextCommandDefault{\\guillemotright}{%\n"
85 " \\penalty10000\\hskip0pt%\n"
86 " {\\usefont{U}{lasy}{m}{n}\\char'51\\kern-.15em\\char'51}%\n"
89 static string const guilsinglleft_def =
90 "\\ProvideTextCommandDefault{\\guilsinglleft}{%\n"
91 " {\\usefont{U}{lasy}{m}{n}\\char'50}%\n"
92 " \\penalty10000\\hskip0pt\\relax%\n"
95 static string const guilsinglright_def =
96 "\\ProvideTextCommandDefault{\\guilsinglright}{%\n"
97 " \\penalty10000\\hskip0pt%\n"
98 " {\\usefont{U}{lasy}{m}{n}\\char'51}%\n"
101 static string const paragraphleftindent_def =
102 "\\newenvironment{LyXParagraphLeftIndent}[1]%\n"
104 " \\begin{list}{}{%\n"
105 " \\setlength{\\topsep}{0pt}%\n"
106 " \\addtolength{\\leftmargin}{#1}\n"
107 // ho hum, yet more things commented out with no hint as to why they
108 // weren't just removed
109 // "%% \\addtolength{\\leftmargin}{#1\\textwidth}\n"
110 // "%% \\setlength{\\textwidth}{#2\\textwidth}\n"
111 // "%% \\setlength\\listparindent\\parindent%\n"
112 // "%% \\setlength\\itemindent\\parindent%\n"
113 " \\setlength{\\parsep}{0pt plus 1pt}%\n"
119 static string const floatingfootnote_def =
120 "%% Special footnote code from the package 'stblftnt.sty'\n"
121 "%% Author: Robin Fairbairns -- Last revised Dec 13 1996\n"
122 "\\let\\SF@@footnote\\footnote\n"
123 "\\def\\footnote{\\ifx\\protect\\@typeset@protect\n"
124 " \\expandafter\\SF@@footnote\n"
126 " \\expandafter\\SF@gobble@opt\n"
129 "\\expandafter\\def\\csname SF@gobble@opt \\endcsname{\\@ifnextchar[%]\n"
130 " \\SF@gobble@twobracket\n"
133 "\\edef\\SF@gobble@opt{\\noexpand\\protect\n"
134 " \\expandafter\\noexpand\\csname SF@gobble@opt \\endcsname}\n"
135 "\\def\\SF@gobble@twobracket[#1]#2{}\n";
137 static string const boldsymbol_def =
138 "%% Bold symbol macro for standard LaTeX users\n"
139 "\\providecommand{\\boldsymbol}[1]{\\mbox{\\boldmath $#1$}}\n";
141 static string const binom_def =
142 "%% Binom macro for standard LaTeX users\n"
143 "\\newcommand{\\binom}[2]{{#1 \\choose #2}}\n";
145 static string const mathcircumflex_def =
146 "%% For printing a cirumflex inside a formula\n"
147 "\\newcommand{\\mathcircumflex}[0]{\\mbox{\\^{}}}\n";
149 static string const tabularnewline_def =
150 "%% Because html converters don't know tabularnewline\n"
151 "\\providecommand{\\tabularnewline}{\\\\}\n";
153 static string const lyxgreyedout_def =
154 "%% The greyedout annotation environment\n"
155 "\\newenvironment{lyxgreyedout}{\\textcolor[gray]{0.8}\\bgroup}{\\egroup}\n";
157 // We want to omit the file extension for includegraphics, but this does not
158 // work when the filename contains other dots.
159 // Idea from http://www.tex.ac.uk/cgi-bin/texfaq2html?label=unkgrfextn
160 static string const lyxdot_def =
161 "%% A simple dot to overcome graphicx limitations\n"
162 "\\newcommand{\\lyxdot}{.}\n";
164 static string const changetracking_dvipost_def =
165 "%% Change tracking with dvipost\n"
167 "\\dvipost{osstart color push Red}\n"
168 "\\dvipost{osend color pop}\n"
169 "\\dvipost{cbstart color push Blue}\n"
170 "\\dvipost{cbend color pop}\n"
171 "\\newcommand{\\lyxadded}[3]{\\changestart#3\\changeend}\n"
172 "\\newcommand{\\lyxdeleted}[3]{%\n"
173 "\\changestart\\overstrikeon#3\\overstrikeoff\\changeend}\n";
175 static string const changetracking_none_def =
176 "\\newcommand{\\lyxadded}[3]{#3}\n"
177 "\\newcommand{\\lyxdeleted}[3]{}\n";
179 static string const textgreek_def =
180 "\\DeclareRobustCommand{\\greektext}{%\n"
181 " \\fontencoding{LGR}\\selectfont\n"
182 " \\def\\encodingdefault{LGR}}\n"
183 "\\DeclareRobustCommand{\\textgreek}[1]{\\leavevmode{\\greektext #1}}\n"
184 "\\DeclareFontEncoding{LGR}{}{}\n";
186 static string const textcyr_def =
187 "\\DeclareRobustCommand{\\cyrtext}{%\n"
188 " \\fontencoding{T2A}\\selectfont\n"
189 " \\def\\encodingdefault{T2A}}\n"
190 "\\DeclareRobustCommand{\\textcyr}[1]{\\leavevmode{\\cyrtext #1}}\n"
191 "\\DeclareFontEncoding{T2A}{}{}\n";
194 /////////////////////////////////////////////////////////////////////
198 /////////////////////////////////////////////////////////////////////
200 LaTeXFeatures::PackagesList LaTeXFeatures::packages_;
203 LaTeXFeatures::LaTeXFeatures(Buffer const & b, BufferParams const & p,
204 OutputParams const & r)
205 : buffer_(&b), params_(p), runparams_(r)
209 bool LaTeXFeatures::useBabel() const
211 return lyxrc.language_use_babel ||
212 (bufferParams().language->lang() != lyxrc.default_language &&
213 !bufferParams().language->babel().empty()) ||
214 this->hasLanguages();
218 void LaTeXFeatures::require(string const & name)
220 if (isRequired(name))
223 features_.push_back(name);
227 void LaTeXFeatures::getAvailable()
230 support::FileName const real_file = libFileSearch("", "packages.lst");
232 if (real_file.empty())
235 lex.setFile(real_file);
240 // Make sure that we are clean
243 bool finished = false;
245 while (lex.isOK() && !finished) {
247 case Lexer::LEX_FEOF:
251 string const name = lex.getString();
252 PackagesList::const_iterator begin = packages_.begin();
253 PackagesList::const_iterator end = packages_.end();
254 if (find(begin, end, name) == end)
255 packages_.push_back(name);
261 void LaTeXFeatures::useLayout(docstring const & layoutname)
263 // Some code to avoid loops in dependency definition
264 static int level = 0;
265 const int maxlevel = 30;
266 if (level > maxlevel) {
267 lyxerr << "LaTeXFeatures::useLayout: maximum level of "
268 << "recursion attained by layout "
269 << to_utf8(layoutname) << endl;
273 TextClass const & tclass = params_.getTextClass();
274 if (tclass.hasLayout(layoutname)) {
275 // Is this layout already in usedLayouts?
276 list<docstring>::const_iterator cit = usedLayouts_.begin();
277 list<docstring>::const_iterator end = usedLayouts_.end();
278 for (; cit != end; ++cit) {
279 if (layoutname == *cit)
283 LayoutPtr const & lyt = tclass[layoutname];
284 if (!lyt->depends_on().empty()) {
286 useLayout(lyt->depends_on());
289 usedLayouts_.push_back(layoutname);
291 lyxerr << "LaTeXFeatures::useLayout: layout `"
292 << to_utf8(layoutname) << "' does not exist in this class"
300 bool LaTeXFeatures::isRequired(string const & name) const
302 return find(features_.begin(), features_.end(), name) != features_.end();
306 bool LaTeXFeatures::mustProvide(string const & name) const
308 return isRequired(name) && !params_.getTextClass().provides(name);
312 bool LaTeXFeatures::isAvailable(string const & name)
314 if (packages_.empty())
316 return find(packages_.begin(), packages_.end(), name) != packages_.end();
320 void LaTeXFeatures::addPreambleSnippet(string const & preamble)
322 FeaturesList::const_iterator begin = preamble_snippets_.begin();
323 FeaturesList::const_iterator end = preamble_snippets_.end();
324 if (find(begin, end, preamble) == end)
325 preamble_snippets_.push_back(preamble);
329 void LaTeXFeatures::useFloat(string const & name)
331 usedFloats_.insert(name);
332 // We only need float.sty if we use non builtin floats, or if we
333 // use the "H" modifier. This includes modified table and
334 // figure floats. (Lgb)
335 Floating const & fl = params_.getTextClass().floats().getType(name);
336 if (!fl.type().empty() && !fl.builtin()) {
342 void LaTeXFeatures::useLanguage(Language const * lang)
344 if (!lang->babel().empty())
345 UsedLanguages_.insert(lang);
346 // CJK languages do not have a babel name.
347 // They use the CJK package
348 if (lang->encoding()->package() == Encoding::CJK)
353 void LaTeXFeatures::includeFile(docstring const & key, string const & name)
355 IncludedFiles_[key] = name;
359 bool LaTeXFeatures::hasLanguages() const
361 return !UsedLanguages_.empty();
365 string LaTeXFeatures::getLanguages() const
367 ostringstream languages;
369 LanguageList::const_iterator const begin = UsedLanguages_.begin();
370 for (LanguageList::const_iterator cit = begin;
371 cit != UsedLanguages_.end();
375 languages << (*cit)->babel();
377 return languages.str();
381 set<string> LaTeXFeatures::getEncodingSet(string const & doc_encoding) const
383 // This does only find encodings of languages supported by babel, but
384 // that does not matter since we don't have a language with an
385 // encoding supported by inputenc but without babel support.
386 set<string> encodings;
387 LanguageList::const_iterator it = UsedLanguages_.begin();
388 LanguageList::const_iterator end = UsedLanguages_.end();
389 for (; it != end; ++it)
390 if ((*it)->encoding()->latexName() != doc_encoding &&
391 (*it)->encoding()->package() == Encoding::inputenc)
392 encodings.insert((*it)->encoding()->latexName());
398 char const * simplefeatures[] = {
399 // note that the package order here will be the same in the LaTeX-output
409 /*For a successful cooperation of the `wrapfig' package with the
410 `float' package you should load the `wrapfig' package *after*
411 the `float' package. See the caption package documentation
436 int const nb_simplefeatures = sizeof(simplefeatures) / sizeof(char const *);
441 string const LaTeXFeatures::getPackages() const
443 ostringstream packages;
444 TextClass const & tclass = params_.getTextClass();
447 // These are all the 'simple' includes. i.e
448 // packages which we just \usepackage{package}
450 for (int i = 0; i < nb_simplefeatures; ++i) {
451 if (mustProvide(simplefeatures[i]))
452 packages << "\\usepackage{"
453 << simplefeatures[i] << "}\n";
457 // The rest of these packages are somewhat more complicated
461 // esint is preferred for esintoramsmath
462 if ((mustProvide("amsmath") &&
463 params_.use_amsmath != BufferParams::package_off) ||
464 (mustProvide("esintoramsmath") &&
465 params_.use_esint == BufferParams::package_off)) {
466 packages << "\\usepackage{amsmath}\n";
469 // wasysym is a simple feature, but it must be after amsmath if both
471 // wasysym redefines some integrals (e.g. iint) from amsmath. That
472 // leads to inconsistent integrals. We only load this package if
473 // the document does not contain integrals (then isRequired("esint")
474 // is false) or if esint is used, since esint redefines all relevant
475 // integral symbols from wasysym and amsmath.
476 // See http://bugzilla.lyx.org/show_bug.cgi?id=1942
477 if (mustProvide("wasysym") &&
478 (params_.use_esint != BufferParams::package_off || !isRequired("esint")))
479 packages << "\\usepackage{wasysym}\n";
482 if (mustProvide("color")) {
483 if (params_.graphicsDriver == "default")
484 packages << "\\usepackage{color}\n";
486 packages << "\\usepackage["
487 << params_.graphicsDriver
492 if (isRequired("makeidx")) {
493 if (!tclass.provides("makeidx"))
494 packages << "\\usepackage{makeidx}\n";
495 packages << "\\makeindex\n";
499 if (mustProvide("graphicx") && params_.graphicsDriver != "none") {
500 if (params_.graphicsDriver == "default")
501 packages << "\\usepackage{graphicx}\n";
503 packages << "\\usepackage["
504 << params_.graphicsDriver
507 // shadecolor for shaded
508 if (isRequired("framed") && mustProvide("color")) {
509 RGBColor c = rgbFromHexName(lcolor.getX11Name(Color_shadedbg));
510 //255.0 to force conversion to double
511 //NOTE As Jürgen Spitzmüller pointed out, an alternative would be
512 //to use the xcolor package instead, and then we can do
513 // \define{shadcolor}{RGB}...
514 //and not do any conversion. We'd then need to require xcolor
515 //in InsetNote::validate().
516 int const stmSize = packages.precision(2);
517 packages << "\\definecolor{shadecolor}{rgb}{"
518 << c.r / 255.0 << ',' << c.g / 255.0 << ',' << c.b / 255.0 << "}\n";
519 packages.precision(stmSize);
522 // lyxskak.sty --- newer chess support based on skak.sty
523 if (mustProvide("chess")) {
524 packages << "\\usepackage[ps,mover]{lyxskak}\n";
528 if ((params_.spacing().getSpace() != Spacing::Single
529 && !params_.spacing().isDefault())
530 || isRequired("setspace")) {
531 packages << "\\usepackage{setspace}\n";
533 switch (params_.spacing().getSpace()) {
534 case Spacing::Default:
535 case Spacing::Single:
536 // we dont use setspace.sty so dont print anything
537 //packages += "\\singlespacing\n";
539 case Spacing::Onehalf:
540 packages << "\\onehalfspacing\n";
542 case Spacing::Double:
543 packages << "\\doublespacing\n";
546 packages << "\\setstretch{"
547 << params_.spacing().getValue() << "}\n";
552 if (mustProvide("amssymb")
553 || params_.use_amsmath == BufferParams::package_on)
554 packages << "\\usepackage{amssymb}\n";
556 // esint must be after amsmath and wasysym, since it will redeclare
557 // inconsistent integral symbols
558 if ((mustProvide("esint") || mustProvide("esintoramsmath")) &&
559 params_.use_esint != BufferParams::package_off)
560 packages << "\\usepackage{esint}\n";
563 if (mustProvide("natbib")) {
564 packages << "\\usepackage[";
565 if (params_.getEngine() == biblio::ENGINE_NATBIB_NUMERICAL) {
566 packages << "numbers";
568 packages << "authoryear";
570 packages << "]{natbib}\n";
573 // jurabib -- we need version 0.6 at least.
574 if (mustProvide("jurabib")) {
575 packages << "\\usepackage{jurabib}[2004/01/25]\n";
578 // bibtopic -- the dot provides the aux file naming which
580 if (mustProvide("bibtopic")) {
581 packages << "\\usepackage[dot]{bibtopic}\n";
584 if (mustProvide("xy"))
585 packages << "\\usepackage[all]{xy}\n";
587 if (mustProvide("nomencl")) {
588 // Make it work with the new and old version of the package,
589 // but don't use the compatibility option since it is
590 // incompatible to other packages.
591 packages << "\\usepackage{nomencl}\n"
592 "% the following is useful when we have the old nomencl.sty package\n"
593 "\\providecommand{\\printnomenclature}{\\printglossary}\n"
594 "\\providecommand{\\makenomenclature}{\\makeglossary}\n"
595 "\\makenomenclature\n";
598 if (mustProvide("listings"))
599 packages << "\\usepackage{listings}\n";
601 return packages.str();
605 string const LaTeXFeatures::getMacros() const
607 ostringstream macros;
609 if (!preamble_snippets_.empty())
611 FeaturesList::const_iterator pit = preamble_snippets_.begin();
612 FeaturesList::const_iterator pend = preamble_snippets_.end();
613 for (; pit != pend; ++pit)
614 macros << *pit << '\n';
616 if (mustProvide("LyX"))
617 macros << lyx_def << '\n';
619 if (mustProvide("lyxline"))
620 macros << lyxline_def << '\n';
622 if (mustProvide("noun"))
623 macros << noun_def << '\n';
625 if (mustProvide("lyxarrow"))
626 macros << lyxarrow_def << '\n';
628 if (mustProvide("textgreek"))
629 macros << textgreek_def << '\n';
631 if (mustProvide("textcyr"))
632 macros << textcyr_def << '\n';
635 if (mustProvide("quotesinglbase"))
636 macros << quotesinglbase_def << '\n';
637 if (mustProvide("quotedblbase"))
638 macros << quotedblbase_def << '\n';
639 if (mustProvide("guilsinglleft"))
640 macros << guilsinglleft_def << '\n';
641 if (mustProvide("guilsinglright"))
642 macros << guilsinglright_def << '\n';
643 if (mustProvide("guillemotleft"))
644 macros << guillemotleft_def << '\n';
645 if (mustProvide("guillemotright"))
646 macros << guillemotright_def << '\n';
649 if (mustProvide("boldsymbol") && !isRequired("amsmath"))
650 macros << boldsymbol_def << '\n';
651 if (mustProvide("binom") && !isRequired("amsmath"))
652 macros << binom_def << '\n';
653 if (mustProvide("mathcircumflex"))
654 macros << mathcircumflex_def << '\n';
657 if (mustProvide("ParagraphLeftIndent"))
658 macros << paragraphleftindent_def;
659 if (mustProvide("NeedLyXFootnoteCode"))
660 macros << floatingfootnote_def;
662 // some problems with tex->html converters
663 if (mustProvide("NeedTabularnewline"))
664 macros << tabularnewline_def;
666 // greyedout environment (note inset)
667 if (mustProvide("lyxgreyedout"))
668 macros << lyxgreyedout_def;
670 if (mustProvide("lyxdot"))
671 macros << lyxdot_def << '\n';
674 getFloatDefinitions(macros);
677 if (mustProvide("ct-dvipost"))
678 macros << changetracking_dvipost_def;
680 if (mustProvide("ct-xcolor-soul")) {
681 int const prec = macros.precision(2);
683 RGBColor cadd = rgbFromHexName(lcolor.getX11Name(Color_addedtext));
684 macros << "\\providecolor{lyxadded}{rgb}{"
685 << cadd.r / 255.0 << ',' << cadd.g / 255.0 << ',' << cadd.b / 255.0 << "}\n";
687 RGBColor cdel = rgbFromHexName(lcolor.getX11Name(Color_deletedtext));
688 macros << "\\providecolor{lyxdeleted}{rgb}{"
689 << cdel.r / 255.0 << ',' << cdel.g / 255.0 << ',' << cdel.b / 255.0 << "}\n";
691 macros.precision(prec);
693 macros << "\\newcommand{\\lyxadded}[3]{{\\color{lyxadded}#3}}\n"
694 << "\\newcommand{\\lyxdeleted}[3]{{\\color{lyxdeleted}\\st{#3}}}\n";
697 if (mustProvide("ct-none"))
698 macros << changetracking_none_def;
704 string const LaTeXFeatures::getBabelOptions() const
708 LanguageList::const_iterator it = UsedLanguages_.begin();
709 LanguageList::const_iterator end = UsedLanguages_.end();
710 for (; it != end; ++it)
711 if (!(*it)->latex_options().empty())
712 tmp << (*it)->latex_options() << '\n';
713 if (!params_.language->latex_options().empty())
714 tmp << params_.language->latex_options() << '\n';
720 docstring const LaTeXFeatures::getTClassPreamble() const
722 // the text class specific preamble
723 TextClass const & tclass = params_.getTextClass();
724 odocstringstream tcpreamble;
726 tcpreamble << tclass.preamble();
728 list<docstring>::const_iterator cit = usedLayouts_.begin();
729 list<docstring>::const_iterator end = usedLayouts_.end();
730 for (; cit != end; ++cit) {
731 tcpreamble << tclass[*cit]->preamble();
734 InsetLayouts const & insetlayouts = tclass.insetlayouts();
735 InsetLayouts::const_iterator cit2 = insetlayouts.begin();
736 InsetLayouts::const_iterator end2 = insetlayouts.end();
737 for (; cit2 != end2; ++cit2) {
738 if (isRequired(to_utf8(cit2->first))) {
739 tcpreamble << from_utf8(cit2->second.preamble);
743 return tcpreamble.str();
747 docstring const LaTeXFeatures::getLyXSGMLEntities() const
749 // Definition of entities used in the document that are LyX related.
750 odocstringstream entities;
752 if (mustProvide("lyxarrow")) {
753 entities << "<!ENTITY lyxarrow \"->\">" << '\n';
756 return entities.str();
760 docstring const LaTeXFeatures::getIncludedFiles(string const & fname) const
762 odocstringstream sgmlpreamble;
764 docstring const basename(from_utf8(onlyPath(fname)));
766 FileMap::const_iterator end = IncludedFiles_.end();
767 for (FileMap::const_iterator fi = IncludedFiles_.begin();
770 sgmlpreamble << "\n<!ENTITY " << fi->first
771 << (isSGMLFilename(fi->second) ? " SYSTEM \"" : " \"")
772 << makeRelPath(from_utf8(fi->second), basename) << "\">";
774 return sgmlpreamble.str();
778 void LaTeXFeatures::showStruct() const {
779 lyxerr << "LyX needs the following commands when LaTeXing:"
780 << "\n***** Packages:" << getPackages()
781 << "\n***** Macros:" << getMacros()
782 << "\n***** Textclass stuff:" << to_utf8(getTClassPreamble())
783 << "\n***** done." << endl;
787 Buffer const & LaTeXFeatures::buffer() const
793 void LaTeXFeatures::setBuffer(Buffer const & buffer)
799 BufferParams const & LaTeXFeatures::bufferParams() const
805 void LaTeXFeatures::getFloatDefinitions(ostream & os) const
807 FloatList const & floats = params_.getTextClass().floats();
809 // Here we will output the code to create the needed float styles.
810 // We will try to do this as minimal as possible.
811 // \floatstyle{ruled}
812 // \newfloat{algorithm}{htbp}{loa}
813 // \floatname{algorithm}{Algorithm}
814 UsedFloats::const_iterator cit = usedFloats_.begin();
815 UsedFloats::const_iterator end = usedFloats_.end();
816 // ostringstream floats;
817 for (; cit != end; ++cit) {
818 Floating const & fl = floats.getType((*cit));
820 // For builtin floats we do nothing.
821 if (fl.builtin()) continue;
823 // We have to special case "table" and "figure"
824 if (fl.type() == "tabular" || fl.type() == "figure") {
825 // Output code to modify "table" or "figure"
826 // but only if builtin == false
827 // and that have to be true at this point in the
829 string const type = fl.type();
830 string const placement = fl.placement();
831 string const style = fl.style();
832 if (!style.empty()) {
833 os << "\\floatstyle{" << style << "}\n"
834 << "\\restylefloat{" << type << "}\n";
836 if (!placement.empty()) {
837 os << "\\floatplacement{" << type << "}{"
838 << placement << "}\n";
841 // The other non builtin floats.
843 string const type = fl.type();
844 string const placement = fl.placement();
845 string const ext = fl.ext();
846 string const within = fl.within();
847 string const style = fl.style();
848 string const name = fl.name();
849 os << "\\floatstyle{" << style << "}\n"
850 << "\\newfloat{" << type << "}{" << placement
851 << "}{" << ext << '}';
853 os << '[' << within << ']';
855 << "\\floatname{" << type << "}{"
858 // What missing here is to code to minimalize the code
859 // output so that the same floatstyle will not be
860 // used several times, when the same style is still in