diff --git a/doc/dox/whatsnew.dox b/doc/dox/whatsnew.dox index 73b292c3c1..163b557d32 100644 --- a/doc/dox/whatsnew.dox +++ b/doc/dox/whatsnew.dox @@ -55,9 +55,11 @@ Changes, compared to \ref page_whatsnew_V2018_08 "v2018.08" include:
  • Updates to JKQTMathText:
  • diff --git a/doc/images/mathparser/MTDarrow.png b/doc/images/mathparser/MTDarrow.png new file mode 100644 index 0000000000..8a4607f618 Binary files /dev/null and b/doc/images/mathparser/MTDarrow.png differ diff --git a/doc/images/mathparser/MTDbar.png b/doc/images/mathparser/MTDbar.png new file mode 100644 index 0000000000..287a6e3ed6 Binary files /dev/null and b/doc/images/mathparser/MTDbar.png differ diff --git a/doc/images/mathparser/MTDddot.png b/doc/images/mathparser/MTDddot.png new file mode 100644 index 0000000000..ed00b48b28 Binary files /dev/null and b/doc/images/mathparser/MTDddot.png differ diff --git a/doc/images/mathparser/MTDdot.png b/doc/images/mathparser/MTDdot.png new file mode 100644 index 0000000000..8eb1493a63 Binary files /dev/null and b/doc/images/mathparser/MTDdot.png differ diff --git a/doc/images/mathparser/MTDdoubleoverline.png b/doc/images/mathparser/MTDdoubleoverline.png new file mode 100644 index 0000000000..09636bd0fa Binary files /dev/null and b/doc/images/mathparser/MTDdoubleoverline.png differ diff --git a/doc/images/mathparser/MTDdoubleunderline.png b/doc/images/mathparser/MTDdoubleunderline.png new file mode 100644 index 0000000000..8f5d9b1e6b Binary files /dev/null and b/doc/images/mathparser/MTDdoubleunderline.png differ diff --git a/doc/images/mathparser/MTDhat.png b/doc/images/mathparser/MTDhat.png new file mode 100644 index 0000000000..8ca1bfe277 Binary files /dev/null and b/doc/images/mathparser/MTDhat.png differ diff --git a/doc/images/mathparser/MTDoverline.png b/doc/images/mathparser/MTDoverline.png new file mode 100644 index 0000000000..75005713e7 Binary files /dev/null and b/doc/images/mathparser/MTDoverline.png differ diff --git a/doc/images/mathparser/MTDtilde.png b/doc/images/mathparser/MTDtilde.png new file mode 100644 index 0000000000..0ef0850756 Binary files /dev/null and b/doc/images/mathparser/MTDtilde.png differ diff --git a/doc/images/mathparser/MTDunderline.png b/doc/images/mathparser/MTDunderline.png new file mode 100644 index 0000000000..d30707b442 Binary files /dev/null and b/doc/images/mathparser/MTDunderline.png differ diff --git a/doc/images/mathparser/MTDvec.png b/doc/images/mathparser/MTDvec.png new file mode 100644 index 0000000000..f2f6c52bab Binary files /dev/null and b/doc/images/mathparser/MTDvec.png differ diff --git a/doc/images/mathparser/MTFMdfrac.png b/doc/images/mathparser/MTFMdfrac.png new file mode 100644 index 0000000000..009d4d8fc7 Binary files /dev/null and b/doc/images/mathparser/MTFMdfrac.png differ diff --git a/doc/images/mathparser/MTFMfrac.png b/doc/images/mathparser/MTFMfrac.png new file mode 100644 index 0000000000..5f14158a9c Binary files /dev/null and b/doc/images/mathparser/MTFMfrac.png differ diff --git a/doc/images/mathparser/MTFMoverbrace.png b/doc/images/mathparser/MTFMoverbrace.png new file mode 100644 index 0000000000..dfa45e4324 Binary files /dev/null and b/doc/images/mathparser/MTFMoverbrace.png differ diff --git a/doc/images/mathparser/MTFMoverset.png b/doc/images/mathparser/MTFMoverset.png new file mode 100644 index 0000000000..6e58eee22f Binary files /dev/null and b/doc/images/mathparser/MTFMoverset.png differ diff --git a/doc/images/mathparser/MTFMsfrac.png b/doc/images/mathparser/MTFMsfrac.png new file mode 100644 index 0000000000..c841f87a94 Binary files /dev/null and b/doc/images/mathparser/MTFMsfrac.png differ diff --git a/doc/images/mathparser/MTFMstackrel.png b/doc/images/mathparser/MTFMstackrel.png new file mode 100644 index 0000000000..ba6d4da2c9 Binary files /dev/null and b/doc/images/mathparser/MTFMstackrel.png differ diff --git a/doc/images/mathparser/MTFMstfrac.png b/doc/images/mathparser/MTFMstfrac.png new file mode 100644 index 0000000000..a27d81fd53 Binary files /dev/null and b/doc/images/mathparser/MTFMstfrac.png differ diff --git a/doc/images/mathparser/MTFMtfrac.png b/doc/images/mathparser/MTFMtfrac.png new file mode 100644 index 0000000000..4eda9a8b7f Binary files /dev/null and b/doc/images/mathparser/MTFMtfrac.png differ diff --git a/doc/images/mathparser/MTFMunderbrace.png b/doc/images/mathparser/MTFMunderbrace.png new file mode 100644 index 0000000000..6b98f5cd4e Binary files /dev/null and b/doc/images/mathparser/MTFMunderbrace.png differ diff --git a/doc/images/mathparser/MTFMunderset.png b/doc/images/mathparser/MTFMunderset.png new file mode 100644 index 0000000000..720236cc3b Binary files /dev/null and b/doc/images/mathparser/MTFMunderset.png differ diff --git a/examples/jkqtmathtext_test/testform.cpp b/examples/jkqtmathtext_test/testform.cpp index 7489aa2165..1e83ac55f6 100644 --- a/examples/jkqtmathtext_test/testform.cpp +++ b/examples/jkqtmathtext_test/testform.cpp @@ -69,6 +69,9 @@ TestForm::TestForm(QWidget *parent) : ui->cmbTestset->addItem("frac test", "$\\frac{a}{b}+\\frac{g}{a}-\\frac{a^2}{b^2}\\cdot\\frac{a^2}{b^{\\frac{1}{2}}}$"); ui->cmbTestset->addItem("tfrac test", "$\\tfrac{a}{b}+\\tfrac{g}{a}-\\tfrac{a^2}{b^2}\\cdot\\tfrac{a^2}{b^{\\tfrac{1}{2}}}$"); ui->cmbTestset->addItem("dfrac test", "$\\dfrac{a}{b}+\\dfrac{g}{a}-\\dfrac{a^2}{b^2}\\cdot\\dfrac{a^2}{b^{\\dfrac{1}{2}}}$"); + ui->cmbTestset->addItem("sfrac test", "$\\sfrac{a}{b}+\\sfrac{g}{a}-\\sfrac{a^2}{b^2}\\cdot\\sfrac{a^2}{b^{\\sfrac{1}{2}}}$"); + ui->cmbTestset->addItem("stfrac test", "$\\stfrac{a}{b}+\\stfrac{g}{a}-\\stfrac{a^2}{b^2}\\cdot\\stfrac{a^2}{b^{\\stfrac{1}{2}}}$"); + ui->cmbTestset->addItem("number fractions test", "frac: \\frac{1}{2}, \\frac{3}{4},\\ \\ \\ tfrac: \\tfrac{1}{2}, \\tfrac{3}{4},\\ \\ \\ sfrac: \\sfrac{1}{2}, \\sfrac{3}{4},\\ \\ \\ stfrac: \\stfrac{1}{2}, \\stfrac{3}{4},\\ \\ \\ "); ui->cmbTestset->addItem("stackrel test", "$\\stackrel{a}{b}+\\stackrel{g}{a}-\\stackrel{a^2}{b^2}\\cdot\\stackrel{a^2}{b^{\\stackrel{1}{2}}}$"); ui->cmbTestset->addItem("brace0 test", "\\langle\\langle -- $\\langle\\langle$"); ui->cmbTestset->addItem("brace1 test", "\\langle\\langle r^{123} -- $\\langle\\langle r^{123}$"); diff --git a/lib/jkqtmathtext/jkqtmathtext.cpp b/lib/jkqtmathtext/jkqtmathtext.cpp index 8d5033ae64..08caf0ff02 100644 --- a/lib/jkqtmathtext/jkqtmathtext.cpp +++ b/lib/jkqtmathtext/jkqtmathtext.cpp @@ -742,10 +742,10 @@ void JKQTMathText::MTfracNode::getSizeInternal(QPainter& painter, JKQTMathText:: ev2.fontSize=ev2.fontSize*parent->getUnderbraceFactor(); } else if (mode==MTFMunderset || mode==MTFMoverset) { ev2.fontSize=ev2.fontSize*parent->getUndersetFactor(); - } else if (mode==MTFMfrac) { + } else if (mode==MTFMfrac || mode==MTFMsfrac) { ev1.fontSize=ev1.fontSize*parent->getFracFactor(); ev2.fontSize=ev2.fontSize*parent->getFracFactor(); - } else if (mode==MTFMtfrac) { + } else if (mode==MTFMtfrac || mode==MTFMstfrac) { ev1.fontSize=ev1.fontSize*parent->getFracFactor()*0.7; ev2.fontSize=ev2.fontSize*parent->getFracFactor()*0.7; } @@ -770,6 +770,11 @@ void JKQTMathText::MTfracNode::getSizeInternal(QPainter& painter, JKQTMathText:: //std::cout<<"=> baselineHeight="<addNode(new MTfracNode(this, n1, n2, MTFMsfrac)); + else error_list.append(tr("error @ ch. %1: expected two arguments in '{' braces after '%2' command").arg(currentTokenID).arg(name)); + } else if (name=="stfrac" || name=="nicefrac" || name=="slanttextfrac" || name=="xtfrac") { + MTnode* n1=parseLatexString(true); + MTnode* n2=nullptr; + if (getToken()==MTTopenbrace) n2=parseLatexString(true); + if (n1 && n2) nl->addNode(new MTfracNode(this, n1, n2, MTFMstfrac)); + else error_list.append(tr("error @ ch. %1: expected two arguments in '{' braces after '%2' command").arg(currentTokenID).arg(name)); } else if (name=="tfrac") { MTnode* n1=parseLatexString(true); MTnode* n2=nullptr; @@ -4257,6 +4281,10 @@ QString JKQTMathText::fracModeToString(JKQTMathText::MTfracMode mode) return "frac"; case MTFMdfrac: return "dfrac"; + case MTFMsfrac: + return "sfrac"; + case MTFMstfrac: + return "stfrac"; case MTFMtfrac: return "tfrac"; case MTFMunderbrace: diff --git a/lib/jkqtmathtext/jkqtmathtext.h b/lib/jkqtmathtext/jkqtmathtext.h index e249647c32..9224e394c0 100644 --- a/lib/jkqtmathtext/jkqtmathtext.h +++ b/lib/jkqtmathtext/jkqtmathtext.h @@ -167,6 +167,8 @@ JKQTP_LIB_EXPORT void initJKQTMathTextResources(); \subsection JKQTMathTextSuppoertedLaTeXMatrix Matrix/Array Type Instructions Several Matrix/Array-typed LaTeX instructions are supported: - $\frac{...}{...}$, $\tfrac{...}{...}$ (70% smaller font), $\dfrac{...}{...}$ \image html jkqtmathtext_brace_frac.png + - $\sfrac{...}{...}$ \image html mathparser/MTFMsfrac.png + - $\stfrac{...}{...}$ (70% smaller font) \image html mathparser/MTFMstfrac.png - $\stackrel{...}{...}$ $\binom{...}{...}$ \image html jkqtmathtext_brace_stackrel.png - $\begin{cases} ... & ... \\ ... & ... \end{cases}$ \image html jkqtmathtext_brace_begincases.png - $\begin{array} a & b & ...\\ c & d & ...\end{array}$ $\begin{matrix} a & b & ...\\ c & d & ...\end{matrix}$ \image html jkqtmathtext_array.png @@ -1082,14 +1084,16 @@ class JKQTP_LIB_EXPORT JKQTMathText : public QObject { }; enum MTfracMode { - MTFMfrac, - MTFMdfrac, - MTFMtfrac, - MTFMunderbrace, - MTFMoverbrace, - MTFMstackrel, - MTFMunderset, - MTFMoverset + MTFMfrac, /*!< \brief normal fraction \image html mathparser/MTFMfrac.png */ + MTFMdfrac, /*!< \brief normal fraction, without scaling of under/over text \image html mathparser/MTFMdfrac.png */ + MTFMtfrac, /*!< \brief text fraction (smaller than MTFMfrac) \image html mathparser/MTFMtfrac.png */ + MTFMsfrac, /*!< \brief slanted fraction \image html mathparser/MTFMsfrac.png */ + MTFMstfrac, /*!< \brief slanted text fraction \image html mathparser/MTFMstfrac.png */ + MTFMunderbrace, /*!< \brief curly underbrace \image html mathparser/MTFMunderbrace.png */ + MTFMoverbrace, /*!< \brief curly overbrace \image html mathparser/MTFMoverbrace.png */ + MTFMstackrel, /*!< \brief binom/fraction without line \image html mathparser/MTFMstackrel.png */ + MTFMunderset, /*!< \brief underset text \image html mathparser/MTFMunderset.png */ + MTFMoverset /*!< \brief overset text \image html mathparser/MTFMoverset.png */ }; static QString fracModeToString(MTfracMode mode); @@ -1165,17 +1169,17 @@ class JKQTP_LIB_EXPORT JKQTMathText : public QObject { enum MTdecoration { - MTDvec, - MTDhat, - MTDdot, - MTDddot, - MTDbar, - MTDarrow, - MTDoverline, - MTDdoubleoverline, - MTDunderline, - MTDdoubleunderline, - MTDtilde + MTDvec, /*!< \brief vector arrow over block \image html mathparser/MTDvec.png */ + MTDhat, /*!< \brief hat over block \image html mathparser/MTDhat.png */ + MTDdot, /*!< \brief single dot over block \image html mathparser/MTDvec.png */ + MTDddot, /*!< \brief double dot over block \image html mathparser/MTDddot.png */ + MTDbar, /*!< \brief bar over block \image html mathparser/MTDbar.png */ + MTDarrow, /*!< \brief arrow over block \image html mathparser/MTDarrow.png */ + MTDoverline, /*!< \brief overline over block \image html mathparser/MTDoverline.png */ + MTDdoubleoverline, /*!< \brief double overline over block \image html mathparser/MTDdoubleoverline.png */ + MTDunderline, /*!< \brief underline under block \image html mathparser/MTDunderline.png */ + MTDdoubleunderline, /*!< \brief double underline under block \image html mathparser/MTDdoubleunderline.png */ + MTDtilde /*!< \brief tilde over block \image html mathparser/MTDtilde.png */ }; static QString decorationToString(MTdecoration mode);