images/math/mathcal_L.png \
images/math/mathcal_O.png \
images/math/mathcircumflex.png \
+ images/math/mathclap.png \
+ images/math/mathllap.png \
+ images/math/mathrlap.png \
images/math/mathrm_T.png \
images/math/matrix.png \
images/math/measuredangle.png \
images/math/smallfrown.png \
images/math/smallsetminus.png \
images/math/smallsmile.png \
+ images/math/smash.png \
images/math/smile.png \
images/math/space.png \
images/math/spadesuit.png \
" Load mathdots automatically "
i = find_token(document.header, "\\use_mhchem" , 0)
if i == -1:
- i = find_token(document.header, "\\use_esint" , 0)
- if i != -1:
- document.header.insert(i + 1, "\\use_mathdots 1")
+ i = find_token(document.header, "\\use_esint" , 0)
+ if i == -1:
+ document.warning("Malformed LyX document: Can't find \\use_mhchem.")
+ return;
+ j = find_token(document.preamble, "\\usepackage{mathdots}", 0)
+ if j == -1:
+ document.header.insert(i + 1, "\\use_mathdots 0")
+ else:
+ document.header.insert(i + 1, "\\use_mathdots 2")
+ del document.preamble[j]
def revert_mathdots(document):
def convert_undertilde(document):
" Load undertilde automatically "
i = find_token(document.header, "\\use_mathdots" , 0)
- if i != -1:
- document.header.insert(i + 1, "\\use_undertilde 1")
+ if i == -1:
+ i = find_token(document.header, "\\use_mhchem" , 0)
+ if i == -1:
+ i = find_token(document.header, "\\use_esint" , 0)
+ if i == -1:
+ document.warning("Malformed LyX document: Can't find \\use_mathdots.")
+ return;
+ j = find_token(document.preamble, "\\usepackage{undertilde}", 0)
+ if j == -1:
+ document.header.insert(i + 1, "\\use_undertilde 0")
+ else:
+ document.header.insert(i + 1, "\\use_undertilde 2")
+ del document.preamble[j]
def revert_undertilde(document):
if i == -1:
document.warning("Malformed LyX document: Can't find \\use_package.")
return;
- document.header.insert(i + 1, "\\use_package mathtools 0")
+ j = find_token(document.preamble, "\\usepackage{mathtools}", 0)
+ if j == -1:
+ document.header.insert(i + 1, "\\use_package mathtools 0")
+ else:
+ document.header.insert(i + 1, "\\use_package mathtools 2")
+ del document.preamble[j]
def revert_use_mathtools(document):
if value == "2": # on
add_to_preamble(document, ["\\usepackage{mathtools}"])
elif value == "1": # auto
- commands = ["lgathered", "rgathered", "vcentcolon", "dblcolon", \
+ commands = ["mathclap", "mathllap", "mathrlap", \
+ "lgathered", "rgathered", "vcentcolon", "dblcolon", \
"coloneqq", "Coloneqq", "coloneq", "Coloneq", "eqqcolon", \
"Eqqcolon", "eqcolon", "Eqcolon", "colonapprox", \
"Colonapprox", "colonsim", "Colonsim"]
Item "Phantom \\phantom" "math-insert \phantom"
Item "Horizontal phantom \\hphantom" "math-insert \hphantom"
Item "Vertical phantom \\vphantom" "math-insert \vphantom"
+ Item "Smash \\smash" "math-insert \smash"
+ Item "Left overlap \\mathllap" "math-insert \mathllap"
+ Item "Center overlap \\mathclap" "math-insert \mathclap"
+ Item "Right overlap \\mathrlap" "math-insert \mathrlap"
End
Toolbar "sqrt-square" "Roots"
packages << "\\PassOptionsToPackage{normalem}{ulem}\n"
"\\usepackage{ulem}\n";
- if (params_.use_package("mhchem") == BufferParams::package_on ||
- (mustProvide("mhchem") &&
- params_.use_package("mhchem") != BufferParams::package_off))
+ if (mustProvide("mhchem") &&
+ params_.use_package("mhchem") != BufferParams::package_off)
packages << "\\PassOptionsToPackage{version=3}{mhchem}\n"
"\\usepackage{mhchem}\n";
LexerKeyword textClassTags[] = {
{ "addtohtmlpreamble", TC_ADDTOHTMLPREAMBLE },
- { "addtohtmlstyles", TC_ADDTOHTMLSTYLES },
+ { "addtohtmlstyles", TC_ADDTOHTMLSTYLES },
{ "addtopreamble", TC_ADDTOPREAMBLE },
{ "citeformat", TC_CITEFORMAT },
{ "classoptions", TC_CLASSOPTIONS },
{ "float", TC_FLOAT },
{ "format", TC_FORMAT },
{ "htmlpreamble", TC_HTMLPREAMBLE },
- { "htmlstyles", TC_HTMLSTYLES },
+ { "htmlstyles", TC_HTMLSTYLES },
{ "htmltocsection", TC_HTMLTOCSECTION },
{ "ifcounter", TC_IFCOUNTER },
{ "ifstyle", TC_IFSTYLE },
globals.push_back(from_ascii("\\hphantom"));
globals.push_back(from_ascii("\\phantom"));
globals.push_back(from_ascii("\\vphantom"));
+ globals.push_back(from_ascii("\\smash"));
+ globals.push_back(from_ascii("\\mathclap"));
+ globals.push_back(from_ascii("\\mathllap"));
+ globals.push_back(from_ascii("\\mathrlap"));
MathWordList const & words = mathedWordList();
MathWordList::const_iterator it2;
//lyxerr << "Globals completion commands: ";
#include "InsetMathPhantom.h"
+#include "LaTeXFeatures.h"
#include "MathStream.h"
#include "frontends/Painter.h"
// We first draw the text and then an arrow
ColorCode const origcol = pi.base.font.color();
- pi.base.font.setColor(Color_special);
+ if (visibleContents())
+ pi.base.font.setColor(Color_special);
cell(0).draw(pi, x + 1, y);
- pi.base.font.setColor(origcol);
+ if (visibleContents())
+ pi.base.font.setColor(origcol);
Dimension const dim = dimension(*pi.base.bv);
if (kind_ == phantom || kind_ == vphantom) {
}
if (kind_ == phantom || kind_ == hphantom) {
- // y1---- / \.
+ // y1---- / \.
// / \.
// y2--- <---------------->
// \ /
- // y3---- \ /
- // | | | |
- // x1 x2 x3 x4
+ // y3---- \ /
+ // | | | |
+ // x1 x2 x3 x4
int const x1 = x;
int const x2 = x + arrow_size;
pi.pain.line(x1, y2, x4, y2, Color_added_space);
}
+ else if (kind_ == mathclap) {
+ // y1---- \ /
+ // \ /
+ // y2--- -------->-<--------
+ // / \.
+ // y3---- / \.
+ // | | | | |
+ // x1 x2 x3 x4 x5
+
+ int const x1 = x;
+ int const x5 = x + dim.wid;
+ int const x3 = x + dim.wid / 2;
+ int const x2 = std::max(x1, x3 - arrow_size);
+ int const x4 = std::min(x5, x3 + arrow_size);
+
+ int const y2 = y + (dim.des - dim.asc) / 2;
+ int const y1 = y2 - arrow_size;
+ int const y3 = y2 + arrow_size;
+
+ // left arrow
+ pi.pain.line(x2, y3, x3, y2, Color_added_space);
+ pi.pain.line(x2, y1, x3, y2, Color_added_space);
+
+ // right arrow
+ pi.pain.line(x4, y3, x3, y2, Color_added_space);
+ pi.pain.line(x4, y1, x3, y2, Color_added_space);
+
+ // joining line
+ pi.pain.line(x1, y2, x5, y2, Color_added_space);
+ }
+
+ else if (kind_ == mathllap) {
+ // y1---- \.
+ // \.
+ // y2--- ------------------>
+ // /
+ // y3---- /
+ // | | |
+ // x1 x2 x3
+
+ int const x1 = x;
+ int const x3 = x + dim.wid;
+ int const x2 = std::max(x1, x3 - arrow_size);
+
+ int const y2 = y + (dim.des - dim.asc) / 2;
+ int const y1 = y2 - arrow_size;
+ int const y3 = y2 + arrow_size;
+
+ // right arrow
+ pi.pain.line(x3, y2, x2, y3, Color_added_space);
+ pi.pain.line(x3, y2, x2, y1, Color_added_space);
+
+ // joining line
+ pi.pain.line(x1, y2, x3, y2, Color_added_space);
+ }
+
+ else if (kind_ == mathrlap) {
+ // y1---- /
+ // /
+ // y2--- <------------------
+ // \.
+ // y3---- \.
+ // | | |
+ // x1 x2 x3
+
+ int const x1 = x;
+ int const x3 = x + dim.wid;
+ int const x2 = std::min(x3, x + arrow_size);
+
+ int const y2 = y + (dim.des - dim.asc) / 2;
+ int const y1 = y2 - arrow_size;
+ int const y3 = y2 + arrow_size;
+
+ // left arrow
+ pi.pain.line(x1, y2, x2, y3, Color_added_space);
+ pi.pain.line(x1, y2, x2, y1, Color_added_space);
+
+ // joining line
+ pi.pain.line(x1, y2, x3, y2, Color_added_space);
+ }
+
+ else if (kind_ == smash) {
+ // y1---------
+ // |
+ // y2----- \ | /
+ // \ /
+ // y3-------- |
+ // / \.
+ // y4----- / | \.
+ // |
+ // y5---------
+ // | | |
+ // / | \.
+ // x1 x2 x3
+
+ int const x2 = x + dim.wid / 2;
+ int const x1 = x2 - arrow_size;
+ int const x3 = x2 + arrow_size;
+
+ int const y1 = y - dim.asc;
+ int const y5 = y + dim.des;
+ int const y3 = y;
+ int const y2 = std::max(y1, y3 - arrow_size);
+ int const y4 = std::min(y5, y3 + arrow_size);
+
+ // top arrow
+ pi.pain.line(x1, y2, x2, y3, Color_added_space);
+ pi.pain.line(x3, y2, x2, y3, Color_added_space);
+
+ // bottom arrow
+ pi.pain.line(x1, y4, x2, y3, Color_added_space);
+ pi.pain.line(x3, y4, x2, y3, Color_added_space);
+
+ // joining line
+ pi.pain.line(x2, y1, x2, y5, Color_added_space);
+ }
+
drawMarkers(pi, x, y);
}
case hphantom:
os << "\\hphantom{";
break;
+ case smash:
+ os << "\\smash{";
+ break;
+ case mathclap:
+ os << "\\mathclap{";
+ break;
+ case mathllap:
+ os << "\\mathllap{";
+ break;
+ case mathrlap:
+ os << "\\mathrlap{";
+ break;
}
os << cell(0) << '}';
}
case hphantom:
os << "[hphantom ";
break;
+ case smash:
+ os << "[smash ";
+ break;
+ case mathclap:
+ os << "[mathclap ";
+ break;
+ case mathllap:
+ os << "[mathllap ";
+ break;
+ case mathrlap:
+ os << "[mathrlap ";
+ break;
}
os << cell(0) << ']';
}
case hphantom:
os << "Hphantom";
break;
+ case smash:
+ os << "Smash";
+ break;
+ case mathllap:
+ os << "Mathllap";
+ break;
+ case mathclap:
+ os << "Mathclap";
+ break;
+ case mathrlap:
+ os << "Mathrlap";
+ break;
+ }
+}
+
+
+void InsetMathPhantom::validate(LaTeXFeatures & features) const
+{
+ InsetMathNest::validate(features);
+ switch (kind_) {
+ case phantom:
+ case vphantom:
+ case hphantom:
+ case smash:
+ break;
+ case mathclap:
+ case mathllap:
+ case mathrlap:
+ features.require("mathtools");
+ break;
}
}
+bool InsetMathPhantom::visibleContents() const
+{
+ return kind_ == phantom || kind_ == vphantom || kind_ == vphantom;
+}
+
+
} // namespace lyx
enum Kind {
phantom,
vphantom,
- hphantom
+ hphantom,
+ smash,
+ mathclap,
+ mathllap,
+ mathrlap
};
///
explicit InsetMathPhantom(Buffer * buf, Kind);
void mathmlize(MathStream &) const {}
/// Nothing for HTML
void htmlize(HtmlStream &) const {}
+ /// request "external features"
+ void validate(LaTeXFeatures & features) const;
+ /// Does the contents appear in LaTeX output?
+ bool visibleContents() const;
private:
///
return MathAtom(new InsetMathPhantom(buf, InsetMathPhantom::phantom));
if (s == "vphantom")
return MathAtom(new InsetMathPhantom(buf, InsetMathPhantom::vphantom));
+ if (s == "smash")
+ return MathAtom(new InsetMathPhantom(buf, InsetMathPhantom::smash));
+ if (s == "mathclap")
+ return MathAtom(new InsetMathPhantom(buf, InsetMathPhantom::mathclap));
+ if (s == "mathllap")
+ return MathAtom(new InsetMathPhantom(buf, InsetMathPhantom::mathllap));
+ if (s == "mathrlap")
+ return MathAtom(new InsetMathPhantom(buf, InsetMathPhantom::mathrlap));
if (s == "ensuremath")
return MathAtom(new InsetMathEnsureMath(buf));
if (isSpecialChar(s))