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"
38 using support::isSGMLFilename;
39 using support::libFileSearch;
40 using support::makeRelPath;
41 using support::onlyPath;
43 /////////////////////////////////////////////////////////////////////
47 /////////////////////////////////////////////////////////////////////
49 //\NeedsTeXFormat{LaTeX2e}
50 //\ProvidesPackage{lyx}[1996/01/11 LLE v0.2 (LyX LaTeX Extensions)]
51 //\message{LyX LaTeX Extensions (LLE v0.2) of 11-Jan-1996.}
53 static string const lyx_def =
54 "\\providecommand{\\LyX}{L\\kern-.1667em\\lower.25em\\hbox{Y}\\kern-.125emX\\@}";
56 static string const lyxline_def =
57 "\\newcommand{\\lyxline}[1][1pt]{%\n"
59 " \\rule[.5ex]{\\linewidth}{#1}\\par}";
61 static string const noun_def = "\\newcommand{\\noun}[1]{\\textsc{#1}}";
63 static string const lyxarrow_def =
64 "\\newcommand{\\lyxarrow}{\\leavevmode\\,$\\triangleright$\\,\\allowbreak}";
66 // for quotes without babel. This does not give perfect results, but
67 // anybody serious about non-english quotes should use babel (JMarc).
69 static string const quotedblbase_def =
70 "\\ProvideTextCommandDefault{\\quotedblbase}{%\n"
71 " \\raisebox{-1.4ex}[1ex][.5ex]{\\textquotedblright}%\n"
72 " \\penalty10000\\hskip0em\\relax%\n"
75 static string const quotesinglbase_def =
76 "\\ProvideTextCommandDefault{\\quotesinglbase}{%\n"
77 " \\raisebox{-1.4ex}[1ex][.5ex]{\\textquoteright}%\n"
78 " \\penalty10000\\hskip0em\\relax%\n"
81 static string const guillemotleft_def =
82 "\\ProvideTextCommandDefault{\\guillemotleft}{%\n"
83 " {\\usefont{U}{lasy}{m}{n}\\char'50\\kern-.15em\\char'50}%\n"
84 "\\penalty10000\\hskip0pt\\relax%\n"
87 static string const guillemotright_def =
88 "\\ProvideTextCommandDefault{\\guillemotright}{%\n"
89 " \\penalty10000\\hskip0pt%\n"
90 " {\\usefont{U}{lasy}{m}{n}\\char'51\\kern-.15em\\char'51}%\n"
93 static string const guilsinglleft_def =
94 "\\ProvideTextCommandDefault{\\guilsinglleft}{%\n"
95 " {\\usefont{U}{lasy}{m}{n}\\char'50}%\n"
96 " \\penalty10000\\hskip0pt\\relax%\n"
99 static string const guilsinglright_def =
100 "\\ProvideTextCommandDefault{\\guilsinglright}{%\n"
101 " \\penalty10000\\hskip0pt%\n"
102 " {\\usefont{U}{lasy}{m}{n}\\char'51}%\n"
105 static string const paragraphleftindent_def =
106 "\\newenvironment{LyXParagraphLeftIndent}[1]%\n"
108 " \\begin{list}{}{%\n"
109 " \\setlength{\\topsep}{0pt}%\n"
110 " \\addtolength{\\leftmargin}{#1}\n"
111 // ho hum, yet more things commented out with no hint as to why they
112 // weren't just removed
113 // "%% \\addtolength{\\leftmargin}{#1\\textwidth}\n"
114 // "%% \\setlength{\\textwidth}{#2\\textwidth}\n"
115 // "%% \\setlength\\listparindent\\parindent%\n"
116 // "%% \\setlength\\itemindent\\parindent%\n"
117 " \\setlength{\\parsep}{0pt plus 1pt}%\n"
123 static string const floatingfootnote_def =
124 "%% Special footnote code from the package 'stblftnt.sty'\n"
125 "%% Author: Robin Fairbairns -- Last revised Dec 13 1996\n"
126 "\\let\\SF@@footnote\\footnote\n"
127 "\\def\\footnote{\\ifx\\protect\\@typeset@protect\n"
128 " \\expandafter\\SF@@footnote\n"
130 " \\expandafter\\SF@gobble@opt\n"
133 "\\expandafter\\def\\csname SF@gobble@opt \\endcsname{\\@ifnextchar[%]\n"
134 " \\SF@gobble@twobracket\n"
137 "\\edef\\SF@gobble@opt{\\noexpand\\protect\n"
138 " \\expandafter\\noexpand\\csname SF@gobble@opt \\endcsname}\n"
139 "\\def\\SF@gobble@twobracket[#1]#2{}\n";
141 static string const boldsymbol_def =
142 "%% Bold symbol macro for standard LaTeX users\n"
143 "\\providecommand{\\boldsymbol}[1]{\\mbox{\\boldmath $#1$}}\n";
145 static string const binom_def =
146 "%% Binom macro for standard LaTeX users\n"
147 "\\newcommand{\\binom}[2]{{#1 \\choose #2}}\n";
149 static string const mathcircumflex_def =
150 "%% For printing a cirumflex inside a formula\n"
151 "\\newcommand{\\mathcircumflex}[0]{\\mbox{\\^{}}}\n";
153 static string const tabularnewline_def =
154 "%% Because html converters don't know tabularnewline\n"
155 "\\providecommand{\\tabularnewline}{\\\\}\n";
157 static string const lyxgreyedout_def =
158 "%% The greyedout annotation environment\n"
159 "\\newenvironment{lyxgreyedout}{\\textcolor[gray]{0.8}\\bgroup}{\\egroup}\n";
161 // We want to omit the file extension for includegraphics, but this does not
162 // work when the filename contains other dots.
163 // Idea from http://www.tex.ac.uk/cgi-bin/texfaq2html?label=unkgrfextn
164 static string const lyxdot_def =
165 "%% A simple dot to overcome graphicx limitations\n"
166 "\\newcommand{\\lyxdot}{.}\n";
168 static string const changetracking_dvipost_def =
169 "%% Change tracking with dvipost\n"
171 "\\dvipost{osstart color push Red}\n"
172 "\\dvipost{osend color pop}\n"
173 "\\dvipost{cbstart color push Blue}\n"
174 "\\dvipost{cbend color pop}\n"
175 "\\newcommand{\\lyxadded}[3]{\\changestart#3\\changeend}\n"
176 "\\newcommand{\\lyxdeleted}[3]{%\n"
177 "\\changestart\\overstrikeon#3\\overstrikeoff\\changeend}\n";
179 static string const changetracking_none_def =
180 "\\newcommand{\\lyxadded}[3]{#3}\n"
181 "\\newcommand{\\lyxdeleted}[3]{}\n";
183 static string const textgreek_def =
184 "\\DeclareRobustCommand{\\greektext}{%\n"
185 " \\fontencoding{LGR}\\selectfont\n"
186 " \\def\\encodingdefault{LGR}}\n"
187 "\\DeclareRobustCommand{\\textgreek}[1]{\\leavevmode{\\greektext #1}}\n"
188 "\\DeclareFontEncoding{LGR}{}{}\n";
190 static string const textcyr_def =
191 "\\DeclareRobustCommand{\\cyrtext}{%\n"
192 " \\fontencoding{T2A}\\selectfont\n"
193 " \\def\\encodingdefault{T2A}}\n"
194 "\\DeclareRobustCommand{\\textcyr}[1]{\\leavevmode{\\cyrtext #1}}\n"
195 "\\DeclareFontEncoding{T2A}{}{}\n";
198 /////////////////////////////////////////////////////////////////////
202 /////////////////////////////////////////////////////////////////////
204 LaTeXFeatures::PackagesList LaTeXFeatures::packages_;
207 LaTeXFeatures::LaTeXFeatures(Buffer const & b, BufferParams const & p,
208 OutputParams const & r)
209 : buffer_(&b), params_(p), runparams_(r)
213 bool LaTeXFeatures::useBabel() const
215 return lyxrc.language_use_babel ||
216 (bufferParams().language->lang() != lyxrc.default_language &&
217 !bufferParams().language->babel().empty()) ||
218 this->hasLanguages();
222 void LaTeXFeatures::require(string const & name)
224 if (isRequired(name))
227 features_.push_back(name);
231 void LaTeXFeatures::getAvailable()
234 support::FileName const real_file = libFileSearch("", "packages.lst");
236 if (real_file.empty())
239 lex.setFile(real_file);
244 // Make sure that we are clean
247 bool finished = false;
249 while (lex.isOK() && !finished) {
251 case Lexer::LEX_FEOF:
255 string const name = lex.getString();
256 PackagesList::const_iterator begin = packages_.begin();
257 PackagesList::const_iterator end = packages_.end();
258 if (find(begin, end, name) == end)
259 packages_.push_back(name);
265 void LaTeXFeatures::useLayout(docstring const & layoutname)
267 // Some code to avoid loops in dependency definition
268 static int level = 0;
269 const int maxlevel = 30;
270 if (level > maxlevel) {
271 lyxerr << "LaTeXFeatures::useLayout: maximum level of "
272 << "recursion attained by layout "
273 << to_utf8(layoutname) << endl;
277 TextClass const & tclass = params_.getTextClass();
278 if (tclass.hasLayout(layoutname)) {
279 // Is this layout already in usedLayouts?
280 list<docstring>::const_iterator cit = usedLayouts_.begin();
281 list<docstring>::const_iterator end = usedLayouts_.end();
282 for (; cit != end; ++cit) {
283 if (layoutname == *cit)
287 LayoutPtr const & lyt = tclass[layoutname];
288 if (!lyt->depends_on().empty()) {
290 useLayout(lyt->depends_on());
293 usedLayouts_.push_back(layoutname);
295 lyxerr << "LaTeXFeatures::useLayout: layout `"
296 << to_utf8(layoutname) << "' does not exist in this class"
304 bool LaTeXFeatures::isRequired(string const & name) const
306 return find(features_.begin(), features_.end(), name) != features_.end();
310 bool LaTeXFeatures::mustProvide(string const & name) const
312 return isRequired(name) && !params_.getTextClass().provides(name);
316 bool LaTeXFeatures::isAvailable(string const & name)
318 if (packages_.empty())
320 return find(packages_.begin(), packages_.end(), name) != packages_.end();
324 void LaTeXFeatures::addPreambleSnippet(string const & preamble)
326 FeaturesList::const_iterator begin = preamble_snippets_.begin();
327 FeaturesList::const_iterator end = preamble_snippets_.end();
328 if (find(begin, end, preamble) == end)
329 preamble_snippets_.push_back(preamble);
333 void LaTeXFeatures::useFloat(string const & name)
335 usedFloats_.insert(name);
336 // We only need float.sty if we use non builtin floats, or if we
337 // use the "H" modifier. This includes modified table and
338 // figure floats. (Lgb)
339 Floating const & fl = params_.getTextClass().floats().getType(name);
340 if (!fl.type().empty() && !fl.builtin()) {
346 void LaTeXFeatures::useLanguage(Language const * lang)
348 if (!lang->babel().empty())
349 UsedLanguages_.insert(lang);
350 // CJK languages do not have a babel name.
351 // They use the CJK package
352 if (lang->encoding()->package() == Encoding::CJK)
357 void LaTeXFeatures::includeFile(docstring const & key, string const & name)
359 IncludedFiles_[key] = name;
363 bool LaTeXFeatures::hasLanguages() const
365 return !UsedLanguages_.empty();
369 string LaTeXFeatures::getLanguages() const
371 ostringstream languages;
373 LanguageList::const_iterator const begin = UsedLanguages_.begin();
374 for (LanguageList::const_iterator cit = begin;
375 cit != UsedLanguages_.end();
379 languages << (*cit)->babel();
381 return languages.str();
385 set<string> LaTeXFeatures::getEncodingSet(string const & doc_encoding) const
387 // This does only find encodings of languages supported by babel, but
388 // that does not matter since we don't have a language with an
389 // encoding supported by inputenc but without babel support.
390 set<string> encodings;
391 LanguageList::const_iterator it = UsedLanguages_.begin();
392 LanguageList::const_iterator end = UsedLanguages_.end();
393 for (; it != end; ++it)
394 if ((*it)->encoding()->latexName() != doc_encoding &&
395 (*it)->encoding()->package() == Encoding::inputenc)
396 encodings.insert((*it)->encoding()->latexName());
402 char const * simplefeatures[] = {
403 // note that the package order here will be the same in the LaTeX-output
413 /*For a successful cooperation of the `wrapfig' package with the
414 `float' package you should load the `wrapfig' package *after*
415 the `float' package. See the caption package documentation
440 int const nb_simplefeatures = sizeof(simplefeatures) / sizeof(char const *);
445 string const LaTeXFeatures::getPackages() const
447 ostringstream packages;
448 TextClass const & tclass = params_.getTextClass();
451 // These are all the 'simple' includes. i.e
452 // packages which we just \usepackage{package}
454 for (int i = 0; i < nb_simplefeatures; ++i) {
455 if (mustProvide(simplefeatures[i]))
456 packages << "\\usepackage{"
457 << simplefeatures[i] << "}\n";
461 // The rest of these packages are somewhat more complicated
465 // esint is preferred for esintoramsmath
466 if ((mustProvide("amsmath") &&
467 params_.use_amsmath != BufferParams::package_off) ||
468 (mustProvide("esintoramsmath") &&
469 params_.use_esint == BufferParams::package_off)) {
470 packages << "\\usepackage{amsmath}\n";
473 // wasysym is a simple feature, but it must be after amsmath if both
475 // wasysym redefines some integrals (e.g. iint) from amsmath. That
476 // leads to inconsistent integrals. We only load this package if
477 // the document does not contain integrals (then isRequired("esint")
478 // is false) or if esint is used, since esint redefines all relevant
479 // integral symbols from wasysym and amsmath.
480 // See http://bugzilla.lyx.org/show_bug.cgi?id=1942
481 if (mustProvide("wasysym") &&
482 (params_.use_esint != BufferParams::package_off || !isRequired("esint")))
483 packages << "\\usepackage{wasysym}\n";
486 if (mustProvide("color")) {
487 if (params_.graphicsDriver == "default")
488 packages << "\\usepackage{color}\n";
490 packages << "\\usepackage["
491 << params_.graphicsDriver
496 if (isRequired("makeidx")) {
497 if (!tclass.provides("makeidx"))
498 packages << "\\usepackage{makeidx}\n";
499 packages << "\\makeindex\n";
503 if (mustProvide("graphicx") && params_.graphicsDriver != "none") {
504 if (params_.graphicsDriver == "default")
505 packages << "\\usepackage{graphicx}\n";
507 packages << "\\usepackage["
508 << params_.graphicsDriver
511 // shadecolor for shaded
512 if (isRequired("framed") && mustProvide("color")) {
513 RGBColor c = rgbFromHexName(lcolor.getX11Name(Color_shadedbg));
514 //255.0 to force conversion to double
515 //NOTE As Jürgen Spitzmüller pointed out, an alternative would be
516 //to use the xcolor package instead, and then we can do
517 // \define{shadcolor}{RGB}...
518 //and not do any conversion. We'd then need to require xcolor
519 //in InsetNote::validate().
520 int const stmSize = packages.precision(2);
521 packages << "\\definecolor{shadecolor}{rgb}{"
522 << c.r / 255.0 << ',' << c.g / 255.0 << ',' << c.b / 255.0 << "}\n";
523 packages.precision(stmSize);
526 // lyxskak.sty --- newer chess support based on skak.sty
527 if (mustProvide("chess")) {
528 packages << "\\usepackage[ps,mover]{lyxskak}\n";
532 if ((params_.spacing().getSpace() != Spacing::Single
533 && !params_.spacing().isDefault())
534 || isRequired("setspace")) {
535 packages << "\\usepackage{setspace}\n";
537 switch (params_.spacing().getSpace()) {
538 case Spacing::Default:
539 case Spacing::Single:
540 // we dont use setspace.sty so dont print anything
541 //packages += "\\singlespacing\n";
543 case Spacing::Onehalf:
544 packages << "\\onehalfspacing\n";
546 case Spacing::Double:
547 packages << "\\doublespacing\n";
550 packages << "\\setstretch{"
551 << params_.spacing().getValue() << "}\n";
556 if (mustProvide("amssymb")
557 || params_.use_amsmath == BufferParams::package_on)
558 packages << "\\usepackage{amssymb}\n";
560 // esint must be after amsmath and wasysym, since it will redeclare
561 // inconsistent integral symbols
562 if ((mustProvide("esint") || mustProvide("esintoramsmath")) &&
563 params_.use_esint != BufferParams::package_off)
564 packages << "\\usepackage{esint}\n";
567 if (mustProvide("natbib")) {
568 packages << "\\usepackage[";
569 if (params_.getEngine() == biblio::ENGINE_NATBIB_NUMERICAL) {
570 packages << "numbers";
572 packages << "authoryear";
574 packages << "]{natbib}\n";
577 // jurabib -- we need version 0.6 at least.
578 if (mustProvide("jurabib")) {
579 packages << "\\usepackage{jurabib}[2004/01/25]\n";
582 // bibtopic -- the dot provides the aux file naming which
584 if (mustProvide("bibtopic")) {
585 packages << "\\usepackage[dot]{bibtopic}\n";
588 if (mustProvide("xy"))
589 packages << "\\usepackage[all]{xy}\n";
591 if (mustProvide("nomencl")) {
592 // Make it work with the new and old version of the package,
593 // but don't use the compatibility option since it is
594 // incompatible to other packages.
595 packages << "\\usepackage{nomencl}\n"
596 "% the following is useful when we have the old nomencl.sty package\n"
597 "\\providecommand{\\printnomenclature}{\\printglossary}\n"
598 "\\providecommand{\\makenomenclature}{\\makeglossary}\n"
599 "\\makenomenclature\n";
602 if (mustProvide("listings"))
603 packages << "\\usepackage{listings}\n";
605 return packages.str();
609 string const LaTeXFeatures::getMacros() const
611 ostringstream macros;
613 if (!preamble_snippets_.empty())
615 FeaturesList::const_iterator pit = preamble_snippets_.begin();
616 FeaturesList::const_iterator pend = preamble_snippets_.end();
617 for (; pit != pend; ++pit)
618 macros << *pit << '\n';
620 if (mustProvide("LyX"))
621 macros << lyx_def << '\n';
623 if (mustProvide("lyxline"))
624 macros << lyxline_def << '\n';
626 if (mustProvide("noun"))
627 macros << noun_def << '\n';
629 if (mustProvide("lyxarrow"))
630 macros << lyxarrow_def << '\n';
632 if (mustProvide("textgreek"))
633 macros << textgreek_def << '\n';
635 if (mustProvide("textcyr"))
636 macros << textcyr_def << '\n';
639 if (mustProvide("quotesinglbase"))
640 macros << quotesinglbase_def << '\n';
641 if (mustProvide("quotedblbase"))
642 macros << quotedblbase_def << '\n';
643 if (mustProvide("guilsinglleft"))
644 macros << guilsinglleft_def << '\n';
645 if (mustProvide("guilsinglright"))
646 macros << guilsinglright_def << '\n';
647 if (mustProvide("guillemotleft"))
648 macros << guillemotleft_def << '\n';
649 if (mustProvide("guillemotright"))
650 macros << guillemotright_def << '\n';
653 if (mustProvide("boldsymbol") && !isRequired("amsmath"))
654 macros << boldsymbol_def << '\n';
655 if (mustProvide("binom") && !isRequired("amsmath"))
656 macros << binom_def << '\n';
657 if (mustProvide("mathcircumflex"))
658 macros << mathcircumflex_def << '\n';
661 if (mustProvide("ParagraphLeftIndent"))
662 macros << paragraphleftindent_def;
663 if (mustProvide("NeedLyXFootnoteCode"))
664 macros << floatingfootnote_def;
666 // some problems with tex->html converters
667 if (mustProvide("NeedTabularnewline"))
668 macros << tabularnewline_def;
670 // greyedout environment (note inset)
671 if (mustProvide("lyxgreyedout"))
672 macros << lyxgreyedout_def;
674 if (mustProvide("lyxdot"))
675 macros << lyxdot_def << '\n';
678 getFloatDefinitions(macros);
681 if (mustProvide("ct-dvipost"))
682 macros << changetracking_dvipost_def;
684 if (mustProvide("ct-xcolor-soul")) {
685 int const prec = macros.precision(2);
687 RGBColor cadd = rgbFromHexName(lcolor.getX11Name(Color_addedtext));
688 macros << "\\providecolor{lyxadded}{rgb}{"
689 << cadd.r / 255.0 << ',' << cadd.g / 255.0 << ',' << cadd.b / 255.0 << "}\n";
691 RGBColor cdel = rgbFromHexName(lcolor.getX11Name(Color_deletedtext));
692 macros << "\\providecolor{lyxdeleted}{rgb}{"
693 << cdel.r / 255.0 << ',' << cdel.g / 255.0 << ',' << cdel.b / 255.0 << "}\n";
695 macros.precision(prec);
697 macros << "\\newcommand{\\lyxadded}[3]{{\\color{lyxadded}#3}}\n"
698 << "\\newcommand{\\lyxdeleted}[3]{{\\color{lyxdeleted}\\st{#3}}}\n";
701 if (mustProvide("ct-none"))
702 macros << changetracking_none_def;
708 string const LaTeXFeatures::getBabelOptions() const
712 LanguageList::const_iterator it = UsedLanguages_.begin();
713 LanguageList::const_iterator end = UsedLanguages_.end();
714 for (; it != end; ++it)
715 if (!(*it)->latex_options().empty())
716 tmp << (*it)->latex_options() << '\n';
717 if (!params_.language->latex_options().empty())
718 tmp << params_.language->latex_options() << '\n';
724 docstring const LaTeXFeatures::getTClassPreamble() const
726 // the text class specific preamble
727 TextClass const & tclass = params_.getTextClass();
728 odocstringstream tcpreamble;
730 tcpreamble << tclass.preamble();
732 list<docstring>::const_iterator cit = usedLayouts_.begin();
733 list<docstring>::const_iterator end = usedLayouts_.end();
734 for (; cit != end; ++cit) {
735 tcpreamble << tclass[*cit]->preamble();
738 InsetLayouts const & insetlayouts = tclass.insetlayouts();
739 InsetLayouts::const_iterator cit2 = insetlayouts.begin();
740 InsetLayouts::const_iterator end2 = insetlayouts.end();
741 for (; cit2 != end2; ++cit2) {
742 if (isRequired(to_utf8(cit2->first))) {
743 tcpreamble << from_utf8(cit2->second.preamble);
747 return tcpreamble.str();
751 docstring const LaTeXFeatures::getLyXSGMLEntities() const
753 // Definition of entities used in the document that are LyX related.
754 odocstringstream entities;
756 if (mustProvide("lyxarrow")) {
757 entities << "<!ENTITY lyxarrow \"->\">" << '\n';
760 return entities.str();
764 docstring const LaTeXFeatures::getIncludedFiles(string const & fname) const
766 odocstringstream sgmlpreamble;
768 docstring const basename(from_utf8(onlyPath(fname)));
770 FileMap::const_iterator end = IncludedFiles_.end();
771 for (FileMap::const_iterator fi = IncludedFiles_.begin();
774 sgmlpreamble << "\n<!ENTITY " << fi->first
775 << (isSGMLFilename(fi->second) ? " SYSTEM \"" : " \"")
776 << makeRelPath(from_utf8(fi->second), basename) << "\">";
778 return sgmlpreamble.str();
782 void LaTeXFeatures::showStruct() const {
783 lyxerr << "LyX needs the following commands when LaTeXing:"
784 << "\n***** Packages:" << getPackages()
785 << "\n***** Macros:" << getMacros()
786 << "\n***** Textclass stuff:" << to_utf8(getTClassPreamble())
787 << "\n***** done." << endl;
791 Buffer const & LaTeXFeatures::buffer() const
797 void LaTeXFeatures::setBuffer(Buffer const & buffer)
803 BufferParams const & LaTeXFeatures::bufferParams() const
809 void LaTeXFeatures::getFloatDefinitions(ostream & os) const
811 FloatList const & floats = params_.getTextClass().floats();
813 // Here we will output the code to create the needed float styles.
814 // We will try to do this as minimal as possible.
815 // \floatstyle{ruled}
816 // \newfloat{algorithm}{htbp}{loa}
817 // \floatname{algorithm}{Algorithm}
818 UsedFloats::const_iterator cit = usedFloats_.begin();
819 UsedFloats::const_iterator end = usedFloats_.end();
820 // ostringstream floats;
821 for (; cit != end; ++cit) {
822 Floating const & fl = floats.getType((*cit));
824 // For builtin floats we do nothing.
825 if (fl.builtin()) continue;
827 // We have to special case "table" and "figure"
828 if (fl.type() == "tabular" || fl.type() == "figure") {
829 // Output code to modify "table" or "figure"
830 // but only if builtin == false
831 // and that have to be true at this point in the
833 string const type = fl.type();
834 string const placement = fl.placement();
835 string const style = fl.style();
836 if (!style.empty()) {
837 os << "\\floatstyle{" << style << "}\n"
838 << "\\restylefloat{" << type << "}\n";
840 if (!placement.empty()) {
841 os << "\\floatplacement{" << type << "}{"
842 << placement << "}\n";
845 // The other non builtin floats.
847 string const type = fl.type();
848 string const placement = fl.placement();
849 string const ext = fl.ext();
850 string const within = fl.within();
851 string const style = fl.style();
852 string const name = fl.name();
853 os << "\\floatstyle{" << style << "}\n"
854 << "\\newfloat{" << type << "}{" << placement
855 << "}{" << ext << '}';
857 os << '[' << within << ']';
859 << "\\floatname{" << type << "}{"
862 // What missing here is to code to minimalize the code
863 // output so that the same floatstyle will not be
864 // used several times, when the same style is still in