void InsetSpecialChar::validate(LaTeXFeatures & features) const { if (kind_ == MENU_SEPARATOR) features.require("lyxarrow"); if (kind_ == NOBREAKDASH) features.require("amsmath"); }
// ideas borrowed from the eLyXer code void InsetMathDecoration::validate(LaTeXFeatures & features) const { if (features.runparams().math_flavor == OutputParams::MathAsHTML) { string const name = to_utf8(key_->name); if (name == "bar") { features.addPreambleSnippet("<style type=\"text/css\">\n" "span.overbar{border-top: thin black solid;}\n" "</style>"); } else if (name == "underbar" || name == "underline") { features.addPreambleSnippet("<style type=\"text/css\">\n" "span.underbar{border-bottom: thin black solid;}\n" "</style>"); } else { features.addPreambleSnippet("<style type=\"text/css\">\n" "span.symbolpair{display: inline-block; text-align:center;}\n" "span.symontop{vertical-align: top;}\n" "span.symonbot{vertical-align: bottom;}\n" "span.symbolpair span{display: block;}\n" "span.symbol{height: 0.5ex;}\n" "</style>"); } } else { if (!key_->requires.empty()) features.require(to_utf8(key_->requires)); } InsetMathNest::validate(features); }
void InsetTOC::validate(LaTeXFeatures & features) const { InsetCommand::validate(features); features.useInsetLayout(getLayout()); if (getCmdName() == "lstlistoflistings") features.require("listings"); }
void InsetWrap::validate(LaTeXFeatures & features) const { features.require("wrapfig"); features.inFloat(true); InsetCollapsable::validate(features); features.inFloat(false); }
void InsetMathSqrt::validate(LaTeXFeatures & features) const { if (features.runparams().math_flavor == OutputParams::MathAsHTML) features.addPreambleSnippet("<style type=\"text/css\">\n" "span.sqrtof{border-top: thin solid black;}\n" "</style>"); InsetMathNest::validate(features); }
void InsetMathBig::validate(LaTeXFeatures & features) const { if (features.runparams().math_flavor == OutputParams::MathAsHTML) features.addCSSSnippet( "span.bigsymbol{font-size: 150%;}\n" "span.biggsymbol{font-size: 200%;}\n" "span.bigggsymbol{font-size: 225%;}"); }
void InsetListings::validate(LaTeXFeatures & features) const { features.require("listings"); string param_string = params().params(); if (param_string.find("\\color") != string::npos) features.require("color"); InsetCollapsable::validate(features); }
void InsetMathSize::validate(LaTeXFeatures & features) const { if (features.runparams().math_flavor == OutputParams::MathAsHTML) features.addCSSSnippet( "span.displaystyle, span.textstyle{font-size: normal;}\n" "span.scriptstyle {font-size: small;}\n" "span.scriptscriptstyle {font-size: x-small;}"); InsetMathNest::validate(features); }
void InsetMathBig::validate(LaTeXFeatures & features) const { if (features.runparams().math_flavor == OutputParams::MathAsHTML) features.addPreambleSnippet("<style type=\"text/css\">\n" "span.bigsymbol{font-size: 150%;}\n" "span.biggsymbol{font-size: 200%;}\n" "span.bigggsymbol{font-size: 225%;}\n" "</style>"); }
void InsetMathSplit::validate(LaTeXFeatures & features) const { if (name_ == "split" || name_ == "gathered" || name_ == "aligned" || name_ == "alignedat" || name_ == "align") features.require("amsmath"); else if (name_ == "lgathered" || name_ == "rgathered") features.require("mathtools"); InsetMathGrid::validate(features); }
void Font::validate(LaTeXFeatures & features) const { BufferParams const & bparams = features.bufferParams(); Language const * doc_language = bparams.language; if (bits_.noun() == FONT_ON) { LYXERR(Debug::LATEX, "font.noun: " << bits_.noun()); features.require("noun"); LYXERR(Debug::LATEX, "Noun enabled. Font: " << to_utf8(stateText(0))); } if (bits_.underbar() == FONT_ON) { LYXERR(Debug::LATEX, "font.underline: " << bits_.underbar()); features.require("ulem"); LYXERR(Debug::LATEX, "Underline enabled. Font: " << to_utf8(stateText(0))); } if (bits_.strikeout() == FONT_ON) { LYXERR(Debug::LATEX, "font.strikeout: " << bits_.strikeout()); features.require("ulem"); LYXERR(Debug::LATEX, "Strikeout enabled. Font: " << to_utf8(stateText(0))); } if (bits_.uuline() == FONT_ON) { LYXERR(Debug::LATEX, "font.uuline: " << bits_.uuline()); features.require("ulem"); LYXERR(Debug::LATEX, "Double underline enabled. Font: " << to_utf8(stateText(0))); } if (bits_.uwave() == FONT_ON) { LYXERR(Debug::LATEX, "font.uwave: " << bits_.uwave()); features.require("ulem"); LYXERR(Debug::LATEX, "Wavy underline enabled. Font: " << to_utf8(stateText(0))); } switch (bits_.color()) { case Color_none: case Color_inherit: case Color_ignore: // probably we should put here all interface colors used for // font displaying! For now I just add this ones I know of (Jug) case Color_latex: case Color_notelabel: break; default: features.require("color"); LYXERR(Debug::LATEX, "Color enabled. Font: " << to_utf8(stateText(0))); } // FIXME: Do something for background and soul package? if (((features.usePolyglossia() && lang_->polyglossia() != doc_language->polyglossia()) || (features.useBabel() && lang_->babel() != doc_language->babel()) || (doc_language->encoding()->package() == Encoding::CJK && lang_ != doc_language)) && lang_ != ignore_language && lang_ != latex_language) { features.useLanguage(lang_); LYXERR(Debug::LATEX, "Found language " << lang_->lang()); } }
void InsetMathAMSArray::validate(LaTeXFeatures & features) const { if (name_ == "CD") // amscd is independent of amsmath although it is part of // the amsmath bundle features.require("amscd"); else features.require("amsmath"); InsetMathGrid::validate(features); }
void InsetRef::validate(LaTeXFeatures & features) const { string const cmd = getCmdName(); if (cmd == "vref" || cmd == "vpageref") features.require("varioref"); else if (cmd == "formatted") { docstring const data = getEscapedLabel(features.runparams()); docstring label; docstring prefix; string const fcmd = to_utf8(getFormattedCmd(data, label, prefix)); if (buffer().params().use_refstyle) { features.require("refstyle"); if (prefix == "cha") features.addPreambleSnippet("\\let\\charef=\\chapref"); else if (!prefix.empty()) { string lcmd = "\\AtBeginDocument{\\providecommand" + fcmd + "[1]{\\ref{" + to_utf8(prefix) + ":#1}}}"; features.addPreambleSnippet(lcmd); } } else { features.require("prettyref"); // prettyref uses "cha" for chapters, so we provide a kind of // translation. if (prefix == "chap") features.addPreambleSnippet("\\let\\pr@chap=\\pr@cha"); } } else if (cmd == "eqref" && !buffer().params().use_refstyle) // with refstyle, we simply output "(\ref{label})" features.require("amsmath"); else if (cmd == "nameref") features.require("nameref"); }
void InsetTOC::validate(LaTeXFeatures & features) const { InsetCommand::validate(features); features.useInsetLayout(getLayout()); if (getCmdName() == "lstlistoflistings") { if (buffer().params().use_minted) features.require("minted"); else features.require("listings"); } }
void InsetMathSubstack::validate(LaTeXFeatures & features) const { if (features.runparams().isLaTeX()) features.require("amsmath"); else if (features.runparams().math_flavor == OutputParams::MathAsHTML) features.addCSSSnippet( "span.substack{display: inline-block; vertical-align: middle; text-align:center; font-size: 75%;}\n" "span.substack span{display: block;}"); InsetMathGrid::validate(features); }
void InsetMathCases::validate(LaTeXFeatures & features) const { features.require("amsmath"); InsetMathGrid::validate(features); if (features.runparams().math_flavor == OutputParams::MathAsHTML) // CSS based on eLyXer's features.addCSSSnippet( "table.cases{display: inline-block; text-align: center;" "border-left: thin solid black; vertical-align: middle; padding-left: 0.5ex;}\n" "table.cases td {text-align: left;}"); }
void InsetSpecialChar::validate(LaTeXFeatures & features) const { if (kind_ == ALLOWBREAK) features.require("lyxzerowidthspace"); if (kind_ == MENU_SEPARATOR) features.require("lyxarrow"); if (kind_ == NOBREAKDASH) features.require("amsmath"); if (kind_ == PHRASE_LYX) features.require("LyX"); }
void InsetMathXArrow::validate(LaTeXFeatures & features) const { features.require("amsmath"); if (features.runparams().math_flavor == OutputParams::MathAsHTML) // CSS adapted from eLyXer features.addCSSSnippet( "span.xarrow{display: inline-block; vertical-align: middle; text-align:center;}\n" "span.xatop{display: block;}\n" "span.xabottom{display: block;}"); InsetMathNest::validate(features); }
void InsetMathEnsureMath::validate(LaTeXFeatures & features) const { // FIXME XHTML // It'd be better to be able to get this from an InsetLayout, but at present // InsetLayouts do not seem really to work for things that aren't InsetTexts. if (features.runparams().math_flavor == OutputParams::MathAsMathML) features.addCSSSnippet("mstyle.math { font-style: italic; }"); else if (features.runparams().math_flavor == OutputParams::MathAsHTML) features.addCSSSnippet("span.mathbox { font-style: italic; }"); InsetMathNest::validate(features); }
void InsetMathUnderset::validate(LaTeXFeatures & features) const { if (features.runparams().isLaTeX()) features.require("amsmath"); else if (features.runparams().math_flavor == OutputParams::MathAsHTML) features.addPreambleSnippet("<style type=\"text/css\">\n" "span.underset{display: inline-block; vertical-align: top; text-align:center;}\n" "span.underset span {display: block;}\n" "span.bottom{font-size: 66%;}\n" "</style>"); InsetMathNest::validate(features); }
void InsetCitation::validate(LaTeXFeatures & features) const { switch (features.bufferParams().citeEngine()) { case ENGINE_BASIC: break; case ENGINE_NATBIB_AUTHORYEAR: case ENGINE_NATBIB_NUMERICAL: features.require("natbib"); break; case ENGINE_JURABIB: features.require("jurabib"); break; } }
void InsetNote::validate(LaTeXFeatures & features) const { switch (params_.type) { case InsetNoteParams::Comment: features.require("verbatim"); break; case InsetNoteParams::Greyedout: features.require("color"); features.require("lyxgreyedout"); InsetCollapsable::validate(features); break; case InsetNoteParams::Note: break; } }
void InsetMathBinom::validate(LaTeXFeatures & features) const { if (features.runparams().isLaTeX()) { if (kind_ == BINOM) features.require("binom"); if (kind_ == DBINOM || kind_ == TBINOM) features.require("amsmath"); } else if (features.runparams().math_flavor == OutputParams::MathAsHTML) features.addPreambleSnippet("<style type=\"text/css\">\n" "span.binom{display: inline-block; vertical-align: bottom; text-align:center;}\n" "span.binom span{display: block;}\n" "span.binomdelim{font-size: 2em;}\n" "</style>"); InsetMathNest::validate(features); }
void InsetMathFrac::validate(LaTeXFeatures & features) const { if (kind_ == NICEFRAC || kind_ == UNITFRAC || kind_ == UNIT) features.require("units"); if (kind_ == CFRAC || kind_ == CFRACLEFT || kind_ == CFRACRIGHT || kind_ == DFRAC || kind_ == TFRAC) features.require("amsmath"); if (features.runparams().math_flavor == OutputParams::MathAsHTML) // CSS adapted from eLyXer features.addPreambleSnippet("<style type=\"text/css\">\n" "span.frac{display: inline-block; vertical-align: middle; text-align:center;}\n" "span.numer{display: block;}\n" "span.denom{display: block; border-top: thin solid #000040;}\n" "</style>"); InsetMathNest::validate(features); }
void BufferEncodings::validate(char_type c, LaTeXFeatures & features, bool for_mathed) { CharInfo const & ci = Encodings::unicodeCharInfo(c); if (ci.isUnicodeSymbol()) { // In mathed, c could be used both in textmode and mathmode docstring const textcommand = ci.textcommand(); bool const math_mode = for_mathed && isMathCmd(c); bool const use_math = math_mode || (!for_mathed && textcommand.empty()); bool const use_text = (for_mathed && isTextCmd(c)) || (!for_mathed && !textcommand.empty()); bool const plain_utf8 = (features.runparams().encoding->name() == "utf8-plain"); bool const unicode_math = (features.isRequired("unicode-math") && features.isAvailable("unicode-math")); // with utf8-plain, we only load packages when in mathed (see #7766) // and if we do not use unicode-math if ((math_mode && !unicode_math) || (use_math && !plain_utf8)) { string const mathpreamble = ci.mathpreamble(); if (!mathpreamble.empty()) { if (ci.mathfeature()) { string feats = mathpreamble; while (!feats.empty()) { string feat; feats = split(feats, feat, ','); features.require(feat); } } else features.addPreambleSnippet(mathpreamble); } } // with utf8-plain, we do not load packages (see #7766) if (use_text && !plain_utf8) { string const textpreamble = ci.textpreamble(); if (!textpreamble.empty()) { if (ci.textfeature()) { string feats = textpreamble; while (!feats.empty()) { string feat; feats = split(feats, feat, ','); features.require(feat); } } else features.addPreambleSnippet(textpreamble); } } } if (for_mathed && isMathSym(c)) { features.require("amstext"); features.require("lyxmathsym"); } }
void InsetMathSymbol::validate(LaTeXFeatures & features) const { // this is not really the ideal place to do this, but we can't // validate in InsetMathExInt. if (features.runparams().math_flavor == OutputParams::MathAsHTML && sym_->name == from_ascii("int")) { features.addCSSSnippet( "span.limits{display: inline-block; vertical-align: middle; text-align:center; font-size: 75%;}\n" "span.limits span{display: block;}\n" "span.intsym{font-size: 150%;}\n" "sub.limit{font-size: 75%;}\n" "sup.limit{font-size: 75%;}"); } else { if (!sym_->requires.empty()) features.require(sym_->requires); } }
void InsetNote::validate(LaTeXFeatures & features) const { switch (params_.type) { case InsetNoteParams::Comment: features.require("verbatim"); if (features.runparams().flavor == OutputParams::HTML) // we do output this but set display to "none" by default, // but people might want to use it. InsetCollapsable::validate(features); break; case InsetNoteParams::Greyedout: features.require("color"); features.require("lyxgreyedout"); InsetCollapsable::validate(features); break; case InsetNoteParams::Note: break; } }
void InsetMathPhantom::validate(LaTeXFeatures & features) const { InsetMathNest::validate(features); switch (kind_) { case phantom: case vphantom: case hphantom: case smash: break; case smasht: case smashb: features.require("amsmath"); break; case mathclap: case mathllap: case mathrlap: features.require("mathtools"); break; } }
void InsetMathDelim::validate(LaTeXFeatures & features) const { InsetMathNest::validate(features); // The delimiters may be used without \left or \right as well. // Therefore they are listed in lib/symbols, and if they have // requirements, we need to add them here. MathWordList const & words = mathedWordList(); MathWordList::const_iterator it = words.find(left_); if (it != words.end()) { docstring const req = it->second.requires; if (!req.empty()) features.require(to_ascii(req)); } it = words.find(right_); if (it != words.end()) { docstring const req = it->second.requires; if (!req.empty()) features.require(to_ascii(req)); } }
void InsetMathXYMatrix::validate(LaTeXFeatures & features) const { features.require("xy"); InsetMathGrid::validate(features); }