This is a tight matrix in script size that is suitable for using inline.
Patch from our own Martin Vermeer and myself.
* \li Syntax: math-matrix <COLS> <ROWS> [<DECORATION>]
* \li Params: <DECORATION>: Decoration determines the LaTeX name of the matrix
that should be created. Possible values include
- pmatrix, bmatrix, Bmatrix, vmatrix, Vmatrix and
+ pmatrix, bmatrix, Bmatrix, vmatrix, Vmatrix, smallmatrix, and
matrix. The default is 'matrix'.
* \li Sample: math-ams-matrix 3 3 bmatrix
* \endvar
}
-Changer MetricsBase::changeArray()
+Changer MetricsBase::changeArray(bool small)
{
+ if (small)
+ return font.changeStyle(SCRIPT_STYLE);
return (font.style() == DISPLAY_STYLE) ? font.changeStyle(TEXT_STYLE)
: Changer();
}
// Temporarily change to the style suitable for use in fractions
Changer changeFrac();
// Temporarily change to the style suitable for use in arrays
- Changer changeArray();
+ // or to style suitable for smallmatrix when \c small is true.
+ Changer changeArray(bool small = false);
// Temporarily change the style to (script)script style
Changer changeScript();
///
N_("{x}"),
N_("|x|"),
N_("||x||"),
+ N_("small"),
""
};
N_("Bmatrix"),
N_("vmatrix"),
N_("Vmatrix"),
+ N_("smallmatrix"),
""
};
<item row="3" column="2">
<widget class="QGroupBox" name="decorationtGB">
<property name="title">
- <string>Decoration</string>
+ <string>Appearance</string>
</property>
<property name="flat">
<bool>true</bool>
}
+int InsetMathAMSArray::rowsep() const
+{
+ return small() ? 0 : InsetMathGrid::rowsep();
+}
+
+
+int InsetMathAMSArray::colsep() const
+{
+ return small() ? InsetMathGrid::colsep() / 2 : InsetMathGrid::colsep();
+}
+
+
+int InsetMathAMSArray::border() const
+{
+ return small() ? 0 : InsetMathGrid::border();
+}
+
+
void InsetMathAMSArray::metrics(MetricsInfo & mi, Dimension & dim) const
{
Changer dummy2 = mi.base.changeEnsureMath();
- Changer dummy = mi.base.changeArray();
+ Changer dummy = mi.base.changeArray(small());
InsetMathGrid::metrics(mi, dim);
}
void InsetMathAMSArray::draw(PainterInfo & pi, int x, int y) const
{
Changer dummy2 = pi.base.changeEnsureMath();
- Dimension const dim = dimension(*pi.base.bv);
- int const yy = y - dim.ascent();
- // Drawing the deco after changeStyle does not work
- mathed_draw_deco(pi, x + 1, yy, 5, dim.height(), from_ascii(name_left()));
- mathed_draw_deco(pi, x + dim.width() - 8, yy, 5, dim.height(), from_ascii(name_right()));
- Changer dummy = pi.base.changeArray();
+ if (name_ != "smallmatrix") {
+ Dimension const dim = dimension(*pi.base.bv);
+ int const yy = y - dim.ascent();
+ // Drawing the deco after changeStyle does not work
+ mathed_draw_deco(pi, x + 1, yy, 5, dim.height(), from_ascii(name_left()));
+ mathed_draw_deco(pi, x + dim.width() - 8, yy, 5, dim.height(), from_ascii(name_right()));
+ }
+ Changer dummy = pi.base.changeArray(small());
InsetMathGrid::draw(pi, x, y);
}
///
InsetMathAMSArray(Buffer * buf, docstring const &, int m, int n);
///
- InsetMathAMSArray(Buffer * buf, docstring const &);
+ InsetMathAMSArray(Buffer * buf, docstring const &); ///
+
+ ///
+ int rowsep() const;
+ ///
+ int colsep() const;
+ ///
+ int border() const;
///
void metrics(MetricsInfo & mi, Dimension & dim) const;
///
///
char const * name_right() const;
///
- int leftMargin() const { return 6; } //override
+ int leftMargin() const { return small() ? 3 : 6; } //override
///
- int rightMargin() const { return 8; } //override
+ int rightMargin() const { return small() ? 3: 6; } //override
///
bool handlesMulticolumn() const { return true; } //override
private:
virtual Inset * clone() const;
///
+ bool small() const { return name_ == "smallmatrix"; }
+ ///
docstring name_;
};
// check if we have a valid decoration
if (name != "pmatrix" && name != "bmatrix"
&& name != "Bmatrix" && name != "vmatrix"
- && name != "Vmatrix" && name != "matrix")
+ && name != "Vmatrix" && name != "matrix"
+ && name != "smallmatrix")
name = from_ascii("matrix");
cur.niceInsert(