#include "Floating.h"
#include "FloatList.h"
#include "Language.h"
+#include "LaTeXPackages.h"
#include "Layout.h"
#include "Lexer.h"
#include "LyXRC.h"
static docstring const tabularnewline_def = from_ascii(
"%% Because html converters don't know tabularnewline\n"
"\\providecommand{\\tabularnewline}{\\\\}\n");
-
+
static docstring const lyxgreyedout_def = from_ascii(
"%% The greyedout annotation environment\n"
"\\newenvironment{lyxgreyedout}\n"
static docstring const lyxref_def = from_ascii(
"\\RS@ifundefined{subref}\n"
- " {\\def\\RSsubtxt{section~}\\newref{sub}{name = \\RSsubtxt}}\n"
+ " {\\def\\RSsubtxt{section~}\\newref{sub}{name = \\RSsubtxt}}\n"
" {}\n"
"\\RS@ifundefined{thmref}\n"
- " {\\def\\RSthmtxt{theorem~}\\newref{thm}{name = \\RSthmtxt}}\n"
+ " {\\def\\RSthmtxt{theorem~}\\newref{thm}{name = \\RSthmtxt}}\n"
" {}\n"
"\\RS@ifundefined{lemref}\n"
" {\\def\\RSlemtxt{lemma~}\\newref{lem}{name = \\RSlemtxt}}\n"
//
/////////////////////////////////////////////////////////////////////
-LaTeXFeatures::Packages LaTeXFeatures::packages_;
-
LaTeXFeatures::LaTeXFeatures(Buffer const & b, BufferParams const & p,
OutputParams const & r)
}
-void LaTeXFeatures::getAvailable()
-{
- Lexer lex;
- support::FileName const real_file = libFileSearch("", "packages.lst");
-
- if (real_file.empty())
- return;
-
- lex.setFile(real_file);
-
- if (!lex.isOK())
- return;
-
- // Make sure that we are clean
- packages_.clear();
-
- bool finished = false;
- // Parse config-file
- while (lex.isOK() && !finished) {
- switch (lex.lex()) {
- case Lexer::LEX_FEOF:
- finished = true;
- break;
- default:
- packages_.insert(lex.getString());
- }
- }
-}
-
-
void LaTeXFeatures::useLayout(docstring const & layoutname)
{
// Some code to avoid loops in dependency definition
DocumentClass const & tclass = params_.documentClass();
if (tclass.hasLayout(layoutname)) {
// Is this layout already in usedLayouts?
- if (find(usedLayouts_.begin(), usedLayouts_.end(), layoutname)
+ if (find(usedLayouts_.begin(), usedLayouts_.end(), layoutname)
!= usedLayouts_.end())
return;
if (!tclass.hasInsetLayout(lname))
return;
// Is this layout already in usedInsetLayouts?
- if (find(usedInsetLayouts_.begin(), usedInsetLayouts_.end(), lname)
+ if (find(usedInsetLayouts_.begin(), usedInsetLayouts_.end(), lname)
!= usedInsetLayouts_.end())
return;
//LYXERR0("from=[" << from << "] to=[" << to << "]");
return theConverters().isReachable(from, to);
}
-
- if (packages_.empty())
- getAvailable();
- string n = name;
- if (suffixIs(n, ".sty"))
- n.erase(name.length() - 4);
- return packages_.find(n) != packages_.end();
+ return LaTeXPackages::isAvailable(name);
}
}
+void LaTeXFeatures::addCSSSnippet(std::string const & snippet)
+{
+ SnippetList::const_iterator begin = css_snippets_.begin();
+ SnippetList::const_iterator end = css_snippets_.end();
+ if (find(begin, end, snippet) == end)
+ css_snippets_.push_back(snippet);
+}
+
+
void LaTeXFeatures::useFloat(string const & name, bool subfloat)
{
if (!usedFloats_[name])
"ifsym",
"marvosym",
"txfonts",
+ "pxfonts",
+ "mathdesign",
"mathrsfs",
+ "mathabx",
"ascii",
"url",
"covington",
// if fontspec is used, AMS packages have to be loaded before
// fontspec (in BufferParams)
- if (!params_.useNonTeXFonts && !loadAMSPackages().empty())
- packages << loadAMSPackages();
+ string const amsPackages = loadAMSPackages();
+ if (!params_.useNonTeXFonts && !amsPackages.empty())
+ packages << amsPackages;
// fixltx2e must be loaded after amsthm, since amsthm produces an error with
// the redefined \[ command (bug 7233). Load is as early as possible, since
packages << "\\usepackage{undertilde}\n";
// [x]color and pdfcolmk are handled in getColorOptions() above
-
+
// makeidx.sty
if (isRequired("makeidx") || isRequired("splitidx")) {
if (!tclass.provides("makeidx") && !isRequired("splitidx"))
<< params_.graphics_driver
<< "]{graphicx}\n";
}
-
+
// lyxskak.sty --- newer chess support based on skak.sty
if (mustProvide("chess"))
packages << "\\usepackage[ps,mover]{lyxskak}\n";
// esint must be after amsmath and wasysym, since it will redeclare
// inconsistent integral symbols
- if ((mustProvide("esint") || mustProvide("esintoramsmath")) &&
+ if (mustProvide("esint") &&
params_.use_esint != BufferParams::package_off)
packages << "\\usepackage{esint}\n";
// jurabib -- we need version 0.6 at least.
if (mustProvide("jurabib"))
packages << "\\usepackage{jurabib}[2004/01/25]\n";
-
+
// xargs -- we need version 1.09 at least
if (mustProvide("xargs"))
packages << "\\usepackage{xargs}[2008/03/08]\n";
}
-string LaTeXFeatures::getPreambleSnippets() const
+string LaTeXFeatures::getPreambleSnippets() const
{
ostringstream snip;
SnippetList::const_iterator pit = preamble_snippets_.begin();
}
+std::string LaTeXFeatures::getCSSSnippets() const
+{
+ ostringstream snip;
+ SnippetList::const_iterator pit = css_snippets_.begin();
+ SnippetList::const_iterator pend = css_snippets_.end();
+ for (; pit != pend; ++pit)
+ snip << *pit << '\n';
+ return snip.str();
+}
+
+
docstring const LaTeXFeatures::getMacros() const
{
odocstringstream macros;
// floats
getFloatDefinitions(macros);
-
- if (mustProvide("refstyle"))
- macros << lyxref_def << '\n';
-
+
+ if (mustProvide("refstyle"))
+ macros << lyxref_def << '\n';
+
// change tracking
if (mustProvide("ct-dvipost"))
macros << changetracking_dvipost_def;
-
+
if (mustProvide("ct-xcolor-ulem")) {
streamsize const prec = macros.precision(2);
-
+
RGBColor cadd = rgbFromHexName(lcolor.getX11Name(Color_addedtext));
macros << "\\providecolor{lyxadded}{rgb}{"
<< cadd.r / 255.0 << ',' << cadd.g / 255.0 << ',' << cadd.b / 255.0 << "}\n";
<< cdel.r / 255.0 << ',' << cdel.g / 255.0 << ',' << cdel.b / 255.0 << "}\n";
macros.precision(prec);
-
+
if (isRequired("hyperref"))
macros << changetracking_xcolor_ulem_hyperref_def;
else
if (mustProvide("amsthm"))
tmp << "\\usepackage{amsthm}\n";
- // esint is preferred for esintoramsmath
- if ((mustProvide("amsmath")
- && params_.use_amsmath != BufferParams::package_off)
- || (mustProvide("esintoramsmath")
- && params_.use_esint == BufferParams::package_off
- && params_.use_amsmath != BufferParams::package_off)) {
+ if (mustProvide("amsmath")
+ && params_.use_amsmath != BufferParams::package_off) {
tmp << "\\usepackage{amsmath}\n";
} else {
// amsbsy and amstext are already provided by amsmath
if (mustProvide("amstext"))
tmp << "\\usepackage{amstext}\n";
}
-
+
if (mustProvide("amssymb")
|| params_.use_amsmath == BufferParams::package_on)
tmp << "\\usepackage{amssymb}\n";
}
-docstring const LaTeXFeatures::getTClassHTMLPreamble() const
+docstring const LaTeXFeatures::getTClassHTMLPreamble() const
{
DocumentClass const & tclass = params_.documentClass();
odocstringstream tcpreamble;
}
-docstring const LaTeXFeatures::getTClassHTMLStyles() const {
+docstring const LaTeXFeatures::getTClassHTMLStyles() const
+{
DocumentClass const & tclass = params_.documentClass();
odocstringstream tcpreamble;
+ tcpreamble << tclass.htmlstyles();
+
list<docstring>::const_iterator cit = usedLayouts_.begin();
list<docstring>::const_iterator end = usedLayouts_.end();
for (; cit != end; ++cit)
UsedFloats::const_iterator fend = usedFloats_.end();
for (; fit != fend; ++fit) {
Floating const & fl = floats.getType(fit->first);
- // we assume builtin floats are translated
+ // we assume builtin floats are translated
if (fl.isPredefined())
continue;
docstring const type = from_ascii(fl.floattype());
}
+void LaTeXFeatures::resolveAlternatives()
+{
+ for (Features::iterator it = features_.begin(); it != features_.end();) {
+ if (contains(*it, '|')) {
+ vector<string> const alternatives = getVectorFromString(*it, "|");
+ vector<string>::const_iterator const end = alternatives.end();
+ vector<string>::const_iterator ita = alternatives.begin();
+ for (; ita != end; ++ita) {
+ if (isRequired(*ita))
+ break;
+ }
+ if (ita == end)
+ require(alternatives.front());
+ features_.erase(it);
+ it = features_.begin();
+ } else
+ ++it;
+ }
+}
+
+
} // namespace lyx