-----------------------
+2013-05-27 Georg Baum <Georg.Baum@post.rwth-aachen.de>
+ * Format incremented to 476
+ Native support for \smash[t] and \smash[b] with automatic amsmath
+ loading
+
2014-05-05 Enrico Forestieri <forenr@lyx.org>
* Format incremented to 475
New Separator insets. The parbreak separator introduces a LaTeX
images/math/smallsetminus.png \
images/math/smallsmile.png \
images/math/smash.png \
+ images/math/smashb.png \
+ images/math/smasht.png \
images/math/smile.png \
images/math/smiley.png \
images/math/space.png \
("1_6", range(277,346), minor_versions("1.6" , 10)),
("2_0", range(346,414), minor_versions("2.0", 8)),
("2_1", range(414,475), minor_versions("2.1", 0)),
- ("2_2", range(475,476), minor_versions("2.2", 0))
+ ("2_2", range(475,477), minor_versions("2.2", 0))
]
####################################################################
i = i + 1
+def revert_smash(document):
+ " Set amsmath to on if smash commands are used "
+
+ commands = ["smash[t]", "smash[b]"]
+ i = find_token(document.header, "\\use_package amsmath", 0)
+ if i == -1:
+ document.warning("Malformed LyX document: Can't find \\use_package amsmath.")
+ return;
+ value = get_value(document.header, "\\use_package amsmath", i).split()[1]
+ if value != "1":
+ # nothing to do if package is not auto but on or off
+ return;
+ j = 0
+ while True:
+ j = find_token(document.body, '\\begin_inset Formula', j)
+ if j == -1:
+ return
+ k = find_end_of_inset(document.body, j)
+ if k == -1:
+ document.warning("Malformed LyX document: Can't find end of Formula inset at line " + str(j))
+ j += 1
+ continue
+ code = "\n".join(document.body[j:k])
+ for c in commands:
+ if code.find("\\%s" % c) != -1:
+ # set amsmath to on, since it is loaded by the newer format
+ document.header[i] = "\\use_package amsmath 2"
+ return
+ j = k
+
+
##
# Conversion hub
#
supported_versions = ["2.2.0","2.2"]
convert = [
[475, [convert_separator]],
+ # nothing to do for 476: We consider it a bug that older versions
+ # did not load amsmath automatically for these commands, and do not
+ # want to hardcode amsmath off.
+ [476, []],
]
revert = [
+ [475, [revert_smash]],
[474, [revert_separator]]
]
Item "Horizontal phantom \\hphantom" "math-insert \hphantom"
Item "Vertical phantom \\vphantom" "math-insert \vphantom"
Item "Smash \\smash" "math-insert \smash"
+ Item "Top smash \\smasht" "math-insert \smasht"
+ Item "Bottom smash \\smashb" "math-insert \smashb"
Item "Left overlap \\mathllap" "math-insert \mathllap"
Item "Center overlap \\mathclap" "math-insert \mathclap"
Item "Right overlap \\mathrlap" "math-insert \mathrlap"
pi.pain.line(x1, y2, x3, y2, Color_added_space);
}
- else if (kind_ == smash) {
+ else if (kind_ == smash || kind_ == smasht || kind_ == smashb) {
// y1---------
// |
// y2----- \ | /
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);
+ if (kind_ != smashb) {
+ 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);
+ if (kind_ != smasht) {
+ 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);
+ if (kind_ == smasht)
+ pi.pain.line(x2, y1, x2, y3, Color_added_space);
+ else if (kind_ == smashb)
+ pi.pain.line(x2, y3, x2, y5, Color_added_space);
+ else
+ pi.pain.line(x2, y1, x2, y5, Color_added_space);
}
drawMarkers(pi, x, y);
case smash:
os << "\\smash{";
break;
+ case smasht:
+ os << "\\smash[t]{";
+ break;
+ case smashb:
+ os << "\\smash[b]{";
+ break;
case mathclap:
os << "\\mathclap{";
break;
case smash:
os << "[smash ";
break;
+ case smasht:
+ os << "[smasht ";
+ break;
+ case smashb:
+ os << "[smashb ";
+ break;
case mathclap:
os << "[mathclap ";
break;
case smash:
os << "Smash";
break;
+ case smasht:
+ os << "Smashtop";
+ break;
+ case smashb:
+ os << "Smashbottom";
+ break;
case mathllap:
os << "Mathllap";
break;
case hphantom:
case smash:
break;
+ case smasht:
+ case smashb:
+ features.require("amsmath");
+ break;
case mathclap:
case mathllap:
case mathrlap:
vphantom,
hphantom,
smash,
+ smasht,
+ smashb,
mathclap,
mathllap,
mathrlap
return MathAtom(new InsetMathCancelto(buf));
if (s == "smash")
return MathAtom(new InsetMathPhantom(buf, InsetMathPhantom::smash));
+ // The following 2 string values are only for math toolbar use, no LaTeX names
+ if (s == "smashb")
+ return MathAtom(new InsetMathPhantom(buf, InsetMathPhantom::smashb));
+ if (s == "smasht")
+ return MathAtom(new InsetMathPhantom(buf, InsetMathPhantom::smasht));
if (s == "mathclap")
return MathAtom(new InsetMathPhantom(buf, InsetMathPhantom::mathclap));
if (s == "mathllap")
skipSpaces();
if (nextToken().asInput() == "[") {
// Since the phantom inset cannot handle optional arguments
- // we must not create an InsetMathPhantom (bug 8967).
+ // other than b and t, we must not create an InsetMathPhantom
+ // if opt is different from b and t (bug 8967).
docstring const opt = parse_verbatim_option();
- docstring const arg = parse_verbatim_item();
- cell->push_back(MathAtom(new MathMacro(buf, t.cs())));
- MathData ar;
- mathed_parse_cell(ar, '[' + opt + ']', mode_);
- cell->append(ar);
- ar = MathData();
- mathed_parse_cell(ar, '{' + arg + '}', mode_);
- cell->append(ar);
+ if (opt == "t" || opt == "b") {
+ cell->push_back(createInsetMath(t.cs() + opt, buf));
+ parse(cell->back().nucleus()->cell(0), FLAG_ITEM, mode);
+ } else {
+ docstring const arg = parse_verbatim_item();
+ cell->push_back(MathAtom(new MathMacro(buf, t.cs())));
+ MathData ar;
+ mathed_parse_cell(ar, '[' + opt + ']', mode_);
+ cell->append(ar);
+ ar = MathData();
+ mathed_parse_cell(ar, '{' + arg + '}', mode_);
+ cell->append(ar);
+ }
}
else {
cell->push_back(createInsetMath(t.cs(), buf));
#LyX file created by tex2lyx 2.2
-\lyxformat 475
+\lyxformat 476
\begin_document
\begin_header
\textclass article
#LyX file created by tex2lyx 2.2
-\lyxformat 475
+\lyxformat 476
\begin_document
\begin_header
\textclass article
#LyX file created by tex2lyx 2.2
-\lyxformat 475
+\lyxformat 476
\begin_document
\begin_header
\textclass article
#LyX file created by tex2lyx 2.2
-\lyxformat 475
+\lyxformat 476
\begin_document
\begin_header
\textclass article
#LyX file created by tex2lyx 2.2
-\lyxformat 475
+\lyxformat 476
\begin_document
\begin_header
\textclass article
#LyX file created by tex2lyx 2.2
-\lyxformat 475
+\lyxformat 476
\begin_document
\begin_header
\textclass article
#LyX file created by tex2lyx 2.2
-\lyxformat 475
+\lyxformat 476
\begin_document
\begin_header
\textclass article
#LyX file created by tex2lyx 2.2
-\lyxformat 475
+\lyxformat 476
\begin_document
\begin_header
\textclass article
#LyX file created by tex2lyx 2.2
-\lyxformat 475
+\lyxformat 476
\begin_document
\begin_header
\textclass amsart
#LyX file created by tex2lyx 2.2
-\lyxformat 475
+\lyxformat 476
\begin_document
\begin_header
\textclass book
#LyX file created by tex2lyx 2.2
-\lyxformat 475
+\lyxformat 476
\begin_document
\begin_header
\textclass article
#LyX file created by tex2lyx 2.2
-\lyxformat 475
+\lyxformat 476
\begin_document
\begin_header
\textclass article
#LyX file created by tex2lyx 2.2
-\lyxformat 475
+\lyxformat 476
\begin_document
\begin_header
\textclass article
// Do not remove the comment below, so we get merge conflict in
// independent branches. Instead add your own.
-#define LYX_FORMAT_LYX 475 // ef: new separator inset
-#define LYX_FORMAT_TEX2LYX 475
+#define LYX_FORMAT_LYX 476 // gb: \smash[t] and \smash[b]
+#define LYX_FORMAT_TEX2LYX 476
#if LYX_FORMAT_TEX2LYX != LYX_FORMAT_LYX
#ifndef _MSC_VER